点灯程序的 test bench ,自动生成如下代码,,
请教 // Add stimulus here
后面怎么写激励信号呢? 谢谢,,不要直接给实例而不说明呀,,最后说明加实例 呵呵,要不还是不懂
谢谢
module test;
// Inputs
reg clk;
reg rst;
reg sw0;
reg sw1;
reg sw2;
reg sw3;
// Outputs
wire led0;
wire led1;
wire led2;
wire led3;
wire led4;
wire led5;
wire led6;
wire led7;
// Instantiate the Unit Under Test (UUT)
sw_led uut (
.clk(clk),
.rst(rst),
.sw0(sw0),
.sw1(sw1),
.sw2(sw2),
.sw3(sw3),
.led0(led0),
.led1(led1),
.led2(led2),
.led3(led3),
.led4(led4),
.led5(led5),
.led6(led6),
.led7(led7)
);
initial begin
// Initialize Inputs
clk = 0;
rst = 1;
sw0 = 0;
sw1 = 0;
sw2 = 0;
sw3 = 0;
// Wait 100 ns for global reset to finish
#100;
// Add stimulus here end endmodule
附点灯的代码
module sw_led(clk, rst, sw0, sw1, sw2, sw3, led0, led1, led2, led3, led4, led5, led6, led7); input
clk; input
rst; input
sw0; input
sw1; input
sw2; input
sw3; output
led0; output
led1; output
led2; output
led3; output
led4; output
led5; output
led6; output
led7;
wire
led0;
wire
led1;
wire
led2;
wire
led3;
wire
led4;
wire
led5;
wire
led6;
wire
led7;
wire [3 :0] sw;
reg [7 :0] led;
assign sw =
{sw0,sw1,sw2,sw3};
assign {led0,led1,led2,led3,led4,led5,led6,led7} = led;
always @ ( posedge clk or negedge rst)
begin
if(!rst)
led<='b0;
else
case ( sw )
4'b1110: led <= 8'b0000_0001;
4'b1101: led <= 8'b0000_0010;
4'b1011: led <= 8'b0000_0100;
4'b0111: led <= 8'b0000_1000;
4'b1100: led <= 8'b0001_0000;
4'b1001: led <= 8'b0010_0000;
4'b0011: led <= 8'b0100_0000;
4'b0110: led <= 8'b1000_0000;
default: led <= 8'b0000_0000;
endcase
endendmodule
此帖出自
小平头技术问答
一周热门 更多>