module test(CLK,STB,DATA,DOUT); input CLK,STB,DATA; output[7:0] DOUT; reg[7:0] DOUT; reg[7:0] shifter; reg[7:0] bufferreg; reg datacoming; reg[2:0] count; //initialize initial begin count = 0; datacoming = 0; bufferreg = 8'b11111111; end always @(posedge CLK) begin if(STB == 1) datacoming = 1; else begin if(count == 1) begin datacoming = 0; end else datacoming = 1; end if(datacoming == 1) begin shifter <= shifter << 1; shifter[0] <= DATA; count = count + 1; if(count == 0) begin bufferreg = shifter; end end DOUT = bufferreg; end endmodule 这是程序,主要目的是将8位移位寄存器每次采集的数据放到一个缓冲寄存器,然后输出。 STB的主要作用是标志数据帧的开始,在bit0持续一个时钟周期(高电平),其它的信号大家都能看懂的,但我仿真出来却有问题,大家能看一下是哪出问题了吗?谢谢!
附件为时序图
|