这个代码的testbench怎么写?
时间:10-02
整理:3721RD
点击:
module led_water(sys_clk,sys_rstn,led);
//输入输出信号定义
input sys_clk; //全局时钟50Mhz
input sys_rstn; //复位信号,低电平有效
output [7:0] led; //led输出信号
reg [7:0] led; //led寄存器
reg [24:0] delay_out; //延时计数器
//逻辑部分
always@(posedge sys_clk or negedge sys_rstn)
begin
if(!sys_rstn)
delay_out<=25'd0;
else
begin
if(delay_out==25'd24999999)
delay_out<=25'd0;
else
delay_out<=delay_out+1'b1;
end
end
always@(posedge sys_clk or negedge sys_rstn)
begin
if(!sys_rstn)
led<=8'b11111111;
else
begin
if(delay_out==25'd24999999)
led<=~led;
else
led<=led;
end
end
endmodule
//输入输出信号定义
input sys_clk; //全局时钟50Mhz
input sys_rstn; //复位信号,低电平有效
output [7:0] led; //led输出信号
reg [7:0] led; //led寄存器
reg [24:0] delay_out; //延时计数器
//逻辑部分
always@(posedge sys_clk or negedge sys_rstn)
begin
if(!sys_rstn)
delay_out<=25'd0;
else
begin
if(delay_out==25'd24999999)
delay_out<=25'd0;
else
delay_out<=delay_out+1'b1;
end
end
always@(posedge sys_clk or negedge sys_rstn)
begin
if(!sys_rstn)
led<=8'b11111111;
else
begin
if(delay_out==25'd24999999)
led<=~led;
else
led<=led;
end
end
endmodule
给个rst,给个clk就行了,clk<= ~clk
还是不会,就是不会写实例化,真的烦
http://blog.csdn.net/hanghang121/article/details/20073985
希望对你有帮助