1 ----------------------------------------------------------------------------------
9 ----------------------------------------------------------------------------------
11 use IEEE.STD_LOGIC_1164.
ALL;
18 -- Uncomment the following library declaration if using
19 -- arithmetic functions with Signed or Unsigned values
20 use IEEE.NUMERIC_STD.
ALL;
22 -- Uncomment the following library declaration if instantiating
23 -- any Xilinx primitives in this code.
25 --use UNISIM.VComponents.all;
27 entity CMX_Jet_Topo_Encoder
is
29 Tobs_to_TOPO : in copy_arr_TOB;
30 overflow : in (num_copies-1 downto 0);
31 --DATA_Et1 : in std_logic_vector((576/2)-1 downto 0);--(TO_Jet_Et1_size*Num_TO_Jet) - 1 downto 0);
32 --DATA_Et2 : in std_logic_vector((640/2)-1 downto 0);--(TO_Jet_Et2_size*Num_TO_Jet) - 1 downto 0);
33 --DATA_pos : in std_logic_vector((576/2)-1 downto 0);--(TO_Jet_eta_size*Num_TO_Jet) - 1 downto 0);
34 --overflow : in std_logic;
36 -- this instructs the modules downstream to plug in the alignment word.
37 send_align_out : out (num_GTX_groups*num_GTX_per_group - 1 downto 0);
39 Data_out : out (TX_indata_length - 1 downto 0));
41 end CMX_Jet_Topo_Encoder;
43 architecture Behavioral
of CMX_Jet_Topo_Encoder is
45 --these consts describe the trigger object arrangement
46 constant num_cols : :=4;
-- 4 Jet TO's per fiber
47 -- indexing starts on the left i.e. TO 0
49 -- occupies the most sig 28 bits
52 --these consts describe the word (16 or 18 bit) object arrangement
54 --16bit+2bit K flag per fiber)
55 --note that these start at the low end
56 --i.e. word 0 is 15 downto 0 in
58 --or 17 down to 0 in final_array
61 -- obsolete -- --first the input data is interpreted as an array of Jet TOs (no logic here
62 -- obsolete -- --just renaming signals)
63 -- obsolete -- signal TO_Jets : arr_TO_Jet;
65 --then the TO_Jets array is packed onto a flat array
66 --it is just a long vector but we can think of this as having 8 rows 128 bits
67 --each (i.e. each row corresponds to data sent on a single fiber)
68 --each 'row' holds 4 jet TO's and is padded with zeros (least sig 15 bits
69 --bit 16 is the overflow)
70 --the position of TO in the row is the column. Columns are filled first
71 -- e.g. Jet TO 0 occupying bits 127 downto 100 is row 0 column 0
72 -- Jet TO 8 is occupying bits 355 downto 327 is row 2 column 1
77 --detects if TO 2 on a given row is 0 energy (then TO 3 is presumeably 0 also)
81 --type arr_ET1ET2 is array (integer range <>) of std_logic_vector(TO_Jet_Et1_size+TO_Jet_Et2_size - 1 downto 0);
82 --signal send_align_ET1ET2 : arr_ET1ET2(num_rows-1 downto 0);
85 --component chipscope_ila_jet_encoder is
87 -- CONTROL : inout std_logic_vector(35 downto 0);
88 -- CLK : in std_logic;
89 -- DATA : in std_logic_vector(585 downto 0);
90 -- TRIG0 : in std_logic_vector(0 to 0));
91 --end component chipscope_ila_jet_encoder;
93 --signal CONTROL : std_logic_vector(35 downto 0);
94 --signal DATA_ila_jet_encoder : std_logic_vector(585 downto 0);
95 --signal TRIG0_ila_jet_encoder : std_logic_vector(0 to 0);
97 --component chipscope_icon_u1_c1 is
99 -- CONTROL0 : inout std_logic_vector(35 downto 0));
100 --end component chipscope_icon_u1_c1;
105 ----form the array of jet TO's
106 --jet_arr_gen: for i_jet in 0 to Num_TO_Jet-1 generate
107 -- TO_Jets(i_jet)(TO_Jet_Et2_size-1 downto 0)<=DATA_Et2((i_jet+1)*TO_Jet_Et2_size - 1 downto i_jet * TO_Jet_Et2_size);
108 -- TO_Jets(i_jet)(TO_Jet_Et2_size+TO_Jet_Et1_size-1 downto TO_Jet_Et2_size)<=DATA_Et1((i_jet+1)*TO_Jet_Et1_size - 1 downto i_jet * TO_Jet_Et1_size);
109 -- TO_Jets(i_jet)(TO_Jet_Et2_size+TO_Jet_Et1_size+TO_Jet_pos_size-1 downto TO_Jet_Et2_size+TO_Jet_Et1_size)<=DATA_pos((i_jet+1)*TO_Jet_pos_size - 1 downto i_jet * TO_Jet_pos_size);
110 --end generate jet_arr_gen;
115 flat_arr_payload_copy_gen: for i_copy in 0 to num_copies-1 generate
116 flat_arr_payload_gen: for i_TO in 0 to Num_TO_Jet-1 generate
123 --constant i_row_cpy : integer := i_row+i_copy*num_rows;
129 --flat_array(msb downto lsb)<=TO_Jets(i_TO);
130 --flat_array(128*i_row + 127 - ( i_col * TO_Jet_size ) downto 128*i_row + 128 - ( ( i_col +1 ) * TO_Jet_size ))<=TO_Jets(i_TO);
134 --just trigger a report
135 assert 1=0 report "WTF: Jet_Topo_Encoder flat_array generation: i_copy: "&'IMAGE(i_copy)&", i_TO: "&'IMAGE(i_TO)&", i_col: "&'IMAGE(i_col)&", i_row: "&'IMAGE(i_row)&", msb: "&'IMAGE(msb)&", i_row_fiber: "&'IMAGE(i_row_fiber)&", msb: "&'IMAGE(msb)&", lsb: "&'IMAGE(lsb) severity NOTE;
137 assert i_TO<=32 report "TOO MANY TOBS in THE Jet Encoder INSTATIATION!!!" severity FAILURE;
138 assert lsb>=0 report "LSB less than 0 in the jet encoder instantiation!!!; i_copy: "&'IMAGE(i_copy)&", i_TO: "&'IMAGE(i_TO)&", i_col: "&'IMAGE(i_col)&", i_row: "&'IMAGE(i_row)&", msb: "&'IMAGE(msb)&", lsb: "&'IMAGE(lsb) severity FAILURE;
140 flat_array(lsb+TO_Jet_Et2_size-1 downto lsb)<=Tobs_to_TOPO(i_copy)(i_TO).Et2;
141 flat_array(lsb+TO_Jet_Et2_size+TO_Jet_Et1_size-1 downto lsb+TO_Jet_Et2_size)<=Tobs_to_TOPO(i_copy)(i_TO).Et1;
142 flat_array(lsb+TO_Jet_Et2_size+TO_Jet_Et1_size+TO_Jet_pos_size-1 downto lsb+TO_Jet_Et2_size+TO_Jet_Et1_size)<=Tobs_to_TOPO(i_copy)(i_TO).pos;
145 end generate flat_arr_payload_gen;
146 end generate flat_arr_payload_copy_gen;
149 flat_arr_overflow_copy_gen: for i_copy in 0 to num_copies-1 generate
153 end generate flat_arr_overflow_gen;
154 end generate flat_arr_overflow_copy_gen;
157 send_align_copy_gen: for i_copy in 0 to num_copies-1 generate
167 end generate send_align_gen;
168 end generate send_align_copy_gen;
175 --chipscope_icon_u1_c1_inst: entity work.chipscope_icon_u1_c1
177 -- CONTROL0 => CONTROL);
179 --chipscope_ila_jet_encoder_inst: entity work.chipscope_ila_jet_encoder
181 -- CONTROL => CONTROL,
183 -- DATA => DATA_ila_jet_encoder,
184 -- TRIG0 => TRIG0_ila_jet_encoder);
186 --TRIG0_ila_jet_encoder(0)<='0';
188 --DATA_ila_jet_encoder(0)<='0';
189 --DATA_ila_jet_encoder(8 downto 1)<=send_align;
190 --DATA_ila_jet_encoder(328 downto 9)<=DATA_Et2;
191 --DATA_ila_jet_encoder(584 downto 329)<=flat_array(255 downto 0);
192 --DATA_ila_jet_encoder(585)<='0';
integer :=i_row + i_copy * num_rows i_row_cpy
integer :=128 * i_row_fiber + 127 - (i_col * TO_Jet_size msb)
integer :=8 num_rows_words
integer :=(i_TO rem num_rows) + num_rows * i_copy i_row
std_logic_vector (num_copies * num_cols_words * num_rows_words * 16 - 1 downto 0) flat_array)
integer :=128 * i_row_fiber + 128 - ((i_col + 1) * TO_Jet_size) lsb
integer :=8 num_cols_words
std_logic_vector (num_rows - 1 downto 0) send_align
integer :=(i_TO / num_rows) i_col
integer :=fiber_to_gtx (i_row) i_row_fiber
arr_19 (num_rows * num_copies - 1 downto 0) send_align_ET1ET2)