library IEEE;
use IEEE.std_logic_1164.all;
-- synopsys translate_off
-library SCM;
-use SCM.COMPONENTS.all;
+--library SCM;
+--use SCM.COMPONENTS.all;
-- synopsys translate_on
entity lattice_scm_bram_fifo is
end Structure;
-- synopsys translate_off
-library SCM;
-configuration Structure_CON of lattice_scm_bram_fifo is
- for Structure
- for all:VHI use entity SCM.VHI(V); end for;
- for all:VLO use entity SCM.VLO(V); end for;
- for all:FIFO16KA use entity SCM.FIFO16KA(V); end for;
- end for;
-end Structure_CON;
+-- library SCM;
+-- configuration Structure_CON of lattice_scm_bram_fifo is
+-- for Structure
+-- for all:VHI use entity SCM.VHI(V); end for;
+-- for all:VLO use entity SCM.VLO(V); end for;
+-- for all:FIFO16KA use entity SCM.FIFO16KA(V); end for;
+-- end for;
+-- end Structure_CON;
-- synopsys translate_on
generic (
API_TYPE : integer range 0 to 1 := c_API_PASSIVE;
- INIT_DEPTH : integer range 0 to 6 := c_FIFO_SMALL;
- REPLY_DEPTH : integer range 0 to 6 := c_FIFO_SMALL;
+ INIT_DEPTH : integer range 0 to 6 := c_FIFO_BRAM;
+ REPLY_DEPTH : integer range 0 to 6 := c_FIFO_NONE;
FIFO_TO_INT_DEPTH : integer range 0 to 6 := c_FIFO_SMALL;
FIFO_TO_APL_DEPTH : integer range 0 to 6 := c_FIFO_SMALL;
SBUF_VERSION : integer range 0 to 1 := c_SBUF_FULL;
MUX_SECURE_MODE : integer range 0 to 1 := c_NON_SECURE_MODE;
- IBUF_SECURE_MODE : integer range 0 to 1 := c_SECURE_MODE;
+ IBUF_SECURE_MODE : integer range 0 to 1 := c_NON_SECURE_MODE;
OBUF_DATA_COUNT_WIDTH : integer range 0 to 7 := std_DATA_COUNT_WIDTH;
- INIT_CAN_SEND_DATA : integer range 0 to 1 := c_YES;
+ INIT_CAN_SEND_DATA : integer range 0 to 1 := c_NO;
REPLY_CAN_SEND_DATA : integer range 0 to 1 := c_YES;
DAT_CHANNEL : integer range 0 to 3 := c_SLOW_CTRL_CHANNEL
);
begin
if rising_edge(CLK) then
if RESET = '1' then
- saved_packet_type <= "111";
+ saved_packet_type <= TYPE_ILLEGAL;
elsif MED_PACKET_NUM_IN = "00" then
saved_packet_type <= MED_DATA_IN(2 downto 0);
end if;
process(CLK)
begin
if rising_edge(CLK) then
- if RESET = '1' then
- saved_fifo_packet_type <= "111";
+ if RESET = '1' or fifo_packet_num_out = "11" then
+ saved_fifo_packet_type <= TYPE_ILLEGAL;
elsif fifo_packet_num_out = "00" then
saved_fifo_packet_type <= fifo_data_out(2 downto 0);
end if;
else
fifo_read <= INT_READ_IN and buf_INT_DATAREADY_OUT and not fifo_empty;
end if;
- if current_fifo_packet_type = TYPE_EOB and fifo_packet_num_out = "00" and USE_ACKNOWLEDGE = 1 then
- tmp_INT_DATA_OUT(2 downto 0) <= TYPE_DAT;
- end if;
+-- if current_fifo_packet_type = TYPE_EOB and fifo_packet_num_out = "00" and USE_ACKNOWLEDGE = 1 then
+-- tmp_INT_DATA_OUT(2 downto 0) <= TYPE_DAT;
+-- end if;
if fifo_empty = '0' and sbuf_free = '1' then
- tmp_INT_DATAREADY_OUT <= '1';
+ if current_fifo_packet_type /= TYPE_EOB then
+ tmp_INT_DATAREADY_OUT <= '1';
+ end if;
if USE_ACKNOWLEDGE = 1 then
if (current_fifo_packet_type = TYPE_EOB or current_fifo_packet_type = TYPE_TRM)
and fifo_packet_num_out = "11" then
signal saved_packet_type : std_logic_vector(2 downto 0);
signal reg_SEND_ACK_IN_2,next_SEND_ACK_IN_2 : std_logic;
- type sending_state_t is (idle, sending_ack);
+ type sending_state_t is (idle, sending_ack, sending_eob);
signal next_sending_state, sending_state : sending_state_t;
signal sending_state_bits : std_logic;
begin
current_NOP_word <= (others => '0');
current_ACK_word <= (others => '0');
- current_EOB_word <= INT_DATA_IN;
+ current_EOB_word <= (others => '0');
+-- current_EOB_word <= INT_DATA_IN;
current_DATA_word <= INT_DATA_IN;
if transfer_counter = "10" then
current_ACK_word(3 downto 0) <= SEND_BUFFER_SIZE_IN;
+ current_EOB_word(DATA_COUNT_WIDTH-1 downto 0) <= CURRENT_DATA_COUNT;
end if;
if transfer_counter = "00" then
current_NOP_word(2 downto 0) <= TYPE_ILLEGAL;
current_ACK_word(2 downto 0) <= TYPE_ACK;
- current_EOB_word(2 downto 0) <= TYPE_EOB or INT_DATA_IN(2 downto 0);
- --this makes an EOB out of an DAT and keeps a TRM
+ current_EOB_word(2 downto 0) <= TYPE_EOB;
+ -- or INT_DATA_IN(2 downto 0) this makes an EOB out of an DAT and keeps a TRM
end if;
end process;
if (reg_INT_READ_OUT = '1' and INT_DATAREADY_IN = '1') then
--can only happen if idle or sending_data
- if send_EOB = '1' then
- current_output_data_buffer <= current_EOB_word;
- else
+-- if send_EOB = '1' then
+-- current_output_data_buffer <= current_EOB_word;
+-- else
current_output_data_buffer <= current_DATA_word;
- end if;
+-- end if;
comb_dataready <= '1'; --I hope sbuf can store
if transfer_counter = "11" then
- if saved_packet_type = TYPE_TRM or saved_packet_type = TYPE_EOB then --TRM means EOB
+ if saved_packet_type = TYPE_TRM then -- or saved_packet_type = TYPE_EOB
next_DATA_COUNT <= (others => '0');
increase_TRANSMITTED_BUFFERS <= '1';
if TRANSMITTED_BUFFERS(0) = '1' then
else
next_DATA_COUNT <= CURRENT_DATA_COUNT +1;
end if;
+ if send_EOB = '1' then
+ next_INT_READ_OUT <= '0';
+ next_sending_state <= sending_eob;
+ end if;
if send_ACK = '1' then
next_INT_READ_OUT <= '0';
next_sending_state <= sending_ack;
end if;
end if;
+ if sending_state = sending_eob then
+ next_INT_READ_OUT <= '0';
+ current_output_data_buffer <= current_EOB_word;
+ if sbuf_free = '1' then
+ comb_dataready <= '1';
+ if (transfer_counter = "11") then
+ next_sending_state <= idle;
+ next_DATA_COUNT <= (others => '0');
+ increase_TRANSMITTED_BUFFERS <= '1';
+ if TRANSMITTED_BUFFERS(0) = '1' then
+ next_INT_READ_OUT <= '0';
+ end if;
+ end if;
+ end if;
+ end if;
+
if sending_state = sending_ack then
next_INT_READ_OUT <= '0';
current_output_data_buffer <= current_ACK_word;
end if;
end if;
+ if send_EOB = '1' and transfer_counter = "00" and (reg_INT_READ_OUT and INT_DATAREADY_IN) = '0' then
+ next_sending_state <= sending_eob;
+ next_INT_READ_OUT <= '0';
+ end if;
if send_ACK = '1' and transfer_counter = "00" and (reg_INT_READ_OUT and INT_DATAREADY_IN) = '0' then
next_sending_state <= sending_ack;
next_INT_READ_OUT <= '0';
end if;
+
if sbuf_free = '0' or send_DATA = '0' then
next_INT_READ_OUT <= '0';
end if;
end process;
-sending_state_bits <= '1' when sending_state = sending_ack else '0';
+--sending_state_bits <= '1' when sending_state = sending_ack else '0' when sending_state = sending_eob else 'U';
REG1 : process(CLK)
begin