|
我刚刚开始学习FPGA,用Verilog语言编了个简单的计数器的例子和仿真测试程序(用 Modelsim SE6.0d),
module counter_5bit(cnt,clk,data,rst,load);
input clk,rst,load;
input [4:0]data;
output [4:0]cnt;
reg [4:0]cnt;
always
if (~rst)
assign cnt = 0;
else
deassign cnt;
always@(posedge clk)
if (load)
#3 cnt <=data;
else if(cnt==5'h8ffff)
#2 cnt <=8'h0;
else
#4 cnt <=cnt+1;
仿真程序:module counter_test_v;
// Inputs
reg clk;
reg [4:0] data;
reg rst;
reg load;
// Outputs
wire [4:0] cnt;
// Instantiate the Unit Under Test (UUT)
counter_5bit uut (
.cnt(cnt),
.clk(clk),
.data(data),
.rst(rst),
.load(load)
);
initial
clk= 0; //初始化时钟信号
always //生成时钟信号
#5 clk = ~clk;
initial
begin //生成测试数据序列
data = 5'h25;
load = 0;
rst = 0;
#10 rst =1;
#50 data = 5'h38;
load = 1;
#10 load = 0;
#50 $finish; //完成测试,结束仿真
end
endmodule
endmodule但是怎么没有信号? |
|