]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
optimizing, untested, Ingo
authorhadaq <hadaq>
Thu, 22 Mar 2007 17:24:42 +0000 (17:24 +0000)
committerhadaq <hadaq>
Thu, 22 Mar 2007 17:24:42 +0000 (17:24 +0000)
trb_net_active_api.vhd
trb_net_ibuf.vhd
trb_net_io_multiplexer.vhd
trb_net_iobuf.vhd
trb_net_obuf.vhd
trb_net_priority_arbiter.vhd
trb_net_sbuf.vhd
trb_net_term_ibuf.vhd

index 693c30feb39937db10e17609c7b49fdaa74d48de..33617eecb90e5f34702e5fcdcd9c48b65a2f08b1 100644 (file)
@@ -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
index 2f6bca7da5892a59554dc1fd799ebc996f540a0a..c81ff40011f6fed08f5d875ca61cdde933a5f9ff 100644 (file)
@@ -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
index 10ee1e731a683a9bc5ca81667d7461f1cdf82ec4..6187223265f40b6d2478ba16a87c4fca272a88da 100644 (file)
@@ -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)
index 0288183f5586e2e186686fa9f475fc88666d8bc2..13c3692bfbedb73c45e1cd3c2c287bd2507657a7 100644 (file)
@@ -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
index ae8e2f4c8b6158981986974a1c7c5e66e6fd2432..25bd49b6bdb16365bc18a5a66bdd94842cd8af18 100644 (file)
@@ -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;
index e867e770e9513c259dc39a241379b4d1ff95272a..79853eb7fd179fe75f749a4cfb12e5c0891bb5d5 100755 (executable)
@@ -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
index 344d99d51cf2e0f5fa5096deab8d68bcbebe7866..ac38dffdb7cc08f014994756509498018212b7d2 100644 (file)
@@ -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
index 5063441ba071c0abeb902296f0f64a8d67688d01..7ebc53e8fcbf714a5515941e81b56e4184368a8e 100644 (file)
@@ -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;