diff --git a/src/socbridge/socbridge_driver.vhd b/src/socbridge/socbridge_driver.vhd index f05bf8c..512587a 100644 --- a/src/socbridge/socbridge_driver.vhd +++ b/src/socbridge/socbridge_driver.vhd @@ -4,7 +4,7 @@ use IEEE.NUMERIC_STD.all; library ganimede; use ganimede.io_types.all; library gan_socbridge; -use gan_socbridge.socbridge_driver_tb_pkg.all; +use gan_socbridge.socbridge_driver_pkg.all; entity socbridge_driver is @@ -114,7 +114,7 @@ begin next_tx_state <= IDLE; end if; when TX_R_BODY => - if st.tx_stage = 0 then + if st.tx_stage <= 1 then next_tx_state <= IDLE; else next_tx_state <= TX_R_BODY; @@ -134,7 +134,7 @@ begin next_tx_state <= IDLE; end if; when TX_W_BODY => - if st.tx_stage = 0 then + if st.tx_stage <= 1 then next_tx_state <= TX_AWAIT; else next_tx_state <= TX_W_BODY; @@ -145,7 +145,7 @@ begin and st.curr_rx_transaction = WRITE_ACK then next_tx_state <= IDLE; elsif (st.curr_tx_transaction = READ_ADD or st.curr_tx_transaction = READ) - and st.curr_rx_transaction = READ_RESPONSE and st.rx_stage = 0 then + and st.curr_rx_transaction = READ_RESPONSE and st.rx_stage = 1 then next_tx_state <= IDLE; else next_tx_state <= TX_AWAIT; @@ -174,7 +174,7 @@ begin next_rx_state <= IDLE; end if; when RX_R_BODY => - if st.rx_stage = 0 then + if st.rx_stage <= 1 then next_rx_state <= IDLE; else next_rx_state <= RX_R_BODY; @@ -194,7 +194,7 @@ begin next_rx_state <= IDLE; -- Potentially superfluous safety end if; when RX_W_BODY => - if st.rx_stage = 0 then + if st.rx_stage <= 1 then next_rx_state <= RX_AWAIT; else next_rx_state <= RX_W_BODY; @@ -205,7 +205,7 @@ begin and st.curr_tx_transaction = WRITE_ACK then next_rx_state <= IDLE; elsif (st.curr_rx_transaction = READ_ADD or st.curr_rx_transaction = READ) - and st.curr_tx_transaction = READ_RESPONSE and st.tx_stage = 0 then + and st.curr_tx_transaction = READ_RESPONSE and st.tx_stage = 1 then next_rx_state <= IDLE; else next_rx_state <= RX_AWAIT; @@ -222,7 +222,11 @@ begin case st.curr_tx_state is when IDLE => when TX_HEADER => - socbridge_driver_to_ext_data_cmd := get_header_bits(st.curr_tx_transaction, st.curr_rx_transaction) & get_size_bits(st.tx_data_size); + if st.curr_tx_transaction = WRITE_ACK or st.curr_tx_transaction = READ_RESPONSE then + socbridge_driver_to_ext_data_cmd := get_header_bits(st.curr_tx_transaction, st.curr_rx_transaction) & get_size_bits(st.rx_data_size); + else + socbridge_driver_to_ext_data_cmd := get_header_bits(st.curr_tx_transaction, st.curr_rx_transaction) & get_size_bits(st.tx_data_size); + end if; when TX_W_BODY => if st.tx_stage > 0 then socbridge_driver_to_ip.is_full_out <= '0'; @@ -305,6 +309,7 @@ begin if st.curr_rx_transaction = WRITE or st.curr_rx_transaction = WRITE_ADD then next_tx_transaction := WRITE_ACK; elsif st.curr_rx_transaction = READ or st.curr_rx_transaction = READ_ADD then + next_tx_data_size <= st.rx_data_size; next_tx_transaction := READ_RESPONSE; end if; end if; @@ -389,6 +394,7 @@ begin case st.curr_rx_state is when IDLE => st.curr_rx_transaction <= next_rx_transaction; + st.rx_data_size <= next_rx_data_size; if next_rx_transaction = WRITE_ADD or next_rx_transaction = WRITE or next_rx_transaction = READ_RESPONSE then st.rx_stage <= next_rx_data_size; diff --git a/src/socbridge/socbridge_driver_tb_pkg.vhd b/src/socbridge/socbridge_driver_pkg.vhd similarity index 97% rename from src/socbridge/socbridge_driver_tb_pkg.vhd rename to src/socbridge/socbridge_driver_pkg.vhd index 0556fe8..eee87af 100644 --- a/src/socbridge/socbridge_driver_tb_pkg.vhd +++ b/src/socbridge/socbridge_driver_pkg.vhd @@ -6,7 +6,7 @@ library ganimede; use ganimede.io_types.all; -package socbridge_driver_tb_pkg is +package socbridge_driver_pkg is subtype command_size_t is integer range 0 to 128; type transaction_t is @@ -70,9 +70,9 @@ package socbridge_driver_tb_pkg is signal G_trans_st : translator_state_rec_t; -- synthesis translate_on -end package socbridge_driver_tb_pkg; +end package socbridge_driver_pkg; -package body socbridge_driver_tb_pkg is +package body socbridge_driver_pkg is function to_string ( a: std_logic_vector) return string is variable b : string (1 to a'length) := (others => NUL); variable stri : integer := 1; @@ -171,4 +171,4 @@ package body socbridge_driver_tb_pkg is val := std_logic_vector(TO_UNSIGNED(size - 1, 3)); return val; end function; -end package body socbridge_driver_tb_pkg; +end package body socbridge_driver_pkg; diff --git a/src/socbridge/socbridge_driver_tb.vhd b/src/socbridge/socbridge_driver_tb.vhd index f118542..64640d7 100644 --- a/src/socbridge/socbridge_driver_tb.vhd +++ b/src/socbridge/socbridge_driver_tb.vhd @@ -3,7 +3,7 @@ use IEEE.std_logic_1164.all; use ieee.numeric_std.all; use IEEE.MATH_REAL.all; library work; -use work.socbridge_driver_tb_pkg.all; +use work.socbridge_driver_pkg.all; library ganimede; use ganimede.io_types.all; library gan_socbridge;