diff --git a/src/socbridge/socbridge_driver.vhd b/src/socbridge/socbridge_driver.vhd index 0b6d178..d7274ea 100644 --- a/src/socbridge/socbridge_driver.vhd +++ b/src/socbridge/socbridge_driver.vhd @@ -99,8 +99,8 @@ begin -- / \ | -- V V | -- TX_HEADER RX_HEADER | --- |\ / | | --- | V V | | +-- | \ / | | +-- | V V | | -- | ADDR1 | | -- | | | | -- | V | | @@ -127,6 +127,16 @@ begin --- Next State Assignment Of RX FSM --- case st.curr_rx_state is when IDLE => + if PACKET_TYPE = COMMAND then -- TODO Make this a real type and variable + next_rx_state <= CMD; + elsif PACKET_TYPE = RESPONSE then + next_rx_state <= RX_HEADER; + else + next_rx_state <= IDLE; + end if; + when CMD => + -- TODO This should be changed to not to check 'st.curr_cmd' but rather + -- the command received which may not be the same variable if st.curr_cmd = WRITE_ADD then next_rx_state <= ADDR1; elsif st.curr_cmd = WRITE then @@ -134,9 +144,7 @@ begin elsif st.curr_cmd = READ_ADD then next_rx_state <= ADDR1; elsif st.curr_cmd = READ then - next_rx_state <= RX_RESPONSE; - else - next_rx_state <= IDLE; + next_rx_state <= GEN_ACCESS; end if; when RX_HEADER => -- The header only takes one word (cycle) to transmit. @@ -168,6 +176,7 @@ begin when ADDR3 => next_rx_state <= ADDR4; when ADDR4 => + -- TODO Unsure about this case. Should we enter RX_RESPONSE here? if st.curr_cmd = WRITE or st.curr_cmd = WRITE_ADD then next_rx_state <= PAYLOAD; else @@ -177,14 +186,24 @@ begin --- Next State Assignment Of TX FSM --- case st.curr_tx_state is - when IDLE => - if st.curr_cmd = WRITE or st.curr_cmd = WRITE_ADD then - next_tx_state <= TX_HEADER; - elsif st.curr_cmd = READ or st.curr_cmd = READ_ADD then - next_tx_state <= RX_HEADER; - else + when IDLE => + if st.curr_cmd = READ_ADD or st.curr_cmd = READ or + st.curr_cmd = WRITE_ADD or st.curr_cmd = WRITE then + next_tx_state <= CMD; + elsif RESPONSE_READY then -- TODO define RESPONSE_READY + next_tx_state <= RESPONSE; + else next_tx_state <= IDLE; end if; + when CMD => + if st.curr_cmd = WRITE_ADD then + next_tx_state <= TX_HEADER; + elsif st.curr_cmd = WRITE then + next_tx_state <= WRITE; + elsif st.curr_cmd = READ or st.curr_cmd = READ_ADD then + next_tx_state <= RX_HEADER; + end if; + when RESPONSE => when TX_HEADER => -- The header only takes one word (cycle) to transmit. -- Continue to body or address directly afterwards. diff --git a/src/socbridge/socbridge_driver_tb_pkg.vhd b/src/socbridge/socbridge_driver_tb_pkg.vhd index 4a8e6f8..bd503dd 100644 --- a/src/socbridge/socbridge_driver_tb_pkg.vhd +++ b/src/socbridge/socbridge_driver_tb_pkg.vhd @@ -16,13 +16,13 @@ package socbridge_driver_tb_pkg is (NO_OP, WRITE_ACK, READ_RESPONSE); type rx_state_t is - (IDLE, RESP, ADDR1, ADDR2, ADDR3, ADDR4, - CMD, READ, WRITE, PAYLOAD, + (IDLE, ADDR1, ADDR2, ADDR3, ADDR4, + CMD, RESPONSE, READ, WRITE, PAYLOAD, RX_HEADER, RX_RESPONSE, RX_BODY); type tx_state_t is - (IDLE, RESP, ADDR1, ADDR2, ADDR3, ADDR4, - CMD, READ, WRITE, PAYLOAD, + (IDLE, ADDR1, ADDR2, ADDR3, ADDR4, + CMD, RESPONSE, READ, WRITE, PAYLOAD, TX_HEADER, TX_BODY, TX_ACK); --- TRANSLATOR --- type translator_state_t is (IDLE, SEND, SEND_ACCEPTED, AWAIT);