From e3494c0a4bb71fe3b0b05d1eb5d59bc8a35156f6 Mon Sep 17 00:00:00 2001 From: hadaq Date: Thu, 22 Mar 2007 17:24:42 +0000 Subject: [PATCH] optimizing, untested, Ingo --- trb_net_active_api.vhd | 6 ++-- trb_net_ibuf.vhd | 6 ++-- trb_net_io_multiplexer.vhd | 18 +++++----- trb_net_iobuf.vhd | 6 ++-- trb_net_obuf.vhd | 34 +++++++++--------- trb_net_priority_arbiter.vhd | 3 +- trb_net_sbuf.vhd | 70 ++++++++++++++++++++++++------------ trb_net_term_ibuf.vhd | 11 ++---- 8 files changed, 84 insertions(+), 70 deletions(-) diff --git a/trb_net_active_api.vhd b/trb_net_active_api.vhd index 693c30f..33617ee 100644 --- a/trb_net_active_api.vhd +++ b/trb_net_active_api.vhd @@ -118,8 +118,7 @@ component trb_net_fifo is SYN_DATA_OUT: out STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0); -- Data word SYN_READ_IN: in STD_LOGIC; -- Status and control port - STAT_BUFFER: out STD_LOGIC_VECTOR (31 downto 0); - CTRL_BUFFER: in STD_LOGIC_VECTOR (31 downto 0) + STAT_BUFFER: out STD_LOGIC ); END component; @@ -317,8 +316,7 @@ INIT_SBUF: trb_net_sbuf COMB_DATA_IN => next_INT_INIT_DATA_OUT, SYN_DATAREADY_OUT => INT_INIT_DATAREADY_OUT, SYN_DATA_OUT => INT_INIT_DATA_OUT, - SYN_READ_IN => INT_INIT_READ_IN, - CTRL_BUFFER => (others => '0') + SYN_READ_IN => INT_INIT_READ_IN ); sbuf_free <= sbuf_next_READ or INT_INIT_READ_IN; --sbuf killed in next cycle diff --git a/trb_net_ibuf.vhd b/trb_net_ibuf.vhd index 2f6bca7..c81ff40 100644 --- a/trb_net_ibuf.vhd +++ b/trb_net_ibuf.vhd @@ -77,8 +77,7 @@ end component; SYN_DATA_OUT: out STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0); -- Data word SYN_READ_IN: in STD_LOGIC; -- Status and control port - STAT_BUFFER: out STD_LOGIC_VECTOR (31 downto 0); - CTRL_BUFFER: in STD_LOGIC_VECTOR (31 downto 0) + STAT_BUFFER: out STD_LOGIC ); END component; @@ -197,8 +196,7 @@ reg_buffer: process(CLK) COMB_DATA_IN => tmp_INT_DATA_OUT, SYN_DATAREADY_OUT => INT_DATAREADY_OUT, SYN_DATA_OUT => INT_DATA_OUT, - SYN_READ_IN => INT_READ_IN, - CTRL_BUFFER => (others => '0') + SYN_READ_IN => INT_READ_IN ); sbuf_free <= comb_next_read or INT_READ_IN; --sbuf killed diff --git a/trb_net_io_multiplexer.vhd b/trb_net_io_multiplexer.vhd index 10ee1e7..6187223 100644 --- a/trb_net_io_multiplexer.vhd +++ b/trb_net_io_multiplexer.vhd @@ -11,9 +11,11 @@ use work.trb_net_std.all; entity trb_net_io_multiplexer is - generic (BUS_WIDTH : integer := 56; - MULT_WIDTH : integer := 5); - +-- generic (BUS_WIDTH : integer := 56; +-- MULT_WIDTH : integer := 5); + generic (BUS_WIDTH : integer := 52; + MULT_WIDTH : integer := 1); + port( -- Misc CLK : in std_logic; @@ -80,8 +82,7 @@ architecture trb_net_io_multiplexer_arch of trb_net_io_multiplexer is SYN_DATA_OUT: out STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0); -- Data word SYN_READ_IN: in STD_LOGIC; -- Status and control port - STAT_BUFFER: out STD_LOGIC_VECTOR (31 downto 0); - CTRL_BUFFER: in STD_LOGIC_VECTOR (31 downto 0) + STAT_BUFFER: out STD_LOGIC ); END component; @@ -136,8 +137,7 @@ architecture trb_net_io_multiplexer_arch of trb_net_io_multiplexer is COMB_DATA_IN => MED_DATA_IN (BUS_WIDTH-MULT_WIDTH-1 downto 0), SYN_DATAREADY_OUT => INT_DATAREADY_OUT(i), SYN_DATA_OUT => INT_DATA_OUT ((BUS_WIDTH-MULT_WIDTH)*(i+1)-1 downto (BUS_WIDTH-MULT_WIDTH)*(i)), - SYN_READ_IN => INT_READ_IN(i), - CTRL_BUFFER => (others => '0') + SYN_READ_IN => INT_READ_IN(i) ); end generate; @@ -212,9 +212,7 @@ INT_READ_OUT <= tmp_INT_READ_OUT; COMB_DATA_IN => current_mux_buffer, SYN_DATAREADY_OUT => MED_DATAREADY_OUT, SYN_DATA_OUT => MED_DATA_OUT, - SYN_READ_IN => MED_READ_IN, --- STAT_BUFFER => - CTRL_BUFFER => (others => '0') + SYN_READ_IN => MED_READ_IN ); process (tmp_INT_READ_OUT, INT_DATA_IN) diff --git a/trb_net_iobuf.vhd b/trb_net_iobuf.vhd index 0288183..13c3692 100644 --- a/trb_net_iobuf.vhd +++ b/trb_net_iobuf.vhd @@ -12,9 +12,11 @@ use work.trb_net_std.all; --Entity decalaration for clock generator entity trb_net_iobuf is - generic (INIT_DEPTH : integer := 3; -- Depth of the FIFO, 2^(n+1), if + generic ( +-- INIT_DEPTH : integer := 0; + INIT_DEPTH : integer := 3; -- Depth of the FIFO, 2^(n+1), if -- the initibuf - REPLY_DEPTH : integer := 3); -- or the replyibuf + REPLY_DEPTH : integer := 3); -- or the replyibuf port( -- Misc diff --git a/trb_net_obuf.vhd b/trb_net_obuf.vhd index ae8e2f4..25bd49b 100644 --- a/trb_net_obuf.vhd +++ b/trb_net_obuf.vhd @@ -10,7 +10,8 @@ use work.trb_net_std.all; --Entity decalaration for clock generator entity trb_net_obuf is - + generic ( + DATA_COUNT_WIDTH : integer := 4); port( -- Misc @@ -54,8 +55,7 @@ architecture trb_net_obuf_arch of trb_net_obuf is SYN_DATA_OUT: out STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0); -- Data word SYN_READ_IN: in STD_LOGIC; -- Status and control port - STAT_BUFFER: out STD_LOGIC_VECTOR (31 downto 0); - CTRL_BUFFER: in STD_LOGIC_VECTOR (31 downto 0) + STAT_BUFFER: out STD_LOGIC ); END component; @@ -68,9 +68,9 @@ architecture trb_net_obuf_arch of trb_net_obuf is signal next_SEND_ACK_IN, reg_SEND_ACK_IN : STD_LOGIC; signal sent_ACK, sent_EOB, sent_DATA : STD_LOGIC; - signal CURRENT_DATA_COUNT, next_DATA_COUNT : STD_LOGIC_VECTOR (15 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 (15 downto 0); + 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 TRANSMITTED_BUFFERS, next_TRANSMITTED_BUFFERS : STD_LOGIC_VECTOR (1 downto 0); signal increase_TRANSMITTED_BUFFERS, decrease_TRANSMITTED_BUFFERS : STD_LOGIC; @@ -98,8 +98,7 @@ architecture trb_net_obuf_arch of trb_net_obuf is COMB_DATA_IN => current_output_buffer, SYN_DATAREADY_OUT => MED_DATAREADY_OUT, SYN_DATA_OUT => MED_DATA_OUT, - SYN_READ_IN => MED_READ_IN, - CTRL_BUFFER => (others => '0') + SYN_READ_IN => MED_READ_IN ); decrease_TRANSMITTED_BUFFERS <= GOT_ACK_IN; @@ -112,7 +111,6 @@ architecture trb_net_obuf_arch of trb_net_obuf is 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, next_TRANSMITTED_BUFFERS) begin current_output_buffer <= current_NOP_word; @@ -152,7 +150,7 @@ architecture trb_net_obuf_arch of trb_net_obuf is end if; --finally, block data read if the rec buffer is full if sent_data = '0' or - (next_DATA_COUNT = max_DATA_COUNT_minus_one) or + (next_DATA_COUNT(DATA_COUNT_WIDTH-1 downto 0) = max_DATA_COUNT_minus_one(DATA_COUNT_WIDTH-1 downto 0)) or next_TRANSMITTED_BUFFERS(1) = '1' then next_INT_READ_OUT <= '0'; @@ -202,7 +200,7 @@ architecture trb_net_obuf_arch of trb_net_obuf is current_EOB_word(TYPE_POSITION) <= TYPE_EOB; current_EOB_word(47 downto 0) <= (others => '0'); - gen_sent_EOB : process (CURRENT_DATA_COUNT, max_DATA_COUNT) + gen_sent_EOB : process (CURRENT_DATA_COUNT, max_DATA_COUNT_minus_one) begin if (CURRENT_DATA_COUNT = max_DATA_COUNT_minus_one) then sent_EOB <= '1'; @@ -218,11 +216,11 @@ architecture trb_net_obuf_arch of trb_net_obuf is sent_DATA <= not TRANSMITTED_BUFFERS(1); -- generate max_DATA_COUNT, comb. operation which should be registered - next_max_DATA_COUNT <= "0000000000000100" when REC_BUFFER_SIZE_IN="0001" else - "0000000000001000" when REC_BUFFER_SIZE_IN="0010" else - "0000000000010000" when REC_BUFFER_SIZE_IN="0011" else - "0000000000100000" when REC_BUFFER_SIZE_IN="0100" else - "0000000000000010"; +-- next_max_DATA_COUNT <= "0000000000000100" when REC_BUFFER_SIZE_IN="0001" else +-- "0000000000001000" when REC_BUFFER_SIZE_IN="0010" else +-- "0000000000010000" when REC_BUFFER_SIZE_IN="0011" else +-- "0000000000100000" when REC_BUFFER_SIZE_IN="0100" else +-- "0000000000000010"; next_max_DATA_COUNT_minus_one <= "0000000000000011" when REC_BUFFER_SIZE_IN="0001" else "0000000000000111" when REC_BUFFER_SIZE_IN="0010" else "0000000000001111" when REC_BUFFER_SIZE_IN="0011" else @@ -235,10 +233,10 @@ architecture trb_net_obuf_arch of trb_net_obuf is begin if rising_edge(CLK) then if RESET = '1' then - max_DATA_COUNT <= (1 => '1', others => '0'); +-- max_DATA_COUNT <= (1 => '1', others => '0'); max_DATA_COUNT_minus_one <= (0 => '1', others => '0'); else - max_DATA_COUNT <= next_max_DATA_COUNT; +-- max_DATA_COUNT <= next_max_DATA_COUNT; max_DATA_COUNT_minus_one <= next_max_DATA_COUNT_minus_one; end if; end if; diff --git a/trb_net_priority_arbiter.vhd b/trb_net_priority_arbiter.vhd index e867e77..79853eb 100755 --- a/trb_net_priority_arbiter.vhd +++ b/trb_net_priority_arbiter.vhd @@ -7,7 +7,8 @@ use work.trb_net_std.all; entity trb_net_priority_arbiter is - generic (WIDTH : integer := 16); +-- generic (WIDTH : integer := 16); + generic (WIDTH : integer := 2); port( -- Misc diff --git a/trb_net_sbuf.vhd b/trb_net_sbuf.vhd index 344d99d..ac38dff 100644 --- a/trb_net_sbuf.vhd +++ b/trb_net_sbuf.vhd @@ -1,7 +1,13 @@ ------------------------------------------------------------------------------- -- Single buffer with one more buffer to keep the speed of the datalink -- The sbuf can be connected to a combinatorial logic (as an output buffer) --- to provide the synchronous logic +-- to provide the synchronous logic +-- +-- 2 versions are provided +-- VERSION=0 is the fast version, so double buffering is done +-- VERSION=1 is half data rate: After data has beed written to the sbuf, +-- the input read signal is stalled until the buffer is empty. +-- Maybe enough for trigger and slow control channels ------------------------------------------------------------------------------- @@ -15,9 +21,10 @@ use work.trb_net_std.all; entity trb_net_sbuf is - generic (DATA_WIDTH : integer := 56); + generic (DATA_WIDTH : integer := 56; + VERSION: integer := 1); -- generic (DATA_WIDTH : integer := 1); - + port( -- Misc CLK : in std_logic; @@ -38,8 +45,7 @@ entity trb_net_sbuf is SYN_DATA_OUT: out STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0); -- Data word SYN_READ_IN: in STD_LOGIC; -- Status and control port - STAT_BUFFER: out STD_LOGIC_VECTOR (31 downto 0); - CTRL_BUFFER: in STD_LOGIC_VECTOR (31 downto 0) + STAT_BUFFER: out STD_LOGIC ); END trb_net_sbuf; @@ -57,40 +63,56 @@ architecture trb_net_sbuf_arch of trb_net_sbuf is signal current_got_overflow, next_got_overflow : std_logic; signal combined_COMB_DATAREADY_IN: std_logic; + signal use_current_b1_buffer: std_logic; + begin COMB_next_READ_OUT <= current_next_READ_OUT; SYN_DATA_OUT <= current_b2_buffer; SYN_DATAREADY_OUT <= current_SYN_DATAREADY_OUT; - STAT_BUFFER(0) <= current_got_overflow; - STAT_BUFFER(31 downto 1) <= (others => '0'); + STAT_BUFFER <= current_got_overflow; combined_COMB_DATAREADY_IN <= (COMB_DATAREADY_IN and COMB_READ_IN); + + GEN1: if VERSION = 0 generate + MUX: process (use_current_b1_buffer) + begin -- simple MUX + if use_current_b1_buffer = '1' then + next_b2_buffer <= current_b1_buffer; + else + next_b2_buffer <= COMB_DATA_IN; + end if; + end process; + end generate; + GEN2: if VERSION = 1 generate + next_b2_buffer <= COMB_DATA_IN; + end generate; + COMB: process (current_buffer_state, COMB_DATAREADY_IN, COMB_READ_IN, SYN_READ_IN, COMB_DATA_IN, current_b1_buffer, current_b2_buffer, current_SYN_DATAREADY_OUT, current_got_overflow) begin -- process COMB next_buffer_state <= current_buffer_state; next_next_READ_OUT <= '1'; --- next_b2_buffer <= current_b2_buffer; --- next_b1_buffer <= current_b1_buffer; - next_b1_buffer <= COMB_DATA_IN; - next_b2_buffer <= COMB_DATA_IN; - move_b1_buffer <= '0'; + if VERSION = 0 then + next_b1_buffer <= COMB_DATA_IN; + move_b1_buffer <= '0'; + end if; + use_current_b1_buffer <= '0'; --by default COMB_DATA_IN; move_b2_buffer <= '0'; next_SYN_DATAREADY_OUT <= current_SYN_DATAREADY_OUT; next_got_overflow <= current_got_overflow; if current_buffer_state = BUFFER_EMPTY then - if combined_COMB_DATAREADY_IN = '1' then -- COMB logic is writing into the sbuf next_buffer_state <= BUFFER_B2_FULL; - next_next_READ_OUT <= '0'; --- next_b2_buffer <= COMB_DATA_IN; + if VERSION = 1 then + next_next_READ_OUT <= '0'; + end if; move_b2_buffer <= '1'; next_SYN_DATAREADY_OUT <= '1'; end if; @@ -100,8 +122,9 @@ begin -- process COMB -- COMB logic is writing into the sbuf -- at the same time syn port is reading next_buffer_state <= BUFFER_B2_FULL; - next_next_READ_OUT <= '0'; --- next_b2_buffer <= COMB_DATA_IN; + if VERSION = 1 then + next_next_READ_OUT <= '0'; + end if; move_b2_buffer <= '1'; next_SYN_DATAREADY_OUT <= '1'; elsif combined_COMB_DATAREADY_IN = '1' then @@ -110,7 +133,6 @@ begin -- process COMB -- buffer next_buffer_state <= BUFFER_B1_FULL; next_next_READ_OUT <= '0'; --PLEASE stop writing --- next_b1_buffer <= COMB_DATA_IN; move_b1_buffer <= '1'; next_SYN_DATAREADY_OUT <= '1'; elsif SYN_READ_IN = '1' then @@ -128,8 +150,7 @@ begin -- process COMB -- at the same time syn port is reading next_buffer_state <= BUFFER_B1_FULL; next_next_READ_OUT <= '0'; --- next_b1_buffer <= COMB_DATA_IN; - next_b2_buffer <= current_b1_buffer; + use_current_b1_buffer <= '1'; move_b1_buffer <= '1'; move_b2_buffer <= '1'; next_SYN_DATAREADY_OUT <= '1'; @@ -143,7 +164,6 @@ begin -- process COMB elsif SYN_READ_IN = '1' then next_buffer_state <= BUFFER_B2_FULL; next_next_READ_OUT <= '0'; --- next_b2_buffer <= current_b1_buffer; next_SYN_DATAREADY_OUT <= '1'; else next_buffer_state <= BUFFER_B1_FULL; @@ -175,7 +195,8 @@ end process COMB; end if; end if; end process; - + + GEN6: if VERSION = 0 generate REG2 : process(CLK) begin if rising_edge(CLK) then @@ -187,7 +208,10 @@ end process COMB; current_b1_buffer <= current_b1_buffer; end if; end if; -end process; + end process; + end generate; + + REG3 : process(CLK) begin if rising_edge(CLK) then diff --git a/trb_net_term_ibuf.vhd b/trb_net_term_ibuf.vhd index 5063441..7ebc53e 100644 --- a/trb_net_term_ibuf.vhd +++ b/trb_net_term_ibuf.vhd @@ -39,7 +39,7 @@ entity trb_net_term_ibuf is ); END trb_net_term_ibuf; -architecture trb_net_term_ibuf_arch of trb_term_net_ibuf is +architecture trb_net_term_ibuf_arch of trb_net_term_ibuf is component trb_net_sbuf is @@ -60,8 +60,7 @@ architecture trb_net_term_ibuf_arch of trb_term_net_ibuf is SYN_DATA_OUT: out STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0); -- Data word SYN_READ_IN: in STD_LOGIC; -- Status and control port - STAT_BUFFER: out STD_LOGIC_VECTOR (31 downto 0); - CTRL_BUFFER: in STD_LOGIC_VECTOR (31 downto 0) + STAT_BUFFER: out STD_LOGIC ); END component; @@ -157,8 +156,7 @@ reg_buffer: process(CLK) COMB_DATA_IN => tmp_INT_DATA_OUT, SYN_DATAREADY_OUT => INT_DATAREADY_OUT, SYN_DATA_OUT => INT_DATA_OUT, - SYN_READ_IN => INT_READ_IN, - CTRL_BUFFER => (others => '0') + SYN_READ_IN => INT_READ_IN ); sbuf_free <= comb_next_read or INT_READ_IN; --sbuf killed @@ -173,7 +171,6 @@ reg_locked: process(CLK) if RESET = '1' then is_locked <= '0'; reg_eob_out <= '0'; - current_last_header <= (others => '0'); elsif CLK_EN = '1' then if release_locked = '1' then is_locked <= '0'; @@ -181,11 +178,9 @@ reg_locked: process(CLK) is_locked <= got_locked; end if; reg_eob_out <= got_eob_out; - current_last_header <= next_last_header; else is_locked <= is_locked; reg_eob_out <= reg_eob_out; - current_last_header <= current_last_header; end if; end if; end process; -- 2.43.0