|
发表于 2008-12-3 14:49:00
|
显示全部楼层
testbench文件如下:
module tb_assert_always();
reg reset_n, clk;
reg[7:0] count;
wire clr;
wire[2:0] fire;
always @(posedge clk)
count <= (~reset_n || clr) ? 8'b0 : (count + 8'd1);
assign clr = (count >= 8'd143) ? 1'b1 : 1'b0;
`ifdef OVL_ASSERT_ON
ovl_always #(
`OVL_ERROR,
`OVL_ASSERT,
"ERROR: count > 15",
`OVL_COVER_CORNER,
`OVL_POSEDGE,
`OVL_ACTIVE_LOW,
`OVL_GATE_CLOCK)
chk_cnt(
clk,
reset_n,
1'b1,
count <= 8'd15,
fire);
`endif
initial begin
clk = 0;
reset_n = 0;
#7 reset_n = 1;
end
always begin
#5 clk = ~clk;
end
always @(posedge clk)
$monitor("At time %t, count = %d", $time, count);
endmodule
modelsim命令运行文件run.do文件内容如下:
# All Rights Reserved.
#
# THIS WORK CONTAINS TRADE SECRET AND PROPRIETARY INFORMATION
# WHICH IS THE PROPERTY OF MENTOR GRAPHICS CORPORATION
# OR ITS LICENSORS AND IS SUBJECT TO LICENSE TERMS.
# Use this run.do file to run this example.
# Either bring up ModelSim and type the following at the "ModelSim>" prompt:
# do run.do
# or, to run from a shell, type the following at the shell prompt:
# vsim -do run.do -c
# (omit the "-c" to see the GUI while running from the shell)
onbreak {resume}
# create library
if [file exists work] {
vdel -all
}
vlib work
# compile and link C source files
#sccom -g count.cpp
#sccom -link
# compile Verilog/VHDL source files
#vlog -f filelist.ovl
vlog +define+OVL_ASSERT_ON ovl_always.v tb_assert_always.v
# open debugging windows
quietly view *
# start and run simulation
vsim tb_assert_always
run 200 ns
注意红体字,就是OVL断言库涉及内容。这样就可以在modelsim中进行《基于断言的RTL设计》了,哥们我半年前就开始做这方面的尝试了,而且是软硬协同仿真。 |
|