@@ -391,7 +391,7 BEGIN -- beh | |||
|
391 | 391 | pirq_ms => 6, |
|
392 | 392 | pirq_wfp => 14, |
|
393 | 393 | hindex => 2, |
|
394 |
top_lfr_version => X"01013 |
|
|
394 | top_lfr_version => X"01013C") -- aa.bb.cc version | |
|
395 | 395 | -- AA : BOARD NUMBER |
|
396 | 396 | -- 0 => MINI_LFR |
|
397 | 397 | -- 1 => EM |
@@ -59,10 +59,10 ENTITY apb_lfr_management IS | |||
|
59 | 59 | HK_val : IN STD_LOGIC; |
|
60 | 60 | HK_sel : OUT STD_LOGIC_VECTOR(1 DOWNTO 0); |
|
61 | 61 | --------------------------------------------------------------------------- |
|
62 | DAC_SDO : OUT STD_LOGIC; | |
|
63 | DAC_SCK : OUT STD_LOGIC; | |
|
64 | DAC_SYNC : OUT STD_LOGIC; | |
|
65 | DAC_CAL_EN : OUT STD_LOGIC; | |
|
62 | DAC_SDO : OUT STD_LOGIC; | |
|
63 | DAC_SCK : OUT STD_LOGIC; | |
|
64 | DAC_SYNC : OUT STD_LOGIC; | |
|
65 | DAC_CAL_EN : OUT STD_LOGIC; | |
|
66 | 66 | --------------------------------------------------------------------------- |
|
67 | 67 | coarse_time : OUT STD_LOGIC_VECTOR(31 DOWNTO 0); --! coarse time |
|
68 | 68 | fine_time : OUT STD_LOGIC_VECTOR(15 DOWNTO 0); --! fine TIME |
@@ -127,18 +127,18 ARCHITECTURE Behavioral OF apb_lfr_manag | |||
|
127 | 127 | SIGNAL HK_sel_s : STD_LOGIC_VECTOR(1 DOWNTO 0); |
|
128 | 128 | |
|
129 | 129 | SIGNAL previous_fine_time_bit : STD_LOGIC; |
|
130 | ||
|
130 | ||
|
131 | 131 | SIGNAL rstn_LFR_TM : STD_LOGIC; |
|
132 | 132 | |
|
133 | 133 | ----------------------------------------------------------------------------- |
|
134 | 134 | -- DAC |
|
135 | 135 | ----------------------------------------------------------------------------- |
|
136 |
CONSTANT |
|
|
137 |
CONSTANT |
|
|
138 |
CONSTANT |
|
|
139 |
CONSTANT |
|
|
140 |
CONSTANT |
|
|
141 | ||
|
136 | CONSTANT PRESZ : INTEGER := 8; | |
|
137 | CONSTANT CPTSZ : INTEGER := 16; | |
|
138 | CONSTANT datawidth : INTEGER := 18; | |
|
139 | CONSTANT dacresolution : INTEGER := 12; | |
|
140 | CONSTANT abits : INTEGER := 8; | |
|
141 | ||
|
142 | 142 | SIGNAL pre : STD_LOGIC_VECTOR(PRESZ-1 DOWNTO 0); |
|
143 | 143 | SIGNAL N : STD_LOGIC_VECTOR(CPTSZ-1 DOWNTO 0); |
|
144 | 144 | SIGNAL Reload : STD_LOGIC; |
@@ -151,6 +151,9 ARCHITECTURE Behavioral OF apb_lfr_manag | |||
|
151 | 151 | SIGNAL DAC_CFG : STD_LOGIC_VECTOR(3 DOWNTO 0); |
|
152 | 152 | SIGNAL DAC_CAL_EN_s : STD_LOGIC; |
|
153 | 153 | |
|
154 | SIGNAL HK_debug_mode : STD_LOGIC; | |
|
155 | SIGNAL HK_sel_debug : STD_LOGIC_VECTOR(1 DOWNTO 0); | |
|
156 | ||
|
154 | 157 | BEGIN |
|
155 | 158 | |
|
156 | 159 | LFR_soft_rstn <= NOT r.LFR_soft_reset; |
@@ -172,17 +175,17 BEGIN | |||
|
172 | 175 | |
|
173 | 176 | coarsetime_reg_updated <= '0'; |
|
174 | 177 | --DAC |
|
175 | pre <= (OTHERS => '1'); | |
|
176 | N <= (OTHERS => '1'); | |
|
177 | Reload <= '1'; | |
|
178 | DATA_IN <= (OTHERS => '0'); | |
|
179 | WEN <= '1'; | |
|
180 | LOAD_ADDRESSN <= '1'; | |
|
181 | ADDRESS_IN <= (OTHERS => '1'); | |
|
182 | INTERLEAVED <= '0'; | |
|
183 | DAC_CFG <= (OTHERS => '0'); | |
|
178 | pre <= (OTHERS => '1'); | |
|
179 | N <= (OTHERS => '1'); | |
|
180 | Reload <= '1'; | |
|
181 | DATA_IN <= (OTHERS => '0'); | |
|
182 | WEN <= '1'; | |
|
183 | LOAD_ADDRESSN <= '1'; | |
|
184 | ADDRESS_IN <= (OTHERS => '1'); | |
|
185 | INTERLEAVED <= '0'; | |
|
186 | DAC_CFG <= (OTHERS => '0'); | |
|
184 | 187 | -- |
|
185 | DAC_CAL_EN_s <= '0'; | |
|
188 | DAC_CAL_EN_s <= '0'; | |
|
186 | 189 | ELSIF clk25MHz'EVENT AND clk25MHz = '1' THEN |
|
187 | 190 | coarsetime_reg_updated <= '0'; |
|
188 | 191 | |
@@ -214,7 +217,9 BEGIN | |||
|
214 | 217 | Rdata(0) <= r.ctrl; |
|
215 | 218 | Rdata(1) <= r.soft_reset; |
|
216 | 219 | Rdata(2) <= r.LFR_soft_reset; |
|
217 | Rdata(31 DOWNTO 3) <= (OTHERS => '0'); | |
|
220 | Rdata(3) <= HK_debug_mode; | |
|
221 | Rdata(5 DOWNTO 4) <= HK_sel_debug; | |
|
222 | Rdata(31 DOWNTO 6) <= (OTHERS => '0'); | |
|
218 | 223 | WHEN ADDR_LFR_MANAGMENT_TIME_LOAD => |
|
219 | 224 | Rdata(30 DOWNTO 0) <= r.coarse_time_load(30 DOWNTO 0); |
|
220 | 225 | WHEN ADDR_LFR_MANAGMENT_TIME_COARSE => |
@@ -252,7 +257,7 BEGIN | |||
|
252 | 257 | WHEN OTHERS => |
|
253 | 258 | Rdata(31 DOWNTO 0) <= (OTHERS => '0'); |
|
254 | 259 | END CASE; |
|
255 | ||
|
260 | ||
|
256 | 261 | --APB Write OP |
|
257 | 262 | IF (apbi.pwrite AND apbi.penable) = '1' THEN |
|
258 | 263 | CASE paddr(7 DOWNTO 2) IS |
@@ -260,24 +265,26 BEGIN | |||
|
260 | 265 | r.ctrl <= apbi.pwdata(0); |
|
261 | 266 | r.soft_reset <= apbi.pwdata(1); |
|
262 | 267 | r.LFR_soft_reset <= apbi.pwdata(2); |
|
268 | HK_debug_mode <= apbi.pwdata(3); | |
|
269 | HK_sel_debug <= apbi.pwdata(5 DOWNTO 4); | |
|
263 | 270 | WHEN ADDR_LFR_MANAGMENT_TIME_LOAD => |
|
264 | 271 | r.coarse_time_load <= apbi.pwdata(30 DOWNTO 0); |
|
265 | 272 | coarsetime_reg_updated <= '1'; |
|
266 | WHEN ADDR_LFR_MANAGMENT_DAC_CONTROL => | |
|
267 | DAC_CFG <= apbi.pwdata(3 DOWNTO 0); | |
|
268 | Reload <= apbi.pwdata(4); | |
|
269 | INTERLEAVED <= apbi.pwdata(5); | |
|
270 | DAC_CAL_EN_s <= apbi.pwdata(6); | |
|
271 | WHEN ADDR_LFR_MANAGMENT_DAC_PRE => | |
|
272 | pre <= apbi.pwdata(PRESZ-1 DOWNTO 0); | |
|
273 | WHEN ADDR_LFR_MANAGMENT_DAC_N => | |
|
274 | N <= apbi.pwdata(CPTSZ-1 DOWNTO 0); | |
|
275 | WHEN ADDR_LFR_MANAGMENT_DAC_ADDRESS_OUT => | |
|
276 | ADDRESS_IN <= apbi.pwdata(abits-1 DOWNTO 0); | |
|
277 | LOAD_ADDRESSN <= '0'; | |
|
278 | WHEN ADDR_LFR_MANAGMENT_DAC_DATA_IN => | |
|
279 | DATA_IN <= apbi.pwdata(datawidth-1 DOWNTO 0); | |
|
280 | WEN <= '0'; | |
|
273 | WHEN ADDR_LFR_MANAGMENT_DAC_CONTROL => | |
|
274 | DAC_CFG <= apbi.pwdata(3 DOWNTO 0); | |
|
275 | Reload <= apbi.pwdata(4); | |
|
276 | INTERLEAVED <= apbi.pwdata(5); | |
|
277 | DAC_CAL_EN_s <= apbi.pwdata(6); | |
|
278 | WHEN ADDR_LFR_MANAGMENT_DAC_PRE => | |
|
279 | pre <= apbi.pwdata(PRESZ-1 DOWNTO 0); | |
|
280 | WHEN ADDR_LFR_MANAGMENT_DAC_N => | |
|
281 | N <= apbi.pwdata(CPTSZ-1 DOWNTO 0); | |
|
282 | WHEN ADDR_LFR_MANAGMENT_DAC_ADDRESS_OUT => | |
|
283 | ADDRESS_IN <= apbi.pwdata(abits-1 DOWNTO 0); | |
|
284 | LOAD_ADDRESSN <= '0'; | |
|
285 | WHEN ADDR_LFR_MANAGMENT_DAC_DATA_IN => | |
|
286 | DATA_IN <= apbi.pwdata(datawidth-1 DOWNTO 0); | |
|
287 | WEN <= '0'; | |
|
281 | 288 | |
|
282 | 289 | WHEN OTHERS => |
|
283 | 290 | NULL; |
@@ -440,7 +447,6 BEGIN | |||
|
440 | 447 | -- for 14, the update frequency is |
|
441 | 448 | -- 4Hz and update for each |
|
442 | 449 | -- HK is 1.33Hz |
|
443 | ||
|
444 | 450 | BEGIN -- PROCESS |
|
445 | 451 | IF resetn = '0' THEN -- asynchronous reset (active low) |
|
446 | 452 | |
@@ -458,9 +464,27 BEGIN | |||
|
458 | 464 | IF previous_fine_time_bit = NOT(fine_time_s(BIT_FREQUENCY_UPDATE)) THEN |
|
459 | 465 | previous_fine_time_bit <= fine_time_s(BIT_FREQUENCY_UPDATE); |
|
460 | 466 | CASE HK_sel_s IS |
|
461 | WHEN "00" => r.HK_temp_0 <= HK_sample; HK_sel_s <= "01"; | |
|
462 |
|
|
|
463 | WHEN "10" => r.HK_temp_2 <= HK_sample; HK_sel_s <= "00"; | |
|
467 | WHEN "00" => | |
|
468 | r.HK_temp_0 <= HK_sample; | |
|
469 | IF HK_debug_mode = '1' THEN | |
|
470 | HK_sel_s <= HK_sel_debug; | |
|
471 | ELSE | |
|
472 | HK_sel_s <= "01"; | |
|
473 | END IF; | |
|
474 | WHEN "01" => | |
|
475 | r.HK_temp_1 <= HK_sample; | |
|
476 | IF HK_debug_mode = '1' THEN | |
|
477 | HK_sel_s <= HK_sel_debug; | |
|
478 | ELSE | |
|
479 | HK_sel_s <= "10"; | |
|
480 | END IF; | |
|
481 | WHEN "10" => | |
|
482 | r.HK_temp_2 <= HK_sample; | |
|
483 | IF HK_debug_mode = '1' THEN | |
|
484 | HK_sel_s <= HK_sel_debug; | |
|
485 | ELSE | |
|
486 | HK_sel_s <= "00"; | |
|
487 | END IF; | |
|
464 | 488 | WHEN OTHERS => NULL; |
|
465 | 489 | END CASE; |
|
466 | 490 | END IF; |
@@ -483,9 +507,9 BEGIN | |||
|
483 | 507 | abits => abits |
|
484 | 508 | ) |
|
485 | 509 | PORT MAP( |
|
486 |
clk |
|
|
487 |
rstn |
|
|
488 | ||
|
510 | clk => clk25MHz, | |
|
511 | rstn => resetn, | |
|
512 | ||
|
489 | 513 | pre => pre, |
|
490 | 514 | N => N, |
|
491 | 515 | Reload => Reload, |
@@ -496,12 +520,12 BEGIN | |||
|
496 | 520 | ADDRESS_OUT => ADDRESS_OUT, |
|
497 | 521 | INTERLEAVED => INTERLEAVED, |
|
498 | 522 | DAC_CFG => DAC_CFG, |
|
499 | ||
|
500 |
SYNC |
|
|
501 |
DOUT |
|
|
502 |
SCLK |
|
|
503 |
SMPCLK |
|
|
523 | ||
|
524 | SYNC => DAC_SYNC, | |
|
525 | DOUT => DAC_SDO, | |
|
526 | SCLK => DAC_SCK, | |
|
527 | SMPCLK => OPEN --DAC_SMPCLK | |
|
504 | 528 | ); |
|
505 | 529 | |
|
506 | 530 | DAC_CAL_EN <= DAC_CAL_EN_s; |
|
507 | END Behavioral; No newline at end of file | |
|
531 | END Behavioral; |
General Comments 0
You need to be logged in to leave comments.
Login now