module ledwater(led,clock,reset_n); //模块名ledwater
output[7:0] led; //定义LED输出口
input clock; //定义时钟输入口
input reset_n; //复位
reg[8:0] led_r; //定义输出寄存器
reg[25:0] count; //时钟分频计数器
wire div_clk;
assign led = led_r[7:0]; //寄存器输出
//时钟分频
always @ (posedge clock or negedge reset_n)
begin
if(~reset_n)
count <= 25'd0;
else if(div_clk)
count <= 25'd0;
else
count <= count + 1'b1;
end
assign div_clk = (count >= 24000000);
always @ (posedge clock or negedge reset_n)
begin
if(~reset_n)
led_r <= 9'b111111111; //是,则重新赋初值
else if(div_clk)
begin
if(led_r == 9'd0) //循环完毕吗?
led_r <= 9'b111111111; //是,则重新赋初值
else
led_r <= led_r << 1; //是,则输出左移一位
end
end
endmodule
谁能大致写下上面的testbench 我就看这个例子参考下 怎么写啊 哭死了要 谢谢了 |