|
![](static/image/common/ico_lz.png)
楼主 |
发表于 2012-6-20 13:29:45
|
显示全部楼层
代码和 tesb bench 来了
谢谢
一个点灯程序的部分代码:
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;
烧到板子里时,按下sw0 ,板子上的LED5灯是亮的, 即led4=1 ,
4'b1001: led <= 8'b0010_0000;
4'b0011: led <= 8'b0100_0000;
4'b0110: led <= 8'b1000_0000;
default: led <= 8'b0000_0000;
但是,仿真时,就出了问题,仿真是对激励如下:
initial begin
//Initialize Inputs
clk= 0;
rst= 0;
sw0= 0;
sw1= 0;
sw2= 0;
sw3= 0;
//Wait 100 ns for global reset to finish
#100;
//Add stimulus here
clk=1;
rst=1;
//#100;
sw0=1;sw1=1;sw2=0;sw3=0;
#10;
clk=0;
rst=0;
#10
clk=1;
rst=1;
sw0=1;sw1=1;sw2=0;sw3=0;
#10;
clk=0;rst=0;
End |
|