joanna_wu 发表于 2010-9-21 09:57:18

请教:Verilog编写SPI slave传输数据出现窜位问题

实现的功能:SPI slave接收到一个数据存到FIFO_i中,进行加1处理然后传给FIFO_o通过SPI slave端传回。
实验结果:接收到的数据前端多了18位,此18位均为0。

always @(posedge clk)
begin
if(~SSEL_active)       
        begin
        count2<=0;
        count3<=0;
        end                       

        if(SSEL_active)       
                if(byte_sent_int)       
                        begin
                           byte_data_sent <= byte_data_tosent;
                                   count3<=1;
            end               
                if(count3==1)       
                        if(SCK_fallingedge)//SCK_risingedge
                                begin
                                  if(count2<15)
                                        begin
                                          byte_data_sent <={byte_data_sent, 1'b0};       
                                          count2 <= count2 +1;
                                end
                                if(count2==15)                                               
                                begin
                                  count2<=0;
                               end
                       end
end       

assignMISO = byte_data_sent;


发送数据:0x00 0x03 0x00 0x07 0x00 0x0b 0x00 0x0f 0x00 0x13 0x00 0x17 0x00 0x1b 0x00 0x1f
接收数据:0x00 0x00 0x00 0x01 0x00 0x02 0x00 0x03 0x00 0x04 0x00 0x05 0x00 0x06 0x00 0x07

窜了18位呢,怎么回事呢,请教!~~
页: [1]
查看完整版本: 请教:Verilog编写SPI slave传输数据出现窜位问题