]> jspc29.x-matter.uni-frankfurt.de Git - trb3.git/commitdiff
Use gray counter for CDC
authorAndreas Neiser <neiser@kph.uni-mainz.de>
Thu, 5 Mar 2015 12:31:38 +0000 (13:31 +0100)
committerAndreas Neiser <neiser@kph.uni-mainz.de>
Sat, 13 Jun 2015 15:37:02 +0000 (17:37 +0200)
ADC/source/adc_processor_cfd.vhd

index 6e14855e0acbb7a65c870f62c4978429a9f3dcd0..d1ad16d38cc1084483a126b9c05982c8bd00d291 100644 (file)
@@ -67,6 +67,8 @@ architecture arch of adc_processor_cfd is
   
   type epoch_counter_t is array(CHANNELS - 1 downto 0) of unsigned(23 downto 0);
   signal epoch_counter, epoch_counter_save : epoch_counter_t;
+  signal epoch_counter_sys, epoch_counter_adc : epoch_counter_t;
+  
   
   signal trigger_delay : unsigned(11 downto 0);
 begin
@@ -81,7 +83,11 @@ begin
   busy_out_sys <= busy_out_adc when rising_edge(CLK_SYS);
   gen_cfd : for i in 0 to CHANNELS - 1 generate
     trigger_gen(i) <= debug_sys(i).Trigger;
-    epoch_counter(i) <= debug_adc(i).EpochCounter when rising_edge(CLK_SYS);
+        
+    -- first convert to gray counting, then do clock domain crossing 
+    epoch_counter_adc(i) <= debug_adc(i).EpochCounter xor shift_right(debug_adc(i).EpochCounter,1);
+    epoch_counter_sys(i) <= epoch_counter_adc(i) when rising_edge(CLK_SYS);
+    epoch_counter(i) <= epoch_counter_sys(i); -- no back conversion to binary for now  
     
     THE_CFD : entity work.adc_processor_cfd_ch
       generic map(