testbench常用任务之SPI slave输出数据
模仿了SPI master从SPI slave读取数据的MiSO数据状态
每8个clk后读取的数据加1
用的一些额外寄存器需要自己声明和初始化
//------------------------------------------------------------------------- //send serial data which is increase by 1 on MiSO line //------------------------------------------------------------------------- task SPIMiSo ; /*port declaration*/ begin repeat(256) begin TmpData = TmpDataBak ; repeat(8) begin //@ (negedge Sclk) ; OutLine = TmpData[7] ; TmpData ={TmpData[6:0],1'b0} ; //左移,低位移入新数据 @ (negedge Sclk) ; OutLine = 0 ; end TmpDataBak = TmpDataBak + 1 ; end end endtask
Good Good Study! Day Day Up!