我正在尝试为我的解码器模块(modelsim中的verilog)编写一个tcl脚本,我需要循环从000到111的'din‘输入值
这就是我现在所想出来的。
vsim work.decode_shift
add wave -noupdate -format Logic -radix binary /decode_shift/din
add wave -noupdate -format Logic -radix binary /decode_shift/dout
for { set i 0 } { $i==0111 } { incr i } {
force din $i
run 100
}
run @500ns它不能工作,因为一些类型的问题,我不知道如何绕过。我做错了什么?在tcl中增加二进制位的正确方法是什么?
发布于 2012-05-20 03:40:25
使用Tcl,您不需要递增二进制数字。将数字格式化为二进制。在8.6之前,您可以使用binary format和binary scan的组合来执行转换,如下所示:
vsim work.decode_shift
add wave -noupdate -format Logic -radix binary /decode_shift/din
add wave -noupdate -format Logic -radix binary /decode_shift/dout
for { set i 0 } { $i<=7 } { incr i } { # Need non-binary literal
# Convert to 8 binary digits, store result in “i_bin” variable
binary scan [binary format c $i] B8 i_bin
force din $i_bin; # Assume takes 8 bits; [string range] to trim otherwise
run 100
}
run @500ns如果你的版本是8.6,你可以这样做:
vsim work.decode_shift
add wave -noupdate -format Logic -radix binary /decode_shift/din
add wave -noupdate -format Logic -radix binary /decode_shift/dout
for { set i 0 } { $i<=0b111 } { incr i } { # Binary literal...
force din [format %04b $i]; # width 4 field, zero padded on left
run 100
}
run @500ns发布于 2012-05-19 22:42:25
不知道这是否能帮助你http://codepad.org/YX4nfMIS (如下所示),它会生成一个二进制表示数字的字符串升序列表。但这可能不是Verilog想要的数据。
set l { "000" "001" "010" "011" "100" "101" "110" "111"}
for { set i 0} { $i<8 } { incr i } {
puts [lindex $l $i]
}或者就像Donal指出的那样
set l { "000" "001" "010" "011" "100" "101" "110" "111"}
foreach i $l {
puts $i
}https://stackoverflow.com/questions/10665943
复制相似问题