CMX
CMX firmware code in-line documentation
 All Classes Namespaces Files Functions Variables
CMX_CP_Topo_Encoder.vhd
Go to the documentation of this file.
1 
10 library IEEE;
11 use IEEE.STD_LOGIC_1164.ALL;
12 
13 library work;
14 use work.CMXpackage.all;
16 
17 
18 -- Uncomment the following library declaration if using
19 -- arithmetic functions with Signed or Unsigned values
20 use IEEE.NUMERIC_STD.ALL;
21 
22 -- Uncomment the following library declaration if instantiating
23 -- any Xilinx primitives in this code.
24 --library UNISIM;
25 --use UNISIM.VComponents.all;
26 
28  port (
29  Tobs_to_TOPO : in copy_arr_TOB; -- TOB arrays to load onto
30  -- encoder; copied x4
31  overflow : in std_logic_vector(num_copies-1 downto 0);
32 
33  -- this instructs the modules downstream to plug in the alignment word.
34  send_align_out : out std_logic_vector(num_GTX_groups*num_GTX_per_group - 1 downto 0);
35 
36  Data_out : out std_logic_vector(TX_indata_length - 1 downto 0));
37  --clk :in std_logic);
38 end CMX_CP_Topo_Encoder;
39 
40 architecture Behavioral of CMX_CP_Topo_Encoder is
41 
42  --these consts describe the trigger object arrangement
43  constant num_cols : integer:=5; -- 4 CP TO's per fiber
44  -- indexing starts on the left i.e. TO 0
45  -- in a given row
46  -- occupies the most sig 28 bits
47  constant num_rows : integer:=6; --6 fibers
48 
49  --these consts describe the word (16 or 18 bit) object arrangement
50  constant num_cols_words : integer:=8; --8 16 bit words per fiber (=8
51  --16bit+2bit K flag per fiber)
52  --note that these start at the low end
53  --i.e. word 0 is 15 downto 0 in
54  --flat_array
55  --or 17 down to 0 in final_array
56  constant num_rows_words : integer:=6; -- 6 fibers (ok a bit redundant)
57 
58 
59  --first the input data is interpreted as an array of CP TOs (no logic here
60  --just renaming signals)
61  --signal TO_CPs : arr_TO_CP;
62 
63  --then the TO_CPs array is packed onto a flat array
64  --it is just a long vector but we can think of this as having 8 rows 128 bits
65  --each (i.e. each row corresponds to data sent on a single fiber)
66  --each 'row' holds 4 jet TO's and is padded with zeros (least sig 15 bits
67  --bit 16 is the overflow)
68  --the position of TO in the row is the column. Columns are filled first
69  -- e.g. CP TO 0 occupying bits 127 downto 100 is row 0 column 0
70  -- CP TO 8 is occupying bits 355 downto 327 is row 2 column 1
71  signal flat_array : std_logic_vector(num_copies*num_cols_words*num_rows_words*16-1 downto 0 );
72 
73 
74 
75  --component chipscope_ila_jet_encoder is
76  -- port (
77  -- CONTROL : inout std_logic_vector(35 downto 0);
78  -- CLK : in std_logic;
79  -- DATA : in std_logic_vector(585 downto 0);
80  -- TRIG0 : in std_logic_vector(0 to 0));
81  --end component chipscope_ila_jet_encoder;
82 
83  --signal CONTROL : std_logic_vector(35 downto 0);
84  --signal DATA_ila_jet_encoder : std_logic_vector(585 downto 0);
85  --signal TRIG0_ila_jet_encoder : std_logic_vector(0 to 0);
86 
87  --component chipscope_icon_u1_c1 is
88  -- port (
89  -- CONTROL0 : inout std_logic_vector(35 downto 0));
90  --end component chipscope_icon_u1_c1;
91 
92 begin
93 
94 
95  ----form the array of jet TO's
96  --jet_arr_gen: for i_jet in 0 to Num_TO_CP-1 generate
97  -- TO_CPs(i_jet)(TO_CP_Et2_size-1 downto 0)<=DATA_Et2((i_jet+1)*TO_CP_Et2_size - 1 downto i_jet * TO_CP_Et2_size);
98  -- TO_CPs(i_jet)(TO_CP_Et2_size+TO_CP_Et1_size-1 downto TO_CP_Et2_size)<=DATA_Et1((i_jet+1)*TO_CP_Et1_size - 1 downto i_jet * TO_CP_Et1_size);
99  -- TO_CPs(i_jet)(TO_CP_Et2_size+TO_CP_Et1_size+TO_CP_pos_size-1 downto TO_CP_Et2_size+TO_CP_Et1_size)<=DATA_pos((i_jet+1)*TO_CP_pos_size - 1 downto i_jet * TO_CP_pos_size);
100  --end generate jet_arr_gen;
101 
102 
103 
104  flat_arr_payload_copy_gen: for i_copy in 0 to num_copies-1 generate
105  flat_arr_payload_gen: for i_TO in 0 to max_tobs_topo-1 generate
106 
107 
108  constant i_col :integer := (i_TO/num_rows);
109  constant i_row :integer := (i_TO rem num_rows)+num_rows*i_copy;
110 
111  --constant msb : integer := 128*i_row + 127 - ( i_col * TO_CP_size );
112  --constant lsb : integer := 128*i_row + 128 - ( ( i_col +1 ) * TO_CP_size );
113 
114  --constant i_row_cpy : integer := i_row+i_copy*num_rows;
115  constant i_row_fiber: integer := fiber_to_gtx(i_row);
116 
117  constant msb : integer := 128*i_row_fiber + 127 - ( i_col * TO_EmTau_size );
118  constant lsb : integer := 128*i_row_fiber + 128 - ( ( i_col +1 ) * TO_EmTau_size );
119 
120  --flat_array(msb downto lsb)<=TO_CPs(i_TO);
121  --flat_array(128*i_row + 127 - ( i_col * TO_CP_size ) downto 128*i_row + 128 - ( ( i_col +1 ) * TO_CP_size ))<=TO_CPs(i_TO);
122 
123  begin
124 
125  assert i_TO<=29 report "TOO MANY TOBS in THE DECODER INSTATIATION!!!" severity FAILURE;
126  assert lsb>=0 report "LSB less than 0 in the decoder instantiation!!!; i_copy: "&integer'IMAGE(i_copy)&", i_TO: "&integer'IMAGE(i_TO)&", i_col: "&integer'IMAGE(i_col)&", i_row: "&integer'IMAGE(i_row)&", msb: "&integer'IMAGE(msb)&", lsb: "&integer'IMAGE(lsb) severity FAILURE;
127 
128  flat_array(lsb+TO_EmTau_CLE_size-1 downto lsb)<=Tobs_to_TOPO(i_copy)(i_TO).CLE;
129  flat_array(lsb+TO_EmTau_CLE_size+TO_EmTau_ISO_size-1 downto lsb+TO_EmTau_CLE_size)<=Tobs_to_TOPO(i_copy)(i_TO).ISO;
130  flat_array(msb downto lsb+TO_EmTau_CLE_size+TO_EmTau_ISO_size)<=Tobs_to_TOPO(i_copy)(i_TO).POS;
131 
132  end generate flat_arr_payload_gen;
133  end generate flat_arr_payload_copy_gen;
134 
135 
136  flat_arr_overflow_copy_gen: for i_copy in 0 to num_copies-1 generate
137  flat_arr_overflow_gen: for i_row in 0 to num_rows-1 generate
138  flat_array(12+ i_row*128+i_copy*num_rows*128)<=overflow(i_copy);
139  flat_array(11+ i_row*128+i_copy*num_rows*128 downto i_row*128+i_copy*num_rows*128)<= (others=>'0');
140  end generate flat_arr_overflow_gen;
141  end generate flat_arr_overflow_copy_gen;
142 
143 
144 
145  send_align_copy_gen: for i_copy in 0 to num_copies-1 generate
146  send_align_gen: for i_row in 0 to num_rows-1 generate
147  constant i_row_cpy : integer := i_row+i_copy*num_rows;
148  constant i_row_fiber: integer := fiber_to_gtx(i_row_cpy);
149  begin
150  send_align_out(i_row_fiber)<= '0' when Tobs_to_TOPO(i_copy)(i_row+2*num_rows).CLE/="00000000" else '1';
151  end generate send_align_gen;
152  end generate send_align_copy_gen;
153 
154 
155 
156 
158 
159  --chipscope_icon_u1_c1_inst: entity work.chipscope_icon_u1_c1
160  -- port map (
161  -- CONTROL0 => CONTROL);
162 
163  --chipscope_ila_jet_encoder_inst: entity work.chipscope_ila_jet_encoder
164  -- port map (
165  -- CONTROL => CONTROL,
166  -- CLK => clk,
167  -- DATA => DATA_ila_jet_encoder,
168  -- TRIG0 => TRIG0_ila_jet_encoder);
169 
170  --TRIG0_ila_jet_encoder(0)<='0';
171 
172  --DATA_ila_jet_encoder(0)<='0';
173  --DATA_ila_jet_encoder(8 downto 1)<=send_align;
174  --DATA_ila_jet_encoder(328 downto 9)<=DATA_Et2;
175  --DATA_ila_jet_encoder(584 downto 329)<=flat_array(255 downto 0);
176  --DATA_ila_jet_encoder(585)<='0';
177 
178 
179 
180 end Behavioral;
181 
integer :=(i_TO / num_rows) i_col
integer :=fiber_to_gtx (i_row) i_row_fiber
out Data_outstd_logic_vector (TX_indata_length - 1 downto 0)
in Tobs_to_TOPOcopy_arr_TOB
_library_ workwork
std_logic_vector (num_copies * num_cols_words * num_rows_words * 16 - 1 downto 0) flat_array)
integer :=(i_TO rem num_rows) + num_rows * i_copy i_row
out send_align_outstd_logic_vector (num_GTX_groups * num_GTX_per_group - 1 downto 0)
integer :=128 * i_row_fiber + 128 - ((i_col + 1) * TO_EmTau_size) lsb
integer :=i_row + i_copy * num_rows i_row_cpy
_library_ ieeeieee
integer :=128 * i_row_fiber + 127 - (i_col * TO_EmTau_size msb)
in overflowstd_logic_vector (num_copies - 1 downto 0)