Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / env / common / coverage / siu / siu_cov_inc.pal
.##########################################################################
.#
.# File: siu_cov_inc.pal
.#
.# Description:
.# -----------
.# Common Pal header file that can be used to include common defines
.# or subroutines. A "toggle" subroutine is provided to generate
.# toggle type coverage for a variable.
.#
.# $Id: $
.#
.##########################################################################
.
.###########################################################################
.# toggle - use to generate toggle type coverage for a signal or field.
.# just pass the number of bits in the variable. Use like this:
.#
.# sample variable_toggle_sample (variable[5:0]) {
.# . &toggle(6);
.# }
.#
.##########################################################################
.sub toggle {
. local($num_bits) = @_;
.
. for($i=$num_bits-1; $i >= 0; $i--) {
. printf (" wildcard state s_bit_%02d_0 ( %d\'b", $i, $num_bits );
. for($j=$num_bits-1; $j >= 0; $j--) {
. if( $i == $j ) { print "0"; }
. else { print "x"; }
. }
. print " );\n";
. printf (" wildcard state s_bit_%02d_1 ( %d\'b", $i, $num_bits );
. for($j=$num_bits-1; $j >= 0; $j--) {
. if( $i == $j ) { print "1"; }
. else { print "x"; }
. }
. print " );\n";
. }
.}
.
.###########################################################################
.# toggle2 - use to generate toggle type coverage for a signal or field.
.# just pass the number of bits in the variable andn its name like this:
.#
.# sample variable_toggle_sample (variable[5:0]) {
.# . &toggle2(6, "variable" );
.# }
.#
.# &toggle uses wildcards which are said to hurt performance. This uses
.# a different technique.
.##########################################################################
.#sub toggle2 {
.# local($num_bits,$variable) = @_;
.#
.# for($i=$num_bits-1; $i >= 0; $i--) {
.# printf(" state s_bit_%02d_0 ( %s[%d] == 1'b0 );\n", $i, $variable, $i );
.# printf(" state s_bit_%02d_1 ( %s[%d] == 1'b1 );\n", $i, $variable, $i );
.# }
.#}