]> jspc29.x-matter.uni-frankfurt.de Git - trbnet.git/commitdiff
30-04-10
authorhadeshyp <hadeshyp>
Fri, 30 Apr 2010 12:02:08 +0000 (12:02 +0000)
committerhadeshyp <hadeshyp>
Fri, 30 Apr 2010 12:02:08 +0000 (12:02 +0000)
gbe_ecp2m/trb_net16_gbe_setup.vhd [new file with mode: 0644]

diff --git a/gbe_ecp2m/trb_net16_gbe_setup.vhd b/gbe_ecp2m/trb_net16_gbe_setup.vhd
new file mode 100644 (file)
index 0000000..85d5e96
--- /dev/null
@@ -0,0 +1,251 @@
+LIBRARY ieee;
+use ieee.std_logic_1164.all;
+USE IEEE.numeric_std.ALL;
+USE IEEE.std_logic_UNSIGNED.ALL;
+
+library work;
+use work.trb_net_std.all;
+use work.trb_net_components.all;
+use work.trb_net16_hub_func.all;
+use work.version.all;
+
+
+entity gbe_setup is
+port(
+       CLK                       : in std_logic;
+       RESET                     : in std_logic;
+
+       -- interface to regio bus
+       BUS_ADDR_IN               : in std_logic_vector(7 downto 0);
+       BUS_DATA_IN               : in std_logic_vector(31 downto 0);
+       BUS_DATA_OUT              : out std_logic_vector(31 downto 0);  -- gk 26.04.10
+       BUS_WRITE_EN_IN           : in std_logic;  -- gk 26.04.10
+       BUS_READ_EN_IN            : in std_logic;  -- gk 26.04.10
+       BUS_ACK_OUT               : out std_logic;  -- gk 26.04.10
+
+       -- gk 26.04.10
+       -- input from gbe_buf (only to return the whole trigger number via regio)
+       GBE_TRIG_NR_IN            : in std_logic_vector(31 downto 0);
+
+       -- output to gbe_buf
+       GBE_SUBEVENT_ID_OUT       : out std_logic_vector(31 downto 0);
+       GBE_SUBEVENT_DEC_OUT      : out std_logic_vector(31 downto 0);
+       GBE_QUEUE_DEC_OUT         : out std_logic_vector(31 downto 0);
+       GBE_MAX_PACKET_OUT        : out std_logic_vector(31 downto 0);
+       GBE_MAX_FRAME_OUT         : out std_logic_vector(15 downto 0);
+       GBE_USE_GBE_OUT           : out std_logic;
+       GBE_USE_TRBNET_OUT        : out std_logic;
+       GBE_USE_MULTIEVENTS_OUT   : out std_logic;
+       GBE_READOUT_CTR_OUT       : out std_logic_vector(23 downto 0);  -- gk 26.04.10
+       GBE_READOUT_CTR_VALID_OUT : out std_logic;  -- gk 26.04.10
+       GBE_DELAY_OUT             : out std_logic_vector(31 downto 0) -- gk 28.04.10
+);
+end entity;
+
+architecture gbe_setup of gbe_setup is
+
+signal reset_values      : std_logic;
+
+signal subevent_id       : std_logic_vector(31 downto 0);
+signal subevent_dec      : std_logic_vector(31 downto 0);
+signal queue_dec         : std_logic_vector(31 downto 0);
+signal max_packet        : std_logic_vector(31 downto 0);
+signal max_frame         : std_logic_vector(15 downto 0);
+signal use_gbe           : std_logic;
+signal use_trbnet        : std_logic;
+signal use_multievents   : std_logic;
+signal readout_ctr       : std_logic_vector(23 downto 0);  -- gk 26.04.10
+signal readout_ctr_valid : std_logic;  -- gk 26.04.10
+signal ack               : std_logic;  -- gk 26.04.10
+signal ack_q             : std_logic;  -- gk 26.04.10
+signal data_out          : std_logic_vector(31 downto 0);  -- gk 26.04.10
+signal delay             : std_logic_vector(31 downto 0);  -- gk 28.04.10
+
+begin
+
+OUT_PROC : process(CLK)
+begin
+       if rising_edge(CLK) then
+               GBE_SUBEVENT_ID_OUT       <= subevent_id;
+               GBE_SUBEVENT_DEC_OUT      <= subevent_dec;
+               GBE_QUEUE_DEC_OUT         <= queue_dec;
+               GBE_MAX_PACKET_OUT        <= max_packet;
+               GBE_MAX_FRAME_OUT         <= max_frame;
+               GBE_USE_GBE_OUT           <= use_gbe;
+               GBE_USE_TRBNET_OUT        <= use_trbnet;
+               GBE_USE_MULTIEVENTS_OUT   <= use_multievents;
+               GBE_READOUT_CTR_OUT       <= readout_ctr;  -- gk 26.04.10
+               GBE_READOUT_CTR_VALID_OUT <= readout_ctr_valid;  -- gk 26.04.10
+               BUS_ACK_OUT               <= ack_q;  -- gk 26.04.10
+               ack_q                     <= ack; -- gk 26.04.10
+               BUS_DATA_OUT              <= data_out;  -- gk 26.04.10
+               GBE_DELAY_OUT             <= delay; -- gk 28.04.10
+       end if;
+end process OUT_PROC;
+
+-- gk 26.04.10
+ACK_PROC : process(CLK)
+begin
+       if rising_edge(CLK) then
+               if (RESET = '1') then
+                       ack <= '0';
+               elsif ((BUS_WRITE_EN_IN = '1') or (BUS_READ_EN_IN = '1')) then
+                       ack <= '1';
+               else
+                       ack <= '0';
+               end if;
+       end if;
+end process ACK_PROC;
+
+WRITE_PROC : process(CLK)
+begin
+       if rising_edge(CLK) then
+               if ( (RESET = '1') or (reset_values = '1') ) then
+                       subevent_id       <= x"0000_00cf";
+                       subevent_dec      <= x"0002_0001";
+                       queue_dec         <= x"0003_0062";
+                       max_packet        <= x"0000_fde8";
+                       max_frame         <= x"0578";
+                       use_gbe           <= '1';
+                       use_trbnet        <= '0';
+                       use_multievents   <= '0';
+                       reset_values      <= '0';
+                       readout_ctr       <= x"00_0000";  -- gk 26.04.10
+                       readout_ctr_valid <= '0';  -- gk 26.04.10
+                       delay             <= x"0000_0000"; -- gk 28.04.10
+               elsif (BUS_WRITE_EN_IN = '1') then
+                       case BUS_ADDR_IN is
+
+                               when x"00" =>
+                                       subevent_id <= BUS_DATA_IN;
+
+                               when x"01" =>
+                                       subevent_dec <= BUS_DATA_IN;
+
+                               when x"02" =>
+                                       queue_dec <= BUS_DATA_IN;
+
+                               when x"03" =>
+                                       max_packet <= BUS_DATA_IN;
+
+                               when x"04" =>
+                                       max_frame <= BUS_DATA_IN(15 downto 0);
+
+                               when x"05" =>
+                                       if (BUS_DATA_IN = x"0000_0000") then
+                                               use_gbe <= '0';
+                                       else
+                                               use_gbe <= '1';
+                                       end if;
+
+                               when x"06" =>
+                                       if (BUS_DATA_IN = x"0000_0000") then
+                                               use_trbnet <= '0';
+                                       else
+                                               use_trbnet <= '1';
+                                       end if;
+
+                               when x"07" =>
+                                       if (BUS_DATA_IN = x"0000_0000") then
+                                               use_multievents <= '0';
+                                       else
+                                               use_multievents <= '1';
+                                       end if;
+
+                               -- gk 26.04.10
+                               when x"08" =>
+                                       readout_ctr <= BUS_DATA_IN(23 downto 0);
+                                       readout_ctr_valid <= '1';
+
+                               -- gk 28.04.10
+                               when x"09" =>
+                                       delay <= BUS_DATA_IN;
+
+                               when x"ff" =>
+                                       if (BUS_DATA_IN = x"ffff_ffff") then
+                                               reset_values <= '1';
+                                       else
+                                               reset_values <= '0';
+                                       end if;
+
+                               when others =>
+                                       subevent_id       <= subevent_id;
+                                       subevent_dec      <= subevent_dec;
+                                       queue_dec         <= queue_dec;
+                                       max_packet        <= max_packet;
+                                       max_frame         <= max_frame;
+                                       use_gbe           <= use_gbe;
+                                       use_trbnet        <= use_trbnet;
+                                       use_multievents   <= use_multievents;
+                                       reset_values      <= reset_values;
+                                       readout_ctr       <= readout_ctr;  -- gk 26.04.10
+                                       readout_ctr_valid <= readout_ctr_valid;  -- gk 26.04.10
+                                       delay             <= delay; -- gk 28.04.10
+                       end case;
+               else
+                       reset_values <= '0';
+                       readout_ctr_valid <= '0';  -- gk 26.04.10
+               end if;
+       end if;
+end process WRITE_PROC;
+
+-- gk 26.04.10
+READ_PROC : process(CLK)
+begin
+       if rising_edge(CLK) then
+               if (RESET = '1') then
+                       data_out <= (others => '0');
+               elsif (BUS_READ_EN_IN = '1') then
+                       case BUS_ADDR_IN is
+
+                               when x"00" =>
+                                       data_out <= subevent_id;
+
+                               when x"01" =>
+                                       data_out <= subevent_dec;
+
+                               when x"02" =>
+                                       data_out <= queue_dec;
+
+                               when x"03" =>
+                                       data_out <= max_packet;
+
+                               when x"04" =>
+                                       data_out(15 downto 0) <= max_frame;
+                                       data_out(31 downto 16) <= (others => '0');
+
+                               when x"05" =>
+                                       if (use_gbe = '0') then
+                                               data_out <= x"0000_0000";
+                                       else
+                                               data_out <= x"0000_0001";
+                                       end if;
+
+                               when x"06" =>
+                                       if (use_trbnet = '0') then
+                                               data_out <= x"0000_0000";
+                                       else
+                                               data_out <= x"0000_0001";
+                                       end if;
+
+                               when x"07" =>
+                                       if (use_multievents = '0') then
+                                               data_out <= x"0000_0000";
+                                       else
+                                               data_out <= x"0000_0001";
+                                       end if;
+
+                               when x"08" =>
+                                       data_out <= GBE_TRIG_NR_IN;
+
+                               when x"09" =>
+                                       data_out <= delay;
+
+                               when others =>
+                                       data_out <= (others => '0');
+                       end case;
+               end if;
+       end if;
+end process READ_PROC;
+
+end architecture;
\ No newline at end of file