| 1 | .########################################################################## |
| 2 | .# |
| 3 | .# File: siu_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 | .# toggle - use to generate toggle type coverage for a signal or field. |
| 17 | .# just pass the number of bits in the variable. Use like this: |
| 18 | .# |
| 19 | .# sample variable_toggle_sample (variable[5:0]) { |
| 20 | .# . &toggle(6); |
| 21 | .# } |
| 22 | .# |
| 23 | .########################################################################## |
| 24 | .sub toggle { |
| 25 | . local($num_bits) = @_; |
| 26 | . |
| 27 | . for($i=$num_bits-1; $i >= 0; $i--) { |
| 28 | . printf (" wildcard state s_bit_%02d_0 ( %d\'b", $i, $num_bits ); |
| 29 | . for($j=$num_bits-1; $j >= 0; $j--) { |
| 30 | . if( $i == $j ) { print "0"; } |
| 31 | . else { print "x"; } |
| 32 | . } |
| 33 | . print " );\n"; |
| 34 | . printf (" wildcard state s_bit_%02d_1 ( %d\'b", $i, $num_bits ); |
| 35 | . for($j=$num_bits-1; $j >= 0; $j--) { |
| 36 | . if( $i == $j ) { print "1"; } |
| 37 | . else { print "x"; } |
| 38 | . } |
| 39 | . print " );\n"; |
| 40 | . } |
| 41 | .} |
| 42 | . |
| 43 | .########################################################################### |
| 44 | .# toggle2 - use to generate toggle type coverage for a signal or field. |
| 45 | .# just pass the number of bits in the variable andn its name like this: |
| 46 | .# |
| 47 | .# sample variable_toggle_sample (variable[5:0]) { |
| 48 | .# . &toggle2(6, "variable" ); |
| 49 | .# } |
| 50 | .# |
| 51 | .# &toggle uses wildcards which are said to hurt performance. This uses |
| 52 | .# a different technique. |
| 53 | .########################################################################## |
| 54 | .#sub toggle2 { |
| 55 | .# local($num_bits,$variable) = @_; |
| 56 | .# |
| 57 | .# for($i=$num_bits-1; $i >= 0; $i--) { |
| 58 | .# printf(" state s_bit_%02d_0 ( %s[%d] == 1'b0 );\n", $i, $variable, $i ); |
| 59 | .# printf(" state s_bit_%02d_1 ( %s[%d] == 1'b1 );\n", $i, $variable, $i ); |
| 60 | .# } |
| 61 | .#} |