Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / coverage / l2sat / l2sat_cov_inc.pal
CommitLineData
86530b38
AT
1.##########################################################################
2.#
3.# File: l2sat_cov_inc.pal
4.#
5.# Description:
6.# -----------
7.# Common Pal header file that can be used to include common defines
8.# or subroutines. A "toggle" subroutine is provided to generate
9.# toggle type coverage for a variable.
10.#
11.# $Id: $
12.#
13.##########################################################################
14.
15
16.## $cores = 8; # default settings
17.## $sys = "MSS"; # default system being simulated
18.# END_INIT
19.## $THREADS_PER_CORE = 4; # a frequently used constant
20. $BANKS = 1;
21.
22// sys = $sys, cores = $cores
23.
24.$CCX_PATH = "`TOP.cpu.ccx";
25.
26. for ( $i = 0; $i < $BANKS; $i++ ) {
27. $L2T_PATH[$i] = "`TOP.cpu.l2t${i}";
28. $L2B_PATH[$i] = "`TOP.cpu.l2b${i}";
29. }
30
31.###########################################################################
32.# toggle - use to generate toggle type coverage for a signal or field.
33.# just pass the number of bits in the variable. Use like this:
34.#
35.# sample variable_toggle_sample (variable[5:0]) {
36.# . &toggle(6);
37.# }
38.#
39.##########################################################################
40.sub toggle {
41. local($num_bits) = @_;
42.
43. for($i=$num_bits-1; $i >= 0; $i--) {
44. printf (" wildcard state s_bit_%02d_0 ( %d\'b", $i, $num_bits );
45. for($j=$num_bits-1; $j >= 0; $j--) {
46. if( $i == $j ) { print "0"; }
47. else { print "x"; }
48. }
49. print " );\n";
50. printf (" wildcard state s_bit_%02d_1 ( %d\'b", $i, $num_bits );
51. for($j=$num_bits-1; $j >= 0; $j--) {
52. if( $i == $j ) { print "1"; }
53. else { print "x"; }
54. }
55. print " );\n";
56. }
57.}
58.
59.
60.###########################################################################
61.# two_errors - use to generate coverage for two sucessive errors.
62.# Use like this:
63.#
64.# sample variable_two_bits_sample (variable[5:0]) {
65.# . &two_errors(32); //32 different errors
66.# }
67.#
68.##########################################################################
69.
70.sub two_errors {
71. local($num_errors) = @_;
72.$state_count = 0;
73.for($i=1; $i <=$num_errors; $i++){
74. for($k=1; $k<=$num_errors; $k++){
75. $new_errors[$k] = 'x';
76. }
77. $new_errors[$i] = '1';
78. for($j=1; $j <=$num_errors; $j++){
79. for($k=1; $k<=$num_errors; $k++){
80. $prev_errors[$k] = 'x';
81. }
82. $prev_errors[$j] = '1';
83. printf (" wildcard state s_bit_%02d ( ", $state_count++);
84. printf("%d\'b", $num_errors*2);
85. for($k=1; $k <= $num_errors; $k++){
86. printf("%s", $new_errors[$k]);
87. }
88. for($k=1; $k <= $num_errors; $k++){
89. printf("%s", $prev_errors[$k]);
90. }
91. printf (" );\n");
92. }
93.}
94.}
95.
96.###########################################################################
97.# partial_cores - use to generate coverage for partial cores.
98.# Use like this:
99.#
100.# sample variable_two_bits_sample (variable[5:0]) {
101.# . &partial_cores(6, 4); //at most 4 out of 6
102.# }
103.#
104.##########################################################################
105.sub partial_cores {
106. local($num_bits, $max_bits) = @_;
107.
108.$state_count = 0;
109.for($i=1; $i <= 2**$num_bits-1; $i++) {
110. $temp = $i;
111. $k = 1;
112. $bit_count = 0;
113. my @tmp;
114. for($k=1; $k <= $num_bits; $k++){
115. if($temp%2 == 0){
116. $tmp[$k] = 0;
117. }
118. else{
119. $tmp[$k] = 1;
120. $bit_count++;
121. }
122. $temp = $temp / 2;
123. }
124. if($bit_count <= $max_bits) {
125. printf (" state s_bit_%02d ( %d\'b", $state_count++, $num_bits );
126. for($j=1; $j <= $num_bits; $j++){
127. printf("%d", $tmp[$j]);
128. }
129. printf (" );\n");
130. }
131. }
132.}
133.###########################################################################
134.# toggle2 - use to generate toggle type coverage for a signal or field.
135.# just pass the number of bits in the variable andn its name like this:
136.#
137.# sample variable_toggle_sample (variable[5:0]) {
138.# . &toggle2(6, "variable" );
139.# }
140.#
141.# &toggle uses wildcards which are said to hurt performance. This uses
142.# a different technique.
143.##########################################################################
144.#sub toggle2 {
145.# local($num_bits,$variable) = @_;
146.#
147.# for($i=$num_bits-1; $i >= 0; $i--) {
148.# printf(" state s_bit_%02d_0 ( %s[%d] == 1'b0 );\n", $i, $variable, $i );
149.# printf(" state s_bit_%02d_1 ( %s[%d] == 1'b1 );\n", $i, $variable, $i );
150.# }
151.#}