@@ -450,7 +450,7 BEGIN -- beh | |||||
450 | pirq_ms => 6, |
|
450 | pirq_ms => 6, | |
451 | pirq_wfp => 14, |
|
451 | pirq_wfp => 14, | |
452 | hindex => 2, |
|
452 | hindex => 2, | |
453 |
top_lfr_version => X"02015 |
|
453 | top_lfr_version => X"020153", -- aa.bb.cc version | |
454 | -- AA : BOARD NUMBER |
|
454 | -- AA : BOARD NUMBER | |
455 | -- 0 => MINI_LFR |
|
455 | -- 0 => MINI_LFR | |
456 | -- 1 => EM |
|
456 | -- 1 => EM |
@@ -9,8 +9,8 USE lpp.general_purpose.SYNC_FF; | |||||
9 | ENTITY top_ad_conv_RHF1401_withFilter IS |
|
9 | ENTITY top_ad_conv_RHF1401_withFilter IS | |
10 | GENERIC( |
|
10 | GENERIC( | |
11 | ChanelCount : INTEGER := 8; |
|
11 | ChanelCount : INTEGER := 8; | |
12 |
ncycle_cnv_high : INTEGER := |
|
12 | ncycle_cnv_high : INTEGER := 13; | |
13 |
ncycle_cnv : INTEGER := 5 |
|
13 | ncycle_cnv : INTEGER := 25; | |
14 | FILTER_ENABLED : INTEGER := 16#FF# |
|
14 | FILTER_ENABLED : INTEGER := 16#FF# | |
15 | ); |
|
15 | ); | |
16 | PORT ( |
|
16 | PORT ( | |
@@ -34,8 +34,7 ARCHITECTURE ar_top_ad_conv_RHF1401 OF t | |||||
34 | SIGNAL cnv_s : STD_LOGIC; |
|
34 | SIGNAL cnv_s : STD_LOGIC; | |
35 | SIGNAL cnv_s_reg : STD_LOGIC; |
|
35 | SIGNAL cnv_s_reg : STD_LOGIC; | |
36 | SIGNAL cnv_sync : STD_LOGIC; |
|
36 | SIGNAL cnv_sync : STD_LOGIC; | |
37 |
SIGNAL cnv_sync_re |
|
37 | SIGNAL cnv_sync_pre : STD_LOGIC; | |
38 | SIGNAL cnv_sync_falling : STD_LOGIC; |
|
|||
39 |
|
38 | |||
40 | SIGNAL ADC_nOE_reg : STD_LOGIC_VECTOR(ChanelCount-1 DOWNTO 0); |
|
39 | SIGNAL ADC_nOE_reg : STD_LOGIC_VECTOR(ChanelCount-1 DOWNTO 0); | |
41 | SIGNAL enable_ADC : STD_LOGIC; |
|
40 | SIGNAL enable_ADC : STD_LOGIC; | |
@@ -54,23 +53,6 ARCHITECTURE ar_top_ad_conv_RHF1401 OF t | |||||
54 |
|
53 | |||
55 | CONSTANT FILTER_ENABLED_STDLOGIC : STD_LOGIC_VECTOR(ChanelCount-1 DOWNTO 0) := STD_LOGIC_VECTOR(to_unsigned(FILTER_ENABLED,ChanelCount)); |
|
54 | CONSTANT FILTER_ENABLED_STDLOGIC : STD_LOGIC_VECTOR(ChanelCount-1 DOWNTO 0) := STD_LOGIC_VECTOR(to_unsigned(FILTER_ENABLED,ChanelCount)); | |
56 |
|
55 | |||
57 | ----------------------------------------------------------------------------- |
|
|||
58 | CONSTANT OE_NB_CYCLE_ENABLED : INTEGER := 1; |
|
|||
59 | CONSTANT DATA_CYCLE_VALID : INTEGER := 2; |
|
|||
60 |
|
||||
61 | -- GEN OutPut Enable |
|
|||
62 | TYPE FSM_GEN_OEn_state IS (IDLE, GEN_OE, WAIT_CYCLE); |
|
|||
63 | SIGNAL state_GEN_OEn : FSM_GEN_OEn_state; |
|
|||
64 | SIGNAL ADC_current : INTEGER RANGE 0 TO ChanelCount-1; |
|
|||
65 | SIGNAL ADC_current_cycle_enabled : INTEGER RANGE 0 TO OE_NB_CYCLE_ENABLED + 1 ; |
|
|||
66 | SIGNAL ADC_data_valid : STD_LOGIC; |
|
|||
67 | SIGNAL ADC_data_valid_s : STD_LOGIC; |
|
|||
68 | SIGNAL ADC_data_reg : Samples14; |
|
|||
69 | ----------------------------------------------------------------------------- |
|
|||
70 | CONSTANT SAMPLE_DIVISION : INTEGER := 10; |
|
|||
71 | SIGNAL sample_val_s : STD_LOGIC; |
|
|||
72 | SIGNAL sample_val_s2 : STD_LOGIC; |
|
|||
73 | SIGNAL sample_val_counter : INTEGER RANGE 0 TO SAMPLE_DIVISION; |
|
|||
74 | BEGIN |
|
56 | BEGIN | |
75 |
|
57 | |||
76 |
|
58 | |||
@@ -85,7 +67,7 BEGIN | |||||
85 | ELSIF cnv_clk'EVENT AND cnv_clk = '1' THEN -- rising clock edge |
|
67 | ELSIF cnv_clk'EVENT AND cnv_clk = '1' THEN -- rising clock edge | |
86 | IF cnv_cycle_counter < ncycle_cnv-1 THEN |
|
68 | IF cnv_cycle_counter < ncycle_cnv-1 THEN | |
87 | cnv_cycle_counter <= cnv_cycle_counter + 1; |
|
69 | cnv_cycle_counter <= cnv_cycle_counter + 1; | |
88 |
IF cnv_cycle_counter < ncycle_cnv_high |
|
70 | IF cnv_cycle_counter < ncycle_cnv_high THEN | |
89 | cnv_s <= '1'; |
|
71 | cnv_s <= '1'; | |
90 | ELSE |
|
72 | ELSE | |
91 | cnv_s <= '0'; |
|
73 | cnv_s <= '0'; | |
@@ -122,167 +104,111 BEGIN | |||||
122 | A => cnv_s_reg, |
|
104 | A => cnv_s_reg, | |
123 | A_sync => cnv_sync); |
|
105 | A_sync => cnv_sync); | |
124 |
|
106 | |||
|
107 | ||||
125 | ----------------------------------------------------------------------------- |
|
108 | ----------------------------------------------------------------------------- | |
126 | -- |
|
109 | -- DATA GEN Output Enable | |
127 | ----------------------------------------------------------------------------- |
|
110 | ----------------------------------------------------------------------------- | |
128 | PROCESS (clk, rstn) |
|
111 | PROCESS (clk, rstn) | |
129 | BEGIN -- PROCESS |
|
112 | BEGIN -- PROCESS | |
130 | IF rstn = '0' THEN -- asynchronous reset (active low) |
|
113 | IF rstn = '0' THEN -- asynchronous reset (active low) | |
131 | cnv_sync_reg <= '0'; |
|
114 | ADC_nOE_reg(ChanelCount-1 DOWNTO 0) <= (OTHERS => '1'); | |
|
115 | cnv_sync_pre <= '0'; | |||
|
116 | enable_ADC <= '0'; | |||
132 | ELSIF clk'event AND clk = '1' THEN -- rising clock edge |
|
117 | ELSIF clk'event AND clk = '1' THEN -- rising clock edge | |
133 |
cnv_sync_ |
|
118 | cnv_sync_pre <= cnv_sync; | |
134 | END IF; |
|
119 | IF cnv_sync = '1' AND cnv_sync_pre = '0' THEN | |
135 | END PROCESS; |
|
120 | enable_ADC <= '1'; | |
136 |
|
121 | ADC_nOE_reg(0) <= '0'; | ||
137 | cnv_sync_falling <= '1' WHEN cnv_sync = '0' AND cnv_sync_reg = '1' ELSE '0'; |
|
122 | ADC_nOE_reg(ChanelCount-1 DOWNTO 1) <= (OTHERS => '1'); | |
138 |
|
||||
139 | ----------------------------------------------------------------------------- |
|
|||
140 | -- GEN OutPut Enable |
|
|||
141 | ----------------------------------------------------------------------------- |
|
|||
142 | PROCESS (clk, rstn) |
|
|||
143 | BEGIN -- PROCESS |
|
|||
144 | IF rstn = '0' THEN |
|
|||
145 | ------------------------------------------------------------------------- |
|
|||
146 | ADC_nOE <= (OTHERS => '1'); |
|
|||
147 | ADC_current <= 0; |
|
|||
148 | ADC_current_cycle_enabled <= 0; |
|
|||
149 | state_GEN_OEn <= IDLE; |
|
|||
150 | ------------------------------------------------------------------------- |
|
|||
151 | ADC_data_reg <= (OTHERS => '0'); |
|
|||
152 | all_channel_sample_reg_init: FOR I IN 0 TO ChanelCount-1 LOOP |
|
|||
153 | sample_reg(I) <= (OTHERS => '0'); |
|
|||
154 | sample(I) <= (OTHERS => '0'); |
|
|||
155 | END LOOP all_channel_sample_reg_init; |
|
|||
156 | sample_val <= '0'; |
|
|||
157 | sample_val_s <= '0'; |
|
|||
158 | sample_val_counter <= 0; |
|
|||
159 | ------------------------------------------------------------------------- |
|
|||
160 | ELSIF clk'event AND clk = '1' THEN |
|
|||
161 | ------------------------------------------------------------------------- |
|
|||
162 | sample_val_s <= '0'; |
|
|||
163 | ADC_nOE <= (OTHERS => '1'); |
|
|||
164 | CASE state_GEN_OEn IS |
|
|||
165 | WHEN IDLE => |
|
|||
166 | IF cnv_sync_falling = '1' THEN |
|
|||
167 | --ADC_nOE(0) <= '1'; |
|
|||
168 | state_GEN_OEn <= GEN_OE; |
|
|||
169 | ADC_current <= 0; |
|
|||
170 | ADC_current_cycle_enabled <= 1; |
|
|||
171 | END IF; |
|
|||
172 |
|
||||
173 | WHEN GEN_OE => |
|
|||
174 | ADC_nOE(ADC_current) <= '0'; |
|
|||
175 |
|
||||
176 | ADC_current_cycle_enabled <= ADC_current_cycle_enabled + 1; |
|
|||
177 |
|
||||
178 | IF ADC_current_cycle_enabled = OE_NB_CYCLE_ENABLED THEN |
|
|||
179 | state_GEN_OEn <= WAIT_CYCLE; |
|
|||
180 | END IF; |
|
|||
181 |
|
||||
182 | WHEN WAIT_CYCLE => |
|
|||
183 | ADC_current_cycle_enabled <= 1; |
|
|||
184 | IF ADC_current = ChanelCount-1 THEN |
|
|||
185 | state_GEN_OEn <= IDLE; |
|
|||
186 | sample_val_s <= '1'; |
|
|||
187 |
|
|
123 | ELSE | |
188 | ADC_current <= ADC_current + 1; |
|
124 | enable_ADC <= NOT enable_ADC; | |
189 | state_GEN_OEn <= GEN_OE; |
|
125 | IF enable_ADC = '0' THEN | |
190 | END IF; |
|
126 | ADC_nOE_reg(ChanelCount-1 DOWNTO 0) <= ADC_nOE_reg(ChanelCount-2 DOWNTO 0) & '1'; | |
191 | WHEN OTHERS => NULL; |
|
|||
192 | END CASE; |
|
|||
193 | ------------------------------------------------------------------------- |
|
|||
194 | ADC_data_reg <= ADC_data; |
|
|||
195 |
|
||||
196 | all_channel_sample_reg: FOR I IN 0 TO ChanelCount-1 LOOP |
|
|||
197 | IF ADC_data_valid = '1' AND ADC_current = I THEN |
|
|||
198 | sample_reg(I) <= ADC_data_result(14 DOWNTO 1); |
|
|||
199 | ELSE |
|
|||
200 | sample_reg(I) <= sample_reg(I); |
|
|||
201 | END IF; |
|
|||
202 | END LOOP all_channel_sample_reg; |
|
|||
203 | ------------------------------------------------------------------------- |
|
|||
204 | sample_val <= '0'; |
|
|||
205 | IF sample_val_s2 = '1' THEN |
|
|||
206 | IF sample_val_counter = SAMPLE_DIVISION-1 THEN |
|
|||
207 | sample_val_counter <= 0; |
|
|||
208 | sample_val <= '1'; -- TODO |
|
|||
209 | sample <= sample_reg; |
|
|||
210 | ELSE |
|
|||
211 | sample_val_counter <= sample_val_counter + 1; |
|
|||
212 | sample_val <= '0'; |
|
|||
213 |
END IF; |
|
127 | END IF; | |
214 | END IF; |
|
128 | END IF; | |
215 |
|
129 | |||
216 | END IF; |
|
130 | END IF; | |
217 | END PROCESS; |
|
131 | END PROCESS; | |
218 |
|
132 | |||
219 |
|
133 | ADC_nOE <= (OTHERS => '1') WHEN enable_ADC = '0' ELSE ADC_nOE_reg; | ||
220 |
|
134 | |||
221 | REG_ADC_DATA_valid: IF DATA_CYCLE_VALID = OE_NB_CYCLE_ENABLED GENERATE |
|
135 | ----------------------------------------------------------------------------- | |
222 | ADC_data_valid_s <= '1' WHEN ADC_current_cycle_enabled = DATA_CYCLE_VALID + 1 ELSE '0'; |
|
136 | -- ADC READ DATA | |
223 |
|
137 | ----------------------------------------------------------------------------- | ||
224 |
|
|
138 | PROCESS (clk, rstn) | |
225 |
|
|
139 | BEGIN -- PROCESS | |
226 |
|
|
140 | IF rstn = '0' THEN -- asynchronous reset (active low) | |
227 | ADC_data_valid <= '0'; |
|
141 | channel_counter <= MAX_COUNTER; | |
228 | sample_val_s2 <= '0'; |
|
142 | ||
|
143 | all_sample_reg_init: FOR I IN ChanelCount-1 DOWNTO 0 LOOP | |||
|
144 | sample_reg(I) <= (OTHERS => '0'); | |||
|
145 | END LOOP all_sample_reg_init; | |||
|
146 | ||||
|
147 | sample_val <= '0'; | |||
|
148 | sample_counter <= 0; | |||
229 |
|
|
149 | ELSIF clk'event AND clk = '1' THEN -- rising clock edge | |
230 | ADC_data_valid <= ADC_data_valid_s; |
|
150 | IF cnv_sync = '1' AND cnv_sync_pre = '0' THEN | |
231 | sample_val_s2 <= sample_val_s; |
|
151 | channel_counter <= 0; | |
|
152 | ELSE | |||
|
153 | IF channel_counter < MAX_COUNTER THEN | |||
|
154 | channel_counter <= channel_counter + 1; | |||
|
155 | END IF; | |||
|
156 | END IF; | |||
|
157 | sample_val <= '0'; | |||
|
158 | ||||
|
159 | all_sample_reg: FOR I IN ChanelCount-1 DOWNTO 0 LOOP | |||
|
160 | IF channel_counter = I*2 THEN | |||
|
161 | IF FILTER_ENABLED_STDLOGIC(I) = '1' THEN | |||
|
162 | sample_reg(I) <= ADC_data_result(14 DOWNTO 1); | |||
|
163 | ELSE | |||
|
164 | sample_reg(I) <= ADC_data; | |||
|
165 | END IF; | |||
|
166 | END IF; | |||
|
167 | END LOOP all_sample_reg; | |||
|
168 | ||||
|
169 | IF channel_counter = (ChanelCount-1)*2 THEN | |||
|
170 | ||||
|
171 | IF sample_counter = MAX_SAMPLE_COUNTER THEN | |||
|
172 | sample_counter <= 0 ; | |||
|
173 | sample_val <= '1'; | |||
|
174 | ELSE | |||
|
175 | sample_counter <= sample_counter +1; | |||
|
176 | END IF; | |||
|
177 | ||||
|
178 | END IF; | |||
232 |
|
|
179 | END IF; | |
233 |
|
|
180 | END PROCESS; | |
234 |
|
181 | |||
235 | END GENERATE REG_ADC_DATA_valid; |
|
182 | -- mux_adc: PROCESS (sample_reg)-- (channel_counter, sample_reg) | |
236 |
|
183 | -- BEGIN -- PROCESS mux_adc | ||
237 | noREG_ADC_DATA_valid: IF DATA_CYCLE_VALID < OE_NB_CYCLE_ENABLED GENERATE |
|
184 | -- CASE channel_counter IS | |
238 | ADC_data_valid_s <= '1' WHEN ADC_current_cycle_enabled = DATA_CYCLE_VALID + 1 ELSE '0'; |
|
185 | -- WHEN OTHERS => ADC_data_selected <= sample_reg(channel_counter/2); | |
239 |
|
186 | -- END CASE; | ||
240 | ADC_data_valid <= ADC_data_valid_s; |
|
187 | -- END PROCESS mux_adc; | |
241 | sample_val_s2 <= sample_val_s; |
|
|||
242 | END GENERATE noREG_ADC_DATA_valid; |
|
|||
243 |
|
||||
244 | REGm_ADC_DATA_valid: IF DATA_CYCLE_VALID > OE_NB_CYCLE_ENABLED GENERATE |
|
|||
245 |
|
||||
246 | ADC_data_valid_s <= '1' WHEN ADC_current_cycle_enabled = OE_NB_CYCLE_ENABLED + 1 ELSE '0'; |
|
|||
247 |
|
||||
248 | REG_1: SYNC_FF |
|
|||
249 | GENERIC MAP ( |
|
|||
250 | NB_FF_OF_SYNC => DATA_CYCLE_VALID-OE_NB_CYCLE_ENABLED+1) |
|
|||
251 | PORT MAP ( |
|
|||
252 | clk => clk, |
|
|||
253 | rstn => rstn, |
|
|||
254 | A => ADC_data_valid_s, |
|
|||
255 | A_sync => ADC_data_valid); |
|
|||
256 |
|
||||
257 | REG_2: SYNC_FF |
|
|||
258 | GENERIC MAP ( |
|
|||
259 | NB_FF_OF_SYNC => DATA_CYCLE_VALID-OE_NB_CYCLE_ENABLED+1) |
|
|||
260 | PORT MAP ( |
|
|||
261 | clk => clk, |
|
|||
262 | rstn => rstn, |
|
|||
263 | A => sample_val_s, |
|
|||
264 | A_sync => sample_val_s2); |
|
|||
265 | END GENERATE REGm_ADC_DATA_valid; |
|
|||
266 |
|
188 | |||
267 |
|
189 | |||
|
190 | ----------------------------------------------------------------------------- | |||
|
191 | -- \/\/\/\/\/\/\/ TODO : this part is not GENERIC !!! \/\/\/\/\/\/\/ | |||
|
192 | ----------------------------------------------------------------------------- | |||
268 |
|
193 | |||
269 |
WITH |
|
194 | WITH channel_counter SELECT | |
270 | ADC_data_selected <= sample_reg(0) WHEN 0, |
|
195 | ADC_data_selected <= sample_reg(0) WHEN 0*2, | |
271 | sample_reg(1) WHEN 1, |
|
196 | sample_reg(1) WHEN 1*2, | |
272 | sample_reg(2) WHEN 2, |
|
197 | sample_reg(2) WHEN 2*2, | |
273 | sample_reg(3) WHEN 3, |
|
198 | sample_reg(3) WHEN 3*2, | |
274 | sample_reg(4) WHEN 4, |
|
199 | sample_reg(4) WHEN 4*2, | |
275 | sample_reg(5) WHEN 5, |
|
200 | sample_reg(5) WHEN 5*2, | |
276 | sample_reg(6) WHEN 6, |
|
201 | sample_reg(6) WHEN 6*2, | |
277 | sample_reg(7) WHEN 7, |
|
202 | sample_reg(7) WHEN 7*2, | |
278 | sample_reg(8) WHEN OTHERS ; |
|
203 | sample_reg(8) WHEN OTHERS ; | |
279 |
|
204 | |||
280 | ADC_data_result <= std_logic_vector(( |
|
205 | ----------------------------------------------------------------------------- | |
281 | signed( ADC_data_selected(13) & ADC_data_selected) + |
|
206 | -- /\/\/\/\/\/\/\ ----------------------------------- /\/\/\/\/\/\/\ | |
282 | signed( ADC_data_reg(13) & ADC_data_reg) |
|
207 | ----------------------------------------------------------------------------- | |
283 | )); |
|
|||
284 |
|
208 | |||
285 | -- sample <= sample_reg; |
|
209 | ADC_data_result <= std_logic_vector( (signed( ADC_data_selected(13) & ADC_data_selected) + signed( ADC_data(13) & ADC_data)) ); | |
|
210 | ||||
|
211 | sample <= sample_reg; | |||
286 |
|
212 | |||
287 | END ar_top_ad_conv_RHF1401; |
|
213 | END ar_top_ad_conv_RHF1401; | |
288 |
|
214 | |||
@@ -299,3 +225,4 END ar_top_ad_conv_RHF1401; | |||||
299 |
|
225 | |||
300 |
|
226 | |||
301 |
|
227 | |||
|
228 |
General Comments 0
You need to be logged in to leave comments.
Login now