FIJI.pm 49.6 KB
Newer Older
Christian Fibich's avatar
Christian Fibich committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#-------------------------------------------------------------------------------
#  University of Applied Sciences Technikum Wien
#
#  Department of Embedded Systems
#  http://embsys.technikum-wien.at
#
#  Josef Ressel Center for Verification of Embedded Computing Systems
#  http://vecs.technikum-wien.at
#
#-------------------------------------------------------------------------------
#  Description:
#  Various constants used in the FIJI packages.
#-------------------------------------------------------------------------------

15
## @file FIJI.pm
Christian Fibich's avatar
Christian Fibich committed
16
# @brief Contains class \ref FIJI
17

18
## @class FIJI
19
#
Christian Fibich's avatar
Christian Fibich committed
20
# @brief Various constants used in the FIJI packages.
21
package FIJI;
Christian Fibich's avatar
Christian Fibich committed
22
use Cwd;
23

24
25
26
use strict;
use warnings;

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

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

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

54
my @optimization_settings = qw(ALLOW OPT_OFF FIX_PLACEMENT);
55
use constant OPTIMIZATION_SETTINGS => \@optimization_settings;
56

57
58
59
60
61
62
#
# 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
    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'],
126
127
};

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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

148
149
150
151
#** @var public %designmap Hash containing all FIJI::Settings
#
# Architecture from http://www.perlmonks.org/?node_id=1072731
#
152
# Fields:
153
154
#    - ini_name     key name in FIJI Settings file
#    - unit         (optional) physical unit
155
#    - type         enables type-specific conversions and tests:
156
157
158
159
#                   - 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
160
#                   FIXME: complete docs
161
162
#    - values       (optional) used to restrict valid values. Can be...
#                   - an array reference listing all valid values (emulates an enum)
163
164
#                   - 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
165
166
167
168
#                     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).
#    - depends_on   (optional) specifies the key of another constant.
169
170
#                   The respective constant is only relevant (and thuse required as input)
#                   if the value of the referenced constant is true.
171
172
173
174
175
176
#    - 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
177
178
#                     The respective constant may not be enabled if the value
#                     of the referenced constant is true
179
my %designmap;
180

181
BEGIN {
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
    %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 => {
197
            description => "Patterns sent per FIU configuration",
198
199
200
201
202
203
204
205
206
207
            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",
208
            default     => "",
209
210
            phases_opt  => [qw(setup download)],
            group       => 'clock',
211
            order       => 10
212
213
214
215
216
217
218
219
220
221
222
223
224
225
        },
        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",
226
            help        => "Output directory for FIJI Instrument (relative to location of FIJI settings file)",
227
            ini_name    => "OUTPUT_DIR",
228
            default     => ".",
229
230
231
232
233
            type        => 'dir',
            group       => 'general_control',
            phases_opt  => [qw(setup)],
            order       => 5,
        },
234
        INST_LOG => {
235
            description => "Instrumentation log file",
236
            help        => "Log file for FIJI Instrumentation tool (relative to location of FIJI settings file)",
237
            ini_name    => "INST_LOG",
238
239
240
241
242
243
            default     => "fiji_instrument.log",
            type        => 'file',
            group       => 'general_control',
            phases_opt  => [qw(setup)],
            order       => 6,
        },
244
245
246
247
248
249
250
251
252
        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,
253
254
255
256
257
258
259
260
            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
261
              }
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
        },
        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
280
                return ($val > 0 && $val <= 16);
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
            },
            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,
304
            type        => 'lfsrpoly',
305
            unit        => 'hex',
306
            depends_on  => 'LFSR_WIDTH',
307
            values      => sub {
308
309
310
                my ($val, $old, $top) = @_;
                $top = 64 if !defined $top;
                return $val > 0 && $val <= (2**($top) - 1);
311
312
313
314
315
316
317
318
319
320
            },
            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',
321
            unit        => 'hex',
322
            depends_on  => 'LFSR_WIDTH',
323
            values      => sub {
324
325
326
                my ($val, $old, $top) = @_;
                $top = 64 if !defined $top;
                return $val > 0 && $val <= (2**($top) - 1);
327
328
329
330
331
332
            },
            group => 'lfsr',
            order => 30,
        },

        # External reset
333
        RST_EXT_EN => {
334
335
            description => "Use external reset",
            help        => "If enabled, the FIJI logic can be reset using an FPGA pin.",
336
            ini_name    => "RST_EXT_EN",
337
            type        => 'boolean',
338
339
            default     => 0,
            phases_opt  => ['setup'],
340
341
342
            group       => 'reset_external',
            order       => 10,
        },
343
        RST_EXT_ACT => {
344
345
            description => "External Reset: Active level",
            help        => "If enabled, the FIJI logic can be reset using an FPGA pin.",
346
            ini_name    => "RST_EXT_ACT",
347
348
            type        => 'bit',
            values      => [qw(0 1)],
349
            phases_opt  => ['setup', 'download'],
350
            default     => '1',
351
            depends_on  => 'RST_EXT_EN',
352
353
354
            group       => 'reset_external',
            order       => 20,
        },
355
        RST_EXT_IN_NAME => {
356
357
            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.",
358
            ini_name    => "RST_EXT_IN_NAME",
Christian Fibich's avatar
Christian Fibich committed
359
            default     => "s_fiji_reset_i",
360
            phases_opt  => ['setup', 'download'],
Christian Fibich's avatar
Christian Fibich committed
361
            type        => "external_port",
362
            group       => 'reset_external',
363
            depends_on  => 'RST_EXT_EN',
364
365
366
367
368
            phases_opt  => [qw(instrument download)],
            order       => 30,
        },

        # Reset from DUT
369
        RST_DUT_OUT_EN => {
370
371
            description  => "Enable DUT-to-FIJI reset",
            help         => "If enabled, a net in the DUT is used as a reset source for the FIJI logic.",
372
            ini_name     => "RST_DUT_OUT_EN",
373
            type         => 'boolean',
374
375
            default      => 0,
            phases_opt  => ['setup'],
376
            group        => 'reset_from_dut',
377
            forbidden_by => 'RST_DUT_IN_EN',
378
379
            order        => 10,
        },
380
        RST_DUT_OUT_NAME => {
381
            description => "Source for DUT-to-FIJI reset",
382
            help        => "If enabled, a net in the DUT is used as a reset source for the FIJI logic.",
383
384
            ini_name    => "RST_DUT_OUT_NAME",
            depends_on  => 'RST_DUT_OUT_EN',
385
            type        => 'net',
386
            default     => "",
387
            phases_opt  => [qw(setup download)],
388
389
390
            group       => 'reset_from_dut',
            order       => 30,
        },
391
        RST_DUT_OUT_ACT => {
392
            description => "Active level of DUT-to-FIJI reset",
393
            help        => "If enabled, a net in the DUT is used as a reset source for the FIJI logic.",
394
            ini_name    => "RST_DUT_OUT_ACT",
395
396
397
            type        => 'bit',
            values      => [qw(0 1)],
            default     => '1',
398
            phases_opt  => ['setup'],
399
            depends_on  => 'RST_DUT_OUT_EN',
400
401
402
403
404
            group       => 'reset_from_dut',
            order       => 20,
        },

        # Reset to DUT
405
        RST_DUT_IN_EN => {
406
407
            description  => "Enable FIJI-to-DUT reset",
            help         => "If enabled, the DUT will be reset from the FIJI logic.",
408
            ini_name     => "RST_DUT_IN_EN",
409
            type         => 'boolean',
410
411
            default      => 0,
            phases_opt  => ['setup'],
412
            group        => 'reset_to_dut',
413
            forbidden_by => 'RST_DUT_OUT_EN',
414
415
            order        => 10,
        },
416
        RST_DUT_IN_NAME => {
417
418
            description => "Port for FIJI-to-DUT reset",
            help        => "The specified DUT reset input will be connected\n to the FIJI logic's reset output.",
419
            ini_name    => "RST_DUT_IN_NAME",
420
            default     => "",
421
            phases_opt  => [qw(setup download)],
422
            depends_on  => 'RST_DUT_IN_EN',
423
424
425
426
            type        => 'toplevel_port',
            group       => 'reset_to_dut',
            order       => 40,
        },
427
        RST_DUT_IN_DUR => {
428
429
            description => "Duration for FIJI-to-DUT reset",
            help        => "Enter the duration of each FIJI-to-DUT reset operation in clock cycles.",
430
            ini_name    => "RST_DUT_IN_DUR",
431
432
            type        => 'natural',
            default     => 1,
433
            phases_opt  => ['setup'],
434
435
436
437
438
            unit        => 'cycles',
            values      => sub {
                my $val = shift;
                return $val > 0 && $val <= 2**32 - 1;
            },
439
            depends_on => 'RST_DUT_IN_EN',
440
441
442
            group      => 'reset_to_dut',
            order      => 30,
        },
443
        RST_DUT_IN_ACT => {
444
            description => "Active level of FIJI-to-DUT reset",
445
            help        => "Enter the level the FIJI-to-DUT reset signal shall be brought to during reset.",
446
            ini_name    => "RST_DUT_IN_ACT",
447
448
            type        => 'bit',
            values      => [qw(0 1)],
449
            phases_opt  => ['setup'],
450
            default     => '1',
451
            depends_on  => 'RST_DUT_IN_EN',
452
453
454
455
456
            group       => 'reset_to_dut',
            order       => 20,
        },

        # Trigger from DUT
457
        TRIG_DUT_EN => {
458
459
            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.",
460
            ini_name    => "TRIG_DUT_EN",
461
            type        => 'boolean',
462
463
            default     => 0,
            phases_opt  => ['setup'],
464
465
466
            group       => 'trigger',
            order       => 10,
        },
467

468
        TRIG_DUT_ACT => {
469
            description => "Active level of DUT-to-FIJI trigger",
470
            help        => "Select the signal level to trigger fault injection.",
471
            ini_name    => "TRIG_DUT_ACT",
472
473
            type        => 'bit',
            values      => [qw(0 1)],
474
            phases_opt  => ['setup'],
475
            default     => '1',
476
            depends_on  => 'TRIG_DUT_EN',
477
            group       => 'trigger',
478
479
480
            order       => 20,
        },

481
        TRIG_DUT_NAME => {
482
483
            description => "Source net for DUT-to-FIJI trigger",
            help        => "Select the net in the DUT which shall be used to trigger fault injection operations.",
484
            ini_name    => "TRIG_DUT_NAME",
485
            default     => "",
486
            phases_opt  => [qw(setup download)],
487
            depends_on  => 'TRIG_DUT_EN',
488
489
            type        => 'net',
            group       => 'trigger',
490
491
492
493
            order       => 30,
        },

        # External trigger
494
        TRIG_EXT_EN => {
495
496
            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.",
497
            ini_name    => "TRIG_EXT_EN",
498
            type        => 'boolean',
499
500
            default     => 0,
            phases_opt  => ['setup'],
501
502
503
            group       => 'trigger',
            order       => 40,
        },
504
        TRIG_EXT_ACT => {
505
            description => "Active level of external trigger",
506
            help        => "Select the port level to trigger fault injection.",
507
            ini_name    => "TRIG_EXT_ACT",
508
509
            type        => 'bit',
            values      => [qw(0 1)],
510
            phases_opt  => ['setup'],
511
            default     => '1',
512
            depends_on  => 'TRIG_EXT_EN',
513
514
515
            group       => 'trigger',
            order       => 50,
        },
516
        TRIG_EXT_IN_NAME => {
517
            description => "External trigger port name",
518
            help        => "Specify the name of the external trigger port in the wrapper.\nThis port name must not exist in the toplevel.",
519
            ini_name    => "TRIG_EXT_IN_NAME",
Christian Fibich's avatar
Christian Fibich committed
520
            type        => "external_port",
521
            phases_opt  => ['setup'],
522
523
            default     => "s_fiji_trig_ext_i",
            depends_on  => 'TRIG_EXT_EN',
524
525
526
            group       => "trigger",
            order       => 60,
        },
527
        FD_1_EN => {
528
529
            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.",
530
            ini_name    => "FD_1_EN",
531
532
            type        => 'boolean',
            default     => 0,
533
            phases_opt  => ['setup'],
534
535
536
            group       => 'fault_detect',
            order       => 10,
        },
537
        FD_1_NAME => {
538
539
            description => "Source net for fault-detect bit 1",
            help        => "Select the net in the DUT which shall be used for the fault detection feature.",
540
            ini_name    => "FD_1_NAME",
541
            type        => 'net',
542
            default     => "",
543
            phases_opt  => [qw(setup download)],
544
            depends_on  => 'FD_1_EN',
545
546
547
            group       => 'fault_detect',
            order       => 20,
        },
548
        FD_1_INVERT => {
549
550
            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.",
551
            ini_name    => "FD_1_INVERT",
552
553
            type        => 'boolean',
            values      => [qw(0 1)],
554
            phases_opt  => ['setup'],
555
            default     => '0',
556
            depends_on  => 'FD_1_EN',
557
558
559
            group       => 'fault_detect',
            order       => 30,
        },
560
        FD_2_EN => {
561
562
            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.",
563
            ini_name    => "FD_2_EN",
564
565
            type        => 'boolean',
            default     => 0,
566
            phases_opt  => ['setup'],
567
568
569
            group       => 'fault_detect',
            order       => 40,
        },
570
        FD_2_NAME => {
571
572
            description => "Source net for fault-detect bit 2",
            help        => "Select the net in the DUT which shall be used for the fault detection feature.",
573
            ini_name    => "FD_2_NAME",
574
            type        => 'net',
575
            default     => "",
576
            phases_opt  => [qw(setup download)],
577
            depends_on  => 'FD_2_EN',
578
579
580
            group       => 'fault_detect',
            order       => 50,
        },
581
        FD_2_INVERT => {
582
583
            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.",
584
            ini_name    => "FD_2_INVERT",
585
586
            type        => 'boolean',
            values      => [qw(0 1)],
587
            phases_opt  => ['setup'],
588
            default     => '0',
589
            depends_on  => 'FD_2_EN',
590
591
592
593
594
            group       => 'fault_detect',
            order       => 60,
        },
        RX_IN_NAME => {
            description => "RX port name",
595
            help        => "Specify the name of the Host-to-FIJI serial RX port in the wrapper.\nThis port name must not exist in the toplevel.",
596
            ini_name    => "RX_IN_NAME",
Christian Fibich's avatar
Christian Fibich committed
597
            type        => "external_port",
598
599
600
            default     => "s_fiji_rx_i",
            phases_opt  => [qw(instrument download)],
            group       => "general_control",
Stefan Tauner's avatar
Stefan Tauner committed
601
            order       => 11,
602
603
604
        },
        TX_OUT_NAME => {
            description => "TX port name",
605
            help        => "Specify the name of the FIJI-to-Host serial TX port in the wrapper.\nThis port name must not exist in the toplevel.",
606
            ini_name    => "TX_OUT_NAME",
Christian Fibich's avatar
Christian Fibich committed
607
            type        => "external_port",
608
609
610
            phases_opt  => [qw(instrument download)],
            default     => "s_fiji_tx_o",
            group       => "general_control",
Stefan Tauner's avatar
Stefan Tauner committed
611
            order       => 12,
612
        },
613
        OPTIMIZATIONS => {
614
            description => "Optimization Settings",
615
            help        => "Specifies which set of constraints to use in synthesis/P&R to\n- prevent optimizations and/or\n- fix physical placement.",
616
            ini_name    => "OPTIMIZATIONS",
617
            type        => "dropdown",
618
            values      => \@optimization_settings,
619
            default     => "ALLOW",
620
            phases_opt  => [qw(setup)],
621
622
623
            group       => "general_control",
            order       => 50,
        },
624
625
626
627
628
629
630
631
632
633
634
        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,
        },
635
        IMPL_TOOL => {
636
637
            description => "Implementation Tool",
            help        => "The FPGA implementation tool that will be used. Needed for generating appropriate constraints.",
638
            ini_name    => "IMPL_TOOL",
639
            type        => "dropdown",
Christian Fibich's avatar
Christian Fibich committed
640
            values      => ["ALTERA_QUARTUS", "XILINX_VIVADO"],
641
642
643
644
645
            default     => "ALTERA_QUARTUS",
            phases_opt  => [qw(setup)],
            group       => "general_control",
            order       => 70,
        },
646
    );
647
648
}

649
650
651
use constant \%designmap;
use constant DESIGNMAP => \%designmap;

Christian Fibich's avatar
Christian Fibich committed
652
653
654
655
656
657
658
#** @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
659
my %displaygroups;
660

661
662
663
664
665
BEGIN {
    %displaygroups = (
        fault_detect => {
            title       => "Fault Detection Settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
666
667
            description => "Settings concerning internal fault detection propagation",
            order       => 80,
668
669
670
671
        },
        trigger => {
            title       => "Trigger Settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
672
673
            description => "Settings concerning internal and external fault injection triggers",
            order       => 70,
674
675
        },
        reset_to_dut => {
676
            title       => "Reset from FIJI to DUT",
677
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
678
679
            description => "Settings concerning FIJI's ability to reset the DUT",
            order       => 60,
680
681
        },
        reset_from_dut => {
682
            title       => "Reset from DUT to FIJI",
683
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
684
685
            description => "Settings concerning FIJI's internal (from DUT) reset feature",
            order       => 50,
686
687
        },
        reset_external => {
688
689
            title       => "External Reset",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
690
691
            description => "Settings concerning FIJI's external (via pin) reset feature",
            order       => 40,
692
693
694
695
        },
        lfsr => {
            title       => "LFSR Settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
696
697
            description => "Settings concerning the LFSR for Stuck-open emulation",
            order       => 30,
698
699
        },
        general_control => {
700
            title       => "General settings",
701
            subtitle    => "",
702
            description => "Settings concerning miscellaneous features of FIJI",
Christian Fibich's avatar
Christian Fibich committed
703
            order       => 10,
704
705
706
707
        },
        clock => {
            title       => "Clock settings",
            subtitle    => "",
Christian Fibich's avatar
Christian Fibich committed
708
709
            description => "Settings concerning the clocking of the FIJI logic",
            order       => 20,
710
711
712
713
714
715
        },
        fius => {
            title       => "FIUs",
            subtitle    => "",
            description => "Settings concerning Fault Injection Units",
            order       => 100
716
        }
717
    );
718
}
719

720
721
use constant \%displaygroups;
use constant DISPLAYGROUPS => \%displaygroups;
722
use constant DISPLAYGROUPS_FIU_KEY => 'fius';
723

Christian Fibich's avatar
Christian Fibich committed
724
725
726
727
728
729
730
731
732
## @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
733
#                   - net: hierarchical path of a net from the input netlist
734
#                   - driver: driver-specific hierarchical path of a net from the input netlist
Christian Fibich's avatar
Christian Fibich committed
735
736
737
738
739
740
741
742
#    - 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
#    - default      (optional) default value if not given in file and not determinable otherwise
743
my %fiumap;
744

745
BEGIN {
746
    %fiumap = (
747
748
749
750
751
752
        FIU_NAME => {
            ini_name => "NAME",
            default  => "",
            help     => "Display name for this FIU",
            phases_opt => [qw(setup instrument download)]
        },
753
754
755
        FIU_NET_NAME => {
            ini_name   => "NET_NAME",
            default    => "",
756
757
            type       => 'net',
            help       => "String representation of the instrumented net.",
758
            phases_opt  => [qw(setup download)], # Either FIU or net name is strongly recommended during download
759
760
761
762
        },
        FIU_DRIVER_TYPE => {
            ini_name   => "DRIVER_TYPE",
            values     => [qw(PIN PORT ASSIGN)],
763
            default    => "PIN",
764
765
766
767
768
            phases_opt => [qw(setup)],
        },
        FIU_DRIVER_PATH => {
            ini_name   => "DRIVER_PATH",
            default    => "",
769
            type       => 'driver',
770
            help       => "String representation of a driver.",
771
            phases_opt  => [qw(setup download)], # Either FIU or net name is strongly recommended during download
772
773
774
775
776
        },
        FIU_MODEL => {
            ini_name   => "FAULT_MODEL",
            default    => "RUNTIME",
            values     => [qw(RUNTIME PASS_THRU STUCK_AT_0 STUCK_AT_1 STUCK_OPEN DELAY SEU)],
777
            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.",
778
779
780
781
782
783
            phases_opt => [qw(setup)],
        },
        FIU_LFSR_MASK => {
            ini_name   => "LFSR_MASK",
            default    => 0,
            type       => 'hexadecimal',
784
            help       => "Selects the bits of the LFSR that are ANDed together to determine the value of a floating net.",
785
786
787
            phases_opt => [qw(setup)],
        },
    );
788
789
790
791
}

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

Christian Fibich's avatar
Christian Fibich committed
793
794
795
796
797
798
799
800
801
802
803
804
#** @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)
805
806
#                   - 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
807
808
809
810
811
812
813
#    - 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
814
#    - default      (optional) default value if not given in file and not determinable otherwise.
815
#                   Can either be a scalar or a function pointer expecting a FIJI settings reference.
Christian Fibich's avatar
Christian Fibich committed
816
817
818
#    - 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
819
my %testconstmap;
820

821
BEGIN {
822
823
824
825
826
827
828
829
830
    %testconstmap = (
        FIJI_CFG => {
            description => "FIJI Settings File",
            ini_name    => "FIJI_CFG",
            default     => "fiji.cfg",

            #gui_modes   => [qw (manual auto random)],
        },
        UART => {
831
            description => "Control UART",
832
            ini_name    => "UART",
833
834
835
836
            default     => sub {
                my $devs = FIJI::Utils::get_uart_devs();
                return (scalar(@$devs) > 0) ? @{$devs}[0] : "";
            },
Christian Fibich's avatar
Christian Fibich committed
837
            help        => "The host's serial port connected to FIJI.\nLinux/Unix: /dev/ttyUSBx, /dev/ttyACMx, /dev/ttySx\nWindows: COMx",
838
            type        => "autocomplete",
839
840
        },
        HALT_ON_FAULT_DETECT => {
Christian Fibich's avatar
Christian Fibich committed
841
842
843
844
845
846
847
            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,
848
            activated_by_settings => sub {
Christian Fibich's avatar
Christian Fibich committed
849
                my $settings = shift;
850
                return ($settings->{'design'}->{'FD_1_EN'} == 1 || $settings->{'design'}->{'FD_2_EN'} == 1);
851
            },
Christian Fibich's avatar
Christian Fibich committed
852
            help                  => "Specify if the injection campaign shall be aborted when a fault has been detected"
853
854
855
856
857
858
859
860
861
862
863
864
865
        },
        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)],
866
            order       => 12,
Christian Fibich's avatar
Christian Fibich committed
867
            help        => "Specify if the injection campaign shall start again after the last test",
868
869
870
871
872
873
874
875
        },
        REPEAT_OFFSET => {
            description => "Repetition start pattern",
            ini_name    => "REPEAT_OFFSET",
            default     => 0,
            type        => 'natural',
            phases_opt  => [qw(manual)],
            gui_modes   => [qw (auto)],
876
            order       => 13,
877
            depends_on  => "REPEAT",
Christian Fibich's avatar
Christian Fibich committed
878
            help        => "Specify an offset for all repetitions except the first"
879
        },
880
881
882
883
884
885
886
887
888
889
890
891
        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"
        },

892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
        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 => {
911
912
913
914
915
916
917
            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
918
            help        => "Specify if the injection campaign shall be halted when the FIC reported that a pattern did not arrive in time."
919
920
921
922
923
924
925
926
927
        },
        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
928
            help        => "Allow multiple FIUs to generate errors within one pattern"
929
        },
930
        MIN_DUR_T1 => {
931
            description => "Minimum Duration T1",
932
            ini_name    => "MIN_DUR_T1",
933
            default     => sub {shift->default_timer_value()},
934
935
936
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            type        => "min_duration",
937
            matching    => "MAX_DUR_T1",
938
            unit        => "cycles",
939
            order       => 20,
Christian Fibich's avatar
Christian Fibich committed
940
            help        => "Minimum duration before the first fault is applied."
941
        },
942
        MIN_DUR_T2 => {
943
            description => "Minimum Duration T2",
944
            ini_name    => "MIN_DUR_T2",
945
            default     => sub {shift->default_timer_value()},
946
947
948
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            type        => "min_duration",
949
            matching    => "MAX_DUR_T2",
950
            unit        => "cycles",
951
            order       => 40,
Christian Fibich's avatar
Christian Fibich committed
952
            help        => "Minimum duration to keep the first fault is enabled."
953
        },
954
        MAX_DUR_T1 => {
955
            description => "Maximum Duration T1",
956
            ini_name    => "MAX_DUR_T1",
957
            default     => sub {10 * shift->default_timer_value()},
958
959
960
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            type        => "max_duration",
961
            matching    => "MIN_DUR_T1",
962
            unit        => "cycles",
963
            order       => 30,
Christian Fibich's avatar
Christian Fibich committed
964
            help        => "Maximum duration before the first fault is applied."
965
        },
966
        MAX_DUR_T2 => {
967
            description => "Maximum Duration T2",
968
            ini_name    => "MAX_DUR_T2",
969
            default     => sub {10 * shift->default_timer_value()},
970
971
972
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            type        => "max_duration",
973
            matching    => "MIN_DUR_T2",
974
            unit        => "cycles",
975
            order       => 50,
Christian Fibich's avatar
Christian Fibich committed
976
            help        => "Maximum duration to keep the first fault is enabled."
977
978
979
980
        },
        PROB_STUCK_AT_0 => {
            description => "Probability of stuck-at-0 fault",
            ini_name    => "PROB_STUCK_AT_0",
981
            default     => 0.1,
982
983
984
985
986
            type        => 'prob',
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            fault       => "STUCK_AT_0",
            order       => 70,
Christian Fibich's avatar
Christian Fibich committed
987
            help        => "Probability of a stuck-at-0 fault.\nFault probabilites add up, the inverse probability of this sum is the error-free probability."
988
989
990
991
        },
        PROB_STUCK_AT_1 => {
            description => "Probability of stuck-at-1 fault",
            ini_name    => "PROB_STUCK_AT_1",
992
            default     => 0.1,
993
994
995
996
997
            type        => 'prob',
            phases_opt  => [qw(manual auto)],
            gui_modes   => [qw (random)],
            fault       => "STUCK_AT_1",
            order       => 80,
Christian Fibich's avatar
Christian Fibich committed
998
            help        => "Probability of a stuck-at-1 fault.\nFault probabilites add up, the inverse probability of this sum is the error-free probability."
999
1000
1001
1002
        },
        PROB_DELAY => {
            description => "Probability of delay fault",
            ini_name    => "PROB_DELAY",
1003
            default     => 0.1,
Christian Fibich's avatar