FPGA学习回顾之SPI的使用

硬件:黑金AX301
教程:黑金附赠教程
用途:记录FPGA中SPI的信号走向以及实施过程

程序顶层(spi_flash_test)状态机走向:
S_IDLE——>S_READ——>S_WAIT(等按键按下)——>S_SE——>S_PP——>S_READ——>S_WAIT。

**程序模块(spi_flash_top)实施过程:
cmd=spi_flash_cmd
ctrl=spi_flash_ctrl
master=spi_master

以顶层Flash_read=1为例

Ctrl:获得cmd,Cmd_valid=1
Cmd:wr_req=1,Send_data=cmd_code
Master:模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:wr_req=1,Send_data=addr[23:16]
Master:模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:wr_req=1,Send_data=addr [15:8]
Master:模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:wr_req=1,Send_data=addr [7:0]
Master:模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:data_recv=data_out,data_valid=1(最后state=S_CMD_ACK)
Ctrl:flash_read_data_out=data_out,flash_read_data_valid=1(state=S_READ)
Ctrl:state=S_ACK

以顶层Flash_write=1为例
顶层:flash_write=1
Ctrl: 获得cmd,Cmd_valid=1
Cmd:wr_req=1,send_data=cmd_code
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master: wr_ack=1
Cmd:state=S_CMD_ACK(最终),cmd_ack=1
Ctrl:state=S_WRITE,cmd=CMD_PP,size=write_size,cmd_valid=1
Cmd:state= S_WR_CMD_CODE,wr_req=1,send_data=cmd_code
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:state=S_WRITE_BYTES,wr_req=1,send_data=addr
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:state=S_WRITE_BYTES,wr_req=1,send_data=addr
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:state=S_WRITE_BYTES,wr_req=1,send_data=addr
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1
Cmd:data_req=1
Ctrl:flash_write_data_req=1
顶层:flash_write_data_in=read_data+1
Ctrl:data_in=flash_write_data_in
Cmd:send_data=data_in,wr_req=1
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master: wr_ack=1
Cmd:state=S_CMD_ACK,cmd_ack=1
Ctrl:state=S_CK_STATE,cmd=CMD_RDSR,cmd_valid=1
Cmd:stare= S_WR_CMD_CODE,send_data=cmd_code
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master: wr_ack=1
Cmd:state= S_READ_BYTES,send_data=addr
Master: 模拟SPI时序,MOSI = MOSI_shift[7],data_out = MISO_shift
Master:wr_ack=1,给data_recv
Cmd:data_valid=1,data_out=data_recv
Ctrl:state_reg=data_out,state=S_ACK

你可能感兴趣的:(FPGA学习回顾之SPI的使用)