1 |
3 |
Quanticles |
|
2 |
|
|
# The list at the beginning defines the scan lists. Defining an input name or output
|
3 |
|
|
# name determines what type of scan signal it is.
|
4 |
|
|
|
5 |
4 |
Quanticles |
# This must be defined, whether or not it's used
|
6 |
|
|
my $scan_reset_name = 'scan_reset';
|
7 |
|
|
|
8 |
3 |
Quanticles |
# Values are always readable (the buffering latch is what is read if writable)
|
9 |
12 |
Quanticles |
# Top of the list is first to come out of the scan chain
|
10 |
|
|
my @signal_list = ( # Outputs - chip to outside
|
11 |
|
|
{ size => 1, writable => 0, name => 'read_data_1'},
|
12 |
|
|
{ size => 2, writable => 0, name => 'read_data_2'},
|
13 |
|
|
{ size => 3, writable => 0, name => 'read_data_3'},
|
14 |
6 |
Quanticles |
|
15 |
12 |
Quanticles |
{ size => 16, writable => 0, name => 'read_data_array', addr_bits => 2, data_bits => 4},
|
16 |
3 |
Quanticles |
|
17 |
12 |
Quanticles |
# Inputs - outside to chip
|
18 |
6 |
Quanticles |
{ size => 1, writable => 1, name => 'memory_load_mode'},
|
19 |
|
|
|
20 |
|
|
{ size => 9, writable => 1, name => 'addr'},
|
21 |
|
|
{ size => 64, writable => 1, name => 'input_data'},
|
22 |
|
|
{ size => 64, writable => 0, name => 'output_data'},
|
23 |
|
|
{ size => 1, writable => 1, name => 'w1_r0'},
|
24 |
|
|
|
25 |
3 |
Quanticles |
{ size => 1, writable => 1, name => 'write_data_1'},
|
26 |
11 |
Quanticles |
{ size => 2, writable => 1, name => 'write_data_2', reset => 3},
|
27 |
3 |
Quanticles |
{ size => 3, writable => 1, name => 'write_data_3'},
|
28 |
|
|
|
29 |
11 |
Quanticles |
{ size => 16, writable => 1, name => 'write_data_array', addr_bits => 2, data_bits => 4, reset => 0xAA55},
|
30 |
12 |
Quanticles |
|
31 |
|
|
# Scan Reset - Make first bit in chain to allow a quick reset if needed
|
32 |
|
|
{ size => 1, writable => 1, name => $scan_reset_name},
|
33 |
3 |
Quanticles |
);
|
34 |
|
|
|
35 |
4 |
Quanticles |
|
36 |
|
|
|
37 |
|
|
# We're going to calculate the total scan chain length.
|
38 |
|
|
# We also use this to set some key values and do some error checking, so do not comment out this section.
|
39 |
3 |
Quanticles |
my $scan_chain_length = 0;
|
40 |
4 |
Quanticles |
my $reset_exists = 0;
|
41 |
|
|
my $scan_reset_bit = -1;
|
42 |
3 |
Quanticles |
|
43 |
|
|
for (my $i = 0; $i < scalar @signal_list; $i++) {
|
44 |
|
|
$signal_list[$i]{start} = $scan_chain_length;
|
45 |
4 |
Quanticles |
|
46 |
|
|
# Check to see if we have a reset signal
|
47 |
|
|
if ($signal_list[$i]{name} eq $scan_reset_name) {
|
48 |
|
|
$scan_reset_exists = 1;
|
49 |
|
|
$scan_reset_bit = $scan_chain_length;
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
# Here we set the default values for the addr_bits and data_bits fields
|
53 |
|
|
$signal_list[$i]{addr_bits} = 0 if (!exists $signal_list[$i]{addr_bits});
|
54 |
|
|
$signal_list[$i]{data_bits} = 0 if (!exists $signal_list[$i]{data_bits});
|
55 |
|
|
|
56 |
|
|
# It's an array if either of these values are set
|
57 |
|
|
if ($signal_list[$i]{addr_bits} == 0 && $signal_list[$i]{data_bits} == 0) {
|
58 |
|
|
|
59 |
|
|
# Default case is that nothing is set so we just add the size
|
60 |
|
|
$scan_chain_length += $signal_list[$i]{size};
|
61 |
|
|
|
62 |
|
|
} else {
|
63 |
|
|
|
64 |
|
|
# Let's do some error checking while we're at it: 2^addr_bits * data_bits >= size
|
65 |
|
|
if ((1 << $signal_list[$i]{addr_bits}) * $signal_list[$i]{data_bits} < $signal_list[$i]{size}) {
|
66 |
|
|
print STDERR "SCAN ERROR: addr_bits ($signal_list[$i]{addr_bits}) and data_bits ( $signal_list[$i]{data_bits})";
|
67 |
|
|
print STDERR " are not big enough to fit size ($signal_list[$i]{size}) for $signal_list[$i]{name}\n";
|
68 |
|
|
die;
|
69 |
|
|
}
|
70 |
|
|
|
71 |
|
|
# Passed the error checking, we're instead going to have address and data fields
|
72 |
|
|
$scan_chain_length += $signal_list[$i]{addr_bits};
|
73 |
|
|
$scan_chain_length += $signal_list[$i]{data_bits};
|
74 |
|
|
|
75 |
|
|
}
|
76 |
3 |
Quanticles |
}
|