-
Notifications
You must be signed in to change notification settings - Fork 0
/
top.vhd
2441 lines (2014 loc) · 85.8 KB
/
top.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-------------------------------------------------------------------------------
-- Title : Zynq RFBPM Top
-------------------------------------------------------------------------------
-- File : top.vhd
-- Author : Joseph Mead [email protected]
-- Created : 5/5/2016
-------------------------------------------------------------------------------
-- Description:
-- Provides the logic for RFBPM DFE board
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- K.Ha kha@ bnl.gov
--
--
--
-- I2C connections for power management.
--
--
--
-- Data PSM_SDA_FPGA connect to PS_MIO35_501_G21
-- Clock PSM_SCL_FPGA connect to PS_MIO34_501_K18
--
--
-- 07/14/17
-- TBT x, y signal changed
--
-- 07/18/17
-- added tbt/fa HS current address
-- added tbt/fa burst enable status
--
-- 08/01/17
-- added tbt_irq and fa_irq
--
-- 08/22/17
-- added 2nd gate and PT hi/lo processing blocks
--
-- 08/24/17
-- dsp_ctrl2 added for gate2 control
--
-- 08/25/17
-- gate2 tbt/fa a,b,c,d added to hp port
--
-- 09/19/17
-- ADC button A and D swapped.
--
-- 09/19/17
-- XADC Wizard added
--
-- 09/22/17
-- PT lo lookup table used Dual port RAM for programable sin/cos
-- 09/26/17
-- Added PT LO band pass filter enable/disable
-- 09/28/17
-- Added PT LO SA phase values
-- Added Button SA phase readout
--
-- 10/02/17
-- Added PT 502.897670180000e+006 33.5012749800000e+006 % default operation
-- Added button mag * ptgain
--
-- 10/05/17
-- Added mix output I&Q, CHA and CHB
-- Added PT count monitoring from ADC waveform
--
-- 10/06/17
-- tbt_wfm_a, b, c, d for PT LOW TBT waveform readadcs
--
--
--
library IEEE;
use IEEE.std_logic_1164.ALL;
--use IEEE.numeric_std.ALL;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
library UNISIM;
use UNISIM.VCOMPONENTS.ALL;
library work;
use work.bpm_package.ALL;
entity top is
generic(
--FPGA_VERSION : integer := 91917;
--FPGA_VERSION : integer := 92217;
--FPGA_VERSION : integer := 92617;
--FPGA_VERSION : integer := 92817;
--FPGA_VERSION : integer := 100217;
--FPGA_VERSION : integer := 100517;
FPGA_VERSION : integer := 100617;
VIVADO_VERSION : integer := 20164;
SIM_MODE : integer := 0;
SDI_ENABLE : integer := 0 -- SDI communication module
);
port (
ddr_addr : inout std_logic_vector ( 14 downto 0 );
ddr_ba : inout std_logic_vector ( 2 downto 0 );
ddr_cas_n : inout std_logic;
ddr_ck_n : inout std_logic;
ddr_ck_p : inout std_logic;
ddr_cke : inout std_logic;
ddr_cs_n : inout std_logic;
ddr_dm : inout std_logic_vector ( 3 downto 0 );
ddr_dq : inout std_logic_vector ( 31 downto 0 );
ddr_dqs_n : inout std_logic_vector ( 3 downto 0 );
ddr_dqs_p : inout std_logic_vector ( 3 downto 0 );
ddr_odt : inout std_logic;
ddr_ras_n : inout std_logic;
ddr_reset_n : inout std_logic;
ddr_we_n : inout std_logic;
fixed_io_ddr_vrn : inout std_logic;
fixed_io_ddr_vrp : inout std_logic;
fixed_io_mio : inout std_logic_vector ( 53 downto 0 );
fixed_io_ps_clk : inout std_logic;
fixed_io_ps_porb : inout std_logic;
fixed_io_ps_srstb : inout std_logic;
--adc inputs
adc_clk_p : in std_logic;
adc_clk_n : in std_logic;
adc0_clk_p : in std_logic;
adc0_clk_n : in std_logic;
adc0_data_p : in std_logic_vector(15 downto 0);
adc0_data_n : in std_logic_vector(15 downto 0);
adc0_ovr_p : in std_logic;
adc0_ovr_n : in std_logic;
adc1_clk_p : in std_logic;
adc1_clk_n : in std_logic;
adc1_data_p : in std_logic_vector(15 downto 0);
adc1_data_n : in std_logic_vector(15 downto 0);
adc1_ovr_p : in std_logic;
adc1_ovr_n : in std_logic;
adc2_clk_p : in std_logic;
adc2_clk_n : in std_logic;
adc2_data_p : in std_logic_vector(15 downto 0);
adc2_data_n : in std_logic_vector(15 downto 0);
adc2_ovr_p : in std_logic;
adc2_ovr_n : in std_logic;
adc3_clk_p : in std_logic;
adc3_clk_n : in std_logic;
adc3_data_p : in std_logic_vector(15 downto 0);
adc3_data_n : in std_logic_vector(15 downto 0);
adc3_ovr_p : in std_logic;
adc3_ovr_n : in std_logic;
--adc control
-- adc_rand : out std_logic;
-- adc_pga : out std_logic;
-- adc_shdn : out std_logic;
-- adc_dith : out std_logic;
-- adc clock synthesizer (AD9510)
ad9510_sclk : out std_logic;
ad9510_sdata : out std_logic;
ad9510_lat : out std_logic;
ad9510_func : out std_logic;
ad9510_status : in std_logic;
ad9510_sdo : in std_logic;
-- pilot tone synthesizer
lmx2541_spiclk : out std_logic;
lmx2541_spidata : out std_logic;
lmx2541_spistrobe : out std_logic;
lmx2541_lockdet : in std_logic;
lmx2541_spice : out std_logic;
lmx2541_rfout_en : out std_logic;
-- rf digital attenuator
dsa0_clk : out std_logic;
dsa0_sdata : out std_logic;
dsa0_latch : out std_logic;
-- pilot tone digital attenuator
dsa2_clk : out std_logic;
dsa2_sdata : out std_logic;
dsa2_latch : out std_logic;
-- tbt clock input
tbt_clk_p : in std_logic;
tbt_clk_n : in std_logic;
-- power good signal
pwr_good : in std_logic;
-- GTX for SDI --
-- gtx_refclk_p : in std_logic;
-- gtx_refclk_n : in std_logic;
-- Embedded Event Receiver
gtx_evr_refclk_p : in std_logic;
gtx_evr_refclk_n : in std_logic;
gtx_evr_rx_p : in std_logic;
gtx_evr_rx_n : in std_logic;
evr_rcvd_clk_p : out std_logic;
evr_rcvd_clk_n : out std_logic;
--si5338 i2c
si5338_i2c_sda : inout std_logic;
si5338_i2c_scl : inout std_logic;
-- sfp0_i2c_scl : inout std_logic;
-- sfp0_i2c_sda : inout std_logic;
-- iic_sdi_sfp0_scl : inout std_logic;
-- iic_sdi_sfp0_sda : inout std_logic;
-- iic_sdi_sfp1_scl : inout std_logic;
-- iic_sdi_sfp1_sda : inout std_logic;
--sfp I/O
sfp_sclk : inout std_logic_vector(5 downto 0);
sfp_sdata : inout std_logic_vector(5 downto 0);
-- front panel I/O
fp_out : out std_logic_vector(1 downto 0);
fp_in : in std_logic_vector(1 downto 0);
-- LED's
dbg_leds : out std_logic_vector(3 downto 0);
sfp_leds : out std_logic_vector(11 downto 0);
fp_leds : out std_logic_vector(7 downto 0);
-- Debug pins
--dbg : out std_logic_vector(25 downto 0);
dbg : out std_logic_vector(20 downto 0);
-- afe temperature sensors
afetemp_scl : out std_logic;
afetemp_sda : inout std_logic;
-- dfe temperature sensors
dfetemp_scl : out std_logic;
dfetemp_sda : inout std_logic
-- SYS clock input
-- sys_clk_p : in std_logic;
-- sys_clk_n : in std_logic
);
end top;
architecture behv of top is
COMPONENT trig_edge_gen
PORT(
clk : IN std_logic;
trig_in : IN std_logic;
trig_out : OUT std_logic
);
END COMPONENT;
COMPONENT trig_times
PORT(
reset : IN std_logic;
evr_clk : IN std_logic;
adc_clk : IN std_logic;
trig_in : IN std_logic;
evr_ts_in : IN std_logic_vector(63 downto 0);
trig_ts : OUT std_logic_vector(63 downto 0)
);
END COMPONENT;
component trig_sel is
port (
adc_clk : in std_logic;
reset : in std_logic;
soft_trig : in std_logic;
evr_trig : in std_logic;
fp_trig : in std_logic;
evr_soft_trig : in std_logic;
trig_sel : in std_logic_vector(1 downto 0);
trig_dly_reg : in std_logic_vector(31 downto 0);
npi_trig : out std_logic
);
end component;
COMPONENT tbt_hp_ddr
PORT(
adc_clk : IN std_logic;
rst : IN std_logic;
tbt_trig : IN std_logic;
endian_en : IN std_logic;
but_va : IN std_logic_vector(31 downto 0);
but_vb : IN std_logic_vector(31 downto 0);
but_vc : IN std_logic_vector(31 downto 0);
but_vd : IN std_logic_vector(31 downto 0);
but_xpos : IN std_logic_vector(31 downto 0);
but_ypos : IN std_logic_vector(31 downto 0);
but_sum : IN std_logic_vector(31 downto 0);
but_va2 : IN std_logic_vector(31 downto 0);
but_vb2 : IN std_logic_vector(31 downto 0);
but_vc2 : IN std_logic_vector(31 downto 0);
but_vd2 : IN std_logic_vector(31 downto 0);
ddr_data : OUT std_logic_vector(31 downto 0);
ddr_data_valid : OUT std_logic
);
END COMPONENT;
COMPONENT data2ddr_tf
PORT(
sys_clk : IN std_logic;
adc_clk : IN std_logic;
reset : IN std_logic;
trig : IN std_logic;
burst_enb : IN std_logic;
burst_len : IN std_logic_vector(31 downto 0);
testdata_en : IN std_logic;
fifo_din_32bit : IN std_logic_vector(31 downto 0);
fifo_din_valid : IN std_logic;
hs_fifo_rdcnt : OUT std_logic_vector(8 downto 0);
hs_fifo_rddata : OUT std_logic_vector(63 downto 0);
hs_fifo_empty : OUT std_logic;
hs_fifo_rden : IN std_logic;
hs_fifo_rst : IN std_logic;
hs_tx_enb : OUT std_logic;
hs_tx_active : OUT std_logic;
dbg_strobe_lat : OUT std_logic
);
END COMPONENT;
-- Verilog source
component bpm_countdatagen
port (
sysClk : in std_logic;
LtableRamInData : in std_logic_vector(31 downto 0);
phaseCnt : in std_logic_vector(9 downto 0);
Reset : in std_logic;
NCO_reset : in std_logic;
sdi_clk : in std_logic;
Trigger : in std_logic;
testMode : in std_logic_vector(3 downto 0);
maxCount : in std_logic_vector(31 downto 0);
fa_pos_x : in std_logic_vector(31 downto 0);
fa_pos_y : in std_logic_vector(31 downto 0);
DataSel : in std_logic;
wfmKx : in std_logic_vector(31 downto 0);
wfmKy : in std_logic_vector(31 downto 0);
wfmPhase_inc : in std_logic_vector(31 downto 0);
-- OUTPUT
LocalDataValid : out std_logic;
LocalCountData : out std_logic_vector(31 downto 0);
LocalBpmPosData : out std_logic_vector(31 downto 0);
RampRst : out std_logic;
fa_evr_trig : out std_logic;
TrigOut : out std_logic;
glitch_out : out std_logic;
test_bit : out std_logic;
sdi_fa_pos_x : out std_logic_vector(31 downto 0);
sdi_fa_pos_y : out std_logic_vector(31 downto 0)
);
end component;
COMPONENT ila_tbt_ddr
PORT (
clk : IN STD_LOGIC;
probe0 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
probe1 : IN STD_LOGIC_VECTOR(8 DOWNTO 0);
probe2 : IN STD_LOGIC_VECTOR(63 DOWNTO 0);
probe3 : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
probe4 : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
probe5 : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
probe6 : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
probe7 : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
probe8 : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
probe9 : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
probe10 : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
probe11 : IN STD_LOGIC_VECTOR(0 DOWNTO 0)
);
END COMPONENT ;
COMPONENT ila_adc_raw
PORT (
clk : IN STD_LOGIC;
probe0 : IN STD_LOGIC_VECTOR(15 DOWNTO 0);
probe1 : IN STD_LOGIC_VECTOR(15 DOWNTO 0);
probe2 : IN STD_LOGIC_VECTOR(15 DOWNTO 0);
probe3 : IN STD_LOGIC_VECTOR(15 DOWNTO 0)
);
END COMPONENT ;
------------------------------------------------------------
signal clk200mhz : std_logic;
signal sys_clk : std_logic;
signal sys_rst : std_logic;
signal sys_rstb : std_logic_vector(0 downto 0);
signal iobus_addr : std_logic_vector(15 downto 0);
signal iobus_cs : std_logic;
signal iobus_rnw : std_logic;
signal iobus_rddata : std_logic_vector(31 downto 0);
signal iobus_wrdata : std_logic_vector(31 downto 0);
signal iobus_leds : std_logic_vector(31 downto 0);
signal sysgen_version : std_logic_vector(31 downto 0);
signal soft_trig : std_logic;
signal hs_cntrl : std_logic_vector(7 downto 0);
signal hs_status : std_logic_vector(3 downto 0);
signal hs_burstlen : std_logic_vector(31 downto 0);
signal hs_ddrbaseaddr : std_logic_vector(31 downto 0);
signal hs_ddrcuraddr : std_logic_vector(31 downto 0);
signal hs_ddrbuflen : std_logic_vector(31 downto 0);
signal hs_throttle : std_logic_vector(31 downto 0);
signal hs_fifo_rdcnt : std_logic_vector (11 downto 0);
signal hs_fifo_rddata : std_logic_vector (63 downto 0);
signal hs_fifo_empty : std_logic;
signal hs_fifo_rden : std_logic;
signal hs_tx_enb : std_logic;
signal hs_tx_active : std_logic;
signal hs_axi_tx_active : std_logic;
signal tenhz_irq : std_logic;
signal other_irq : std_logic;
signal fa_irq : std_logic;
signal tbt_irq : std_logic;
signal lmx2541_we : std_logic;
signal lmx2541_data : std_logic_vector(31 downto 0);
signal lmx2541_rfenb : std_logic;
signal dsa0_we : std_logic;
signal dsa2_we : std_logic;
signal dsa_data : std_logic_vector(7 downto 0);
signal dsa0_debug : std_logic_vector(8 downto 0);
signal dsa0_clk_i : std_logic;
signal dsa0_sdata_i : std_logic;
signal dsa0_latch_i : std_logic;
signal dsa2_debug : std_logic_vector(8 downto 0);
--ad9510
signal ad9510_we : std_logic;
signal ad9510_data : std_logic_vector(31 downto 0);
signal ad9510_debug : std_logic_vector(8 downto 0);
signal ad9510_sclk_i : std_logic;
signal ad9510_sdata_i : std_logic;
signal ad9510_lat_i : std_logic;
signal adc_clk_stopped : std_logic;
signal adc_clk_locked : std_logic;
signal adc_fifo_wren : std_logic;
signal adc_dbg_sel : std_logic_vector(31 downto 0);
signal dds_adcsim_din : std_logic_vector(31 downto 0);
signal dds_adcsim_we : std_logic_vector(2 downto 0);
signal adc_clk : std_logic;
signal adc_sat : std_logic_vector(3 downto 0);
signal adca_raw : std_logic_vector(15 downto 0);
signal adcb_raw : std_logic_vector(15 downto 0);
signal adcc_raw : std_logic_vector(15 downto 0);
signal adcd_raw : std_logic_vector(15 downto 0);
--
signal adca_data : std_logic_vector(15 downto 0);
signal adcb_data : std_logic_vector(15 downto 0);
signal adcc_data : std_logic_vector(15 downto 0);
signal adcd_data : std_logic_vector(15 downto 0);
--
signal adca_filt : std_logic_vector(15 downto 0);
signal adcb_filt : std_logic_vector(15 downto 0);
signal adcc_filt : std_logic_vector(15 downto 0);
signal adcd_filt : std_logic_vector(15 downto 0);
signal adc_chb_but2 : std_logic_vector(15 downto 0);
signal adc_chc_but2 : std_logic_vector(15 downto 0);
signal adc_cha_but2 : std_logic_vector(15 downto 0);
signal adc_chd_but2 : std_logic_vector(15 downto 0);
signal pt_va_lo_filt : std_logic_vector(15 downto 0);
signal pt_vb_lo_filt : std_logic_vector(15 downto 0);
signal pt_vc_lo_filt : std_logic_vector(15 downto 0);
signal pt_vd_lo_filt : std_logic_vector(15 downto 0);
signal pt_va_hi : std_logic_vector(15 downto 0);
signal pt_vb_hi : std_logic_vector(15 downto 0);
signal pt_vc_hi : std_logic_vector(15 downto 0);
signal pt_vd_hi : std_logic_vector(15 downto 0);
signal adc_fifo_empty : std_logic_vector(3 downto 0);
signal tbt_extclk : std_logic;
signal inttrig_enb : std_logic_vector(3 downto 0);
signal tbt_gate : std_logic;
signal tbt_trig : std_logic_vector(0 downto 0);
signal pt_trig : std_logic;
signal fa_trig : std_logic_vector(0 downto 0);
signal sa_trig : std_logic_vector(0 downto 0);
signal dma_trig : std_logic;
signal tbt_sum : std_logic_vector(31 downto 0);
signal tbt_cha : std_logic_vector(31 downto 0);
signal tbt_chb : std_logic_vector(31 downto 0);
signal tbt_chc : std_logic_vector(31 downto 0);
signal tbt_chd : std_logic_vector(31 downto 0);
signal but_coslkup : std_logic_vector(15 downto 0);
signal but_sinlkup : std_logic_vector(15 downto 0);
signal sa_trig_stretch : std_logic;
signal dma_trig_stretch : std_logic;
signal dsp_filt_bypass : std_logic_vector(3 downto 0);
signal kx : std_logic_vector(31 downto 0);
signal ky : std_logic_vector(31 downto 0);
signal cha_gain : std_logic_vector(15 downto 0);
signal chb_gain : std_logic_vector(15 downto 0);
signal chc_gain : std_logic_vector(15 downto 0);
signal chd_gain : std_logic_vector(15 downto 0);
signal xpos_offset : std_logic_vector(31 downto 0);
signal ypos_offset : std_logic_vector(31 downto 0);
signal xpos_offset2 : std_logic_vector(31 downto 0);
signal ypos_offset2 : std_logic_vector(31 downto 0);
signal evr_ts : std_logic_vector(63 downto 0);
signal evr_ts_trig : std_logic_vector(63 downto 0);
signal evr_mapping_ram : std_logic_vector(31 downto 0);
signal evr_mapping_ram_we: std_logic;
signal evr_trig_out : std_logic_vector(7 downto 0);
signal evr_clk : std_logic;
signal evr_rcvd_clk : std_logic;
signal evr_tbt_trig : std_logic;
signal evr_fa_trig : std_logic;
signal evr_sa_trig : std_logic;
signal evr_gps_trig : std_logic;
signal evr_dma_trig : std_logic;
signal evr_dbg : std_logic_vector(19 downto 0);
signal sys_status : std_logic_vector(31 downto 0);
signal adc_trig_count : std_logic_vector(31 downto 0);
signal sa_count : std_logic_vector(31 downto 0);
signal sa_cha : std_logic_vector(31 downto 0);
signal sa_chb : std_logic_vector(31 downto 0);
signal sa_chc : std_logic_vector(31 downto 0);
signal sa_chd : std_logic_vector(31 downto 0);
signal sa_xpos : std_logic_vector(31 downto 0);
signal sa_ypos : std_logic_vector(31 downto 0);
signal sa_sum : std_logic_vector(31 downto 0);
signal but_q_sa : std_logic_vector(31 downto 0);
signal i2c1_scl_i : std_logic;
signal i2c1_scl_t : std_logic;
signal i2c1_scl_o : std_logic;
signal i2c1_sda_i : std_logic;
signal i2c1_sda_t : std_logic;
signal i2c1_sda_o : std_logic;
signal iic_rtl_scl_i : std_logic; --=> iic_rtl_scl_i;
signal iic_rtl_scl_o : std_logic; --=> iic_rtl_scl_o;
signal iic_rtl_scl_t : std_logic; --=> iic_rtl_scl_t;
signal iic_rtl_sda_i : std_logic; --=> iic_rtl_sda_i;
signal iic_rtl_sda_o : std_logic; --=> iic_rtl_sda_o;
signal iic_rtl_sda_t : std_logic; --=> iic_rtl_sda_o;
signal iic_sel : STD_LOGIC_VECTOR ( 0 to 0 );
signal iic_sdi_sfp0_scl_i : std_logic; --in STD_LOGIC;
signal iic_sdi_sfp0_scl_o : std_logic; --out STD_LOGIC;
signal iic_sdi_sfp0_scl_t : std_logic; --out STD_LOGIC;
signal iic_sdi_sfp0_sda_i : std_logic; --in STD_LOGIC;
signal iic_sdi_sfp0_sda_o : STD_LOGIC;
signal iic_sdi_sfp0_sda_t : STD_LOGIC;
--
signal iic_sdi_sfp1_scl_i : std_logic; --STD_LOGIC;
signal iic_sdi_sfp1_scl_o : std_logic; --STD_LOGIC;
signal iic_sdi_sfp1_scl_t : std_logic; --STD_LOGIC;
signal iic_sdi_sfp1_sda_i : std_logic; --STD_LOGIC;
signal iic_sdi_sfp1_sda_o : std_logic; --STD_LOGIC;
signal iic_sdi_sfp1_sda_t : std_logic; --STD_LOGIC;
-- EVR signals
-- signal sysClk50M : std_logic;
-- signal evrTrig0_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig1_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig2_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig3_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig4_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig5_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig6_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig7_dly : std_logic_vector(31 downto 0) := X"00000002";
-- signal evrTrig0_width : std_logic_vector(31 downto 0) := X"00000100";
-- signal evrTrig1_width : std_logic_vector(31 downto 0) := X"00000100";
-- signal evrTrig2_width : std_logic_vector(31 downto 0) := X"00000100";
-- signal evrTrig3_width : std_logic_vector(31 downto 0) := X"00000100";
-- signal evrTrig4_width : std_logic_vector(31 downto 0) := X"00000100";
-- signal evrTrig5_width : std_logic_vector(31 downto 0) := X"00000100";
-- signal evrTrig6_width : std_logic_vector(31 downto 0) := X"00000100";
-- signal evrTrig7_width : std_logic_vector(31 downto 0) := X"00000100";
signal evrTrigOut : std_logic_vector(7 downto 0);
-- temperature sensor
signal dfe_temp0 : std_logic_vector(15 downto 0);
signal dfe_temp1 : std_logic_vector(15 downto 0);
signal dfe_temp2 : std_logic_vector(15 downto 0);
signal dfe_temp3 : std_logic_vector(15 downto 0);
signal dfe_temp_debug : std_logic_vector(7 downto 0);
signal afe_temp0 : std_logic_vector(15 downto 0);
signal afe_temp1 : std_logic_vector(15 downto 0);
signal afe_temp_debug : std_logic_vector(7 downto 0);
--
signal npi_trig_dly : std_logic_vector(31 downto 0);
signal npi_trig_sel : std_logic_vector(1 downto 0);
signal sdi_ctrl : std_logic_vector(31 downto 0);
signal sdi_device_addr : std_logic_vector(31 downto 0);
signal sdi_packet_len : std_logic_vector(11 downto 0);
signal evr_width_trig0 : std_logic_vector(31 downto 0);
signal adc_data_endian_en : std_logic;
signal adc_ddr_data_sel : std_logic_vector(1 downto 0);
signal locked : std_logic;
--
signal S00_AXIS_tdata : STD_LOGIC_VECTOR ( 63 downto 0 );
signal S00_AXIS_tready : STD_LOGIC;
signal S00_AXIS_tvalid : STD_LOGIC;
------------------------------------------
signal evr_single_trig_out : std_logic;
signal soft_trig_out : std_logic;
signal ddr_trig_start : std_logic;
signal tbt_hs_ddr_baseaddr : std_logic_vector(31 downto 0); -- from arm DDR BASE address
signal tbt_hs_ddr_buflen : std_logic_vector(31 downto 0); -- from arm Burst Length
signal tbt_hs_burst_len : std_logic_vector(31 downto 0);
signal fa_hs_ddr_baseaddr : std_logic_vector(31 downto 0);
signal fa_hs_ddr_buflen : std_logic_vector(31 downto 0);
signal fa_hs_burst_len : std_logic_vector(31 downto 0);
signal tbt_hs_ddr_curaddr : std_logic_vector(31 downto 0);
signal fa_hs_ddr_curaddr : std_logic_vector(31 downto 0);
signal tbt_ddr_data_in : std_logic_vector(31 downto 0);
signal tbt_ddr_data_valid : std_logic;
signal fa_ddr_data_in : std_logic_vector(31 downto 0);
signal fa_ddr_data_valid : std_logic;
signal tbt_fa_ddr_data_in : std_logic_vector(31 downto 0);
signal tbt_fa_ddr_data_valid : std_logic;
signal tbt_fa_hs_burst_len : std_logic_vector(31 downto 0);
-- tbt
signal tbt_hs_fifo_rdcnt : std_logic_vector (8 downto 0);
signal tbt_hs_fifo_rddata : std_logic_vector (63 downto 0);
signal tbt_hs_fifo_rden : std_logic;
signal tbt_hs_tx_enb : std_logic;
signal tbt_hs_tx_active : std_logic;
signal tbt_hs_fifo_empty : std_logic;
signal tbt_hs_axi_tx_active : std_logic;
signal tbt_hs_dbg_strobe_lat : std_logic;
-- fa
signal fa_hs_fifo_rdcnt : std_logic_vector (8 downto 0);
signal fa_hs_fifo_rddata : std_logic_vector (63 downto 0);
signal fa_hs_fifo_rden : std_logic;
signal fa_hs_tx_enb : std_logic;
signal fa_hs_tx_active : std_logic;
signal fa_hs_fifo_empty : std_logic;
signal fa_hs_axi_tx_active : std_logic;
-------------------------------------------------------------
-- tbt signals
signal but_pha_tbt : std_logic_vector(31 downto 0);
signal but_phb_tbt : std_logic_vector(31 downto 0);
signal but_phc_tbt : std_logic_vector(31 downto 0);
signal but_phd_tbt : std_logic_vector(31 downto 0);
signal but_xpos_tbt : std_logic_vector(31 downto 0);
signal but_ypos_tbt : std_logic_vector(31 downto 0);
signal but_xpos_nm_tbt : std_logic_vector(31 downto 0);
signal but_ypos_nm_tbt : std_logic_vector(31 downto 0);
signal but_va_fa : std_logic_vector(31 downto 0);
signal but_vb_fa : std_logic_vector(31 downto 0);
signal but_vc_fa : std_logic_vector(31 downto 0);
signal but_vd_fa : std_logic_vector(31 downto 0);
signal but_xpos_fa : std_logic_vector(31 downto 0);
signal but_ypos_fa : std_logic_vector(31 downto 0);
signal but_sum_fa : std_logic_vector(31 downto 0);
signal but_q_fa : std_logic_vector(31 downto 0);
signal but_va_sa2 : std_logic_vector(31 downto 0);
signal but_vb_sa2 : std_logic_vector(31 downto 0);
signal but_vc_sa2 : std_logic_vector(31 downto 0);
signal but_vd_sa2 : std_logic_vector(31 downto 0);
signal but_sum_sa2 : std_logic_vector(31 downto 0);
signal but_xpos_sa2 : std_logic_vector(31 downto 0);
signal but_ypos_sa2 : std_logic_vector(31 downto 0);
signal dbg_tbt_hs_fifo_rden : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal dbg_tbt_hs_axi_tx_active : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal dbg_tbt_hs_tx_enb : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal dbg_tbt_hs_tx_active : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal dbg_tbt_hs_fifo_empty : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal dbg_tbt_ddr_data_valid : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal dbg_ddr_trig_start : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal dbg_tbt_hs_dbg_strobe_lat : STD_LOGIC_VECTOR(0 DOWNTO 0);
signal test_reg0 : std_logic_vector(31 downto 0);
signal test_reg1 : std_logic_vector(31 downto 0);
signal pT_LoDpramData : std_logic_vector(31 downto 0);
signal pT_LoDpramAddr : std_logic_vector(31 downto 0);
signal pt_va_sa_hi : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_vb_sa_hi : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_vc_sa_hi : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_vd_sa_hi : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_va_sa_lo : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_vb_sa_lo : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_vc_sa_lo : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_vd_sa_lo : STD_LOGIC_VECTOR(31 DOWNTO 0);
-- PT LO phase
signal but_ptLoPhase_sA : std_logic_vector(31 downto 0);
signal but_ptLoPhase_sB : std_logic_vector(31 downto 0);
signal but_ptLoPhase_sC : std_logic_vector(31 downto 0);
signal but_ptLoPhase_sD : std_logic_vector(31 downto 0);
signal but_pha_sa : std_logic_vector(31 downto 0);
signal but_pha_sb : std_logic_vector(31 downto 0);
signal but_pha_sc : std_logic_vector(31 downto 0);
signal but_pha_sd : std_logic_vector(31 downto 0);
signal but_phase_Q_sa : std_logic_vector(31 downto 0);
signal but_phase_I_sa : std_logic_vector(31 downto 0);
-- 2nd Gate signals
signal tbt_gate2_ctrl : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal tbt_gate1: std_logic_vector(0 downto 0);
signal tbt_gate2: std_logic_vector(0 downto 0);
signal tbt_trig2: std_logic;
signal tbt_trig_src : std_logic_vector(0 downto 0);
signal but_sum_tbt2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_va_tbt2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_vb_tbt2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_vc_tbt2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_vd_tbt2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_xpos_nm_tbt2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_ypos_nm_tbt2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
--
signal but_va_fa2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_vb_fa2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_vc_fa2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_vd_fa2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_xpos_fa2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal but_ypos_fa2 : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_coslkup_lo : STD_LOGIC_VECTOR(15 DOWNTO 0);
signal pt_sinlkup_lo : STD_LOGIC_VECTOR(15 DOWNTO 0);
signal pt_coslkup : STD_LOGIC_VECTOR(15 DOWNTO 0);
signal pt_sinlkup : STD_LOGIC_VECTOR(15 DOWNTO 0);
signal pt_ram_data : STD_LOGIC_VECTOR ( 31 downto 0 );
signal pt_ram_addr : STD_LOGIC_VECTOR ( 9 downto 0 );
signal pt_ram_sin_we : STD_LOGIC_VECTOR ( 0 to 0 );
signal pt_ram_cos_we : STD_LOGIC_VECTOR ( 0 to 0 );
signal pt_tbt_gate_ctrl : STD_LOGIC_VECTOR(31 DOWNTO 0);
signal pt_lo_filt_bypass : std_logic_vector( 1-1 downto 0 );
signal pt_lo_gate_en : std_logic_vector( 1-1 downto 0 );
signal pt_sa_gain_a : std_logic_vector( 24-1 downto 0 );
signal pt_sa_gain_b : std_logic_vector( 24-1 downto 0 );
signal pt_sa_gain_c : std_logic_vector( 24-1 downto 0 );
signal pt_sa_gain_d : std_logic_vector( 24-1 downto 0 );
signal pt_lo_nco_count : std_logic_vector( 9 downto 0 );
signal pt_lo_nco_count16 : std_logic_vector( 15 downto 0 );
signal pt_lo_imag_cha : std_logic_vector( 16-1 downto 0 );
signal pt_lo_qmag_cha : std_logic_vector( 16-1 downto 0 );
signal pt_lo_imag_chb : std_logic_vector( 16-1 downto 0 );
signal pt_lo_qmag_chb : std_logic_vector( 16-1 downto 0 );
signal pt_va_tbt_lo : std_logic_vector( 32-1 downto 0 );
signal pt_vb_tbt_lo : std_logic_vector( 32-1 downto 0 );
signal pt_vc_tbt_lo : std_logic_vector( 32-1 downto 0 );
signal pt_vd_tbt_lo : std_logic_vector( 32-1 downto 0 );
signal tbt_wfm_a : std_logic_vector( 32-1 downto 0 );
signal tbt_wfm_b : std_logic_vector( 32-1 downto 0 );
signal tbt_wfm_c : std_logic_vector( 32-1 downto 0 );
signal tbt_wfm_d : std_logic_vector( 32-1 downto 0 );
-----////////////// S D I C O M M ///////////////-----
signal sdi_evr_fa_trig : std_logic;
signal sdi_glitch_out : std_logic;
signal sdi_test_bit : std_logic;
signal sdi_fa_pos_x : std_logic_vector(31 downto 0);
signal sdi_fa_pos_y : std_logic_vector(31 downto 0);
signal sdi_fa_xpos : std_logic_vector(31 downto 0);
signal sdi_fa_ypos : std_logic_vector(31 downto 0);
signal Sdi_WfmFreq : std_logic_vector(31 downto 0);
signal Sdi_Wfm_Kx : std_logic_vector(31 downto 0);
signal Sdi_Wfm_Ky : std_logic_vector(31 downto 0);
signal tbt_gate_dly : std_logic_vector(31 downto 0);
signal tbt_gate_width : std_logic_vector(15 downto 0);
signal sfp_i2c_trig : std_logic;
signal sfp_i2c_addr : std_logic_vector(8 downto 0);
signal sfp0_i2c_data : std_logic_vector(15 downto 0);
signal sfp1_i2c_data : std_logic_vector(15 downto 0);
signal sfp2_i2c_data : std_logic_vector(15 downto 0);
signal sfp3_i2c_data : std_logic_vector(15 downto 0);
signal sfp4_i2c_data : std_logic_vector(15 downto 0);
signal sfp5_i2c_data : std_logic_vector(15 downto 0);
signal sfp_i2c_trig_src : std_logic;
--Inputs
signal fclk_clk2_25MHz : std_logic;
--signal sysClk : std_logic := '0';
--signal SdiReset : std_logic := '0';
signal UserSdiReset : std_logic;
--signal gtx_refclk_n : std_logic;
--signal gtx_refclk_p : std_logic;
signal RXN_IN : std_logic_vector(1 downto 0) := (others => '0');
signal RXP_IN : std_logic_vector(1 downto 0) := (others => '0');
signal SdiTrig_i : std_logic;
signal SdiUsrNpiTrigger : std_logic;
signal SdiUsrRstTrig : std_logic;
signal DeviceAddress : std_logic_vector(15 downto 0) := (others => '0');
signal PacketLength : std_logic_vector(11 downto 0) := (others => '0');
--signal CWLocalDataClock : std_logic := '0';
signal sdi_LocalDataValid : std_logic;
signal sdi_LocalData : std_logic_vector(31 downto 0) := (others => '0');
signal bpm_SimLocalData : std_logic_vector(31 downto 0) := (others => '0');
signal CWLocalData : std_logic_vector(31 downto 0) := (others => '0');
signal CWLocalDataValid : std_logic := '0';
--signal CCWLocalData : std_logic_vector(31 downto 0) := (others => '0');
--signal CCWLocalDataValid : std_logic := '0';
signal DpramOutMode : std_logic := '0';
signal LinkOutDir : std_logic_vector(1 downto 0) := (others => '0');
signal DpRamTrigSrc : std_logic := '0';
signal MaskContrl : std_logic_vector(11 downto 0) := (others => '0');
--signal MasterPacketAddress : std_logic_vector(15 downto 0) := (others => '0');
signal axiBusClk : std_logic := '0';
signal axi_bus_en : std_logic := '0';
signal axi_bus_addr : std_logic_vector(9 downto 0) := (others => '0');
--Outputs
signal TXN_OUT : std_logic_vector(1 downto 0);
signal TXP_OUT : std_logic_vector(1 downto 0);
signal StartCalc : std_logic;
signal DPRAM_ReadStart : std_logic;
signal DPRAM_Valid : std_logic;
signal DPRAM_WR_OUT : std_logic;
signal axi_bus_data : std_logic_vector(31 downto 0);
signal NipStrobe : std_logic;
signal NpiRst_Out : std_logic;
signal TxClock125MHz : std_logic;
signal LinkHead : std_logic_vector(31 downto 0);
signal LinkData : std_logic_vector(31 downto 0);
signal LinkDataValid : std_logic;
signal LinkStartOfPacket : std_logic_vector(1 downto 0);
signal CWLocalModeState : std_logic;
signal CCWLocalModeState : std_logic;
signal CWRemoteModeState : std_logic;
signal CCWRemoteModeState : std_logic;
signal sfp_link : std_logic_vector(7 downto 0);
signal CW_LedRxFifoValid : std_logic;
signal AllLinkValidStatus : std_logic;
signal DirLED : std_logic;
signal CCW_LinkDataValid : std_logic;
signal BiDirLinkDataValid : std_logic;
signal RemotePacketDroppedStatus : std_logic_vector(3 downto 0);
signal CWRemoteModeDone_o : std_logic;
signal CCWRemoteModeDone_o : std_logic;
signal MyLocalLoopbackDataValid_o : std_logic_vector(3 downto 0);
signal CW_RcvPacketMaskStatus : std_logic;
signal CCW_RcvPacketMaskStatus : std_logic;
signal ReceivedRemotePacketHead_s : std_logic_vector(3 downto 0);
signal CWSingleSdiDebugOut : std_logic_vector(15 downto 0);
signal CCWSingleSdiDebugOut : std_logic_vector(15 downto 0);
signal MPMC_data_X : std_logic_vector(31 downto 0);
signal MPMC_data_Y : std_logic_vector(31 downto 0);
signal dpram_data_o : std_logic_vector(31 downto 0);
signal dpram_addr_o : std_logic_vector(9 downto 0);
signal dpram_wr_o : std_logic;
signal pkt_head_info : std_logic_vector(9 downto 0);
signal CWReStateDbg : std_logic_vector(5 downto 0);
signal CCWReStateDbg : std_logic_vector(5 downto 0);
signal CW_RxUsrClock : std_logic;
signal CCW_RxUsrClock : std_logic;
signal CWRXDATAIn : std_logic_vector(31 downto 0);
signal CCWRXDATAIn : std_logic_vector(31 downto 0);
signal CWCharIsIn : std_logic;
signal CCWCharIsIn : std_logic;
signal TRACK_DATA_OUT0 : std_logic;
signal TRACK_DATA_OUT1 : std_logic;
signal q0_clk1_refclk_o : std_logic;
signal trig_WD_timeout_cnt : std_logic_vector(31 downto 0);
signal CW_CRCErrorCount : std_logic_vector(31 downto 0);
signal CCW_CRCErrorCount : std_logic_vector(31 downto 0);
signal CW_LocalLoopbackDataErrorCnt : std_logic_vector(31 downto 0);
signal CCW_LocalLoopbackDataErrorCnt : std_logic_vector(31 downto 0);
signal CW_LocalTxRxFrameErrorVal : std_logic_vector(31 downto 0);
signal CCW_LocalTxRxFrameErrorVal : std_logic_vector(31 downto 0);
signal CwRemoteTimeoutCnt : std_logic_vector(31 downto 0);
signal CcwRemoteTimeoutCnt : std_logic_vector(31 downto 0);
signal CW_ReLocalHead_WD_timeout_cnt : std_logic_vector(31 downto 0);
signal CCW_ReLocalHead_WD_timeout_cnt : std_logic_vector(31 downto 0);
signal CW_wd_LocalTxPacketTimeout_cnt : std_logic_vector(31 downto 0);
signal CCW_wd_LocalTxPacketTimeout_cnt : std_logic_vector(31 downto 0);
signal EvrTrigCnt : std_logic_vector(31 downto 0);
signal CW_LinkOfLockErrorCnt : std_logic_vector(31 downto 0);
signal CCW_LinkOfLockErrorCnt : std_logic_vector(31 downto 0);
signal CW_RcvPktMask_WD_timeout_cnt : std_logic_vector(31 downto 0);
signal CCW_RcvPktMask_WD_timeout_cnt : std_logic_vector(31 downto 0);
signal DRAM_ReadStart_WD_cnt : std_logic_vector(31 downto 0);
-------------------------------------------------------
-- --debug signals (connect to ila)
attribute mark_debug : string;
attribute mark_debug of iobus_addr: signal is "true";
attribute mark_debug of iobus_cs: signal is "true";
attribute mark_debug of iobus_rnw: signal is "true";
attribute mark_debug of iobus_wrdata: signal is "true";
attribute mark_debug of iobus_rddata: signal is "true";
attribute mark_debug of sys_rst: signal is "true";
--attribute mark_debug of adc_clk: signal is "true";
attribute mark_debug of inttrig_enb : signal is "true";
attribute mark_debug of tbt_gate : signal is "true";
attribute mark_debug of tbt_trig :signal is "true";
--attribute mark_debug of pt_trig : signal is "true";
attribute mark_debug of fa_trig :signal is "true";
attribute mark_debug of sa_trig :signal is "true";