entity trb_net16_api_base is
generic (
- API_TYPE : integer := 1; -- type of api: 0 passive, 1 active
+ API_TYPE : integer := 0; -- type of api: 0 passive, 1 active
--FIFO size is given in 2^(n+1) 64Bit-packets i.e. 2^(n+3) 16bit packets
FIFO_TO_INT_DEPTH : integer := 1; -- direction to medium
FIFO_TO_APL_DEPTH : integer := 1; -- direction to application
STAT_FIFO_TO_APL(10) <= reg_APL_DATAREADY_OUT;
---------------------------------------
--- a sbuf on the active channel
+-- a sbuf (to_int direction)
---------------------------------------
- ACTIVE_SBUF: trb_net16_sbuf
+ SBUF: trb_net16_sbuf
generic map (
DATA_WIDTH => 16,
NUM_WIDTH => 2,
next_wait_for_answer <= '0';
get_slave_running <= '0';
- if reg_APL_TYP_OUT = TYPE_TRM and reg_APL_PACKET_NUM_OUT = "11" and APL_READ_IN = '1' then
+ if reg_APL_TYP_OUT = TYPE_TRM and reg_APL_PACKET_NUM_OUT = "11" and (APL_READ_IN = '1' or state_to_apl = WRONG_ADDR) then
next_state_to_apl <= IDLE;
end if;
entity trb_net16_endpoint_0_trg_1_api is
generic (
- API_TYPE : integer range 0 to 1 := 1;
- INIT_DEPTH : integer range 0 to 6 := 0;
+ API_TYPE : integer range 0 to 1 := 0;
+ INIT_DEPTH : integer range 0 to 6 := 1;
REPLY_DEPTH : integer range 0 to 6 := 1;
FIFO_TO_INT_DEPTH : integer range 0 to 6 := 1;
FIFO_TO_APL_DEPTH : integer range 0 to 6 := 1;
MUX_WIDTH : integer range 1 to 5 := 3;
MUX_SECURE_MODE : integer range 0 to 1 := 0;
IBUF_SECURE_MODE : integer range 0 to 1 := 1;
+ IOBUF_USE_ACKNOWLEDGE : integer range 0 to 1 := 1;
+ INIT_CAN_SEND_DATA : integer range 0 to 1 := 1;
+ REPLY_CAN_SEND_DATA : integer range 0 to 1 := 1;
DAT_CHANNEL : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
DATA_WIDTH : integer := 16;
NUM_WIDTH : integer := 2
component trb_net16_iobuf is
- generic (INIT_DEPTH : integer := 3;
- REPLY_DEPTH : integer := 3;
- IBUF_SECURE_MODE : integer range 0 to 1 := 1);
-
+ generic (
+ INIT_DEPTH : integer := 1;
+ REPLY_DEPTH : integer := 1;
+ IBUF_SECURE_MODE : integer range 0 to 1 := 1;
+ --use sbuf in med_to_api direction?
+ USE_ACKNOWLEDGE : integer range 0 to 1 := 0;
+ INIT_CAN_SEND_DATA : integer range 0 to 1 := 0;
+ REPLY_CAN_SEND_DATA : integer range 0 to 1 := 1
+ );
port(
-- Misc
CLK : in std_logic;
-- for the direction to
-- internal world
FIFO_TO_APL_DEPTH : integer := 3; -- direction to application
- FIFO_TERM_BUFFER_DEPTH : integer := 0; -- fifo for auto-answering of
- -- the master path, if set to 0
- -- no buffer is used at all
SBUF_VERSION : integer range 0 to 1 := 0
);
API_TYPE => 1,
FIFO_TO_INT_DEPTH => FIFO_TO_INT_DEPTH,
FIFO_TO_APL_DEPTH => FIFO_TO_APL_DEPTH,
- FIFO_TERM_BUFFER_DEPTH => 0,
SBUF_VERSION => SBUF_VERSION
)
port map (
API_TYPE => 0,
FIFO_TO_INT_DEPTH => FIFO_TO_INT_DEPTH,
FIFO_TO_APL_DEPTH => FIFO_TO_APL_DEPTH,
- FIFO_TERM_BUFFER_DEPTH => 0,
SBUF_VERSION => SBUF_VERSION
)
port map (
IOBUF: trb_net16_iobuf
- generic map (INIT_DEPTH => INIT_DEPTH,
- REPLY_DEPTH => REPLY_DEPTH,
- IBUF_SECURE_MODE => IBUF_SECURE_MODE)
-
+ generic map (
+ INIT_DEPTH => INIT_DEPTH,
+ REPLY_DEPTH => REPLY_DEPTH,
+ IBUF_SECURE_MODE => IBUF_SECURE_MODE,
+ USE_ACKNOWLEDGE => IOBUF_USE_ACKNOWLEDGE,
+ INIT_CAN_SEND_DATA => INIT_CAN_SEND_DATA,
+ REPLY_CAN_SEND_DATA => REPLY_CAN_SEND_DATA
+ )
port map (
-- Misc
CLK => CLK ,
generic (API_TYPE : integer := API_TYPE; -- type of api: 0 passive, 1 active
--FIFO size is given in 2^(n+1) 64Bit-packets i.e. 2^(n+3) 16bit packets
FIFO_TO_INT_DEPTH : integer := 1; -- direction to medium
- FIFO_TO_APL_DEPTH : integer := 1; -- direction to application
- FIFO_TERM_BUFFER_DEPTH : integer := 0); -- fifo for auto-answering master path
- -- if set to 0, no buffer is used
+ FIFO_TO_APL_DEPTH : integer := 1); -- direction to application
port(
-- Misc
CLK : in std_logic;
component trb_net16_term is
generic (
- FIFO_TERM_BUFFER_DEPTH : integer := 0; -- fifo for auto-answering of
- -- the master path, if set to 0
- -- no buffer is used at all
SECURE_MODE : integer range 0 to 1 := 0
--if secure_mode is not used, apl must provide error pattern and dtype until
--next trigger comes in. In secure mode these must be available when hold_trm goes low
generic map (
API_TYPE => 1,
FIFO_TO_INT_DEPTH => DAT_FIFO_TO_INT_DEPTH,
- FIFO_TO_APL_DEPTH => DAT_FIFO_TO_APL_DEPTH,
- FIFO_TERM_BUFFER_DEPTH => 0
+ FIFO_TO_APL_DEPTH => DAT_FIFO_TO_APL_DEPTH
)
port map (
-- Misc
generic map (
API_TYPE => 0,
FIFO_TO_INT_DEPTH => DAT_FIFO_TO_INT_DEPTH,
- FIFO_TO_APL_DEPTH => DAT_FIFO_TO_APL_DEPTH,
- FIFO_TERM_BUFFER_DEPTH => 0
+ FIFO_TO_APL_DEPTH => DAT_FIFO_TO_APL_DEPTH
)
port map (
-- Misc
TRG_INIT : trb_net16_term
generic map (
- FIFO_TERM_BUFFER_DEPTH => 0,
SECURE_MODE => TRG_SECURE_MODE
)
port map(
generic (
DATA_WIDTH : integer := 16; -- FIFO word width
NUM_WIDTH : integer := 2;
- DEPTH : integer := 1 -- Depth of the FIFO, 2^(n+1) 64Bit packets
+ DEPTH : integer := 6 -- Depth of the FIFO, 2^(n+1) 64Bit packets
);
port (
CLK : in std_logic;
HUB_CTRL_CHANNELNUM : integer range 0 to 3 := 0;
HUB_CTRL_DEPTH : integer range 0 to 6 := 1;
HUB_CTRL_REG_ADDR_WIDTH : integer range 1 to 7 := 4;
- IBUF_SECURE_MODE : integer range 0 to 1 := 1;
+ IBUF_SECURE_MODE : integer range 0 to 1 := 0;
--media interfaces
MII_NUMBER : integer range 2 to 16 := 12;
--each row is one media interface and each column is one channel. starting with 0,0, ending with 15,15
API_TYPE : integer := 1;
FIFO_TO_INT_DEPTH : integer := 1;
FIFO_TO_APL_DEPTH : integer := 1;
- FIFO_TERM_BUFFER_DEPTH : integer := 0;
SBUF_VERSION : integer := 0);
port(
-- Misc
component trb_net16_term is
generic (
- FIFO_TERM_BUFFER_DEPTH : integer := 0; -- fifo for auto-answering of
- -- the master path, if set to 0
- -- no buffer is used at all
SECURE_MODE : integer range 0 to 1 := 0
--if secure_mode is not used, apl must provide error pattern and dtype until
--next trigger comes in. In secure mode these must be available when hold_trm goes low
--generate multiplexers
gen_muxes: for i in 0 to MII_NUMBER-1 generate
+ constant t : integer := 0;
+ begin
MPLEX: trb_net16_io_multiplexer
generic map (
DATA_WIDTH => DATA_WIDTH,
--generate IOBufs for MII
gen_iobufs: for i in 0 to MII_NUMBER*2**(MUX_WIDTH-1)-1 generate
+ constant t : integer := 0;
begin
IOBUF: trb_net16_iobuf
generic map (
generic map(
API_TYPE => 0,
FIFO_TO_INT_DEPTH => HUB_CTRL_DEPTH,
- FIFO_TO_APL_DEPTH => HUB_CTRL_DEPTH,
- FIFO_TERM_BUFFER_DEPTH => 0
+ FIFO_TO_APL_DEPTH => HUB_CTRL_DEPTH
)
port map(
-- Misc
constant aploffset : integer := i - offset;
begin
gen_pas_api : if API_TYPE(aploffset) = 0 generate
+ constant t : integer := 0;
+ begin
PAS_API : trb_net16_api_base
generic map(
API_TYPE => API_TYPE(aploffset),
FIFO_TO_INT_DEPTH => API_FIFO_TO_INT_DEPTH(aploffset),
- FIFO_TO_APL_DEPTH => API_FIFO_TO_APL_DEPTH(aploffset),
- FIFO_TERM_BUFFER_DEPTH => 0
+ FIFO_TO_APL_DEPTH => API_FIFO_TO_APL_DEPTH(aploffset)
)
port map(
-- Misc
);
end generate;
gen_act_api : if API_TYPE(aploffset) = 1 generate
+ constant t : integer := 0;
+ begin
ACT_API : trb_net16_api_base
generic map(
API_TYPE => API_TYPE(aploffset),
FIFO_TO_INT_DEPTH => API_FIFO_TO_INT_DEPTH(aploffset),
- FIFO_TO_APL_DEPTH => API_FIFO_TO_APL_DEPTH(aploffset),
- FIFO_TERM_BUFFER_DEPTH => 0
+ FIFO_TO_APL_DEPTH => API_FIFO_TO_APL_DEPTH(aploffset)
)
port map(
-- Misc
begin
TRG : trb_net16_term
generic map (
- FIFO_TERM_BUFFER_DEPTH => 0,
SECURE_MODE => TRG_SECURE_MODE
)
port map(
INIT_READ_OUT <= buf_INIT_READ_OUT;
gen_iro : for i in 0 to POINT_NUMBER-1 generate
- buf_INIT_READ_OUT(i) <= init_arbiter_read_out(i) and not init_locked;
+ buf_INIT_READ_OUT(i) <= init_arbiter_read_out(i) and not init_locked and INIT_muxed_READ;
end generate;
gen_init_pool_data0: for i in 0 to DATA_WIDTH-1 generate
CTRL => (others => '0')
);
- reply_arbiter_input <= REPLY_DATAREADY_IN;
+ reply_arbiter_input <= REPLY_DATAREADY_IN and not REPLY_reading_trm;
-- we have to care to read multiples of four packets from every point
-- release is currently done after first packet of TRM
end if;
end process;
- reply_arbiter_CLK_EN <= not reply_point_lock; --1 cycle too late?
+ reply_arbiter_CLK_EN <= not next_point_lock;
comb_REPLY_POOL_DATAREADY <= comb_REPLY_muxed_DATAREADY;
comb_REPLY_POOL_DATA <= comb_REPLY_muxed_DATA;
comb_REPLY_POOL_PACKET_NUM <= comb_REPLY_muxed_PACKET_NUM;
- if send_reply_trm = '1' and comb_REPLY_muxed_PACKET_NUM = "11" then
+ if send_reply_trm = '1' then
next_state <= SENDING_REPLY_TRM;
end if;
end if;
entity trb_net16_ibuf is
generic (
DEPTH : integer range 0 to 7 := 1;
- IBUF_SECURE_MODE : integer range 0 to 1 := 1
+ USE_ACKNOWLEDGE : integer range 0 to 1 := 1;
+ IBUF_SECURE_MODE : integer range 0 to 1 := 0
--use sbuf in med_to_api direction?
);
port(
next_rec_buffer_size_out <= current_rec_buffer_size_out;
next_error_state <= current_error_state;
if MED_DATAREADY_IN = '1' and reg_read_out= '1' then
- if current_packet_type = TYPE_ACK then
+ if current_packet_type = TYPE_ACK and USE_ACKNOWLEDGE = 1 then
if MED_PACKET_NUM_IN = "00" and current_error_state /= GOT_OVERFLOW_ERROR then
got_ack_internal <= '1';
end if;
);
sbuf_free <= comb_next_read or INT_READ_IN; --sbuf killed
+ end generate;
+ gen_notsecure : if IBUF_SECURE_MODE = 0 generate
+ INT_DATA_OUT <= tmp_INT_DATA_OUT;
+ INT_DATAREADY_OUT <= tmp_INT_DATAREADY_OUT;
+ INT_PACKET_NUM_OUT <= tmp_INT_PACKET_NUM_OUT;
+ sbuf_free <= '1';
+ end generate;
+
-- this process controls what will be forwarded to the internal point
DATA_OUT : process (INT_HEADER_IN, fifo_data_out,
tmp_INT_DATAREADY_OUT <= '0';
got_eob_out <= '0';
got_locked <= is_locked;
- fifo_read <= sbuf_free and not fifo_empty;
- if current_fifo_packet_type = TYPE_EOB and fifo_packet_num_out = "00" then
+ if IBUF_SECURE_MODE = 1 then
+ fifo_read <= sbuf_free and not fifo_empty;
+ 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 fifo_empty = '0' and sbuf_free = '1' then
tmp_INT_DATAREADY_OUT <= '1';
- if (current_fifo_packet_type = TYPE_EOB or current_fifo_packet_type = TYPE_TRM)
- and fifo_packet_num_out = "11" then
- got_eob_out <= '1';
- end if;
- if current_fifo_packet_type = TYPE_TRM then
- got_locked <= is_locked or not release_locked;
- end if;
- end if;
- end process;
- end generate;
-
- gen_notsecure : if IBUF_SECURE_MODE = 0 generate
- DATA_OUT : process (INT_HEADER_IN, fifo_data_out, INT_READ_IN,
- release_locked, is_locked, sbuf_free, fifo_empty,
- fifo_packet_num_out, current_fifo_packet_type)
- begin
- INT_DATA_OUT <= fifo_data_out;
- INT_PACKET_NUM_OUT <= fifo_packet_num_out;
- buf_INT_DATAREADY_OUT <= '0';
- got_eob_out <= '0';
- got_locked <= is_locked;
- fifo_read <= INT_READ_IN and buf_INT_DATAREADY_OUT and not fifo_empty;
- if current_fifo_packet_type = TYPE_EOB and fifo_packet_num_out = "00" then
- INT_DATA_OUT(2 downto 0) <= TYPE_DAT;
- end if;
- if fifo_empty = '0' then
- buf_INT_DATAREADY_OUT <= '1';
- if (current_fifo_packet_type = TYPE_EOB or current_fifo_packet_type = TYPE_TRM)
- and fifo_packet_num_out = "11" then
- got_eob_out <= '1';
- end if;
- if current_fifo_packet_type = TYPE_TRM then
- got_locked <= is_locked or not release_locked;
+ 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
+ got_eob_out <= '1';
+ end if;
+ if current_fifo_packet_type = TYPE_TRM then
+ got_locked <= is_locked or not release_locked;
+ end if;
end if;
end if;
end process;
- INT_DATAREADY_OUT <= buf_INT_DATAREADY_OUT;
- end generate;
-
--BUGBUG HDR retransmit needed
release_locked <= CTRL_LOCKED(0);
STAT_LOCKED(0) <= is_locked;
STAT_LOCKED(15 downto 1) <= (others => '0');
-
- reg_locked: process(CLK)
- begin
- if rising_edge(CLK) then
- if RESET = '1' then
- is_locked <= '0';
- reg_eob_out <= '0';
- elsif CLK_EN = '1' then
- is_locked <= got_locked and not release_locked;
- reg_eob_out <= got_eob_out;
- else
- is_locked <= is_locked;
- reg_eob_out <= reg_eob_out;
+
+ gen_ack1 : if USE_ACKNOWLEDGE = 1 generate
+ reg_locked: process(CLK)
+ begin
+ if rising_edge(CLK) then
+ if RESET = '1' then
+ is_locked <= '0';
+ reg_eob_out <= '0';
+ elsif CLK_EN = '1' then
+ is_locked <= got_locked and not release_locked;
+ reg_eob_out <= got_eob_out;
+ else
+ is_locked <= is_locked;
+ reg_eob_out <= reg_eob_out;
+ end if;
end if;
- end if;
- end process;
+ end process;
+ end generate;
--saving last HDR
reading_header <= '1' when (current_fifo_packet_type = TYPE_HDR and fifo_empty = '0') else '0';
-- make STAT_BUFFER
STAT_BUFFER(3 downto 0) <= (fifo_depth(3 downto 0));
- STAT_BUFFER(7 downto 4) <= current_rec_buffer_size_out;
- STAT_BUFFER(8) <= reg_eob_out;
- STAT_BUFFER(9) <= reg_ack_internal;
+
+ gen_ack2 : if USE_ACKNOWLEDGE = 1 generate
+ STAT_BUFFER(7 downto 4) <= current_rec_buffer_size_out;
+ STAT_BUFFER(8) <= reg_eob_out;
+ STAT_BUFFER(9) <= reg_ack_internal;
+ end generate;
+ gen_ack3 : if USE_ACKNOWLEDGE = 0 generate
+ STAT_BUFFER(9 downto 4) <= (others => '0');
+ end generate;
+
MAKE_ERROR_BITS : process(current_error_state)
begin
generic (
INIT_DEPTH : integer := 1;
REPLY_DEPTH : integer := 1;
- IBUF_SECURE_MODE : integer range 0 to 1 := 0
+ IBUF_SECURE_MODE : integer range 0 to 1 := 1;
--use sbuf in med_to_api direction?
+ USE_ACKNOWLEDGE : integer range 0 to 1 := 1;
+ INIT_CAN_SEND_DATA : integer range 0 to 1 := 1;
+ REPLY_CAN_SEND_DATA : integer range 0 to 1 := 1
);
port(
-- Misc
component trb_net16_obuf is
generic (
- DATA_COUNT_WIDTH : integer := 5
+ DATA_COUNT_WIDTH : integer := 5;
+ CAN_SEND_DATA : integer range 0 to 1 := 1;
+ USE_ACKNOWLEDGE : integer range 0 to 1
);
port(
-- Misc
);
end component;
+ component trb_net16_obuf_nodata is
+ port(
+ -- Misc
+ CLK : in std_logic;
+ RESET : in std_logic;
+ CLK_EN : in std_logic;
+ -- Media direction port
+ MED_DATAREADY_OUT: out std_logic;
+ MED_DATA_OUT: out std_logic_vector (15 downto 0); -- Data word
+ MED_PACKET_NUM_OUT:out std_logic_vector(1 downto 0);
+ MED_READ_IN: in std_logic;
+ --STAT
+ STAT_LOCKED: out std_logic_vector (15 downto 0);
+ CTRL_LOCKED: in std_logic_vector (15 downto 0);
+ STAT_BUFFER: out std_logic_vector (31 downto 0);
+ CTRL_BUFFER: in std_logic_vector (31 downto 0)
+ );
+ end component;
+
component trb_net16_ibuf is
generic (
DEPTH : integer range 0 to 7 := 1;
+ USE_ACKNOWLEDGE : integer range 0 to 1;
IBUF_SECURE_MODE : integer range 0 to 1 := 1
--use sbuf in med_to_api direction?
);
INITIBUF : trb_net16_ibuf
generic map (
DEPTH => INIT_DEPTH,
+ USE_ACKNOWLEDGE => USE_ACKNOWLEDGE,
IBUF_SECURE_MODE => IBUF_SECURE_MODE)
port map (
CLK => CLK,
REPLYIBUF : trb_net16_ibuf
generic map (
DEPTH => REPLY_DEPTH,
+ USE_ACKNOWLEDGE => USE_ACKNOWLEDGE,
IBUF_SECURE_MODE => IBUF_SECURE_MODE)
port map (
CLK => CLK,
);
end generate;
- INITOBUF : trb_net16_obuf
- port map (
- CLK => CLK,
- RESET => RESET,
- CLK_EN => CLK_EN,
- MED_DATAREADY_OUT => MED_INIT_DATAREADY_OUT,
- MED_DATA_OUT => MED_INIT_DATA_OUT,
- MED_PACKET_NUM_OUT => MED_INIT_PACKET_NUM_OUT,
- MED_READ_IN => MED_INIT_READ_IN,
- INT_DATAREADY_IN => INT_INIT_DATAREADY_IN,
- INT_DATA_IN => INT_INIT_DATA_IN,
- INT_PACKET_NUM_IN => INT_INIT_PACKET_NUM_IN,
- INT_READ_OUT => INT_INIT_READ_OUT,
- STAT_LOCKED(15 downto 0) => INITOBUF_stat_locked,
- CTRL_LOCKED(15 downto 0) => INITOBUF_ctrl_locked,
- STAT_BUFFER(31 downto 0) => INITOBUF_stat_buffer,
- CTRL_BUFFER(31 downto 0) => INITOBUF_ctrl_buffer
- );
+ genINITOBUF1 : if INIT_CAN_SEND_DATA = 1 generate
+ INITOBUF : trb_net16_obuf
+ generic map (
+ USE_ACKNOWLEDGE => USE_ACKNOWLEDGE
+ )
+ port map (
+ CLK => CLK,
+ RESET => RESET,
+ CLK_EN => CLK_EN,
+ MED_DATAREADY_OUT => MED_INIT_DATAREADY_OUT,
+ MED_DATA_OUT => MED_INIT_DATA_OUT,
+ MED_PACKET_NUM_OUT => MED_INIT_PACKET_NUM_OUT,
+ MED_READ_IN => MED_INIT_READ_IN,
+ INT_DATAREADY_IN => INT_INIT_DATAREADY_IN,
+ INT_DATA_IN => INT_INIT_DATA_IN,
+ INT_PACKET_NUM_IN => INT_INIT_PACKET_NUM_IN,
+ INT_READ_OUT => INT_INIT_READ_OUT,
+ STAT_LOCKED(15 downto 0) => INITOBUF_stat_locked,
+ CTRL_LOCKED(15 downto 0) => INITOBUF_ctrl_locked,
+ STAT_BUFFER(31 downto 0) => INITOBUF_stat_buffer,
+ CTRL_BUFFER(31 downto 0) => INITOBUF_ctrl_buffer
+ );
+ end generate;
+ genINITOBUF2 : if INIT_CAN_SEND_DATA = 0 generate
+ gen_INITOBUF3 : if USE_ACKNOWLEDGE = 1 generate
+ INITOBUF : trb_net16_obuf_nodata
+ port map (
+ CLK => CLK,
+ RESET => RESET,
+ CLK_EN => CLK_EN,
+ MED_DATAREADY_OUT => MED_INIT_DATAREADY_OUT,
+ MED_DATA_OUT => MED_INIT_DATA_OUT,
+ MED_PACKET_NUM_OUT => MED_INIT_PACKET_NUM_OUT,
+ MED_READ_IN => MED_INIT_READ_IN,
+ STAT_LOCKED(15 downto 0) => INITOBUF_stat_locked,
+ CTRL_LOCKED(15 downto 0) => INITOBUF_ctrl_locked,
+ STAT_BUFFER(31 downto 0) => INITOBUF_stat_buffer,
+ CTRL_BUFFER(31 downto 0) => INITOBUF_ctrl_buffer
+ );
+ INT_INIT_READ_OUT <= '0';
+ end generate;
+ gen_INITOBUF4 : if USE_ACKNOWLEDGE = 0 generate
+ MED_INIT_DATAREADY_OUT <= '0';
+ MED_INIT_DATA_OUT <= (others => '0');
+ MED_INIT_PACKET_NUM_OUT <= (others => '0');
+ end generate;
+ end generate;
- REPLYOBUF : trb_net16_obuf
- port map (
- CLK => CLK,
- RESET => RESET,
- CLK_EN => CLK_EN,
- MED_DATAREADY_OUT => MED_REPLY_DATAREADY_OUT,
- MED_DATA_OUT => MED_REPLY_DATA_OUT,
- MED_PACKET_NUM_OUT => MED_REPLY_PACKET_NUM_OUT,
- MED_READ_IN => MED_REPLY_READ_IN,
- INT_DATAREADY_IN => INT_REPLY_DATAREADY_IN,
- INT_DATA_IN => INT_REPLY_DATA_IN,
- INT_PACKET_NUM_IN => INT_REPLY_PACKET_NUM_IN,
- INT_READ_OUT => INT_REPLY_READ_OUT,
- STAT_LOCKED(15 downto 0) => REPLYOBUF_stat_locked,
- CTRL_LOCKED(15 downto 0) => REPLYOBUF_ctrl_locked,
- STAT_BUFFER(31 downto 0) => REPLYOBUF_stat_buffer,
- CTRL_BUFFER(31 downto 0) => REPLYOBUF_ctrl_buffer
- );
+
+ genREPLYOBUF1 : if REPLY_CAN_SEND_DATA = 1 generate
+ REPLYOBUF : trb_net16_obuf
+ generic map (
+ USE_ACKNOWLEDGE => USE_ACKNOWLEDGE
+ )
+ port map (
+ CLK => CLK,
+ RESET => RESET,
+ CLK_EN => CLK_EN,
+ MED_DATAREADY_OUT => MED_REPLY_DATAREADY_OUT,
+ MED_DATA_OUT => MED_REPLY_DATA_OUT,
+ MED_PACKET_NUM_OUT => MED_REPLY_PACKET_NUM_OUT,
+ MED_READ_IN => MED_REPLY_READ_IN,
+ INT_DATAREADY_IN => INT_REPLY_DATAREADY_IN,
+ INT_DATA_IN => INT_REPLY_DATA_IN,
+ INT_PACKET_NUM_IN => INT_REPLY_PACKET_NUM_IN,
+ INT_READ_OUT => INT_REPLY_READ_OUT,
+ STAT_LOCKED(15 downto 0) => REPLYOBUF_stat_locked,
+ CTRL_LOCKED(15 downto 0) => REPLYOBUF_ctrl_locked,
+ STAT_BUFFER(31 downto 0) => REPLYOBUF_stat_buffer,
+ CTRL_BUFFER(31 downto 0) => REPLYOBUF_ctrl_buffer
+ );
+ end generate;
+ genREPLYOBUF2 : if REPLY_CAN_SEND_DATA = 0 generate
+ gen_REPLYOBUF3 : if USE_ACKNOWLEDGE = 1 generate
+ REPLYOBUF : trb_net16_obuf_nodata
+ port map (
+ CLK => CLK,
+ RESET => RESET,
+ CLK_EN => CLK_EN,
+ MED_DATAREADY_OUT => MED_REPLY_DATAREADY_OUT,
+ MED_DATA_OUT => MED_REPLY_DATA_OUT,
+ MED_PACKET_NUM_OUT => MED_REPLY_PACKET_NUM_OUT,
+ MED_READ_IN => MED_REPLY_READ_IN,
+ STAT_LOCKED(15 downto 0) => REPLYOBUF_stat_locked,
+ CTRL_LOCKED(15 downto 0) => REPLYOBUF_ctrl_locked,
+ STAT_BUFFER(31 downto 0) => REPLYOBUF_stat_buffer,
+ CTRL_BUFFER(31 downto 0) => REPLYOBUF_ctrl_buffer
+ );
+ INT_REPLY_READ_OUT <= '0';
+ end generate;
+ gen_REPLYOBUF4 : if USE_ACKNOWLEDGE = 0 generate
+ MED_REPLY_DATAREADY_OUT <= '0';
+ MED_REPLY_DATA_OUT <= (others => '0');
+ MED_REPLY_PACKET_NUM_OUT <= (others => '0');
+ end generate;
+ end generate;
+
+
+-- REPLYOBUF : trb_net16_obuf
+-- generic map (
+-- USE_ACKNOWLEDGE => USE_ACKNOWLEDGE
+-- )
+-- port map (
+-- CLK => CLK,
+-- RESET => RESET,
+-- CLK_EN => CLK_EN,
+-- MED_DATAREADY_OUT => MED_REPLY_DATAREADY_OUT,
+-- MED_DATA_OUT => MED_REPLY_DATA_OUT,
+-- MED_PACKET_NUM_OUT => MED_REPLY_PACKET_NUM_OUT,
+-- MED_READ_IN => MED_REPLY_READ_IN,
+-- INT_DATAREADY_IN => INT_REPLY_DATAREADY_IN,
+-- INT_DATA_IN => INT_REPLY_DATA_IN,
+-- INT_PACKET_NUM_IN => INT_REPLY_PACKET_NUM_IN,
+-- INT_READ_OUT => INT_REPLY_READ_OUT,
+-- STAT_LOCKED(15 downto 0) => REPLYOBUF_stat_locked,
+-- CTRL_LOCKED(15 downto 0) => REPLYOBUF_ctrl_locked,
+-- STAT_BUFFER(31 downto 0) => REPLYOBUF_stat_buffer,
+-- CTRL_BUFFER(31 downto 0) => REPLYOBUF_ctrl_buffer
+-- );
-- build the registers according to the wiki page
REPLYOBUF_ctrl_buffer(9 downto 0) <= REPLYIBUF_stat_buffer(9 downto 0);
REPLYOBUF_ctrl_buffer(31 downto 10) <= (others => '0');
- STAT_LOCKED(0) <= INIT_IS_LOCKED;
- STAT_LOCKED(1) <= REPLY_IS_LOCKED;
- STAT_LOCKED(31 downto 2) <= (others => '0');
- STAT_GEN <= (others => '0');
-
- REPLYOBUF_ctrl_locked(15 downto 2) <= (others => '0');
- REPLYIBUF_ctrl_locked(15 downto 2) <= (others => '0');
- INITOBUF_ctrl_locked(15 downto 2) <= (others => '0');
- INITIBUF_ctrl_locked(15 downto 2) <= (others => '0');
-
--- comb part of the locking control
- comb_locked : process (INIT_IS_LOCKED, REPLY_IS_LOCKED, INITIBUF_stat_locked,
- REPLYOBUF_stat_locked, REPLYIBUF_stat_locked,
- INITOBUF_stat_locked, CTRL_LOCKED)
-
- begin -- process
- next_INIT_IS_LOCKED <= INIT_IS_LOCKED;
- next_REPLY_IS_LOCKED <= REPLY_IS_LOCKED;
- REPLYOBUF_ctrl_locked(1 downto 0) <= (others => '0');
- REPLYIBUF_ctrl_locked(1 downto 0) <= (others => '0');
- INITOBUF_ctrl_locked(1 downto 0) <= (others => '0');
- INITIBUF_ctrl_locked(1 downto 0) <= (others => '0');
+ gen0a: if USE_ACKNOWLEDGE = 0 generate
+ STAT_LOCKED <= (others => '0');
+ REPLYOBUF_ctrl_locked <= (others => '0');
+ REPLYIBUF_ctrl_locked <= (others => '0');
+ INITOBUF_ctrl_locked <= (others => '0');
+ INITIBUF_ctrl_locked <= (others => '0');
+ end generate;
+ gen0: if USE_ACKNOWLEDGE = 1 generate
+ STAT_LOCKED(0) <= INIT_IS_LOCKED;
+ STAT_LOCKED(1) <= REPLY_IS_LOCKED;
+ STAT_LOCKED(31 downto 2) <= (others => '0');
- if REPLY_IS_LOCKED = '1' then
- -- listen to INITOBUF
- if INITOBUF_stat_locked(0) = '1' or CTRL_LOCKED(1) = '1' then
- next_REPLY_IS_LOCKED <= '0';
- REPLYIBUF_ctrl_locked(0) <= '1';
- else
- next_REPLY_IS_LOCKED <= '1';
- end if;
- else
- -- listen to REPLYIBUF itself
- if REPLYIBUF_stat_locked(0) = '1' then
- next_REPLY_IS_LOCKED <= '1';
- INITOBUF_ctrl_locked(0) <= '1';
- else
- next_REPLY_IS_LOCKED <= '0';
- end if;
- end if;
- if INIT_IS_LOCKED = '1' then
- -- listen to REPLYOBUF
- if REPLYOBUF_stat_locked(0) = '1' or CTRL_LOCKED(0) = '1' then
- next_INIT_IS_LOCKED <= '0';
- INITIBUF_ctrl_locked(0) <= '1';
+ STAT_GEN <= (others => '0');
+
+ REPLYOBUF_ctrl_locked(15 downto 2) <= (others => '0');
+ REPLYIBUF_ctrl_locked(15 downto 2) <= (others => '0');
+ INITOBUF_ctrl_locked(15 downto 2) <= (others => '0');
+ INITIBUF_ctrl_locked(15 downto 2) <= (others => '0');
+
+ -- comb part of the locking control
+ comb_locked : process (INIT_IS_LOCKED, REPLY_IS_LOCKED, INITIBUF_stat_locked,
+ REPLYOBUF_stat_locked, REPLYIBUF_stat_locked,
+ INITOBUF_stat_locked, CTRL_LOCKED)
+
+ begin -- process
+ next_INIT_IS_LOCKED <= INIT_IS_LOCKED;
+ next_REPLY_IS_LOCKED <= REPLY_IS_LOCKED;
+ REPLYOBUF_ctrl_locked(1 downto 0) <= (others => '0');
+ REPLYIBUF_ctrl_locked(1 downto 0) <= (others => '0');
+ INITOBUF_ctrl_locked(1 downto 0) <= (others => '0');
+ INITIBUF_ctrl_locked(1 downto 0) <= (others => '0');
+
+ if REPLY_IS_LOCKED = '1' then
+ -- listen to INITOBUF
+ if INITOBUF_stat_locked(0) = '1' or CTRL_LOCKED(1) = '1' then
+ next_REPLY_IS_LOCKED <= '0';
+ REPLYIBUF_ctrl_locked(0) <= '1';
+ else
+ next_REPLY_IS_LOCKED <= '1';
+ end if;
else
- next_INIT_IS_LOCKED <= '1';
- end if;
- else
- -- listen to INITIBUF itself
- if INITIBUF_stat_locked(0) = '1' then
- next_INIT_IS_LOCKED <= '1';
- REPLYOBUF_ctrl_locked(0) <= '1';
+ -- listen to REPLYIBUF itself
+ if REPLYIBUF_stat_locked(0) = '1' then
+ next_REPLY_IS_LOCKED <= '1';
+ INITOBUF_ctrl_locked(0) <= '1';
+ else
+ next_REPLY_IS_LOCKED <= '0';
+ end if;
+ end if;
+ if INIT_IS_LOCKED = '1' then
+ -- listen to REPLYOBUF
+ if REPLYOBUF_stat_locked(0) = '1' or CTRL_LOCKED(0) = '1' then
+ next_INIT_IS_LOCKED <= '0';
+ INITIBUF_ctrl_locked(0) <= '1';
+ else
+ next_INIT_IS_LOCKED <= '1';
+ end if;
else
- next_INIT_IS_LOCKED <= '0';
- end if;
- end if;
+ -- listen to INITIBUF itself
+ if INITIBUF_stat_locked(0) = '1' then
+ next_INIT_IS_LOCKED <= '1';
+ REPLYOBUF_ctrl_locked(0) <= '1';
+ else
+ next_INIT_IS_LOCKED <= '0';
+ end if;
+ end if;
+
+ end process;
- end process;
-
- reg_locked: process(CLK)
- begin
- if rising_edge(CLK) then
- if RESET = '1' then
- INIT_IS_LOCKED <= '0';
- REPLY_IS_LOCKED <= '1';
- elsif CLK_EN = '1' then
- INIT_IS_LOCKED <= next_INIT_IS_LOCKED;
- REPLY_IS_LOCKED <= next_REPLY_IS_LOCKED;
- else
- INIT_IS_LOCKED <= INIT_IS_LOCKED;
- REPLY_IS_LOCKED <= REPLY_IS_LOCKED;
+ reg_locked: process(CLK)
+ begin
+ if rising_edge(CLK) then
+ if RESET = '1' then
+ INIT_IS_LOCKED <= '0';
+ REPLY_IS_LOCKED <= '1';
+ elsif CLK_EN = '1' then
+ INIT_IS_LOCKED <= next_INIT_IS_LOCKED;
+ REPLY_IS_LOCKED <= next_REPLY_IS_LOCKED;
+ else
+ INIT_IS_LOCKED <= INIT_IS_LOCKED;
+ REPLY_IS_LOCKED <= REPLY_IS_LOCKED;
+ end if;
end if;
- end if;
- end process;
+ end process;
+ end generate;
end architecture;
--- /dev/null
+LIBRARY IEEE;
+USE IEEE.std_logic_1164.ALL;
+USE IEEE.std_logic_ARITH.ALL;
+USE IEEE.std_logic_UNSIGNED.ALL;
+use work.trb_net_std.all;
+
+entity trb_net16_obuf_nodata is
+ port(
+ -- Misc
+ CLK : in std_logic;
+ RESET : in std_logic;
+ CLK_EN : in std_logic;
+ -- Media direction port
+ MED_DATAREADY_OUT: out std_logic;
+ MED_DATA_OUT: out std_logic_vector (15 downto 0); -- Data word
+ MED_PACKET_NUM_OUT:out std_logic_vector(1 downto 0);
+ MED_READ_IN: in std_logic;
+ --STAT
+ STAT_LOCKED: out std_logic_vector (15 downto 0);
+ CTRL_LOCKED: in std_logic_vector (15 downto 0);
+ STAT_BUFFER: out std_logic_vector (31 downto 0);
+ CTRL_BUFFER: in std_logic_vector (31 downto 0)
+ );
+end entity;
+
+
+
+architecture trb_net16_obuf_nodata_arch of trb_net16_obuf_nodata is
+
+ signal SEND_BUFFER_SIZE_IN : std_logic_vector(3 downto 0);
+ signal SEND_ACK_IN : std_logic;
+ signal current_NOP_word : std_logic_vector(15 downto 0);
+ signal current_ACK_word : std_logic_vector(15 downto 0);
+ signal transfer_counter : std_logic_vector(1 downto 0);
+
+ signal buf_MED_DATAREADY_OUT, next_MED_DATAREADY_OUT : std_logic;
+ signal buf_MED_DATA_OUT, next_MED_DATA_OUT : std_logic_vector(15 downto 0);
+ signal buf_MED_PACKET_NUM_OUT : std_logic_vector(1 downto 0);
+ signal sending_ACK, next_sending_ACK : std_logic;
+ signal send_ACK : std_logic;
+ signal reg_SEND_ACK_IN_2, next_SEND_ACK_IN_2 : std_logic;
+ signal reg_SEND_ACK_IN, next_SEND_ACK_IN : std_logic;
+
+begin
+ SEND_BUFFER_SIZE_IN <= CTRL_BUFFER(3 downto 0);
+ SEND_ACK_IN <= CTRL_BUFFER(8);
+
+ send_ACK <= SEND_ACK_IN or reg_SEND_ACK_IN or reg_SEND_ACK_IN_2;
+ next_SEND_ACK_IN_2 <= (reg_SEND_ACK_IN_2 or SEND_ACK_IN) and reg_SEND_ACK_IN;
+
+ MED_DATAREADY_OUT <= buf_MED_DATAREADY_OUT;
+ MED_PACKET_NUM_OUT <= buf_MED_PACKET_NUM_OUT;
+ MED_DATA_OUT <= buf_MED_DATA_OUT;
+
+ process(current_NOP_word, send_ACK, SEND_ACK, current_ACK_word, transfer_counter, MED_READ_IN)
+ begin
+ next_MED_DATA_OUT <= current_NOP_word;
+ next_MED_DATAREADY_OUT <= '0';
+ next_SEND_ACK_IN <= send_ACK;
+
+
+ if reg_SEND_ACK_IN = '1' then
+ next_MED_DATA_OUT <= current_ACK_word;
+ next_MED_DATAREADY_OUT <= '1';
+ if transfer_counter <= "11" and MED_READ_IN = '1' then
+ next_SEND_ACK_IN <= '0';
+ end if;
+ end if;
+ end process;
+
+ REG_SEND_DATA : process(CLK)
+ begin
+ if rising_edge(CLK) then
+ if RESET = '1' then
+ buf_MED_DATA_OUT <= (others => '0');
+ buf_MED_PACKET_NUM_OUT <= (others => '0');
+ buf_MED_DATAREADY_OUT <= '0';
+ else
+ buf_MED_DATA_OUT <= next_MED_DATA_OUT;
+ buf_MED_PACKET_NUM_OUT <= transfer_counter;
+ buf_MED_DATAREADY_OUT <= next_MED_DATAREADY_OUT;
+ end if;
+ end if;
+ end process;
+
+ GENERATE_WORDS : process(transfer_counter, SEND_BUFFER_SIZE_IN)
+ begin
+ current_NOP_word <= (others => '0');
+ current_NOP_word(2 downto 0) <= TYPE_ILLEGAL;
+ current_ACK_word <= (others => '0');
+ if transfer_counter = "10" then
+ current_ACK_word(3 downto 0) <= SEND_BUFFER_SIZE_IN;
+ elsif transfer_counter = "00" then
+ current_ACK_word(2 downto 0) <= TYPE_ACK;
+ end if;
+ end process;
+
+ REG_TRANSFER_COUNTER : process(CLK)
+ begin
+ if rising_edge(CLK) then
+ if RESET = '1' then
+ transfer_counter <= (others => '0');
+ elsif buf_MED_DATAREADY_OUT = '1' and MED_READ_IN = '1' then
+ transfer_counter <= transfer_counter + 1;
+ end if;
+ end if;
+ end process;
+
+ REG_SEND_ACK : process(CLK)
+ begin
+ if rising_edge(CLK) then
+ if RESET = '1' then
+ reg_SEND_ACK_IN <= '0';
+ reg_SEND_ACK_IN_2 <= '0';
+ elsif CLK_EN = '1' then
+ reg_SEND_ACK_IN <= next_SEND_ACK_IN;
+ reg_SEND_ACK_IN_2 <= next_SEND_ACK_IN_2;
+ end if;
+ end if;
+ end process;
+
+ STAT_LOCKED <= (others => '0');
+ STAT_BUFFER <= (others => '0');
+
+end architecture;
process(RESET, reg_APL_DTYPE_OUT, reg_APL_SEQNR_OUT, reg_APL_GOT_TRM, current_packet_type,
INT_PACKET_NUM_IN, INT_DATA_IN, APL_RELEASE_TRM, send_trm,
- transfer_counter, INT_READ_IN, saved_packet_type, buf_APL_ERROR_PATTERN_IN, buf_APL_DTYPE_IN)
+ transfer_counter, INT_READ_IN, saved_packet_type, buf_APL_ERROR_PATTERN_IN,
+ buf_APL_DTYPE_IN, buf_INT_DATA_OUT, buf_INT_DATAREADY_OUT)
begin
--next_APL_ERROR_PATTERN_OUT <= reg_APL_ERROR_PATTERN_OUT;
next_APL_DTYPE_OUT <= reg_APL_DTYPE_OUT;
MED_REPLY_DATAREADY_IN, MED_REPLY_PACKET_NUM_IN, MED_REPLY_DATA_IN,
send_INIT_ack, send_REPLY_ack, send_REPLY_trm, sending_REPLY_ACK,
REPLY_transfer_counter, REPLY_saved_packet_type, MED_INIT_READ_IN,
- INIT_SEQNR, INIT_transfer_counter, INIT_saved_packet_type, MED_REPLY_READ_IN)
+ INIT_SEQNR, INIT_transfer_counter, INIT_saved_packet_type, MED_REPLY_READ_IN,
+ buf_MED_INIT_DATA_OUT, buf_MED_REPLY_DATA_OUT, buf_MED_INIT_DATAREADY_OUT,
+ buf_MED_REPLY_DATAREADY_OUT)
begin
sent_INIT_ack <= '0';
sent_REPLY_ack <= '0';
+--this fifo uses standard read behaviour: data is available one clock cycle after read was high.
+
+
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
move_b1_buffer <= '1';
move_b2_buffer <= '1';
elsif combined_COMB_DATAREADY_IN = '1' then
- -- ONLY COMB logic is writing into the sbuf
- -- FATAL ERROR
+ -- ONLY COMB logic is writing into the sbuf FATAL ERROR
next_got_overflow <= '1';
elsif SYN_READ_IN = '1' then
next_buffer_state <= BUFFER_B2_FULL;
move_b1_buffer <= '1';
move_b2_buffer <= '1';
end if;
+
end if;
-- for version1 it is more complicated: we have to gate