FIJI.pm 51.2 KB
Newer Older
1
2
3
#-----------------------------------------------------------------------
# Fault InJection Instrumenter (FIJI)
# https://embsys.technikum-wien.at/projects/vecs/fiji
Christian Fibich's avatar
Christian Fibich committed
4
#
5
6
# Copyright (C) 2017 Christian Fibich <fibich@technikum-wien.at>
# Copyright (C) 2017 Stefan Tauner <tauner@technikum-wien.at>
Christian Fibich's avatar
Christian Fibich committed
7
#
8
9
# This module is free software; you can redistribute it and/or modify
# it under the same terms as Perl itself.
Christian Fibich's avatar
Christian Fibich committed
10
#
11
12
13
14
15
16
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See the LICENSE file for more details.
#-----------------------------------------------------------------------
Christian Fibich's avatar
Christian Fibich committed
17

18
## @file FIJI.pm
Christian Fibich's avatar
Christian Fibich committed
19
# @brief Contains class \ref FIJI
20

21
## @class FIJI
Christian Fibich's avatar
Christian Fibich committed
22
# @brief Various constants used in the FIJI packages.
23

24
25
package FIJI;

26
27
28
use strict;
use warnings;

29
use Cwd;
30
31
32
use Cwd 'realpath';
use File::Spec;
use Log::Log4perl qw(:easy);
Stefan Tauner's avatar
Stefan Tauner committed
33

34
use constant FIJI_DIR => realpath(File::Spec->rel2abs("..", $FindBin::Bin));
Christian Fibich's avatar
Christian Fibich committed
35
36
37
38
39
use constant FIJI_DOCUMENTATION_PATH => realpath(
    File::Spec->rel2abs(
        File::Spec->catfile(
            "..",
            "docs",
40
            "user_guide",
Christian Fibich's avatar
Christian Fibich committed
41
42
43
44
45
            "fiji_user_guide.pdf"
        ),
        $FindBin::Bin
    )
);
46

Stefan Tauner's avatar
Stefan Tauner committed
47
48
49
50
51
52
53
54
55
56
use constant FIJI_MEDIA_PATH => realpath(
    File::Spec->rel2abs(
        File::Spec->catfile(
            "..",
            "media",
        ),
        $FindBin::Bin
    )
);

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

my $version;
BEGIN {
    local $/ = undef;
    my $version_file = File::Spec->rel2abs(
        File::Spec->catfile(
            "..",
            "VERSION",
        ),
        $FindBin::Bin
    );
    open FILE, $version_file or die "Couldn't open VERSION file: $!";
    $version = <FILE>;
    close FILE;
};
use constant FIJI_VERSION => $version;

74
my @optimization_settings = qw(ALLOW OPT_OFF FIX_PLACEMENT);
75
use constant OPTIMIZATION_SETTINGS => \@optimization_settings;
76

77
78
79
80
81
82
#
# Maximal period polynomials for LFSRs of given lengths
# Thank you http://www.eej.ulst.ac.uk/~ian/modules/EEE515/files/old_files/lfsr/lfsr_table.pdf
# Our LFSR uses bit numbers are mirrored compared to the document above.
#
use constant LFSR_POLY_CHOICES => {
Christian Fibich's avatar
Christian Fibich committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
    2  => ['0x3'],
    3  => ['0x3'],
    4  => ['0x3'],
    5  => ['0x5', '0xF'],
    6  => ['0x3', '0x1B'],
    7  => ['0x3', '0xF'],
    8  => ['0x1D'],
    9  => ['0x11', '0x1B'],
    10 => ['0x9', '0x1B'],
    11 => ['0x5', '0x17'],
    12 => ['0x53'],
    13 => ['0x1B'],
    14 => ['0x2B'],
    15 => ['0x3', '0x17'],
    16 => ['0x2D'],
    17 => ['0x9', '0xF'],
    18 => ['0x81', '0x27'],
    19 => ['0x27'],
    20 => ['0x9', '0x53'],
    21 => ['0x5', '0x27'],
    22 => ['0x3', '0x39'],
    23 => ['0x21', '0x2B'],
    24 => ['0x1B'],
    25 => ['0x9', '0xF'],
    26 => ['0x47'],
    27 => ['0x27'],
    28 => ['0x9', '0x53'],
    29 => ['0x5', '0x17'],
    30 => ['0x53'],
    31 => ['0x9', '0xF'],
    32 => ['0xC5'],
    33 => ['0x2001', '0x53'],
    34 => ['0x119'],
    35 => ['0x5', '0x183'],
    36 => ['0x801', '0x183'],
    37 => ['0x53'],
    38 => ['0x63'],
    39 => ['0x11', '0x93'],
    40 => ['0x39'],
    41 => ['0x9', '0xF'],
    42 => ['0xA5'],
    43 => ['0x63'],
    44 => ['0x65'],
    45 => ['0x1B'],
    46 => ['0x1C1'],
    47 => ['0x21', '0x33'],
    48 => ['0x291'],
    49 => ['0x201', '0x71'],
    50 => ['0x1D'],
    51 => ['0x4B'],
    52 => ['0x9', '0x4B'],
    53 => ['0x47'],
    54 => ['0x149'],
    55 => ['0x1000001', '0x47'],
    56 => ['0x95'],
    57 => ['0x81', '0x2D'],
    58 => ['0x80001', '0x63'],
    59 => ['0x95'],
    60 => ['0x3', '0x35'],
    61 => ['0x27'],
    62 => ['0x69'],
    63 => ['0x3', '0x33'],
    64 => ['0x1B'],
146
147
};

148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
use constant FIJI_LOGO => <<logo_end;
FIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJI
FIJIFIJIFIJIFIJIF   FIJIFIJIFIJIFIJIFIJI
FIJIFIJIFIJIFIJ    IFIJIFIJIFIJIFIJIFIJI
FIJIF       FI           IJIFIJIFIJIFIJI
FIJIFIJIFI            JIFIJIFIJIFIJIFIJI
FIJIFIJI            FIJIFIJIFIJIFIJIFIJI
FIJIFI     I   IFI   IJIFIJIFIJIFIJIFIJI
FIJIF         JIFIJ   JIFIJIFIJIFIJIFIJI
FIJIFIJIFI   IJIFIJI   IFIJIFIJIFIJIFIJI
FIJIFIJIF    IJIFIJIFIJIFIJIFIJIFIJIFIJI
FIJIFIJI    FIJIFIJIFIJIFIJIFIJIFIJIFIJI
FIJIFIJ     FIJIF           FIJIFIJIFIJI
FIJIFI     IFI      Fault      IFIJIFIJI
FIJIF             InJection     FIJIFIJI
FIJ              Instrumenter    IJIFIJI
F                                    IJI
FIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJIFIJI
logo_end

168
169
170
171
#** @var public %designmap Hash containing all FIJI::Settings
#
# Architecture from http://www.perlmonks.org/?node_id=1072731
#
172
# Fields:
173
174
#    - ini_name     key name in FIJI Settings file
#    - unit         (optional) physical unit
175
#    - type         enables type-specific conversions and tests:
176
177
178
179
#                   - natural: values must be oct, hex, binary strings looking like a real number.
#                   - hexadecimal: values must be hexadecimal numbers.
#                   - boolean: will be convert to a truth value by Perl semantics
#                   - net: name of a net from the input netlist
180
#                   FIXME: complete docs (e.g., dut_port, external_port)
181
182
#    - values       (optional) used to restrict valid values. Can be...
#                   - an array reference listing all valid values (emulates an enum)
183
184
#                   - a code reference to a function that gets the new plus old values
#                     (as well as the value of the dependency if there is one) and
185
186
187
#                     returns true if the new value is allowed, or false otherwise.
#    - phases_opt   (optional) list of phases (subset of "setup", "instrument", "download")
#                   where no value must be present in input (e.g. ID is only necessary while downloading).
188
189
#    - phases_moot  (optional) list of phases (subset of "setup", "instrument", "download")
#                   where values present in the input are not validated at all.
190
#    - depends_on   (optional) specifies the key of another constant.
191
#                   The respective constant is only relevant (and thus required as input)
192
#                   if the value of the referenced constant is true.
193
194
195
196
197
198
#    - group        (optional) specifies how to group this value in output. Value will not be displayed if undef
#    - order        (optional) specifies how to sort this value in output group
#    - noedit       (optional) display value, but don't allow to alter
#    - default      (optional) default value if not given in file and not determinable otherwise
#    - help         (optional) short help text, e.g. to be displayed via Tk:Balloon
#    - forbidden_by (optional) specifies the key of another constant
199
200
#                     The respective constant may not be enabled if the value
#                     of the referenced constant is true
201
my %designmap;
202

203
BEGIN {
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
    %designmap = (
        FIU_NUM => {
            description => "Number of FIUs",
            ini_name    => "FIU_NUM",
            type        => 'natural',
            phases_opt  => [qw(setup instrument download)],    # auto-generated if need be
        },
        FIU_CFG_BITS => {
            description => "Bits per FIU pattern",
            ini_name    => "FIU_CFG_BITS",
            default     => 3,
            type        => 'natural',
            phases_opt  => [qw(setup instrument download)],    # currently not user-configurable at all
        },
        CFGS_PER_MSG => {
219
            description => "Patterns sent per FIU configuration",
220
221
222
223
224
225
226
227
228
229
            ini_name    => "CFGS_PER_MSG",
            default     => 2,
            type        => 'natural',
            phases_opt  => [qw(setup instrument download)],    # currently not user-configurable at all
        },
        CLOCK_NET => {
            type        => 'net',
            description => "Clock net",
            help        => "Select a net in the DUT which shall be used to clock the FIJI logic",
            ini_name    => "CLOCK_NET",
230
            default     => "",
231
232
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
233
            group       => 'clock',
234
            order       => 10
235
236
237
238
239
240
241
242
243
244
245
246
247
248
        },
        FREQUENCY => {
            description => "Clock frequency",
            help        => "Enter the clock frequency in Hz.\n This information is needed e.g. to calculate the Baud rate prescaler",
            ini_name    => "FREQUENCY",
            default     => 50e6,
            type        => 'natural',
            phases_opt  => [qw(setup download)],
            unit        => 'Hz',
            group       => 'clock',
            order       => 20,
        },
        OUTPUT_DIR => {
            description => "Output directory",
249
            help        => "Output directory for FIJI Instrument (relative to location of FIJI settings file)",
250
            ini_name    => "OUTPUT_DIR",
251
            default     => ".",
252
253
254
255
256
            type        => 'dir',
            group       => 'general_control',
            phases_opt  => [qw(setup)],
            order       => 5,
        },
257
        INST_LOG => {
258
            description => "Instrumentation log file",
259
            help        => "Log file for FIJI Instrumentation tool (relative to location of FIJI settings file)",
260
            ini_name    => "INST_LOG",
261
262
263
264
265
266
            default     => "fiji_instrument.log",
            type        => 'file',
            group       => 'general_control',
            phases_opt  => [qw(setup)],
            order       => 6,
        },
267
268
269
270
271
272
273
274
275
        BAUDRATE => {
            description => "Baud rate",
            help        => "Enter the Baud rate for communication between Host and FIJI logic.",
            ini_name    => "BAUDRATE",
            default     => 115200,
            type        => 'natural',
            unit        => 'bps',
            group       => 'general_control',
            order       => 10,
276
277
278
279
280
281
282
283
            depends_on  => "FREQUENCY",
            values      => sub {
                my ($baud, $old, $fclk) = @_;
                if (defined $fclk) {
                    return $baud < $fclk;
                } else {
                    return 1;
                }
Christian Fibich's avatar
Christian Fibich committed
284
              }
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
        },
        ID => {
            description => "Design ID",
            help        => "The design ID is automatically calculated upon instrumentation.",
            ini_name    => "ID",
            type        => 'hexadecimal',
            phases_opt  => [qw(setup instrument)],                                              # generated in instrumentation
            noedit      => 1,
        },
        TIMER_WIDTH => {
            description => "Timer width",
            help        => "Enter the timer width in bytes.\n This influences the maximum fault duration.",
            ini_name    => "TIMER_WIDTH",
            default     => 4,
            type        => 'natural',
            unit        => 'bytes',
            values      => sub {
                my $val = shift;
Christian Fibich's avatar
Christian Fibich committed
303
                return ($val > 0 && $val <= 16);
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
            },
            group => 'general_control',
            order => 20,
        },
        LFSR_WIDTH => {
            description => "LFSR width",
            help        => "Enter the width of the LFSR in bits.\n The LFSR is used to emulate \"floating\" nets in the stuck-open model.",
            ini_name    => "LFSR_WIDTH",
            default     => 16,
            type        => 'natural',
            unit        => 'bits',
            values      => sub {
                my $val = shift;
                return $val > 0 && $val <= 64;
            },
            group => 'lfsr',
            order => 10,
        },
        LFSR_POLY => {
            description => "LFSR polynomial",
            help        => "Enter the polynomial for the LFSR.\n The LFSR is used to emulate \"floating\" nets in the stuck-open model.",
            ini_name    => "LFSR_POLY",
            default     => 0x2D,
327
            type        => 'lfsrpoly',
328
            unit        => 'hex',
329
            depends_on  => 'LFSR_WIDTH',
330
            values      => sub {
331
332
333
                my ($val, $old, $top) = @_;
                $top = 64 if !defined $top;
                return $val > 0 && $val <= (2**($top) - 1);
334
335
336
337
338
339
340
341
342
343
            },
            group => 'lfsr',
            order => 20,
        },
        LFSR_SEED => {
            description => "LFSR seed value",
            help        => "Enter the starting value for the LFSR.\n The LFSR is used to emulate \"floating\" nets in the stuck-open model.",
            ini_name    => "LFSR_SEED",
            default     => 0xCAFE,
            type        => 'hexadecimal',
344
            unit        => 'hex',
345
            depends_on  => 'LFSR_WIDTH',
346
            values      => sub {
347
348
349
                my ($val, $old, $top) = @_;
                $top = 64 if !defined $top;
                return $val > 0 && $val <= (2**($top) - 1);
350
351
352
353
354
355
            },
            group => 'lfsr',
            order => 30,
        },

        # External reset
356
        RST_EXT_EN => {
357
358
            description => "Use external reset",
            help        => "If enabled, the FIJI logic can be reset using an FPGA pin.",
359
            ini_name    => "RST_EXT_EN",
360
            type        => 'boolean',
361
362
            default     => 0,
            phases_opt  => ['setup'],
363
364
365
            group       => 'reset_external',
            order       => 10,
        },
366
        RST_EXT_ACT => {
367
368
            description => "External Reset: Active level",
            help        => "If enabled, the FIJI logic can be reset using an FPGA pin.",
369
            ini_name    => "RST_EXT_ACT",
370
371
372
            type        => 'bit',
            values      => [qw(0 1)],
            default     => '1',
373
            phases_opt  => ['setup', 'download'],
374
            depends_on  => 'RST_EXT_EN',
375
376
377
            group       => 'reset_external',
            order       => 20,
        },
378
        RST_EXT_IN_NAME => {
379
380
            description => "External Reset: Port name",
            help        => "Specify the name of the external reset port in the wrapper.\nThis port name must not exist in the toplevel.",
381
            ini_name    => "RST_EXT_IN_NAME",
Christian Fibich's avatar
Christian Fibich committed
382
            default     => "s_fiji_reset_i",
383
384
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
Christian Fibich's avatar
Christian Fibich committed
385
            type        => "external_port",
386
            group       => 'reset_external',
387
            depends_on  => 'RST_EXT_EN',
388
389
390
391
            order       => 30,
        },

        # Reset from DUT
392
        RST_DUT_OUT_EN => {
393
394
            description  => "Enable DUT-to-FIJI reset",
            help         => "If enabled, a net in the DUT is used as a reset source for the FIJI logic.",
395
            ini_name     => "RST_DUT_OUT_EN",
396
            type         => 'boolean',
397
398
            default      => 0,
            phases_opt  => ['setup'],
399
            group        => 'reset_from_dut',
400
            forbidden_by => 'RST_DUT_IN_EN',
401
402
            order        => 10,
        },
403
        RST_DUT_OUT_NAME => {
404
            description => "Source for DUT-to-FIJI reset",
405
            help        => "If enabled, a net in the DUT is used as a reset source for the FIJI logic.",
406
407
            ini_name    => "RST_DUT_OUT_NAME",
            depends_on  => 'RST_DUT_OUT_EN',
408
            type        => 'net',
409
            default     => "",
410
411
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
412
413
414
            group       => 'reset_from_dut',
            order       => 30,
        },
415
        RST_DUT_OUT_ACT => {
416
            description => "Active level of DUT-to-FIJI reset",
417
            help        => "If enabled, a net in the DUT is used as a reset source for the FIJI logic.",
418
            ini_name    => "RST_DUT_OUT_ACT",
419
420
421
            type        => 'bit',
            values      => [qw(0 1)],
            default     => '1',
422
            phases_opt  => ['setup'],
423
            depends_on  => 'RST_DUT_OUT_EN',
424
425
426
427
428
            group       => 'reset_from_dut',
            order       => 20,
        },

        # Reset to DUT
429
        RST_DUT_IN_EN => {
430
431
            description  => "Enable FIJI-to-DUT reset",
            help         => "If enabled, the DUT will be reset from the FIJI logic.",
432
            ini_name     => "RST_DUT_IN_EN",
433
            type         => 'boolean',
434
435
            default      => 0,
            phases_opt  => ['setup'],
436
            group        => 'reset_to_dut',
437
            forbidden_by => 'RST_DUT_OUT_EN',
438
439
            order        => 10,
        },
440
        RST_DUT_IN_NAME => {
441
442
            description => "Port for FIJI-to-DUT reset",
            help        => "The specified DUT reset input will be connected\n to the FIJI logic's reset output.",
443
            ini_name    => "RST_DUT_IN_NAME",
444
            default     => "",
445
            phases_opt  => [qw(setup download)],
446
            depends_on  => 'RST_DUT_IN_EN',
447
            type        => 'dut_port',
448
449
450
            group       => 'reset_to_dut',
            order       => 40,
        },
451
        RST_DUT_IN_DUR => {
452
453
            description => "Duration for FIJI-to-DUT reset",
            help        => "Enter the duration of each FIJI-to-DUT reset operation in clock cycles.",
454
            ini_name    => "RST_DUT_IN_DUR",
455
456
            type        => 'natural',
            default     => 1,
457
            phases_opt  => ['setup'],
458
459
460
461
462
            unit        => 'cycles',
            values      => sub {
                my $val = shift;
                return $val > 0 && $val <= 2**32 - 1;
            },
463
            depends_on => 'RST_DUT_IN_EN',
464
465
466
            group      => 'reset_to_dut',
            order      => 30,
        },
467
        RST_DUT_IN_ACT => {
468
            description => "Active level of FIJI-to-DUT reset",
469
            help        => "Enter the level the FIJI-to-DUT reset signal shall be brought to during reset.",
470
            ini_name    => "RST_DUT_IN_ACT",
471
472
473
            type        => 'bit',
            values      => [qw(0 1)],
            default     => '1',
474
            phases_opt  => ['setup'],
475
            depends_on  => 'RST_DUT_IN_EN',
476
477
478
479
480
            group       => 'reset_to_dut',
            order       => 20,
        },

        # Trigger from DUT
481
        TRIG_DUT_EN => {
482
483
            description => "Enable DUT-to-FIJI trigger",
            help        => "If enabled, a signal in the DUT can be selected to trigger fault injection operations.\n" . "Once a pattern is downloaded with the INTERNAL trigger enabled, the FIJI logic waits for\n" . "an inactive-to-active transition on this signal before starting to count down duration t1.",
484
            ini_name    => "TRIG_DUT_EN",
485
            type        => 'boolean',
486
487
            default     => 0,
            phases_opt  => ['setup'],
488
489
490
            group       => 'trigger',
            order       => 10,
        },
491

492
        TRIG_DUT_ACT => {
493
            description => "Active level of DUT-to-FIJI trigger",
494
            help        => "Select the signal level to trigger fault injection.",
495
            ini_name    => "TRIG_DUT_ACT",
496
497
498
            type        => 'bit',
            values      => [qw(0 1)],
            default     => '1',
499
            phases_opt  => ['setup'],
500
            depends_on  => 'TRIG_DUT_EN',
501
            group       => 'trigger',
502
503
504
            order       => 20,
        },

505
        TRIG_DUT_NAME => {
506
507
            description => "Source net for DUT-to-FIJI trigger",
            help        => "Select the net in the DUT which shall be used to trigger fault injection operations.",
508
            ini_name    => "TRIG_DUT_NAME",
509
            default     => "",
510
511
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
512
            depends_on  => 'TRIG_DUT_EN',
513
514
            type        => 'net',
            group       => 'trigger',
515
516
517
518
            order       => 30,
        },

        # External trigger
519
        TRIG_EXT_EN => {
520
521
            description => "Enable external trigger",
            help        => "If enabled, an I/O port can be selected to trigger fault injection operations.\n" . "Once a pattern is downloaded with the EXTERNAL trigger enabled, the FIJI logic waits for \n" . "an inactive-to-active transition on this port before starting to count down duration t1. \n" . "The port is synchronized to the FIJI logic's clock, thus introducing a few clock cycles delay.",
522
            ini_name    => "TRIG_EXT_EN",
523
            type        => 'boolean',
524
525
            default     => 0,
            phases_opt  => ['setup'],
526
527
528
            group       => 'trigger',
            order       => 40,
        },
529
        TRIG_EXT_ACT => {
530
            description => "Active level of external trigger",
531
            help        => "Select the port level to trigger fault injection.",
532
            ini_name    => "TRIG_EXT_ACT",
533
534
535
            type        => 'bit',
            values      => [qw(0 1)],
            default     => '1',
536
            phases_opt  => ['setup'],
537
            depends_on  => 'TRIG_EXT_EN',
538
539
540
            group       => 'trigger',
            order       => 50,
        },
541
        TRIG_EXT_IN_NAME => {
542
            description => "External trigger port name",
543
            help        => "Specify the name of the external trigger port in the wrapper.\nThis port name must not exist in the toplevel.",
544
            ini_name    => "TRIG_EXT_IN_NAME",
Christian Fibich's avatar
Christian Fibich committed
545
            type        => "external_port",
546
            default     => "s_fiji_trig_ext_i",
547
548
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
549
            depends_on  => 'TRIG_EXT_EN',
550
551
552
            group       => "trigger",
            order       => 60,
        },
553
        FD_1_EN => {
554
555
            description => "Enable fault-detect bit 1",
            help        => "If enabled, a signal in the DUT can be selected as a return channel.\n" . "This could e.g. be the output of a fault detection unit. \n" . "The FIJI logic registers inactive-to-active transition on this signal and returns the status \n" . "in the serial communication messages to the host.",
556
            ini_name    => "FD_1_EN",
557
558
            type        => 'boolean',
            default     => 0,
559
            phases_opt  => ['setup'],
560
561
562
            group       => 'fault_detect',
            order       => 10,
        },
563
        FD_1_NAME => {
564
565
            description => "Source net for fault-detect bit 1",
            help        => "Select the net in the DUT which shall be used for the fault detection feature.",
566
            ini_name    => "FD_1_NAME",
567
            type        => 'net',
568
            default     => "",
569
570
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
571
            depends_on  => 'FD_1_EN',
572
573
574
            group       => 'fault_detect',
            order       => 20,
        },
575
        FD_1_INVERT => {
576
577
            description => "Invert fault detect bit 1",
            help        => "Specifies if the selected net shall be inverted prior to edge detection.\n" . "Leave unchecked if the net uses positive logic.",
578
            ini_name    => "FD_1_INVERT",
579
580
581
            type        => 'boolean',
            values      => [qw(0 1)],
            default     => '0',
582
            phases_opt  => ['setup'],
583
            depends_on  => 'FD_1_EN',
584
585
586
            group       => 'fault_detect',
            order       => 30,
        },
587
        FD_2_EN => {
588
589
            description => "Enable fault-detect bit 2",
            help        => "If enabled, a signal in the DUT can be selected as a return channel.\n" . "This could e.g. be the output of a fault detection unit. \n" . "The FIJI logic registers inactive-to-active transition on this signal and returns the status \n" . "in the serial communication messages to the host.",
590
            ini_name    => "FD_2_EN",
591
592
            type        => 'boolean',
            default     => 0,
593
            phases_opt  => ['setup'],
594
595
596
            group       => 'fault_detect',
            order       => 40,
        },
597
        FD_2_NAME => {
598
599
            description => "Source net for fault-detect bit 2",
            help        => "Select the net in the DUT which shall be used for the fault detection feature.",
600
            ini_name    => "FD_2_NAME",
601
            type        => 'net',
602
            default     => "",
603
604
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
605
            depends_on  => 'FD_2_EN',
606
607
608
            group       => 'fault_detect',
            order       => 50,
        },
609
        FD_2_INVERT => {
610
611
            description => "Invert fault detect bit 2",
            help        => "Specify if the selected net shall be inverted prior to edge detection.\n" . "Leave unchecked if the net uses positive logic.",
612
            ini_name    => "FD_2_INVERT",
613
614
615
            type        => 'boolean',
            values      => [qw(0 1)],
            default     => '0',
616
            phases_opt  => ['setup'],
617
            depends_on  => 'FD_2_EN',
618
619
620
621
622
            group       => 'fault_detect',
            order       => 60,
        },
        RX_IN_NAME => {
            description => "RX port name",
623
            help        => "Specify the name of the Host-to-FIJI serial RX port in the wrapper.\nThis port name must not exist in the toplevel.",
624
            ini_name    => "RX_IN_NAME",
Christian Fibich's avatar
Christian Fibich committed
625
            type        => "external_port",
626
            default     => "s_fiji_rx_i",
627
628
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
629
            group       => "general_control",
Stefan Tauner's avatar
Stefan Tauner committed
630
            order       => 11,
631
632
633
        },
        TX_OUT_NAME => {
            description => "TX port name",
634
            help        => "Specify the name of the FIJI-to-Host serial TX port in the wrapper.\nThis port name must not exist in the toplevel.",
635
            ini_name    => "TX_OUT_NAME",
Christian Fibich's avatar
Christian Fibich committed
636
            type        => "external_port",
637
            default     => "s_fiji_tx_o",
638
639
            phases_opt  => [qw(setup)],
            phases_moot => [qw(download)],
640
            group       => "general_control",
Stefan Tauner's avatar
Stefan Tauner committed
641
            order       => 12,
642
        },
643
        OPTIMIZATIONS => {
644
            description => "Optimization Settings",
645
            help        => "Specifies which set of constraints to use in synthesis/P&R to\n- prevent optimizations and/or\n- fix physical placement.",
646
            ini_name    => "OPTIMIZATIONS",
647
            type        => "dropdown",
648
            values      => \@optimization_settings,
649
            default     => "ALLOW",
650
            phases_opt  => [qw(setup)],
651
652
653
            group       => "general_control",
            order       => 50,
        },
654
655
656
657
658
659
660
661
662
663
664
        SYNTHESIS_TOOL => {
            description => "Synthesis Tool",
            help        => "The FPGA synthesis tool that will be used. Needed for generating appropriate constraints.",
            ini_name    => "SYNTHESIS_TOOL",
            type        => "dropdown",
            values      => ["SYNPLIFY_PRO"],
            default     => "SYNPLIFY_PRO",
            phases_opt  => [qw(setup)],
            group       => "general_control",
            order       => 60,
        },
665
        IMPL_TOOL => {
666
667
            description => "Implementation Tool",
            help        => "The FPGA implementation tool that will be used. Needed for generating appropriate constraints.",
668
            ini_name    => "IMPL_TOOL",
669
            type        => "dropdown",
Christian Fibich's avatar
Christian Fibich committed
670
            values      => ["ALTERA_QUARTUS", "XILINX_VIVADO"],
671
672
673
674
675
            default     => "ALTERA_QUARTUS",
            phases_opt  => [qw(setup)],
            group       => "general_control",
            order       => 70,
        },
676
    );
677
678
}

679
680
681
use constant \%designmap;
use constant DESIGNMAP => \%designmap;

Christian Fibich's avatar
Christian Fibich committed
682
683
684
685
686
687
688
#** @var public %displaygroups Hash containing groups for displaying \ref designmap
##
# Fields:
#    -title         Just a short title
#    -subtitle      ...
#    -description   Longer description
#    -order         The sorting order to display this group
689
my %displaygroups;
690

691
692
693
694
695
BEGIN {
    %displaygroups = (
        fault_detect => {
            title       => "Fault Detection Settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
696
697
            description => "Settings concerning internal fault detection propagation",
            order       => 80,
698
699
700
701
        },
        trigger => {
            title       => "Trigger Settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
702
703
            description => "Settings concerning internal and external fault injection triggers",
            order       => 70,
704
705
        },
        reset_to_dut => {
706
            title       => "Reset from FIJI to DUT",
707
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
708
709
            description => "Settings concerning FIJI's ability to reset the DUT",
            order       => 60,
710
711
        },
        reset_from_dut => {
712
            title       => "Reset from DUT to FIJI",
713
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
714
715
            description => "Settings concerning FIJI's internal (from DUT) reset feature",
            order       => 50,
716
717
        },
        reset_external => {
718
719
            title       => "External Reset",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
720
721
            description => "Settings concerning FIJI's external (via pin) reset feature",
            order       => 40,
722
723
724
725
        },
        lfsr => {
            title       => "LFSR Settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
726
727
            description => "Settings concerning the LFSR for Stuck-open emulation",
            order       => 30,
728
729
        },
        general_control => {
730
            title       => "General settings",
731
            subtitle    => "",
732
            description => "Settings concerning miscellaneous features of FIJI",
Christian Fibich's avatar
Christian Fibich committed
733
            order       => 10,
734
735
736
737
        },
        clock => {
            title       => "Clock settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
738
739
            description => "Settings concerning the clocking of the FIJI logic",
            order       => 20,
740
741
742
743
744
745
        },
        fius => {
            title       => "FIUs",
            subtitle    => "",
            description => "Settings concerning Fault Injection Units",
            order       => 100
746
        }
747
    );
748
}
749

750
751
use constant \%displaygroups;
use constant DISPLAYGROUPS => \%displaygroups;
752
use constant DISPLAYGROUPS_FIU_KEY => 'fius';
753

Christian Fibich's avatar
Christian Fibich committed
754
755
756
757
758
759
760
761
762
## @var public %fiumap Hash containing all FIJI::Settings for FIUs
#
# Fields:
#    - ini_name     key name in FIJI Settings file
#    - unit         (optional) physical unit
#    - type         (optional) enables type-specific conversions and tests:
#                   - natural: values must be oct, hex, binary strings looking like a real number.
#                   - hexadecimal: values must be hexadecimal numbers.
#                   - boolean: will be convert to a truth value by Perl semantics
763
#                   - net: hierarchical path of a net from the input netlist
764
#                   - driver: driver-specific hierarchical path of a net from the input netlist
Christian Fibich's avatar
Christian Fibich committed
765
766
767
768
769
770
771
#    - values       (optional) used to restrict valid values. Can be...
#                   - an array reference listing all valid values (emulates an enum)
#                   - a code reference to a function that gets the new and old values and
#                     returns true if the new value is allowed, or false otherwise.
#    - phases_opt   (optional) list of phases (subset of "setup", "instrument", "download")
#                   where no value must be present in input (e.g. ID is only necessary while downloading).
#    - group        (optional) specifies how to group this value in output. Value will not be displayed if undef
772
773
774
#    - default      (optional) default value if not given in file and not determinable otherwise.
#                   Can either be a scalar or a function pointer expecting following parameters:
#                   related FIJI settings hash, the tool phase, FIJI design settings, FIU number.
775
my %fiumap;
776

777
BEGIN {
778
    %fiumap = (
779
780
781
782
783
784
        FIU_NAME => {
            ini_name => "NAME",
            default  => "",
            help     => "Display name for this FIU",
            phases_opt => [qw(setup instrument download)]
        },
785
786
787
        FIU_NET_NAME => {
            ini_name   => "NET_NAME",
            default    => "",
788
789
            type       => 'net',
            help       => "String representation of the instrumented net.",
790
791
            phases_opt  => [qw(setup)], # Either FIU or net name is strongly recommended during download
            phases_moot => [qw(download)],
792
793
794
795
        },
        FIU_DRIVER_TYPE => {
            ini_name   => "DRIVER_TYPE",
            values     => [qw(PIN PORT ASSIGN)],
796
            default    => "PIN",
797
798
799
800
801
            phases_opt => [qw(setup)],
        },
        FIU_DRIVER_PATH => {
            ini_name   => "DRIVER_PATH",
            default    => "",
802
            type       => 'driver',
803
            help       => "String representation of a driver.",
804
805
            phases_opt  => [qw(setup)], # Either FIU or net name is strongly recommended during download
            phases_moot => [qw(download)],
806
807
808
809
810
        },
        FIU_MODEL => {
            ini_name   => "FAULT_MODEL",
            default    => "RUNTIME",
            values     => [qw(RUNTIME PASS_THRU STUCK_AT_0 STUCK_AT_1 STUCK_OPEN DELAY SEU)],
811
            help       => "Possible fault models: no fault (PASS_THRU), a single mode that can be switched on and off, or selection and activation of the type at RUNTIME.",
812
813
814
815
            phases_opt => [qw(setup)],
        },
        FIU_LFSR_MASK => {
            ini_name   => "LFSR_MASK",
816
817
818
819
820
821
            default    => sub {
                my ($consts_ref, $phase, $design_ref, $i) = @_;
                $i = 0 if !defined($i);
                my $mask_width = defined($design_ref) && defined($design_ref->{'LFSR_WIDTH'}) ? $design_ref->{'LFSR_WIDTH'} : 1;
                return 1 << ($i % $mask_width);
            },
822
            type       => 'hexadecimal',
823
            help       => "Selects the bits of the LFSR that are ANDed together to determine the value of a floating net.",
824
825
826
            phases_opt => [qw(setup)],
        },
    );
827
828
829
830
}

use constant \%fiumap;
use constant FIUMAP => \%fiumap;
831

Christian Fibich's avatar
Christian Fibich committed
832
833
834
835
836
837
838
839
840
841
842
843
#** @var public %testconstmap Hash containing all global values of FIJI::Tests
#
# Fields:
#    - ini_name     key name in FIJI Tests file
#    - unit         (optional) physical unit
#    - type         (optional) enables type-specific conversions and tests:
#                   - natural: values must be oct, hex, binary strings looking like a real number.
#                   - hexadecimal: values must be hexadecimal numbers.
#                   - boolean: will be convert to a truth value by Perl semantics
#                   - net: name of a net from the input netlist
#    - values       (optional) used to restrict valid values. Can be...
#                   - an array reference listing all valid values (emulates an enum)
844
845
#                   - a code reference to a function that gets the old value and current settings and
#                     returns the allowed value(s).
Christian Fibich's avatar
Christian Fibich committed
846
847
848
849
850
851
852
#    - phases_opt   (optional) list of phases (subset of "setup", "instrument", "download")
#                   where no value must be present in input (e.g. ID is only necessary while downloading).
#    - gui_modes    (optional) specifies in which mode of {manual,auto,random} this key will be displayed in the GUI
#    - depends_on   (optional) specifies the key of another constant.
#                   The respective constant is only relevant (and thuse required as input)
#                   if the value of the referenced constant is true.
#    - order        (optional) specifies how to sort this value in output group
853
#    - default      (optional) default value if not given in file and not determinable otherwise.
854
#                   Can either be a scalar or a function pointer expecting a FIJI settings reference.
Christian Fibich's avatar
Christian Fibich committed
855
856
857
#    - help         (optional) short help text, e.g. to be displayed via Tk:Balloon
#                     The respective constant may not be enabled if the value
#                     of the referenced constant is true
858
my %testconstmap;
859

860
BEGIN {
861
862
863
864
865
866
867
868
869
    %testconstmap = (
        FIJI_CFG => {
            description => "FIJI Settings File",
            ini_name    => "FIJI_CFG",
            default     => "fiji.cfg",

            #gui_modes   => [qw (manual auto random)],
        },
        UART => {
870
            description => "Control UART",
871
            ini_name    => "UART",
872
873
874
875
            default     => sub {
                my $devs = FIJI::Utils::get_uart_devs();
                return (scalar(@$devs) > 0) ? @{$devs}[0] : "";
            },
Christian Fibich's avatar
Christian Fibich committed
876
            help        => "The host's serial port connected to FIJI.\nLinux/Unix: /dev/ttyUSBx, /dev/ttyACMx, /dev/ttySx\nWindows: COMx",
877
            type        => "autocomplete",
878
879
        },
        HALT_ON_FAULT_DETECT => {
Christian Fibich's avatar
Christian Fibich committed
880
881
882
883
884
885
886
            description           => "Halt on detected fault?",
            ini_name              => "HALT_ON_FAULT_DETECT",
            default               => 1,
            type                  => 'boolean',
            phases_opt            => [qw(manual)],
            gui_modes             => [qw (auto random)],
            order                 => 10,
887
            activated_by_settings => sub {
Christian Fibich's avatar
Christian Fibich committed
888
                my $settings = shift;
889
                return ($settings->{'design'}->{'FD_1_EN'} == 1 || $settings->{'design'}->{'FD_2_EN'} == 1);
890
            },
Christian Fibich's avatar
Christian Fibich committed
891
            help                  => "Specify if the injection campaign shall be aborted when a fault has been detected"
892
893
894
895
896
897
898
899
900
901
902
903
904
        },
        NUM_TESTS => {
            ini_name   => "NUM_TESTS",
            type       => 'natural',
            phases_opt => [qw(manual)],
        },
        REPEAT => {
            description => "Repeat Injection?",
            ini_name    => "REPEAT",
            default     => 0,
            type        => 'boolean',
            phases_opt  => [qw(manual)],
            gui_modes   => [qw (auto)],
905
            order       => 12,
Christian Fibich's avatar
Christian Fibich committed
906
            help        => "Specify if the injection campaign shall start again after the last test",
907
908
909
910
911
912
913
914
        },
        REPEAT_OFFSET => {
            description => "Repetition start pattern",
            ini_name    => "REPEAT_OFFSET",
            default     => 0,
            type        => 'natural',
            phases_opt  => [qw(manual)],
            gui_modes   => [qw (auto)],
915
            order       => 13,
916
            depends_on  => "REPEAT",
Christian Fibich's avatar
Christian Fibich committed
917
            help        => "Specify an offset for all repetitions except the first"
918
        },
919
920
921
922
923
924
925
926
927
928
929
930
        REPEAT_NUM => {
            description => "Number of repetitions",
            ini_name    => "REPEAT_NUM",
            default     => 0,
            type        => 'natural',
            phases_opt  => [qw(manual)],
            gui_modes   => [qw (auto)],
            order       => 14,
            depends_on  => "REPEAT",
            help        => "Specify a number of repetitions"
        },

931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
        HALT_ON_UART_ERROR => {
            ini_name   => "HALT_ON_UART_ERROR",
            default    => 1,
            type       => 'boolean',
            phases_opt => [qw(manual)],
        },
        HALT_ON_CRC_ERROR => {
            ini_name   => "HALT_ON_CRC_ERROR",
            default    => 1,
            type       => 'boolean',
            phases_opt => [qw(manual)],
        },
        HALT_ON_ID_ERROR => {
            ini_name   => "HALT_ON_ID_ERROR",
            default    => 1,
            type       => 'boolean',
            phases_opt => [qw(manual)],
        },
        HALT_ON_UNDERRUN => {
950
951
952
953
954
955
956
            description => "Halt on buffer underrun?",
            ini_name    => "HALT_ON_UNDERRUN",
            default     => 0,
            type        => 'boolean',
            phases_opt  => [qw(manual)],
            gui_modes   => [qw (auto random)],
            order       => 11,
Christian Fibich's avatar
Christian Fibich committed
957
            help        => "Specify if the injection campaign shall be halted when the FIC reported that a pattern did not arrive in time."
958
959
960
961
962
963
964
965
966
        },
        MULTIFAULT => {
            description => "Generate multiple faults per pattern?",
            ini_name    => "MULTIFAULT",
            default     => 1,
            type        => 'boolean',
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            order       => 60,
Christian Fibich's avatar
Christian Fibich committed
967
            help        => "Allow multiple FIUs to generate errors within one pattern"
968
        },
969
        MIN_DUR_T1 => {
970
            description => "Minimum Duration T1",
971
            ini_name    => "MIN_DUR_T1",
972
            default     => sub {shift->default_timer_value()},
973
974
975
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            type        => "min_duration",
976
            matching    => "MAX_DUR_T1",
977
            unit        => "cycles",
978
            order       => 20,
Christian Fibich's avatar
Christian Fibich committed
979
            help        => "Minimum duration before the first fault is applied."
980
        },
981
        MIN_DUR_T2 => {
982
            description => "Minimum Duration T2",
983
            ini_name    => "MIN_DUR_T2",
984
            default     => sub {shift->default_timer_value()},
985
986
987
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            type        => "min_duration",
988
            matching    => "MAX_DUR_T2",
989
            unit        => "cycles",
990
            order       => 40,
Christian Fibich's avatar
Christian Fibich committed
991
            help        => "Minimum duration to keep the first fault is enabled."
992
        },
993
        MAX_DUR_T1 => {
994
            description => "Maximum Duration T1",
995
            ini_name    => "MAX_DUR_T1",
996
            default     => sub {10 * shift->default_timer_value()},
997
998
999
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            type        => "max_duration",
1000
            matching    => "MIN_DUR_T1",
For faster browsing, not all history is shown. View entire blame