-- part 2: connection to apl
-- if fifo_to_apl_empty = '0' then
- if fifo_to_apl_empty = '0' and reg_APL_DATAREADY_OUT = '0' then --is this really correct????
+ if fifo_to_apl_empty = '0' and not (reg_APL_DATAREADY_OUT = '1' and APL_READ_IN = '1') then --is this really correct????
next_APL_DATAREADY_OUT <= '1';
end if; -- read/no read
-- connect receiver
fifo_to_apl_data_in <= INT_SLAVE_DATA_IN;
+
+-- this has to be registered!
-- reg_APL_DATAREADY_OUT <= next_APL_DATAREADY_OUT;
-- reg_APL_DATA_OUT <= next_APL_DATA_OUT;
-- reg_APL_TYP_OUT <= next_APL_TYP_OUT;
+
APL_DATAREADY_OUT <= reg_APL_DATAREADY_OUT;
APL_DATA_OUT <= reg_APL_DATA_OUT;
APL_TYP_OUT <= reg_APL_TYP_OUT;
or (slave_running = '0' and API_TYPE = 0))
else '1';
APL_SEQNR_OUT <= sequence_counter;
-
+
+--removed and put into main state machine
-- generate the sequence counter
-- -- combinatorial part
-- SEQNR_COMB : process(sequence_counter, current_state, next_state)
STAT_BUFFER: out STD_LOGIC_VECTOR (31 downto 0);
CTRL_BUFFER: in STD_LOGIC_VECTOR (31 downto 0)
);
-END trb_net_obuf;
+end trb_net_obuf;
architecture trb_net_obuf_arch of trb_net_obuf is
component trb_net_sbuf is
-
generic (DATA_WIDTH : integer := 56;
VERSION : integer := 1);
-- Status and control port
STAT_BUFFER: out STD_LOGIC
);
- END component;
+ end component;
signal current_output_buffer : STD_LOGIC_VECTOR (50 downto 0);
signal current_ACK_word, current_EOB_word, current_DATA_word, current_NOP_word :
signal CURRENT_DATA_COUNT, next_DATA_COUNT : STD_LOGIC_VECTOR (DATA_COUNT_WIDTH-1 downto 0);
-- signal max_DATA_COUNT, next_max_DATA_COUNT : STD_LOGIC_VECTOR (15 downto 0);
signal max_DATA_COUNT_minus_one, next_max_DATA_COUNT_minus_one : STD_LOGIC_VECTOR (DATA_COUNT_WIDTH-1 downto 0);
+ signal max_DATA_COUNT_minus_two, next_max_DATA_COUNT_minus_two : STD_LOGIC_VECTOR (DATA_COUNT_WIDTH-1 downto 0);
signal tmp_next_max_DATA_COUNT_minus_one : STD_LOGIC_VECTOR (15 downto 0);
+ signal tmp_next_max_DATA_COUNT_minus_two : STD_LOGIC_VECTOR (15 downto 0);
signal TRANSMITTED_BUFFERS, next_TRANSMITTED_BUFFERS : STD_LOGIC_VECTOR (1 downto 0);
signal increase_TRANSMITTED_BUFFERS, decrease_TRANSMITTED_BUFFERS : STD_LOGIC;
CURRENT_DATA_COUNT,reg_SEND_ACK_IN,reg_INT_READ_OUT,
INT_DATAREADY_IN, INT_DATA_IN, sent_ACK, sent_EOB,
current_ACK_word,current_EOB_word, sbuf_free, sent_data,
- max_DATA_COUNT_minus_one,next_DATA_COUNT,
+ max_DATA_COUNT_minus_two,next_DATA_COUNT,
next_TRANSMITTED_BUFFERS)
begin
current_output_buffer <= current_NOP_word;
current_output_buffer <= current_ACK_word;
next_SEND_ACK_IN <= '0';
comb_dataready <= '1';
- next_INT_READ_OUT <= '0'; --stop activity to be on the save side
+ next_INT_READ_OUT <= '0'; --stop activity to be on the safe side
elsif sent_ACK = '1' and sbuf_free = '0' then
next_SEND_ACK_IN <= '1';
elsif sent_EOB = '1' and sbuf_free = '1' then
next_DATA_COUNT <= (others => '0');
increase_TRANSMITTED_BUFFERS <= '1';
comb_dataready <= '1';
- next_INT_READ_OUT <= '0'; --stop activity to be on the save side
+ next_INT_READ_OUT <= '0'; --stop activity to be on the safe side
end if;
--finally, block data read if the rec buffer is full
if sent_data = '0' or
- (next_DATA_COUNT(DATA_COUNT_WIDTH-1 downto 0) = max_DATA_COUNT_minus_one(DATA_COUNT_WIDTH-1 downto 0))
+ ((current_DATA_COUNT(DATA_COUNT_WIDTH-1 downto 0) = (max_DATA_COUNT_minus_two(DATA_COUNT_WIDTH-1 downto 0)))
+ and reg_INT_READ_OUT = '1' and INT_DATAREADY_IN = '1' and INT_DATA_IN(TYPE_POSITION) = TYPE_TRM)
+ --long version of (next_count = max_count-1)
or (next_TRANSMITTED_BUFFERS(1) = '1' and SWITCH_OFF_BUFFER_CHECK = 0)
then
next_INT_READ_OUT <= '0';
"0000000000001111" when REC_BUFFER_SIZE_IN="0011" else
"0000000000011111" when REC_BUFFER_SIZE_IN="0100" else
"0000000000000001";
+ tmp_next_max_DATA_COUNT_minus_two <= "0000000000000010" when REC_BUFFER_SIZE_IN="0001" else
+ "0000000000000110" when REC_BUFFER_SIZE_IN="0010" else
+ "0000000000001110" when REC_BUFFER_SIZE_IN="0011" else
+ "0000000000011110" when REC_BUFFER_SIZE_IN="0100" else
+ "0000000000000000";
next_max_DATA_COUNT_minus_one(DATA_COUNT_WIDTH-1 downto 0) <= tmp_next_max_DATA_COUNT_minus_one(DATA_COUNT_WIDTH-1 downto 0);
+ next_max_DATA_COUNT_minus_two(DATA_COUNT_WIDTH-1 downto 0) <= tmp_next_max_DATA_COUNT_minus_two(DATA_COUNT_WIDTH-1 downto 0);
-- next_max_DATA_COUNT <= 2 ** (REC_BUFFER_SIZE_IN + 1);
-- BUGBUG via pattern_gen
-- max_DATA_COUNT <= (1 => '1', others => '0');
max_DATA_COUNT_minus_one(0) <= '1';
max_DATA_COUNT_minus_one(DATA_COUNT_WIDTH-1 downto 1) <= (others => '0');
+ max_DATA_COUNT_minus_two(DATA_COUNT_WIDTH-1 downto 0) <= (others => '0');
else
-- max_DATA_COUNT <= next_max_DATA_COUNT;
max_DATA_COUNT_minus_one <= next_max_DATA_COUNT_minus_one;
+ max_DATA_COUNT_minus_two <= next_max_DATA_COUNT_minus_two;
end if;
end if;
end process;
is_locked <= '0';
elsif CLK_EN = '1' then
is_locked <= got_locked;
-
else
is_locked <= is_locked;
end if;