##// END OF EJS Templates
Correction du CIC (probleme d'ecriture des datas des COMB 256)
pellion -
r501:36e175c5d607 JC
parent child
Show More
@@ -1,249 +1,249
1 ------------------------------------------------------------------------------
1 ------------------------------------------------------------------------------
2 -- This file is a part of the LPP VHDL IP LIBRARY
2 -- This file is a part of the LPP VHDL IP LIBRARY
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
3 -- Copyright (C) 2009 - 2010, Laboratory of Plasmas Physic - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 3 of the License, or
7 -- the Free Software Foundation; either version 3 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------
18 -------------------------------------------------------------------------------
19 -- Author : Jean-christophe Pellion
19 -- Author : Jean-christophe Pellion
20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
20 -- Mail : jean-christophe.pellion@lpp.polytechnique.fr
21 -- jean-christophe.pellion@easii-ic.com
21 -- jean-christophe.pellion@easii-ic.com
22 ----------------------------------------------------------------------------
22 ----------------------------------------------------------------------------
23
23
24 LIBRARY ieee;
24 LIBRARY ieee;
25 USE ieee.std_logic_1164.ALL;
25 USE ieee.std_logic_1164.ALL;
26 USE ieee.numeric_std.ALL;
26 USE ieee.numeric_std.ALL;
27
27
28
28
29 LIBRARY lpp;
29 LIBRARY lpp;
30 USE lpp.cic_pkg.ALL;
30 USE lpp.cic_pkg.ALL;
31 USE lpp.data_type_pkg.ALL;
31 USE lpp.data_type_pkg.ALL;
32
32
33 ENTITY cic_lfr_control IS
33 ENTITY cic_lfr_control IS
34 PORT (
34 PORT (
35 clk : IN STD_LOGIC;
35 clk : IN STD_LOGIC;
36 rstn : IN STD_LOGIC;
36 rstn : IN STD_LOGIC;
37 run : IN STD_LOGIC;
37 run : IN STD_LOGIC;
38 --
38 --
39 data_in_valid : IN STD_LOGIC;
39 data_in_valid : IN STD_LOGIC;
40 data_out_16_valid : OUT STD_LOGIC;
40 data_out_16_valid : OUT STD_LOGIC;
41 data_out_256_valid : OUT STD_LOGIC;
41 data_out_256_valid : OUT STD_LOGIC;
42 --
42 --
43 OPERATION : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
43 OPERATION : OUT STD_LOGIC_VECTOR(15 DOWNTO 0)
44 );
44 );
45
45
46 END cic_lfr_control;
46 END cic_lfr_control;
47
47
48 ARCHITECTURE beh OF cic_lfr_control IS
48 ARCHITECTURE beh OF cic_lfr_control IS
49
49
50 TYPE STATE_CIC_LFR_TYPE IS (IDLE,
50 TYPE STATE_CIC_LFR_TYPE IS (IDLE,
51 RUN_PROG_I,
51 RUN_PROG_I,
52 RUN_PROG_C16,
52 RUN_PROG_C16,
53 RUN_PROG_C256
53 RUN_PROG_C256
54 );
54 );
55
55
56 SIGNAL STATE_CIC_LFR : STATE_CIC_LFR_TYPE;
56 SIGNAL STATE_CIC_LFR : STATE_CIC_LFR_TYPE;
57
57
58 SIGNAL nb_data_receipt : INTEGER := 0;
58 SIGNAL nb_data_receipt : INTEGER := 0;
59 SIGNAL current_cmd : INTEGER := 0;
59 SIGNAL current_cmd : INTEGER := 0;
60 SIGNAL current_channel : INTEGER := 0;
60 SIGNAL current_channel : INTEGER := 0;
61 SIGNAL sample_16_odd : STD_LOGIC;
61 SIGNAL sample_16_odd : STD_LOGIC;
62 SIGNAL sample_256_odd : STD_LOGIC;
62 SIGNAL sample_256_odd : STD_LOGIC;
63
63
64 TYPE PROGRAM_ARRAY IS ARRAY (INTEGER RANGE <>) OF STD_LOGIC_VECTOR(13 DOWNTO 0);
64 TYPE PROGRAM_ARRAY IS ARRAY (INTEGER RANGE <>) OF STD_LOGIC_VECTOR(13 DOWNTO 0);
65 --OPERATION( 8 DOWNTO 0) <= PROGRAM_ARRAY( 8 DOWNTO 0) sauf pour PROG_I(0)
65 --OPERATION( 8 DOWNTO 0) <= PROGRAM_ARRAY( 8 DOWNTO 0) sauf pour PROG_I(0)
66 --OPERATION(13 DOWNTO 12) <= PROGRAM_ARRAY(10 DOWNTO 9)
66 --OPERATION(13 DOWNTO 12) <= PROGRAM_ARRAY(10 DOWNTO 9)
67 --OPERATION(11 DOWNTO 9) <= current_channel
67 --OPERATION(11 DOWNTO 9) <= current_channel
68 --OPERATION(14) <= PROGRAM_ARRAY(11) selon sample_X_odd et l'etat
68 --OPERATION(14) <= PROGRAM_ARRAY(11) selon sample_X_odd et l'etat
69 CONSTANT PROG : PROGRAM_ARRAY(0 TO 28) :=
69 CONSTANT PROG : PROGRAM_ARRAY(0 TO 28) :=
70 (
70 (
71 -- DCBA 98765 43210
71 -- DCBA 98765 43210
72 --PROG I------------------
72 --PROG I------------------
73 "0001" & "00011" & "00000", --0
73 "0001" & "00011" & "00000", --0
74 "0101" & "00010" & "00001", --1
74 "0101" & "00010" & "00001", --1
75 "0101" & "00010" & "00001", --2
75 "0101" & "00010" & "00001", --2
76 "0001" & "00010" & "01011", --3
76 "0001" & "00010" & "01011", --3
77 "0101" & "00010" & "01001", --4
77 "0101" & "00010" & "01001", --4
78 "0101" & "00010" & "01001", --5
78 "0101" & "00010" & "01001", --5
79 "0001" & "00010" & "01011", --6
79 "0001" & "00010" & "01011", --6
80 "0101" & "00010" & "01001", --7
80 "0101" & "00010" & "01001", --7
81 "0101" & "00010" & "01001", --8
81 "0101" & "00010" & "01001", --8
82 --PROG_C16
82 --PROG_C16
83 "1001" & "00100" & "10010", --9
83 "1001" & "00100" & "10010", --9
84 "1001" & "10010" & "10101", --10
84 "1001" & "10010" & "10101", --10
85 "1001" & "10010" & "10101", --11
85 "1001" & "10010" & "10101", --11
86 "1010" & "10010" & "10101", --12
86 "1010" & "10010" & "10101", --12
87 "1001" & "01000" & "10010", --13
87 "1001" & "01000" & "10010", --13
88 "1001" & "10010" & "11101", --14
88 "1001" & "10010" & "11101", --14
89 "1001" & "10010" & "11101", --15
89 "1001" & "10010" & "11101", --15
90 "1010" & "10010" & "11101", --16
90 "1010" & "10010" & "11101", --16
91 --PROG_C256
91 --PROG_C256
92 "1001" & "00100" & "10010", --17
92 "1001" & "00100" & "10010", --17
93 "1001" & "10110" & "10101", --18
93 "1001" & "10110" & "10101", --18
94 "1001" & "10110" & "10101", --19
94 "1001" & "10110" & "10101", --19
95 "1010" & "10110" & "10101", --20
95 "1010" & "10110" & "10101", --20
96 "1001" & "01000" & "10010", --21
96 "1001" & "01000" & "10010", --21
97 "1001" & "10110" & "11101", --22
97 "1001" & "10110" & "11101", --22
98 "1001" & "10110" & "11101", --23
98 "1001" & "10110" & "11101", --23
99 "1010" & "10110" & "11101", --24
99 "1010" & "10110" & "11101", --24
100 "1001" & "01100" & "10010", --25
100 "1001" & "01100" & "10010", --25
101 "1001" & "10110" & "11101", --26
101 "1001" & "10110" & "11101", --26
102 "1001" & "10110" & "11101", --27
102 "1001" & "10110" & "11101", --27
103 "1010" & "10110" & "11101" --28
103 "1010" & "10110" & "11101" --28
104 );
104 );
105
105
106
106
107 CONSTANT PROG_START_I : INTEGER := 0;
107 CONSTANT PROG_START_I : INTEGER := 0;
108 CONSTANT PROG_END_I : INTEGER := 8;
108 CONSTANT PROG_END_I : INTEGER := 8;
109 CONSTANT PROG_START_C16 : INTEGER := 9;
109 CONSTANT PROG_START_C16 : INTEGER := 9;
110 CONSTANT PROG_END_C16 : INTEGER := 16;
110 CONSTANT PROG_END_C16 : INTEGER := 16;
111 CONSTANT PROG_START_C256 : INTEGER := 17;
111 CONSTANT PROG_START_C256 : INTEGER := 17;
112 CONSTANT PROG_END_C256 : INTEGER := 28;
112 CONSTANT PROG_END_C256 : INTEGER := 28;
113
113
114 BEGIN
114 BEGIN
115
115
116 OPERATION(2 DOWNTO 0) <= STD_LOGIC_VECTOR(to_unsigned(current_channel, 3)); --SEL_SAMPLE
116 OPERATION(2 DOWNTO 0) <= STD_LOGIC_VECTOR(to_unsigned(current_channel, 3)); --SEL_SAMPLE
117 OPERATION(4 DOWNTO 3) <= PROG(current_cmd)(1 DOWNTO 0); --SEL_DATA_A
117 OPERATION(4 DOWNTO 3) <= PROG(current_cmd)(1 DOWNTO 0); --SEL_DATA_A
118 OPERATION(6 DOWNTO 5) <= "00" WHEN STATE_CIC_LFR = IDLE ELSE PROG(current_cmd)(3 DOWNTO 2); --ALU_CMD
118 OPERATION(6 DOWNTO 5) <= "00" WHEN STATE_CIC_LFR = IDLE ELSE PROG(current_cmd)(3 DOWNTO 2); --ALU_CMD
119 OPERATION(7) <= '0' WHEN STATE_CIC_LFR = IDLE ELSE PROG(current_cmd)(4); --CARRY_PUSH
119 OPERATION(7) <= '0' WHEN STATE_CIC_LFR = IDLE ELSE PROG(current_cmd)(4); --CARRY_PUSH
120 OPERATION(8) <= PROG(current_cmd)(5); --@_init
120 OPERATION(8) <= PROG(current_cmd)(5); --@_init
121 OPERATION(9) <= PROG(current_cmd)(6); --@_add_1
121 OPERATION(9) <= PROG(current_cmd)(6); --@_add_1
122
122
123 OPERATION(10) <= PROG(current_cmd)(7) AND PROG(current_cmd)(9) AND sample_256_odd WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE
123 OPERATION(10) <= PROG(current_cmd)(7) AND sample_256_odd WHEN STATE_CIC_LFR = RUN_PROG_C256 AND PROG(current_cmd)(9) = '1' ELSE
124 PROG(current_cmd)(7); --@_sel(1..0)
124 PROG(current_cmd)(7); --@_sel(1..0)
125 OPERATION(11) <= PROG(current_cmd)(8);
125 OPERATION(11) <= PROG(current_cmd)(8);
126 OPERATION(12) <= PROG(current_cmd)(9) AND sample_16_odd WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE
126 OPERATION(12) <= PROG(current_cmd)(9) AND sample_16_odd WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE
127 --PROG(current_cmd)(9) AND sample_256_odd WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE
127 --PROG(current_cmd)(9) AND sample_256_odd WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE
128 PROG(current_cmd)(9) WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE
128 PROG(current_cmd)(9) WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE
129 '0'; --@_sel(2)
129 '0'; --@_sel(2)
130
130
131
131
132 OPERATION(13) <= '0' WHEN STATE_CIC_LFR = IDLE ELSE PROG(current_cmd)(10); --WE
132 OPERATION(13) <= '0' WHEN STATE_CIC_LFR = IDLE ELSE PROG(current_cmd)(10); --WE
133 OPERATION(14) <= PROG(current_cmd)(12); -- SEL_DATA_A = data_b_reg
133 OPERATION(14) <= PROG(current_cmd)(12); -- SEL_DATA_A = data_b_reg
134 OPERATION(15) <= PROG(current_cmd)(13); -- WRITE_ADDR_sel
134 OPERATION(15) <= PROG(current_cmd)(13); -- WRITE_ADDR_sel
135 data_out_16_valid <= PROG(current_cmd)(11) WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE '0';
135 data_out_16_valid <= PROG(current_cmd)(11) WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE '0';
136 data_out_256_valid <= PROG(current_cmd)(11) WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE '0';
136 data_out_256_valid <= PROG(current_cmd)(11) WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE '0';
137
137
138
138
139
139
140
140
141
141
142
142
143
143
144
144
145
145
146
146
147 --OPERATION(1 DOWNTO 0) <= PROG(current_cmd)(1 DOWNTO 0);
147 --OPERATION(1 DOWNTO 0) <= PROG(current_cmd)(1 DOWNTO 0);
148 --OPERATION(2) <= '0' WHEN STATE_CIC_LFR = IDLE ELSE
148 --OPERATION(2) <= '0' WHEN STATE_CIC_LFR = IDLE ELSE
149 -- PROG(current_cmd)(2);
149 -- PROG(current_cmd)(2);
150 --OPERATION(5 DOWNTO 3) <= STD_LOGIC_VECTOR(to_unsigned(current_channel, 3)) WHEN STATE_CIC_LFR = RUN_PROG_I AND current_cmd = 0 ELSE
150 --OPERATION(5 DOWNTO 3) <= STD_LOGIC_VECTOR(to_unsigned(current_channel, 3)) WHEN STATE_CIC_LFR = RUN_PROG_I AND current_cmd = 0 ELSE
151 -- PROG(current_cmd)(5 DOWNTO 3);
151 -- PROG(current_cmd)(5 DOWNTO 3);
152
152
153 --OPERATION(8 DOWNTO 6) <= "000" WHEN STATE_CIC_LFR = IDLE ELSE
153 --OPERATION(8 DOWNTO 6) <= "000" WHEN STATE_CIC_LFR = IDLE ELSE
154 -- PROG(current_cmd)(8 DOWNTO 6);
154 -- PROG(current_cmd)(8 DOWNTO 6);
155 --OPERATION(11 DOWNTO 9) <= STD_LOGIC_VECTOR(to_unsigned(current_channel, 3));
155 --OPERATION(11 DOWNTO 9) <= STD_LOGIC_VECTOR(to_unsigned(current_channel, 3));
156 --OPERATION(13 DOWNTO 12) <= PROG(current_cmd)(10 DOWNTO 9);
156 --OPERATION(13 DOWNTO 12) <= PROG(current_cmd)(10 DOWNTO 9);
157 --OPERATION(14) <= PROG(current_cmd)(11) AND sample_16_odd WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE
157 --OPERATION(14) <= PROG(current_cmd)(11) AND sample_16_odd WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE
158 -- PROG(current_cmd)(11) AND sample_256_odd WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE '0';
158 -- PROG(current_cmd)(11) AND sample_256_odd WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE '0';
159
159
160 --OPERATION(15) <= PROG(current_cmd)(12);
160 --OPERATION(15) <= PROG(current_cmd)(12);
161
161
162 --data_out_16_valid <= PROG(current_cmd)(13) WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE '0';
162 --data_out_16_valid <= PROG(current_cmd)(13) WHEN STATE_CIC_LFR = RUN_PROG_C16 ELSE '0';
163 --data_out_256_valid <= PROG(current_cmd)(13) WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE '0';
163 --data_out_256_valid <= PROG(current_cmd)(13) WHEN STATE_CIC_LFR = RUN_PROG_C256 ELSE '0';
164
164
165 PROCESS (clk, rstn)
165 PROCESS (clk, rstn)
166 BEGIN
166 BEGIN
167 IF rstn = '0' THEN
167 IF rstn = '0' THEN
168 STATE_CIC_LFR <= IDLE;
168 STATE_CIC_LFR <= IDLE;
169 nb_data_receipt <= 0;
169 nb_data_receipt <= 0;
170 current_channel <= 0;
170 current_channel <= 0;
171 current_cmd <= 0;
171 current_cmd <= 0;
172 sample_16_odd <= '0';
172 sample_16_odd <= '0';
173 sample_256_odd <= '0';
173 sample_256_odd <= '0';
174
174
175 ELSIF clk'EVENT AND clk = '1' THEN
175 ELSIF clk'EVENT AND clk = '1' THEN
176
176
177 CASE STATE_CIC_LFR IS
177 CASE STATE_CIC_LFR IS
178 WHEN IDLE =>
178 WHEN IDLE =>
179 IF data_in_valid = '1' THEN
179 IF data_in_valid = '1' THEN
180 STATE_CIC_LFR <= RUN_PROG_I;
180 STATE_CIC_LFR <= RUN_PROG_I;
181 current_cmd <= PROG_START_I;
181 current_cmd <= PROG_START_I;
182 current_channel <= 0;
182 current_channel <= 0;
183 nb_data_receipt <= nb_data_receipt + 1;
183 nb_data_receipt <= nb_data_receipt + 1;
184 END IF;
184 END IF;
185
185
186 WHEN RUN_PROG_I =>
186 WHEN RUN_PROG_I =>
187 IF current_cmd = PROG_END_I THEN
187 IF current_cmd = PROG_END_I THEN
188 IF nb_data_receipt MOD 16 = 15 THEN
188 IF nb_data_receipt MOD 16 = 15 THEN
189 STATE_CIC_LFR <= RUN_PROG_C16;
189 STATE_CIC_LFR <= RUN_PROG_C16;
190 current_cmd <= PROG_START_C16;
190 current_cmd <= PROG_START_C16;
191 IF current_channel = 0 THEN
191 IF current_channel = 0 THEN
192 sample_16_odd <= NOT sample_16_odd;
192 sample_16_odd <= NOT sample_16_odd;
193 END IF;
193 END IF;
194 ELSE
194 ELSE
195 IF current_channel = 5 THEN
195 IF current_channel = 5 THEN
196 current_channel <= 0;
196 current_channel <= 0;
197 STATE_CIC_LFR <= IDLE;
197 STATE_CIC_LFR <= IDLE;
198 ELSE
198 ELSE
199 current_cmd <= PROG_START_I;
199 current_cmd <= PROG_START_I;
200 current_channel <= current_channel + 1;
200 current_channel <= current_channel + 1;
201 END IF;
201 END IF;
202 END IF;
202 END IF;
203 ELSE
203 ELSE
204 current_cmd <= current_cmd +1;
204 current_cmd <= current_cmd +1;
205 END IF;
205 END IF;
206
206
207 WHEN RUN_PROG_C16 =>
207 WHEN RUN_PROG_C16 =>
208 IF current_cmd = PROG_END_C16 THEN
208 IF current_cmd = PROG_END_C16 THEN
209 IF nb_data_receipt MOD 256 = 255 THEN
209 IF nb_data_receipt MOD 256 = 255 THEN
210 STATE_CIC_LFR <= RUN_PROG_C256;
210 STATE_CIC_LFR <= RUN_PROG_C256;
211 current_cmd <= PROG_START_C256;
211 current_cmd <= PROG_START_C256;
212 IF current_channel = 0 THEN
212 IF current_channel = 0 THEN
213 sample_256_odd <= NOT sample_256_odd;
213 sample_256_odd <= NOT sample_256_odd;
214 END IF;
214 END IF;
215 ELSE
215 ELSE
216 IF current_channel = 5 THEN
216 IF current_channel = 5 THEN
217 current_channel <= 0;
217 current_channel <= 0;
218 STATE_CIC_LFR <= IDLE;
218 STATE_CIC_LFR <= IDLE;
219 ELSE
219 ELSE
220 STATE_CIC_LFR <= RUN_PROG_I;
220 STATE_CIC_LFR <= RUN_PROG_I;
221 current_cmd <= PROG_START_I;
221 current_cmd <= PROG_START_I;
222 current_channel <= current_channel + 1;
222 current_channel <= current_channel + 1;
223 END IF;
223 END IF;
224 END IF;
224 END IF;
225 ELSE
225 ELSE
226 current_cmd <= current_cmd +1;
226 current_cmd <= current_cmd +1;
227 END IF;
227 END IF;
228
228
229 WHEN RUN_PROG_C256 =>
229 WHEN RUN_PROG_C256 =>
230 IF current_cmd = PROG_END_C256 THEN
230 IF current_cmd = PROG_END_C256 THEN
231 -- data_out_256_valid <= '1';
231 -- data_out_256_valid <= '1';
232 IF current_channel = 5 THEN
232 IF current_channel = 5 THEN
233 current_channel <= 0;
233 current_channel <= 0;
234 STATE_CIC_LFR <= IDLE;
234 STATE_CIC_LFR <= IDLE;
235 ELSE
235 ELSE
236 STATE_CIC_LFR <= RUN_PROG_I;
236 STATE_CIC_LFR <= RUN_PROG_I;
237 current_cmd <= PROG_START_I;
237 current_cmd <= PROG_START_I;
238 current_channel <= current_channel + 1;
238 current_channel <= current_channel + 1;
239 END IF;
239 END IF;
240 ELSE
240 ELSE
241 current_cmd <= current_cmd +1;
241 current_cmd <= current_cmd +1;
242 END IF;
242 END IF;
243
243
244 WHEN OTHERS => NULL;
244 WHEN OTHERS => NULL;
245 END CASE;
245 END CASE;
246 END IF;
246 END IF;
247 END PROCESS;
247 END PROCESS;
248
248
249 END beh;
249 END beh;
General Comments 0
You need to be logged in to leave comments. Login now