SBUF_VERSION : integer range 0 to 1 := 0;
MUX_WIDTH : integer range 1 to 5 := 3;
MUX_SECURE_MODE : integer range 0 to 1 := 0;
- DAT_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 0;
+ DAT_CHANNEL : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
DATA_WIDTH : integer := 16;
NUM_WIDTH : integer := 2
);
entity trb_net16_endpoint_1_trg_0_api is
generic (
- TRG_INIT_DEPTH : integer := 0; -- Depth of the FIFO, 2^(n+1), if
- -- the initibuf
- TRG_REPLY_DEPTH : integer := 0; -- or the replyibuf
- MUX_WIDTH : integer := 3;
- MUX_SECURE_MODE : integer := 0;
- TRG_CHANNEL : integer := 0;
- DATA_WIDTH : integer := 16; --not to be changed
- NUM_WIDTH : integer := 2; --not to be changed
- TRG_SECURE_MODE : integer := 0 -- if 0, error pattern and dtype must be valid until next
+ TRG_INIT_DEPTH : integer := 0;
+ TRG_REPLY_DEPTH : integer := 0;
+ MUX_WIDTH : integer := 3;
+ MUX_SECURE_MODE : integer := 0;
+ TRG_CHANNEL : integer := 0;
+ DATA_WIDTH : integer := 16; --not to be changed
+ NUM_WIDTH : integer := 2; --not to be changed
+ TRG_SECURE_MODE : integer := 0 -- if 0, error pattern and dtype must be valid until next
-- trigger comes in. if 1 these can be valid on falling edge of hold_trm only
);
--Multiplexer
MUX_WIDTH : integer range 1 to 5 := 3;
MUX_SECURE_MODE : integer range 0 to 1 := 0;
- TRG_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 0;
- DAT_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 2;
+ TRG_CHANNEL : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
+ DAT_CHANNEL : integer range 0 to 3 := 2; --range 0 to 2**(MUX_WIDTH-1)
--General
DATA_WIDTH : integer range 16 to 16 := 16;
NUM_WIDTH : integer range 2 to 2 := 2
--Multiplexer
MUX_WIDTH : integer range 1 to 5 := 3;
MUX_SECURE_MODE : integer range 0 to 1 := 0;
- TRG1_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 0;
- TRG2_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 1;
- DAT_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 3;
+ TRG1_CHANNEL : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
+ TRG2_CHANNEL : integer range 0 to 3 := 1; --range 0 to 2**(MUX_WIDTH-1)
+ DAT_CHANNEL : integer range 0 to 3 := 3; --range 0 to 2**(MUX_WIDTH-1)
--General
DATA_WIDTH : integer range 16 to 16 := 16;
NUM_WIDTH : integer range 2 to 2 := 2
--Multiplexer
MUX_WIDTH : integer range 1 to 5 := 3;
MUX_SECURE_MODE : integer range 0 to 1 := 0;
- TRG1_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 0;
- TRG2_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 1;
- DAT1_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 2;
- DAT2_CHANNEL : integer range 0 to 2**(MUX_WIDTH-1) := 3;
+ TRG1_CHANNEL : integer range 0 to 3 := 0; --range 0 to 2**(MUX_WIDTH-1)
+ TRG2_CHANNEL : integer range 0 to 3 := 1; --range 0 to 2**(MUX_WIDTH-1)
+ DAT1_CHANNEL : integer range 0 to 3 := 2; --range 0 to 2**(MUX_WIDTH-1)
+ DAT2_CHANNEL : integer range 0 to 3 := 3; --range 0 to 2**(MUX_WIDTH-1)
--General
DATA_WIDTH : integer range 16 to 16 := 16;
NUM_WIDTH : integer range 2 to 2 := 2
generic (
--general settings
MUX_SECURE_MODE : integer range 0 to 1 := 0;
- MUX_WIDTH : integer range 1 to 3 := 3;
+ MUX_WIDTH : integer range 1 to 3 := 1;
DATA_WIDTH : integer range 16 to 16 := 16;
NUM_WIDTH : integer range 2 to 2 := 2;
--hub control
HUB_ADDRESS : std_logic_vector(15 downto 0) := x"F001";
- HUB_CTRL_CHANNELNUM : integer range 0 to 2**(MUX_WIDTH-1)-1 := 3;
+ HUB_CTRL_CHANNELNUM : integer range 0 to 3 := 3;
HUB_CTRL_DEPTH : integer range 0 to 6 := 1;
HUB_CTRL_REG_ADDR_WIDTH : integer range 1 to 7 := 4;
--media interfaces
- MII_NUMBER : integer range 2 to 16 := 2;
+ 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
--CHANNEL 3 2 1 0
- MII_INIT_DEPTH : hub_iobuf_config_t := (1,1,0,0, --MII 0
- 1,1,0,0,
- 1,1,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0); --MII 15
- MII_REPLY_DEPTH : hub_iobuf_config_t := (1,1,0,0, --MII 0
- 1,1,0,0,
- 1,1,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0,
- 0,0,0,0); --MII 15
+ MII_INIT_DEPTH : hub_iobuf_config_t := (6,6,6,6, --MII 6
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6); --MII 65
+ MII_REPLY_DEPTH : hub_iobuf_config_t := (6,6,6,6, --MII 6
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6,
+ 6,6,6,6); --MII 15
-- settings for apis
API_NUMBER : integer range 0 to 16 := 0;
API_CHANNELS : hub_api_config_t := (3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3);
API_FIFO_TO_INT_DEPTH : hub_api_config_t := (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
API_FIFO_TO_APL_DEPTH : hub_api_config_t := (1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
--trigger reading interfaces
- TRG_NUMBER : integer range 0 to 16 := 2;
+ TRG_NUMBER : integer range 0 to 16 := 0;
TRG_SECURE_MODE : integer range 0 to 1 := 0;
TRG_CHANNELS : hub_api_config_t := (0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0)
);
--Media interfacces
--each port is one bit bigger than actually necessary to avoid error messages
- MED_DATAREADY_OUT : out std_logic_vector (MII_NUMBER+1 downto 0);
- MED_DATA_OUT : out std_logic_vector (MII_NUMBER*DATA_WIDTH+1 downto 0);
- MED_PACKET_NUM_OUT: out std_logic_vector (MII_NUMBER*NUM_WIDTH+1 downto 0);
- MED_READ_IN : in std_logic_vector (MII_NUMBER+1 downto 0);
- MED_DATAREADY_IN : in std_logic_vector (MII_NUMBER+1 downto 0);
- MED_DATA_IN : in std_logic_vector (MII_NUMBER*DATA_WIDTH+1 downto 0);
- MED_PACKET_NUM_IN : in std_logic_vector (MII_NUMBER*NUM_WIDTH+1 downto 0);
- MED_READ_OUT : out std_logic_vector (MII_NUMBER+1 downto 0); -- buffer reads a word from media
- MED_ERROR_IN : in std_logic_vector (MII_NUMBER*3+1 downto 0);
+ MED_DATAREADY_OUT : out std_logic_vector (MII_NUMBER-1 downto 0);
+ MED_DATA_OUT : out std_logic_vector (MII_NUMBER*DATA_WIDTH-1 downto 0);
+ MED_PACKET_NUM_OUT: out std_logic_vector (MII_NUMBER*NUM_WIDTH-1 downto 0);
+ MED_READ_IN : in std_logic_vector (MII_NUMBER-1 downto 0);
+ MED_DATAREADY_IN : in std_logic_vector (MII_NUMBER-1 downto 0);
+ MED_DATA_IN : in std_logic_vector (MII_NUMBER*DATA_WIDTH-1 downto 0);
+ MED_PACKET_NUM_IN : in std_logic_vector (MII_NUMBER*NUM_WIDTH-1 downto 0);
+ MED_READ_OUT : out std_logic_vector (MII_NUMBER-1 downto 0); -- buffer reads a word from media
+ MED_ERROR_IN : in std_logic_vector (MII_NUMBER*3-1 downto 0);
--API: interfaces
- APL_DATA_IN : in std_logic_vector (API_NUMBER*DATA_WIDTH downto 0);
- APL_PACKET_NUM_IN : in std_logic_vector (API_NUMBER*NUM_WIDTH downto 0);
- APL_WRITE_IN : in std_logic_vector (API_NUMBER downto 0);
- APL_FIFO_FULL_OUT : out std_logic_vector (API_NUMBER downto 0);
- APL_SHORT_TRANSFER_IN : in std_logic_vector (API_NUMBER downto 0);
- APL_DTYPE_IN : in std_logic_vector (API_NUMBER*4 downto 0);
- APL_ERROR_PATTERN_IN : in std_logic_vector (API_NUMBER*32 downto 0);
- APL_SEND_IN : in std_logic_vector (API_NUMBER downto 0);
- APL_TARGET_ADDRESS_IN : in std_logic_vector (API_NUMBER*16 downto 0);
- APL_DATA_OUT : out std_logic_vector (API_NUMBER*16 downto 0);
- APL_PACKET_NUM_OUT: out std_logic_vector (API_NUMBER*NUM_WIDTH downto 0);
- APL_TYP_OUT : out std_logic_vector (API_NUMBER*3 downto 0);
- APL_DATAREADY_OUT : out std_logic_vector (API_NUMBER downto 0);
- APL_READ_IN : in std_logic_vector (API_NUMBER downto 0);
- APL_RUN_OUT : out std_logic_vector (API_NUMBER downto 0);
- APL_MY_ADDRESS_IN : in std_logic_vector (API_NUMBER*16 downto 0);
- APL_SEQNR_OUT : out std_logic_vector (API_NUMBER*8 downto 0);
+ APL_DATA_IN : in std_logic_vector (VAL(API_NUMBER*DATA_WIDTH) downto 0);
+ APL_PACKET_NUM_IN : in std_logic_vector (VAL(API_NUMBER*NUM_WIDTH) downto 0);
+ APL_WRITE_IN : in std_logic_vector (VAL(API_NUMBER) downto 0);
+ APL_FIFO_FULL_OUT : out std_logic_vector (VAL(API_NUMBER) downto 0);
+ APL_SHORT_TRANSFER_IN : in std_logic_vector (VAL(API_NUMBER) downto 0);
+ APL_DTYPE_IN : in std_logic_vector (VAL(API_NUMBER*4) downto 0);
+ APL_ERROR_PATTERN_IN : in std_logic_vector (VAL(API_NUMBER*32) downto 0);
+ APL_SEND_IN : in std_logic_vector (VAL(API_NUMBER) downto 0);
+ APL_TARGET_ADDRESS_IN : in std_logic_vector (VAL(API_NUMBER*16) downto 0);
+ APL_DATA_OUT : out std_logic_vector (VAL(API_NUMBER*16) downto 0);
+ APL_PACKET_NUM_OUT: out std_logic_vector (VAL(API_NUMBER*NUM_WIDTH) downto 0);
+ APL_TYP_OUT : out std_logic_vector (VAL(API_NUMBER*3) downto 0);
+ APL_DATAREADY_OUT : out std_logic_vector (VAL(API_NUMBER) downto 0);
+ APL_READ_IN : in std_logic_vector (VAL(API_NUMBER) downto 0);
+ APL_RUN_OUT : out std_logic_vector (VAL(API_NUMBER) downto 0);
+ APL_MY_ADDRESS_IN : in std_logic_vector (VAL(API_NUMBER*16) downto 0);
+ APL_SEQNR_OUT : out std_logic_vector (VAL(API_NUMBER*8) downto 0);
--TRG interfaces
- TRG_GOT_TRIGGER_OUT : out std_logic_vector (TRG_NUMBER downto 0);
- TRG_ERROR_PATTERN_OUT : out std_logic_vector (TRG_NUMBER*32 downto 0);
- TRG_DTYPE_OUT : out std_logic_vector (TRG_NUMBER*4 downto 0);
- TRG_SEQNR_OUT : out std_logic_vector (TRG_NUMBER*8 downto 0);
- TRG_ERROR_PATTERN_IN : in std_logic_vector (TRG_NUMBER*32 downto 0);
- TRG_RELEASE_IN : in std_logic_vector (TRG_NUMBER downto 0);
+ TRG_GOT_TRIGGER_OUT : out std_logic_vector (VAL(TRG_NUMBER) downto 0);
+ TRG_ERROR_PATTERN_OUT : out std_logic_vector (VAL(TRG_NUMBER*32) downto 0);
+ TRG_DTYPE_OUT : out std_logic_vector (VAL(TRG_NUMBER*4) downto 0);
+ TRG_SEQNR_OUT : out std_logic_vector (VAL(TRG_NUMBER*8) downto 0);
+ TRG_ERROR_PATTERN_IN : in std_logic_vector (VAL(TRG_NUMBER*32) downto 0);
+ TRG_RELEASE_IN : in std_logic_vector (VAL(TRG_NUMBER) downto 0);
--Status ports (for debugging)
HUB_STAT_CHANNEL : out std_logic_vector (2**(MUX_WIDTH-1)*16-1 downto 0);
HUB_STAT_GEN : out std_logic_vector (31 downto 0);
--- HUB_CTRL_CHANNEL : in std_logic_vector (2**(MUX_WIDTH-1)*16-1 downto 0);
--- HUB_CTRL_activepoints : in std_logic_vector (2**(MUX_WIDTH-1)*32-1 downto 0);
--- HUB_CTRL_GEN : in std_logic_vector (31 downto 0);
+
MPLEX_CTRL : in std_logic_vector (MII_NUMBER*32-1 downto 0);
MPLEX_STAT : out std_logic_vector (MII_NUMBER*32-1 downto 0)
);
begin
--set unused signals
- MED_DATAREADY_OUT(MII_NUMBER+1 downto MII_NUMBER) <= "00";
- MED_DATA_OUT(MII_NUMBER*DATA_WIDTH+1 downto MII_NUMBER*DATA_WIDTH) <= "00";
- MED_PACKET_NUM_OUT(MII_NUMBER*NUM_WIDTH+1 downto MII_NUMBER*NUM_WIDTH) <= "00";
- MED_READ_OUT(MII_NUMBER+1 downto MII_NUMBER) <= "00";
+
<= hub_to_buf_REPLY_READ(buf_to_hub_num);
end generate;
g5: if api_num /= 0 generate
- gen_hublogicsignals2 : for api in 0 to api_num-1 generate
+ gen_hublogicsignals2 : for api in 0 to API_NUMBER-1 generate
constant hublogic_num : integer := first_point_num + MII_NUMBER + is_ctrl_channel + calc_special_number(CHANNEL, api, API_CHANNELS);
- constant buf_to_hub_num : integer := 2**(MUX_WIDTH-1)*MII_NUMBER + is_ctrl_channel + api;
+ constant buf_to_hub_num : integer := 2**(MUX_WIDTH-1)*MII_NUMBER + 1 + api;
--calc_special_number(CHANNEL, api, API_CHANNELS)
begin
h1: if API_CHANNELS(api) = CHANNEL generate
end generate;
end generate;
g3: if trg_num /= 0 generate
- gen_hublogicsignals3 : for trg in 0 to trg_num-1 generate
- constant hublogic_num : integer := first_point_num + MII_NUMBER + is_ctrl_channel + calc_special_number(CHANNEL, api_num, TRG_CHANNELS) + calc_special_number(CHANNEL, trg, TRG_CHANNELS);
- constant buf_to_hub_num : integer := 2**(MUX_WIDTH-1)*MII_NUMBER + is_ctrl_channel + api_num + trg;
+ gen_hublogicsignals3 : for trg in 0 to TRG_NUMBER-1 generate
+ constant hublogic_num : integer := first_point_num + MII_NUMBER + is_ctrl_channel + calc_special_number(CHANNEL, API_NUMBER, API_CHANNELS) + calc_special_number(CHANNEL, trg, TRG_CHANNELS);
+ constant buf_to_hub_num : integer := 2**(MUX_WIDTH-1)*MII_NUMBER + 1 + API_NUMBER + trg;
begin
h1: if TRG_CHANNELS(trg) = CHANNEL generate
HUB_INIT_DATAREADY_IN (hublogic_num)
HC_STAT_REGS(31 downto 0) <= buf_HUB_STAT_GEN;
HC_STAT_REGS(32+2**(MUX_WIDTH-1)*16-1 downto 32) <= buf_HUB_STAT_CHANNEL;
-
+
HUB_CTRL_GEN <= HC_CTRL_REGS(31 downto 0);
HUB_CTRL_CHANNEL <= HC_CTRL_REGS(32+2**(MUX_WIDTH-1)*16-1 downto 32);
HUB_CTRL_activepoints <= HC_CTRL_REGS(128+2**(MUX_WIDTH-1)*32-1 downto 128);
function reportint(i : integer)
return integer;
+ function VAL(i : integer)
+ return integer;
end package trb_net16_hub_func;
package body trb_net16_hub_func is
+ function VAL(i : integer)
+ return integer is
+ begin
+ if i > 0 then
+ return i-1;
+ else
+ return 0;
+ end if;
+ end function;
+
function calc_is_ctrl_channel(CHANNEL : integer; HUB_CTRL_CHANNEL : integer)
return integer is
begin
entity trb_net16_hub_logic is
generic (
--media interfaces
- POINT_NUMBER : integer range 2 to 32 := 5;
+ POINT_NUMBER : integer range 2 to 32 := 12;
--general settings
DATA_WIDTH : integer range 16 to 16 := 16;
signal get_locked, release_locked : std_logic;
signal got_trm : std_logic_vector(POINT_NUMBER-1 downto 0);
signal locking_point, next_locking_point : std_logic_vector(POINT_NUMBER-1 downto 0);
- signal reading_from_point : std_logic_vector(POINT_NUMBER-1 downto 0);
+ signal reading_from_point,next_reading_from_point : std_logic_vector(POINT_NUMBER-1 downto 0);
signal send_reply_trm : std_logic;
signal init_locked, next_init_locked : std_logic;
signal comb_REPLY_POOL_next_read : std_logic;
- signal reply_point_lock : std_logic;
- signal release_point_lock, get_point_lock : std_logic;
+ signal reply_point_lock, next_point_lock : std_logic;
signal tmp_REPLY_READ_OUT : std_logic_vector(POINT_NUMBER-1 downto 0);
signal comb_REPLY_muxed_DATAREADY : std_logic;
STAT(7 downto 0) <= (others => '0');
STAT(15 downto 8) <= data_counter;
-STAT_POINTS_locked(POINT_NUMBER-1 downto 0) <= not got_trm when locked = '1' else (others => '0');
+STAT_POINTS_locked(POINT_NUMBER-1 downto 0) <= not got_trm;
STAT_POINTS_locked(31 downto POINT_NUMBER) <= (others => '0');
STAT_ERRORBITS <= REPLY_combined_trm_F1 & REPLY_combined_trm_F2;
--Datapool for Init-Channel
INIT_muxed_DATAREADY <= or_all(INIT_DATAREADY_IN) and not init_locked and INIT_muxed_READ;
- INIT_POOL_READ <= and_all(INIT_READ_IN or init_has_read_from_pool or locking_point);
+ INIT_POOL_READ <= and_all(INIT_READ_IN or init_has_read_from_pool or locking_point or not CTRL_activepoints(POINT_NUMBER-1 downto 0));
INIT_READ_OUT <= buf_INIT_READ_OUT;
- buf_INIT_READ_OUT <= init_arbiter_read_out when init_locked = '0' else (others => '0');
+ 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;
+ end generate;
gen_init_pool_data0: for i in 0 to DATA_WIDTH-1 generate
process(INIT_DATA_IN, buf_INIT_READ_OUT)
if rising_edge(CLK) then
if RESET = '1' or INIT_POOL_READ = '1' then
init_has_read_from_pool(i) <= '0';
- else
- if INIT_POOL_DATAREADY = '1' and INIT_READ_IN(i) = '1' then
- init_has_read_from_pool(i) <= '1';
- end if;
+ elsif INIT_POOL_DATAREADY = '1' and INIT_READ_IN(i) = '1' then
+ init_has_read_from_pool(i) <= '1';
end if;
end if;
end process;
--locked signals
--locked: transfer is running
--init_locked: waiting for reply channel to finish
- send_reply_trm <= '1' when and_all(got_trm) = '1'
- else '0';
+ --send_reply_trm <= '1' when and_all(got_trm) = '1' else '0';
+ send_reply_trm <= and_all(got_trm);
get_locked <= INIT_muxed_DATAREADY;
next_locked <= (get_locked or locked) and not release_locked;
next_locking_point <= (buf_INIT_READ_OUT and INIT_DATAREADY_IN) when (locked = '0' and REPLY_POOL_DATAREADY = '0') else locking_point;
REPLY_reading_trm;
REPLY_READ_OUT <= buf_REPLY_READ_OUT;
- REPLY_MUX_real_reading <= or_all(REPLY_MUX_reading) and REPLY_POOL_next_read;
+ REPLY_MUX_real_reading <= REPLY_POOL_next_read; --or_all(REPLY_MUX_reading) and
+ --REPLY_MUX_reading always contains a 1 (?)
--saving necessary data
----------------------------------
gen_reading_trmFn : for i in 0 to POINT_NUMBER-1 generate
- reading_trmF1(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "01"
- and REPLY_reading_trm(i) = '1'
- and REPLY_DATAREADY_IN(i) = '1'
- else '0';
- reading_trmF2(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "10"
- and REPLY_reading_trm(i) = '1'
- and REPLY_DATAREADY_IN(i) = '1'
- else '0';
+-- reading_trmF1(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "01"
+-- and REPLY_reading_trm(i) = '1'
+-- and REPLY_DATAREADY_IN(i) = '1'
+-- else '0';
+-- reading_trmF2(i) <= '1' when REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1 downto i*NUM_WIDTH) = "10"
+-- and REPLY_reading_trm(i) = '1'
+-- and REPLY_DATAREADY_IN(i) = '1'
+-- else '0';
+ reading_trmF1(i) <= not REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1) and REPLY_PACKET_NUM_IN(i*NUM_WIDTH)
+ and REPLY_reading_trm(i) and REPLY_DATAREADY_IN(i);
+
+ reading_trmF2(i) <= REPLY_PACKET_NUM_IN((i+1)*NUM_WIDTH-1) and not REPLY_PACKET_NUM_IN(i*NUM_WIDTH)
+ and REPLY_reading_trm(i) and REPLY_DATAREADY_IN(i);
end generate;
gen_combining_trm : for j in 0 to DATA_WIDTH-1 generate
-- we have to care to read multiples of four packets from every point
-- release is currently done after first packet of TRM
- gen_reply_point_lock : process(comb_REPLY_POOL_PACKET_NUM, comb_REPLY_POOL_DATAREADY, REPLY_DATAREADY_IN,
- saved_REPLY_TYPE, comb_REPLY_muxed_PACKET_NUM, comb_REPLY_muxed_DATAREADY,
- comb_REPLY_muxed_DATA, buf_REPLY_READ_OUT, REPLY_MUX_reading)
+ gen_reply_point_lock : process(reply_point_lock, reading_from_point, comb_REPLY_muxed_PACKET_NUM, REPLY_MUX_reading,
+ REPLY_DATAREADY_IN, comb_REPLY_muxed_DATA, REPLY_MUX_reading)
begin
- release_point_lock <= '0';
- get_point_lock <= '0';
+ next_point_lock <= reply_point_lock;
+ next_reading_from_point <= reading_from_point;
if comb_REPLY_muxed_PACKET_NUM = "00" and or_all(REPLY_MUX_reading and REPLY_DATAREADY_IN) = '1' then
if comb_REPLY_muxed_DATA(2 downto 0) = TYPE_TRM then
- release_point_lock <= '1';
+ next_point_lock <= '0';
+ next_reading_from_point <= (others => '0');
else
- get_point_lock <= '1';
+ next_point_lock <= '1';
+ reading_from_point <= REPLY_MUX_reading;
end if;
end if;
end process;
gen_point_lock : process(CLK)
begin
if rising_edge(CLK) then
- if RESET = '1' or release_point_lock = '1' then
+ if RESET = '1' then
reply_point_lock <= '0';
reading_from_point <= (others => '0');
- elsif get_point_lock = '1' then
- reply_point_lock <= '1';
- reading_from_point <= REPLY_MUX_reading;
+ else
+ reply_point_lock <=next_point_lock;
+ reading_from_point <= next_reading_from_point;
end if;
end if;
end process;
- reply_arbiter_CLK_EN <= not reply_point_lock;
+ reply_arbiter_CLK_EN <= not reply_point_lock; --1 cycle too late?
entity trb_net16_ibuf is
generic (
DEPTH : integer range 0 to 7 := 1;
- SBUF_VERSION : integer range 0 to 1 := 0
+ IBUF_SECURE_MODE : integer range 0 to 1 := 1
+ --use sbuf in med_to_api direction?
);
port(
-- Misc
type ERROR_STATE is (IDLE, GOT_OVERFLOW_ERROR, GOT_LOCKED_ERROR, GOT_UNDEFINED_ERROR);
signal current_error_state, next_error_state : ERROR_STATE;
signal next_rec_buffer_size_out, current_rec_buffer_size_out: std_logic_vector(3 downto 0);
+ signal buf_INT_DATAREADY_OUT : std_logic;
begin
FIFO: trb_net16_fifo
if MED_PACKET_NUM_IN = "10" then
next_rec_buffer_size_out <= MED_DATA_IN(3 downto 0);
end if;
- elsif fifo_full = '0' then
- fifo_write <= '1';
- next_read_out <= '1';
- elsif fifo_full = '1' then
- next_error_state <= GOT_OVERFLOW_ERROR;
- elsif is_locked = '1' then
- next_error_state <= GOT_LOCKED_ERROR;
- end if; -- end TYPE
- end if; -- end MED_DATAREADY_IN
- if fifo_full = '0' then -- and is_locked = '0' then
+ else
+ if fifo_full = '0' then
+ fifo_write <= '1';
+ else
+ next_error_state <= GOT_OVERFLOW_ERROR;
+ end if;
+-- elsif is_locked = '1' then
+-- next_error_state <= GOT_LOCKED_ERROR;
+ end if;
+ end if;
+ if fifo_full = '0' then
next_read_out <= '1';
end if;
end process;
end if;
end process;
+ gensecure : if IBUF_SECURE_MODE = 1 generate
+ SBUF: trb_net16_sbuf
+ generic map (DATA_WIDTH => 16, NUM_WIDTH => 2, Version => 0)
+ port map (
+ CLK => CLK,
+ RESET => RESET,
+ CLK_EN => CLK_EN,
+ COMB_DATAREADY_IN => tmp_INT_DATAREADY_OUT,
+ COMB_next_READ_OUT => comb_next_read,
+ COMB_READ_IN => '1',
+ COMB_DATA_IN => tmp_INT_DATA_OUT,
+ COMB_PACKET_NUM_IN => tmp_INT_PACKET_NUM_OUT,
+ SYN_DATAREADY_OUT => INT_DATAREADY_OUT,
+ SYN_DATA_OUT => INT_DATA_OUT,
+ SYN_PACKET_NUM_OUT => INT_PACKET_NUM_OUT,
+ SYN_READ_IN => INT_READ_IN
+ );
- SBUF: trb_net16_sbuf
- generic map (DATA_WIDTH => 16, NUM_WIDTH => 2, Version => SBUF_VERSION)
- port map (
- CLK => CLK,
- RESET => RESET,
- CLK_EN => CLK_EN,
- COMB_DATAREADY_IN => tmp_INT_DATAREADY_OUT,
- COMB_next_READ_OUT => comb_next_read,
- COMB_READ_IN => '1',
- COMB_DATA_IN => tmp_INT_DATA_OUT,
- COMB_PACKET_NUM_IN => tmp_INT_PACKET_NUM_OUT,
- SYN_DATAREADY_OUT => INT_DATAREADY_OUT,
- SYN_DATA_OUT => INT_DATA_OUT,
- SYN_PACKET_NUM_OUT => INT_PACKET_NUM_OUT,
- SYN_READ_IN => INT_READ_IN
- );
-
- sbuf_free <= comb_next_read or INT_READ_IN; --sbuf killed
+ sbuf_free <= comb_next_read or INT_READ_IN; --sbuf killed
--- this process controls what will be forwarded to the internal point
- DATA_OUT : process (INT_HEADER_IN, fifo_data_out,
- release_locked, is_locked, sbuf_free, fifo_empty,
- fifo_packet_num_out, current_fifo_packet_type)
- begin
- tmp_INT_DATA_OUT <= fifo_data_out;
- tmp_INT_PACKET_NUM_OUT <= fifo_packet_num_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
- 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';
+ -- this process controls what will be forwarded to the internal point
+ DATA_OUT : process (INT_HEADER_IN, fifo_data_out,
+ release_locked, is_locked, sbuf_free, fifo_empty,
+ fifo_packet_num_out, current_fifo_packet_type)
+ begin
+ tmp_INT_DATA_OUT <= fifo_data_out;
+ tmp_INT_PACKET_NUM_OUT <= fifo_packet_num_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
+ tmp_INT_DATA_OUT(2 downto 0) <= TYPE_DAT;
end if;
- if current_fifo_packet_type = TYPE_TRM then
- got_locked <= is_locked or not release_locked;
+ 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 if;
+ end process;
+ end generate;
+ gen_notsecure : if IBUF_SECURE_MODE = 0 generate
+ DATA_OUT : process (INT_HEADER_IN, fifo_data_out,
+ 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
+ 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;
- end process;
+ INT_DATAREADY_OUT <= buf_INT_DATAREADY_OUT;
--BUGBUG HDR retransmit needed
--Entity decalaration for clock generator
entity trb_net16_iobuf is
generic (
- --FIFO size is given in 2^(n+1) 64Bit-packets i.e. 2^(n+3) 16bit packets
INIT_DEPTH : integer := 1;
- REPLY_DEPTH : integer := 1);
+ REPLY_DEPTH : integer := 1;
+ IBUF_SECURE_MODE : integer range 0 to 1 := 0
+ --use sbuf in med_to_api direction?
+ );
port(
-- Misc
CLK : in std_logic;
component trb_net16_ibuf is
generic (
DEPTH : integer range 0 to 7 := 1;
- SBUF_VERSION : integer range 0 to 1 := 0
+ IBUF_SECURE_MODE : integer range 0 to 1 := 1
+ --use sbuf in med_to_api direction?
);
port(
-- Misc
GEN_INIT_IBUF: if INIT_DEPTH>0 generate
INITIBUF : trb_net16_ibuf
generic map (
- DEPTH => INIT_DEPTH)
+ DEPTH => INIT_DEPTH,
+ IBUF_SECURE_MODE => IBUF_SECURE_MODE)
port map (
CLK => CLK,
RESET => RESET,
GEN_REPLY_IBUF : if REPLY_DEPTH > 0 generate
REPLYIBUF : trb_net16_ibuf
generic map (
- DEPTH => REPLY_DEPTH)
+ DEPTH => REPLY_DEPTH,
+ IBUF_SECURE_MODE => IBUF_SECURE_MODE)
port map (
CLK => CLK,
RESET => RESET,
end generate;
INITOBUF : trb_net16_obuf
-
--- generic map (
--- DATA_COUNT_WIDTH => 16
--- )
port map (
CLK => CLK,
RESET => RESET,
);
REPLYOBUF : trb_net16_obuf
--- generic map (
--- DATA_COUNT_WIDTH => 16
--- )
port map (
CLK => CLK,
RESET => RESET,
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 TRANSMITTED_BUFFERS, next_TRANSMITTED_BUFFERS : STD_LOGIC_VECTOR (1 downto 0);
signal increase_TRANSMITTED_BUFFERS, decrease_TRANSMITTED_BUFFERS : STD_LOGIC;
send_EOB <= '1' when (CURRENT_DATA_COUNT = max_DATA_COUNT_minus_one) else '0';
-
-- buffer registers
STAT_BUFFER(1 downto 0) <= TRANSMITTED_BUFFERS;
STAT_BUFFER(14 downto 2) <= (others => '0');