]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
obuf working with EOB, ACK, Ingo
authorhadaq <hadaq>
Thu, 31 Aug 2006 12:54:09 +0000 (12:54 +0000)
committerhadaq <hadaq>
Thu, 31 Aug 2006 12:54:09 +0000 (12:54 +0000)
testbench/in_obuf.txt [new file with mode: 0644]
testbench/in_obuf_ctrl.txt [new file with mode: 0644]
testbench/out_obuf.txt [new file with mode: 0644]
testbench/trb_net_obuf_testbench.vhd
trb_net_obuf.vhd

diff --git a/testbench/in_obuf.txt b/testbench/in_obuf.txt
new file mode 100644 (file)
index 0000000..531f5ae
--- /dev/null
@@ -0,0 +1,13 @@
+0:000:0000:0000
+0:000:0000:0000
+0:000:0000:0000
+0:000:0000:0000
+1:001:0000:0001 --hdr
+1:000:0000:0010 --dat
+1:000:0000:0011 --dat
+1:000:0000:0100 --dat
+1:000:0000:0001 --dat  
+1:000:0000:0010 --dat
+1:000:0000:0011 --dat
+1:010:0000:0000 --trm
+0:000:0000:0000
\ No newline at end of file
diff --git a/testbench/in_obuf_ctrl.txt b/testbench/in_obuf_ctrl.txt
new file mode 100644 (file)
index 0000000..3ba408a
--- /dev/null
@@ -0,0 +1,13 @@
+000000
+000000
+000001
+000001
+000001 
+000001 
+000001 
+000001 
+000001   
+000001 
+010001 --sent ack
+100001 --got ack
+000001
\ No newline at end of file
diff --git a/testbench/out_obuf.txt b/testbench/out_obuf.txt
new file mode 100644 (file)
index 0000000..8c7d43b
--- /dev/null
@@ -0,0 +1,17 @@
+1
+1
+1
+1
+1
+1 -- 0 -- add waitstates
+1
+1
+1
+1
+1
+1
+0
+0
+0
+0
+0
\ No newline at end of file
index 791d4b44ff1d9896501ce477992d3dcd5eb00f5c..b16b1908bb4a356fe3000b45ccb9e4a0d231851d 100644 (file)
@@ -106,6 +106,22 @@ begin
     wait;
   end process DO_RESET;
 
+ STIMULI1: process (CLK)
+    file protokoll : text open read_mode is "in_obuf_ctrl.txt";
+    variable myoutline : line;
+    variable leer : character;
+    variable varx4 : std_logic_vector(5 downto 0);
+
+    begin
+      if falling_edge(CLK) then
+        if (not endfile(protokoll)) then
+          readline(protokoll,myoutline);
+          read(myoutline,varx4);
+          read_ctrl <= varx4;
+        end if;
+      end if;
+    end process;
+    
   STIMULI: process
     file protokoll : text open read_mode is "in_obuf.txt";
     variable myoutline : line;
@@ -113,7 +129,6 @@ begin
     variable var1, var2 : std_logic;
     variable varx1 : std_logic_vector(2 downto 0);
     variable varx2, varx3 : std_logic_vector(3 downto 0);
-    variable varx4 : std_logic_vector(5 downto 0);
     begin
       wait on CLK;
 
@@ -122,9 +137,9 @@ begin
       if (not endfile(protokoll)) then
         readline(protokoll,myoutline);
 
-        read(myoutline,varx4);
-        read_ctrl <= varx4;
-        read(myoutline,leer);
+--         read(myoutline,varx4);
+--         read_ctrl <= varx4;
+--         read(myoutline,leer);
         
         read(myoutline,var1);
         int_dataready_in <= var1;
index bf1d38d03ef5a65c964ad8c870fe77e310a25008..6266af9b0c7a134279e2f4d36347ba731d1d2445 100644 (file)
@@ -39,7 +39,7 @@ END trb_net_obuf;
 architecture trb_net_obuf_arch of trb_net_obuf is
 
   signal current_output_buffer, next_output_buffer : STD_LOGIC_VECTOR (53 downto 0);
-  signal current_ACK_word, current_EOB_word, current_DATA_word :
+  signal current_ACK_word, current_EOB_word, current_DATA_word, current_NOP_word :
     STD_LOGIC_VECTOR (53 downto 0);
   signal current_DATAREADY_OUT, next_DATAREADY_OUT : STD_LOGIC;
 
@@ -65,33 +65,50 @@ architecture trb_net_obuf_arch of trb_net_obuf is
     MED_DATA_OUT <= current_output_buffer(50 downto 0);
     MED_ERROR_OUT <= current_output_buffer(53 downto 51);
 
-    decrease_TRANSMITTED_BUFFERS <= '0';
+    decrease_TRANSMITTED_BUFFERS <= GOT_ACK_IN;
     
     COMB_NEXT_TRANSFER : process(current_output_buffer, current_DATAREADY_OUT, sent_DATA,
-                                 MED_READ_IN, current_DATA_word, sent_EOB)
+                                 MED_READ_IN, current_DATA_word, sent_EOB, sent_ACK,
+                                 current_EOB_word, current_ACK_word, reg_SEND_ACK_IN )
     begin  -- process
       next_DATAREADY_OUT <= current_DATAREADY_OUT;
       next_output_buffer <= current_output_buffer;
       INT_READ_OUT       <= '0';
       increase_TRANSMITTED_BUFFERS <= '0';
       next_DATA_COUNT    <= CURRENT_DATA_COUNT;
+      next_SEND_ACK_IN   <= reg_SEND_ACK_IN;
 -- EOB should go into the stream
-      if (current_DATAREADY_OUT = '0' and sent_EOB  = '1')
-        or (current_DATAREADY_OUT = '1' and  sent_EOB = '1' and MED_READ_IN = '1' ) then
+      if (current_DATAREADY_OUT = '0' and sent_ACK  = '1')
+        or (current_DATAREADY_OUT = '1' and  sent_ACK = '1' and MED_READ_IN = '1' ) then
         next_DATAREADY_OUT <= '1';
-        next_output_buffer <= current_EOB_word;
-        next_DATA_COUNT    <= (others => '0');
+        next_output_buffer <= current_ACK_word;
+        next_SEND_ACK_IN   <= '0';
+      else
+        next_SEND_ACK_IN   <= sent_ACK;
+        if (current_DATAREADY_OUT = '0' and sent_EOB  = '1')
+          or (current_DATAREADY_OUT = '1' and  sent_EOB = '1' and MED_READ_IN = '1' ) then
+          next_DATAREADY_OUT <= '1';
+          next_output_buffer <= current_EOB_word;
+          next_DATA_COUNT    <= (others => '0');
+          increase_TRANSMITTED_BUFFERS <= '1';
 -- we have something to offer
-      elsif (current_DATAREADY_OUT = '0' and sent_DATA  = '1')
-        or (current_DATAREADY_OUT = '1' and  sent_DATA = '1' and MED_READ_IN = '1' ) then
-        next_DATAREADY_OUT <= '1';
-        next_output_buffer <= current_DATA_word;
-        INT_READ_OUT       <= '1';
-        next_DATA_COUNT    <= CURRENT_DATA_COUNT +1;
+        elsif (current_DATAREADY_OUT = '0' and sent_DATA  = '1')
+          or (current_DATAREADY_OUT = '1' and  sent_DATA = '1' and MED_READ_IN = '1' ) then
+          next_DATAREADY_OUT <= '1';
+          next_output_buffer <= current_DATA_word;
+          INT_READ_OUT       <= '1';
+          if INT_DATA_IN(TYPE_POSITION) = TYPE_TRM then  --TRM means EOB
+            next_DATA_COUNT    <= (others => '0');
+            increase_TRANSMITTED_BUFFERS <= '1';
+          else
+            next_DATA_COUNT    <= CURRENT_DATA_COUNT +1;
+          end if;
 -- we will be empty in the next step
-      elsif (current_DATAREADY_OUT = '0' and sent_DATA = '0')
-        or (current_DATAREADY_OUT = '1' and sent_DATA  = '0' and MED_READ_IN = '1' ) then
-        next_DATAREADY_OUT <= '0';
+        elsif (current_DATAREADY_OUT = '0' and sent_DATA = '0')
+          or (current_DATAREADY_OUT = '1' and sent_DATA  = '0' and MED_READ_IN = '1' ) then
+          next_DATAREADY_OUT <= '0';
+          next_output_buffer <= current_NOP_word;
+        end if;
       end if;
     end process;
 
@@ -146,6 +163,10 @@ architecture trb_net_obuf_arch of trb_net_obuf is
         sent_EOB <= '0';
       end if;
     end process;
+
+  current_NOP_word(TYPE_POSITION) <= TYPE_ILLEGAL;
+  current_NOP_word(47 downto 0)   <= (others => '0');
+  current_NOP_word(53 downto 51)  <= (others => '0');
     
   current_DATA_word(50 downto 0)  <= INT_DATA_IN;
   current_DATA_word(53 downto 51) <= INT_ERROR_IN;