]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
added new lvl1 trigger receiver
authorhadeshyp <hadeshyp>
Fri, 12 Sep 2008 12:48:50 +0000 (12:48 +0000)
committerhadeshyp <hadeshyp>
Fri, 12 Sep 2008 12:48:50 +0000 (12:48 +0000)
trb_net16_med_16_SDR_OS.vhd
trb_net16_med_tlk.vhd
trb_net16_trigger.vhd [new file with mode: 0644]

index 6f5f1507f63fb8dfc401ba5e6857fbbce2f3fb5f..a3e2273714569ea92c2664f47e811087e032ee0e 100644 (file)
@@ -279,7 +279,7 @@ process(CLK)
   rx_reset        <= buf_RX_CTRL(2);
   rx_parity       <= buf_RX_CTRL(3);
 
-  rx_parity_match      <= not xor_all(rx_parity & buf_RX_DATA);
+  rx_parity_match      <= '1' when rx_parity = xor_all(buf_RX_DATA) else '0';
   next_rx_fifo_write_enable <= (buf_RX_CLK xor last_RX_CLK) and rx_datavalid;
   next_rx_fifo_data_in      <= rx_first_packet & rx_parity_match & buf_RX_DATA;
 
index 97de445216d9090d79e484bf0c2f162eee311757..13c474dc91d48e2db2f6b3d55a852560700c36b4 100644 (file)
@@ -36,6 +36,7 @@ entity trb_net16_med_tlk is
     MED_PACKET_NUM_OUT  : out std_logic_vector (1 downto 0);
     MED_ERROR_OUT       : out std_logic_vector (2 downto 0);
     STAT                : out std_logic_vector (63 downto 0);
+    STAT_MONITOR        : out std_logic_vector ( 100 downto 0);
     STAT_OP             : out std_logic_vector (15 downto 0);
     CTRL_OP             : in  std_logic_vector (15 downto 0)
                         --connect STAT(0) to LED
@@ -204,6 +205,8 @@ begin
   STAT(63 downto 62) <= resync_counter;
   --STAT(63 downto 57) <= (others => '0');
   
+  STAT_MONITOR(17 downto 0) <= fifo_din_a;
+
 
   process(TLK_RX_CLK)
     begin
diff --git a/trb_net16_trigger.vhd b/trb_net16_trigger.vhd
new file mode 100644 (file)
index 0000000..54bbad1
--- /dev/null
@@ -0,0 +1,235 @@
+
+-- can only be used in combination with term_ibuf -> no check for packet type!
+
+LIBRARY IEEE;
+USE IEEE.std_logic_1164.ALL;
+USE IEEE.std_logic_ARITH.ALL;
+USE IEEE.std_logic_UNSIGNED.ALL;
+
+library work;
+use work.trb_net_std.all;
+
+
+entity trb_net16_trigger is
+  generic (
+    USE_TRG_PORT : integer range 0 to 1 := c_YES;
+               --even when NO, ERROR_PACKET_IN is used for automatic replys
+    SECURE_MODE  : integer range 0 to 1 := std_TERM_SECURE_MODE
+               --if secure_mode is not used, apl must provide error pattern and dtype until
+               --next trigger comes in. In secure mode these need to be available while relase_trg is high only
+    );
+  port(
+    --  Misc
+    CLK    : in std_logic;
+    RESET  : in std_logic;
+    CLK_EN : in std_logic;
+
+    INT_DATAREADY_OUT:     out std_logic;
+    INT_DATA_OUT:          out std_logic_vector (c_DATA_WIDTH-1 downto 0);
+    INT_PACKET_NUM_OUT:    out std_logic_vector (c_NUM_WIDTH-1  downto 0);
+    INT_READ_IN:           in  std_logic;
+
+    INT_DATAREADY_IN:      in  std_logic;
+    INT_DATA_IN:           in  std_logic_vector (c_DATA_WIDTH-1 downto 0);
+    INT_PACKET_NUM_IN:     in  std_logic_vector (c_NUM_WIDTH-1  downto 0);
+    INT_READ_OUT:          out std_logic;
+    -- Trigger information output
+    TRG_TYPE_OUT          : out std_logic_vector (3 downto 0);
+    TRG_NUMBER_OUT        : out std_logic_vector (15 downto 0);
+    TRG_CODE_OUT          : out std_logic_vector (7 downto 0);
+    TRG_INFORMATION_OUT   : out std_logic_vector (15 downto 0);
+    TRG_RECEIVED_OUT      : out std_logic;
+    TRG_RELEASE_IN        : in  std_logic;
+    TRG_ERROR_PATTERN_IN  : in  std_logic_vector (31 downto 0)
+    );
+end entity;
+
+architecture trb_net16_trigger_arch of trb_net16_trigger is
+
+  signal next_TRG_TYPE_OUT, reg_TRG_TYPE_OUT: std_logic_vector(3 downto 0);
+  signal next_TRG_NUMBER_OUT, reg_TRG_NUMBER_OUT: std_logic_vector(15 downto 0);
+  signal next_TRG_CODE_OUT, reg_TRG_CODE_OUT: std_logic_vector(7 downto 0);
+  signal next_TRG_INFORMATION_OUT, reg_TRG_INFORMATION_OUT: std_logic_vector(15 downto 0);
+  signal next_TRG_RECEIVED_OUT, reg_TRG_RECEIVED_OUT: std_logic;
+  signal buf_TRG_ERROR_PATTERN_IN: std_logic_vector(31 downto 0);
+
+
+  signal saved_packet_type           : std_logic_vector(2 downto 0);
+
+  signal transfer_counter                                 : std_logic_vector(1 downto 0);
+  signal send_trm, next_send_trm                          : std_logic;
+  signal buf_INT_DATAREADY_OUT, next_INT_DATAREADY_OUT    : std_logic;
+  signal buf_INT_DATA_OUT, next_INT_DATA_OUT              : std_logic_vector(15 downto 0);
+
+begin
+
+  g1: if USE_TRG_PORT = 1 generate
+    TRG_TYPE_OUT <= reg_TRG_TYPE_OUT;
+    TRG_CODE_OUT <= reg_TRG_CODE_OUT;
+    TRG_NUMBER_OUT <= reg_TRG_NUMBER_OUT;
+    TRG_CODE_OUT <= reg_TRG_CODE_OUT;
+    TRG_INFORMATION_OUT <= reg_TRG_INFORMATION_OUT;
+    TRG_RECEIVED_OUT <= reg_TRG_RECEIVED_OUT;
+    INT_READ_OUT <= '1'; --not send_trm and not reg_APL_GOT_TRM;
+    end generate;
+  g1n: if USE_TRG_PORT = 0 generate
+    TRG_TYPE_OUT <= (others => '0');
+    TRG_CODE_OUT <= (others => '0');
+    TRG_NUMBER_OUT <= (others => '0');
+    TRG_CODE_OUT <= (others => '0');
+    TRG_INFORMATION_OUT <= (others => '0');
+    TRG_RECEIVED_OUT <= '0';
+    INT_READ_OUT <= '1'; --not send_trm;
+    end generate;  
+
+
+    process(RESET, transfer_counter, INT_READ_IN, saved_packet_type, buf_TRG_ERROR_PATTERN_IN,
+            reg_TRG_TYPE_OUT, reg_TRG_CODE_OUT, reg_TRG_NUMBER_OUT, reg_TRG_CODE_OUT,
+            reg_TRG_INFORMATION_OUT, reg_TRG_RECEIVED_OUT, INT_PACKET_NUM_IN, INT_DATA_IN,
+            buf_INT_DATA_OUT, TRG_RELEASE_IN, send_trm, buf_INT_DATAREADY_OUT)
+      begin
+        if USE_TRG_PORT = 1 then
+          next_TRG_TYPE_OUT <= reg_TRG_TYPE_OUT;
+          next_TRG_CODE_OUT <= reg_TRG_CODE_OUT;
+          next_TRG_NUMBER_OUT <= reg_TRG_NUMBER_OUT;
+          next_TRG_CODE_OUT <= reg_TRG_CODE_OUT;
+          next_TRG_INFORMATION_OUT <= reg_TRG_INFORMATION_OUT;
+          next_TRG_RECEIVED_OUT <= reg_TRG_RECEIVED_OUT;
+          if saved_packet_type = TYPE_TRM then
+            if INT_PACKET_NUM_IN = "01" then
+              next_TRG_INFORMATION_OUT         <= INT_DATA_IN(15 downto 0);
+            elsif INT_PACKET_NUM_IN = "10" then
+              next_TRG_NUMBER_OUT(15 downto 8) <= INT_DATA_IN(7 downto 0);
+              next_TRG_CODE_OUT                <= INT_DATA_IN(15 downto 8);
+            elsif INT_PACKET_NUM_IN = "11" then
+              next_TRG_TYPE_OUT                <= INT_DATA_IN(3 downto 0);
+              next_TRG_NUMBER_OUT(7 downto 0)  <= INT_DATA_IN(11 downto 4);
+              next_TRG_RECEIVED_OUT            <= '1';
+            end if;
+          end if;
+          end if;
+        next_send_trm              <= '0';
+        next_INT_DATAREADY_OUT     <= '0';
+        next_INT_DATA_OUT          <= buf_INT_DATA_OUT;
+
+        if (reg_TRG_RECEIVED_OUT = '1' and (TRG_RELEASE_IN = '1'  or USE_TRG_PORT = 0)) or send_trm = '1' then
+--        if (reg_APL_GOT_TRM = '1' and (APL_RELEASE_TRM = '1' )) or send_trm = '1'  or 0 = 0 then
+                           --next_transfer_counter is used for transmission!
+          if transfer_counter = "10" and INT_READ_IN = '1' then
+            next_send_trm <= '0';
+          else
+            next_send_trm <= '1';
+          end if;
+          next_INT_DATAREADY_OUT <= '1';
+        end if;
+        if buf_INT_DATAREADY_OUT = '1' and INT_READ_IN = '1' then
+          if transfer_counter = "11" then
+            next_INT_DATA_OUT <= (others => '0');
+            next_INT_DATA_OUT(2 downto 0) <= TYPE_TRM;
+          elsif transfer_counter = "00" then
+            next_INT_DATA_OUT <= buf_TRG_ERROR_PATTERN_IN(31 downto 16);
+          elsif transfer_counter = "01" then
+            next_INT_DATA_OUT <= buf_TRG_ERROR_PATTERN_IN(15 downto 0);
+          else
+            next_INT_DATA_OUT <= (others => '0');
+            next_INT_DATA_OUT(11 downto 4) <= reg_TRG_NUMBER_OUT(7 downto 0);
+          end if;
+        end if;
+        if (TRG_RELEASE_IN = '1' and reg_TRG_RECEIVED_OUT = '1') or USE_TRG_PORT = c_NO then
+          next_TRG_RECEIVED_OUT <= '0';
+        end if;
+      end process;
+
+  --save data from api while sending trailer in secure mode
+  SECURE_GEN: if SECURE_MODE = 1 generate
+    CLK_REG2: process(CLK)
+      begin
+        if rising_edge(CLK) then
+          if RESET = '1' then
+            buf_TRG_ERROR_PATTERN_IN <= (others => '0');
+          elsif CLK_EN = '1' and TRG_RELEASE_IN = '1' then
+            buf_TRG_ERROR_PATTERN_IN <= TRG_ERROR_PATTERN_IN;
+          end if;
+        end if;
+      end process;
+  end generate;
+
+  SECURE_GEN2: if SECURE_MODE = 0 generate
+    buf_TRG_ERROR_PATTERN_IN <= TRG_ERROR_PATTERN_IN;
+  end generate;
+
+  --count packets
+    REG_TRANSFER_COUNTER : process(CLK)
+      begin
+        if rising_edge(CLK) then
+          if RESET = '1' then
+            transfer_counter <= (others => '0');
+          elsif CLK_EN = '1' and buf_INT_DATAREADY_OUT = '1' and INT_READ_IN = '1' then
+            transfer_counter <= transfer_counter + 1;
+          end if;
+        end if;
+      end process;
+
+    INT_DATAREADY_OUT <= buf_INT_DATAREADY_OUT;
+    INT_DATA_OUT      <= buf_INT_DATA_OUT;
+    INT_PACKET_NUM_OUT <= transfer_counter;
+    INT_OUT_REG: process(CLK)
+      begin
+        if rising_edge(CLK) then
+          if RESET = '1' then
+            buf_INT_DATA_OUT <= "0000000000000" & TYPE_TRM;
+            buf_INT_DATAREADY_OUT <= '0';
+          elsif CLK_EN = '1' then
+            buf_INT_DATA_OUT <= next_INT_DATA_OUT;
+            buf_INT_DATAREADY_OUT <= next_INT_DATAREADY_OUT;
+          end if;
+        end if;
+      end process;
+
+  --this holds the current packet type
+  process(CLK)
+    begin
+      if rising_edge(CLK) then
+        if RESET = '1' or (INT_PACKET_NUM_IN = "11" and INT_DATAREADY_IN = '1') then --or 
+          saved_packet_type <= "111";
+        elsif CLK_EN = '1' and INT_PACKET_NUM_IN = "00" then
+          saved_packet_type <= INT_DATA_IN(2 downto 0);
+        end if;
+      end if;
+    end process;
+
+  REG_send_trm: process(CLK)
+    begin
+    if rising_edge(CLK) then
+      if RESET = '1' then
+        send_trm <= '0';
+        reg_TRG_RECEIVED_OUT <= '0';
+        reg_TRG_NUMBER_OUT <= (others => '0');
+      elsif CLK_EN = '1' then
+        send_trm <= next_send_trm;
+        reg_TRG_RECEIVED_OUT <= next_TRG_RECEIVED_OUT;
+        reg_TRG_NUMBER_OUT <= next_TRG_NUMBER_OUT;
+      end if;
+    end if;
+  end process;
+    
+  g2: if USE_TRG_PORT = 1 generate
+    CLK_REG: process(CLK)
+      begin
+        if rising_edge(CLK) then
+          if RESET = '1' then
+            reg_TRG_TYPE_OUT <= (others => '0');
+            reg_TRG_CODE_OUT <= (others => '0');
+            reg_TRG_INFORMATION_OUT <= (others => '0');
+          elsif CLK_EN = '1' then
+            reg_TRG_TYPE_OUT <= next_TRG_TYPE_OUT;
+            reg_TRG_CODE_OUT <= next_TRG_CODE_OUT;
+            reg_TRG_INFORMATION_OUT <= next_TRG_INFORMATION_OUT;
+          end if;
+        end if;
+      end process;
+  end generate;
+
+end architecture;