This is an old revision of the document!
If you hate to type repetitive TCL commands to exercise your design, here is are some ideas.
It turns out TCL is a full-featured programming language (even if it is verbose and perhaps clunky). But, once you find some examples to cannibalize, it can be pretty easy to create very compact simulation scripts.
====Using Looping to Exercise All Combinations of 1's and 0's The following code sample shows how to loop across all combinations of 4-bits (from 0000 to 1111).
Note that when you set a variable name you just state it but when you want to get at the value stored in that variable you must prefix it with a $ sign.
Note also that you call functions using [functionName … ] syntax. In this case, “expr” evaluates an arithmetic expression.
set i 0
while {$i < 16} {
set a [expr ($i >> 3) & 1]
set b [expr ($i >> 2) & 1]
set c [expr ($i >> 1) & 1]
set d [expr ($i >> 0) & 1]
puts "Test this combination: $a $b $c $d"
add_force mySignal3 $a
add_force mySignal2 $b
add_force mySignal1 $c
add_force mySignal0 $d
run 100ns
incr i
}
Or, it could be simpler:
set i 0
while {$i < 16} {
add_force mySignal3 [expr ($i >> 3) & 1]
add_force mySignal2 [expr ($i >> 2) & 1]
add_force mySignal1 [expr ($i >> 1) & 1]
add_force mySignal0 [expr ($i >> 0) & 1]
run 100ns
incr i
}
And, if what you are forcing is itself a 4-bit quantity, this works just fine:
set i 0
while {$i < 16} {
add_force mySignal $i
run 100ns
incr i
}