-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathmain.v
3920 lines (3773 loc) · 109 KB
/
main.v
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
`timescale 1ps / 1ps
////////////////////////////////////////////////////////////////////////////////
//
// Filename: ../demo-out/main.v
//
// Project: AutoFPGA, a utility for composing FPGA designs from peripherals
// {{{
// Computer Generated: This file is computer generated by AUTOFPGA. DO NOT EDIT.
// DO NOT EDIT THIS FILE!
//
// CmdLine: ./autofpga -d -o ../demo-out -I ../auto-data allclocks.txt bkram.txt buserr.txt clkcheck.txt crossbus.txt ddr3.txt edidslvscope.txt edid.txt exconsole.txt flashcfg.txt flash.txt global.txt gpio.txt gps.txt hdmi.txt i2ccpu.txt i2cdma.txt i2saudio.txt icape.txt meganet.txt mdio.txt pic.txt pwrcount.txt rtcdate.txt rtcgps.txt spio.txt sdio.txt vadj33.txt version.txt wboledbw.txt wbpmic.txt wbuarbiter.txt wbubus.txt zipcpu.txt zipmaster.txt
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
// }}}
// Copyright (C) 2017-2024, Gisselquist Technology, LLC
// {{{
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program. (It's in the $(ROOT)/doc directory. Run make with no
// target there if the PDF file isn't present.) If not, see
// <http://www.gnu.org/licenses/> for a copy.
// }}}
// License: GPL, v3, as defined and found on www.gnu.org,
// {{{
// http://www.gnu.org/licenses/gpl.html
//
//
////////////////////////////////////////////////////////////////////////////////
//
// }}}
`default_nettype none
////////////////////////////////////////////////////////////////////////////////
//
// Macro defines
// {{{
//
//
// Here is a list of defines which may be used, post auto-design
// (not post-build), to turn particular peripherals (and bus masters)
// on and off. In particular, to turn off support for a particular
// design component, just comment out its respective `define below.
//
// These lines are taken from the respective @ACCESS tags for each of our
// components. If a component doesn't have an @ACCESS tag, it will not
// be listed here.
//
// First, the independent access fields for any bus masters
`define EXBUS_MASTER
`define ALLCLOCKS_PRESENT
`define VADJ_ACCESS
// And then for the independent peripherals
`define FLASH_ACCESS
`define I2CCPU_ACCESS
`define EDID_ACCESS
`define GPSUART_ACCESS
`define VIDPIPE_ACCESS
`define EDIDSLVSCOPE_SCOPC
`define CFG_ACCESS
`define BKRAM_ACCESS
`define SDRAM_ACCESS
`define DDR3_PHY_ACCESS
`define I2CDMA_ACCESS
`define PWRCOUNT_ACCESS
`define MEGANET_ACCESS
`define RTC_ACCESS
`define SPIO_ACCESS
`define GPIO_ACCESS
`define SDIO_ACCESS
`define BUSPIC_ACCESS
`define GPSTRK_ACCESS
`define NETCTRL_ACCESS
`define VERSION_ACCESS
`define OLEDBW_ACCESS
`define MICROPHONE_ACCESS
`define INCLUDE_ZIPCPU
//
//
// The list of those things that have @DEPENDS tags
//
//
//
// Dependencies
// Any core with both an @ACCESS and a @DEPENDS tag will show up here.
// The @DEPENDS tag will turn into a series of ifdef's, with the @ACCESS
// being defined only if all of the ifdef's are true//
// Deplist for @$(PREFIX)=rtcdate
`ifdef RTC_ACCESS
`define RTCDATE_ACCESS
`endif // RTC_ACCESS
// Deplist for @$(PREFIX)=flashcfg
`ifdef FLASH_ACCESS
`define FLASHCFG_ACCESS
`endif // FLASH_ACCESS
// Deplist for @$(PREFIX)=txclk
`ifdef ALLCLOCKS_PRESENT
`define TXCLK
`endif // ALLCLOCKS_PRESENT
// Deplist for @$(PREFIX)=adcclk
`ifdef ALLCLOCKS_PRESENT
`define ADCCLK
`endif // ALLCLOCKS_PRESENT
// Deplist for @$(PREFIX)=i2saudio
// Deplist for @$(PREFIX)=rxeth0ck
`ifdef MEGANET_ACCESS
`define RXETH0CK
`endif // MEGANET_ACCESS
// Deplist for @$(PREFIX)=i2saudio
//
// The following macros have unmet dependencies. They are listed
// here for reference, but their dependencies cannot be met.
// Unmet Dependency list for @$(PREFIX)=i2saudio
`ifdef ARBITRARY_CLOCK_GENERATOR_ACCESS // This value is unknown
`define I2SAUDIO
`endif
//
// End of dependency list
//
//
// }}}
////////////////////////////////////////////////////////////////////////////////
//
// Any include files
// {{{
// These are drawn from anything with a MAIN.INCLUDE definition.
`include "builddate.v"
// }}}
//
// Finally, we define our main module itself. We start with the list of
// I/O ports, or wires, passed into (or out of) the main function.
//
// These fields are copied verbatim from the respective I/O port lists,
// from the fields given by @MAIN.PORTLIST
//
module main(i_clk, i_reset,
// {{{
// The Universal QSPI Flash
o_flash_cs_n, o_flash_sck, o_flash_dat, i_flash_dat, o_flash_mod,
i_i2c_sda, i_i2c_scl,
o_i2c_sda, o_i2c_scl,
// UART/host to wishbone interface
i_wbu_uart_rx, o_wbu_uart_tx,
i_edid_sda, i_edid_scl,
o_edid_sda, o_edid_scl,
// The GPS-UART
i_gpsu_rx, o_gpsu_tx,
// HDMI control ports
`ifndef VERILATOR
i_hdmiclk,
`endif
i_pixclk,
i_hdmi_red, i_hdmi_grn, i_hdmi_blu,
o_hdmi_red, o_hdmi_grn, o_hdmi_blu,
o_hdmi_iodelay, i_hdmi_iodelay,
o_pix_reset_n, i_pxpll_locked, o_hdmirx_reset_n,
o_pxclk_cksel,
// EDID RX definitions
i_edidslv_scl, i_edidslv_sda,
o_edidslv_scl, o_edidslv_sda,
// DDR3 Controller Interface
i_ddr3_iserdes_data, i_ddr3_iserdes_dqs,
i_ddr3_iserdes_bitslip_reference,
i_ddr3_idelayctrl_rdy,
o_ddr3_cmd,
o_ddr3_dqs_tri_control, o_ddr3_dq_tri_control,
o_ddr3_toggle_dqs, o_ddr3_data, o_ddr3_dm,
o_ddr3_odelay_data_cntvaluein, o_ddr3_odelay_dqs_cntvaluein,
o_ddr3_idelay_data_cntvaluein, o_ddr3_idelay_dqs_cntvaluein,
o_ddr3_odelay_data_ld, o_ddr3_odelay_dqs_ld,
o_ddr3_idelay_data_ld, o_ddr3_idelay_dqs_ld,
o_ddr3_bitslip,
o_ddr3_leveling_calib,
o_ddr3_reset,
o_i2s_lrclk, o_i2s_bclk, o_i2s_mclk, o_i2s_dac, i_i2s_adc,
o_pxclk_cyc, o_pxclk_stb, o_pxclk_we,
o_pxclk_addr, o_pxclk_data, o_pxclk_sel,
i_pxclk_stall, i_pxclk_ack, i_pxclk_idata,
// Ethernet control (packets) lines
o_net_reset_n,
// eth_int_b // Interrupt, leave floating
// eth_pme_b // Power management event, leave floating
i_net_rx_clk, i_net_rx_dv, i_net_rx_err, i_net_rxd,
o_net_tx_clk, o_net_tx_ctl, o_net_txd,
// SPIO interface
i_sw, i_btnc, i_btnd, i_btnl, i_btnr, i_btnu, o_led,
// GPIO ports
`ifdef VERILATOR
o_trace, o_halt,
`endif
i_gpio, o_gpio,
// SDIO SD Card
i_sdio_detect,
//
o_sdio_cfg_ddr,
o_sdio_cfg_ds,
o_sdio_cfg_dscmd,
o_sdio_cfg_sample_shift,
o_sdio_cmd_tristate,
o_sdio_data_tristate,
//
o_sdio_sdclk,
o_sdio_cmd_en,
o_sdio_cmd_data,
o_sdio_data_en,
o_sdio_rx_en,
o_sdio_tx_data,
//
i_sdio_cmd_strb,
i_sdio_cmd_data,
i_sdio_cmd_collision,
i_sdio_crcack,
i_sdio_crcnak,
i_sdio_card_busy,
i_sdio_rx_strb,
i_sdio_rx_data,
//
i_sdio_ac_valid,
i_sdio_ac_data,
i_sdio_ad_valid,
i_sdio_ad_data,
o_sdio_hwreset_n, o_sdio_1p8v,
i_sdio_debug,
// Extra clocks
i_clk_125mhz,
// The GPS 1PPS signal port
i_gps_pps,
// The ethernet MDIO wires
o_mdclk, o_mdio, o_mdwe, i_mdio,
// OLED control interface (roughly SPI)
o_oled_sck, o_oled_mosi, o_oled_dcn,
// The PMic3 microphone wires
o_mic_csn, o_mic_sck, i_mic_din,
// Veri1ator only interface
cpu_sim_cyc,
cpu_sim_stb,
cpu_sim_we,
cpu_sim_addr,
cpu_sim_data,
cpu_sim_stall,
cpu_sim_ack,
cpu_sim_idata,
`ifdef VERILATOR
cpu_prof_stb,
cpu_prof_addr,
cpu_prof_ticks,
`endif
i_cpu_reset
// }}}
);
////////////////////////////////////////////////////////////////////////////////
//
// Any parameter definitions
// {{{
// These are drawn from anything with a MAIN.PARAM definition.
// As they aren't connected to the toplevel at all, it would
// be best to use localparam over parameter, but here we don't
// check
////////////////////////////////////////////////////////////////////////
//
// EXBUS parameters
// {{{
// Baudrate : 1000000
// Clock : 100000000
localparam [23:0] BUSUART = 24'h64; // 1000000 baud
localparam DBGBUSBITS = $clog2(BUSUART);
// }}}
localparam ICAPE_LGDIV=3;
localparam real SDRAMCONTROLLER_CLK_PERIOD = 10_000, //ps, clock period of the controller interface
DDR3_CLK_PERIOD = 2_500; //ps, clock period of the DDR3 RAM device (must be 1/4 of the CONTROLLER_CLK_PERIOD)
localparam SDRAMROW_BITS = 14, // width of row address
SDRAMCOL_BITS = 10, // width of column address
SDRAMBA_BITS = 3, // width of bank address
SDRAMDQ_BITS = 8, // Size of one octet
SDRAMBYTE_LANES = 2, //8 lanes of DQ
SDRAMAUX_WIDTH = 4, //width of aux line (must be >= 4)
SDRAMSERDES_RATIO = $rtoi(SDRAMCONTROLLER_CLK_PERIOD/DDR3_CLK_PERIOD),
//4 is the width of a single ddr3 command {cs_n, ras_n, cas_n, we_n} plus 3 (ck_en, odt, reset_n) plus bank bits plus row bits
SDRAMCMD_LEN = 4 + 3 + SDRAMBA_BITS + SDRAMROW_BITS;
parameter [15:0] UDP_DBGPORT = 6784;
localparam [47:0] DEF_HWMAC = 48'h82_33_48_02_e1_c8;
localparam [31:0] DEF_IPADDR = { 8'd192, 8'd168, 8'd15, 8'd29 };
localparam [31:0] GPSCLOCK_DEFAULT_STEP = 32'haabcc771;
////////////////////////////////////////////////////////////////////////
//
// Variables/definitions/parameters used by the ZipCPU bus master
// {{{
//
// A 32-bit address indicating where the ZipCPU should start running
// from
`ifdef BKROM_ACCESS
localparam RESET_ADDRESS = @$(/bkrom.BASE);
`else
`ifdef FLASH_ACCESS
localparam RESET_ADDRESS = 23068672;
`else
localparam RESET_ADDRESS = 268435456;
`endif // FLASH_ACCESS
`endif // BKROM_ACCESS
//
// The number of valid bits on the bus
localparam ZIP_ADDRESS_WIDTH = 27; // Zip-CPU address width
//
// Number of ZipCPU interrupts
localparam ZIP_INTS = 16;
//
// ZIP_START_HALTED
//
// A boolean, indicating whether or not the ZipCPU be halted on startup?
`ifdef BKROM_ACCESS
localparam ZIP_START_HALTED=1'b0;
`else
localparam ZIP_START_HALTED=1'b1;
`endif
// }}}
// }}}
////////////////////////////////////////////////////////////////////////////////
//
// Port declarations
// {{{
// The next step is to declare all of the various ports that were just
// listed above.
//
// The following declarations are taken from the values of the various
// @MAIN.IODECL keys.
//
input wire i_clk;
// verilator lint_off UNUSED
input wire i_reset;
// verilator lint_on UNUSED
// The Universal QSPI flash
output wire o_flash_cs_n, o_flash_sck;
output wire [3:0] o_flash_dat;
input wire [3:0] i_flash_dat;
output wire [1:0] o_flash_mod;
// I2C Port declarations
// {{{
input wire i_i2c_sda, i_i2c_scl;
output wire o_i2c_sda, o_i2c_scl;
// }}}
input wire i_wbu_uart_rx;
output wire o_wbu_uart_tx;
// I2C Port declarations
// {{{
input wire i_edid_sda, i_edid_scl;
output wire o_edid_sda, o_edid_scl;
// }}}
input wire i_gpsu_rx;
output wire o_gpsu_tx;
// hdmi declarations
// {{{
`ifndef VERILATOR
input wire i_hdmiclk;
`endif
input wire i_pixclk;
input wire [9:0] i_hdmi_red, i_hdmi_grn, i_hdmi_blu;
output wire [9:0] o_hdmi_red, o_hdmi_grn, o_hdmi_blu;
output wire [14:0] o_hdmi_iodelay;
input wire [14:0] i_hdmi_iodelay;
output wire o_pix_reset_n, o_hdmirx_reset_n;
input wire i_pxpll_locked;
output wire [1:0] o_pxclk_cksel;
// }}}
// EDID RX definitions
input wire i_edidslv_scl, i_edidslv_sda;
output wire o_edidslv_scl, o_edidslv_sda;
// DDR3 Controller I/O declarations
// {{{
input wire [SDRAMDQ_BITS*SDRAMBYTE_LANES*8-1:0] i_ddr3_iserdes_data;
input wire [SDRAMBYTE_LANES*8-1:0] i_ddr3_iserdes_dqs;
input wire [SDRAMBYTE_LANES*8-1:0] i_ddr3_iserdes_bitslip_reference;
input wire i_ddr3_idelayctrl_rdy;
output wire [SDRAMCMD_LEN*SDRAMSERDES_RATIO-1:0] o_ddr3_cmd;
output wire o_ddr3_dqs_tri_control, o_ddr3_dq_tri_control;
output wire o_ddr3_toggle_dqs;
output wire [SDRAMDQ_BITS*SDRAMBYTE_LANES*8-1:0] o_ddr3_data;
output wire [(SDRAMDQ_BITS*SDRAMBYTE_LANES*8)/8-1:0] o_ddr3_dm;
output wire [4:0] o_ddr3_odelay_data_cntvaluein, o_ddr3_odelay_dqs_cntvaluein;
output wire [4:0] o_ddr3_idelay_data_cntvaluein, o_ddr3_idelay_dqs_cntvaluein;
output wire [SDRAMBYTE_LANES-1:0] o_ddr3_odelay_data_ld, o_ddr3_odelay_dqs_ld;
output wire [SDRAMBYTE_LANES-1:0] o_ddr3_idelay_data_ld, o_ddr3_idelay_dqs_ld;
output wire [SDRAMBYTE_LANES-1:0] o_ddr3_bitslip;
output wire o_ddr3_leveling_calib;
output wire o_ddr3_reset;
// }}}
output wire o_i2s_lrclk, o_i2s_bclk, o_i2s_mclk, o_i2s_dac;
input wire i_i2s_adc;
output wire o_pxclk_cyc, o_pxclk_stb, o_pxclk_we;
output wire [6:0] o_pxclk_addr;
output wire [31:0] o_pxclk_data;
output wire [3:0] o_pxclk_sel;
input wire i_pxclk_stall, i_pxclk_ack;
input wire [31:0] i_pxclk_idata;
// Ethernet (RGMII) control
// {{{
// Verilator lint_off SYNCASYNCNET
output wire o_net_reset_n;
// Verilator lint_on SYNCASYNCNET
input wire i_net_rx_clk, i_net_rx_dv, i_net_rx_err;
input wire [7:0] i_net_rxd;
output wire [1:0] o_net_tx_clk;
output wire o_net_tx_ctl;
output wire [7:0] o_net_txd;
// }}}
// SPIO interface
input wire [8-1:0] i_sw;
input wire i_btnc, i_btnd, i_btnl, i_btnr, i_btnu;
output wire [8-1:0] o_led;
localparam NGPI = 8, NGPO=10;
// GPIO ports
`ifdef VERILATOR
output wire o_trace;
output wire o_halt;
`endif
input [(NGPI-1):0] i_gpio;
output wire [(NGPO-1):0] o_gpio;
// SDIO SD Card declarations
// {{{
input wire i_sdio_detect;
//
output wire o_sdio_cfg_ddr;
output wire o_sdio_cfg_ds;
output wire o_sdio_cfg_dscmd;
output wire [4:0] o_sdio_cfg_sample_shift;
output wire o_sdio_cmd_tristate;
output wire o_sdio_data_tristate;
//
output wire [7:0] o_sdio_sdclk;
output wire o_sdio_cmd_en;
output wire [1:0] o_sdio_cmd_data;
output wire o_sdio_data_en;
output wire o_sdio_rx_en;
output wire [31:0] o_sdio_tx_data;
//
input wire [1:0] i_sdio_cmd_strb;
input wire [1:0] i_sdio_cmd_data;
input wire i_sdio_cmd_collision;
input wire i_sdio_crcack;
input wire i_sdio_crcnak;
input wire i_sdio_card_busy;
input wire [1:0] i_sdio_rx_strb;
input wire [15:0] i_sdio_rx_data;
//
input wire i_sdio_ac_valid;
input wire [1:0] i_sdio_ac_data;
input wire i_sdio_ad_valid;
input wire [31:0] i_sdio_ad_data;
output wire o_sdio_hwreset_n,
o_sdio_1p8v;
// Verilator lint_off UNUSED
input wire [31:0] i_sdio_debug;
// Verilator lint_on UNUSED
// }}}
// Extra clocks
// Verilator lint_off UNUSED
input wire i_clk_125mhz;
// Verilator lint_on UNUSED
//The GPS Clock
input wire i_gps_pps;
// Ethernet control (MDIO)
output wire o_mdclk, o_mdio, o_mdwe;
input wire i_mdio;
// OLEDBW interface
output wire o_oled_sck, o_oled_mosi, o_oled_dcn;
output wire o_mic_csn, o_mic_sck;
input wire i_mic_din;
input wire cpu_sim_cyc, cpu_sim_stb;
input wire cpu_sim_we;
input wire [6:0] cpu_sim_addr;
input wire [31:0] cpu_sim_data;
//
output wire cpu_sim_stall, cpu_sim_ack;
output wire [31:0] cpu_sim_idata;
//
`ifdef VERILATOR
output wire cpu_prof_stb;
output wire [27+$clog2(128/8)-1:0] cpu_prof_addr;
output wire [31:0] cpu_prof_ticks;
`endif
input wire i_cpu_reset;
// }}}
// Make Verilator happy
// {{{
// Defining bus wires for lots of components often ends up with unused
// wires lying around. We'll turn off Ver1lator's lint warning
// here that checks for unused wires.
// }}}
// verilator lint_off UNUSED
////////////////////////////////////////////////////////////////////////
//
// Declaring interrupt lines
// {{{
// These declarations come from the various components values
// given under the @INT.<interrupt name>.WIRE key.
//
wire i2c_int; // i2c.INT.I2C.WIRE
wire edid_int; // edid.INT.EDID.WIRE
wire gpsurxf_int; // gpsu.INT.GPSRXF.WIRE
wire gpsutxf_int; // gpsu.INT.GPSTXF.WIRE
wire gpsutx_int; // gpsu.INT.GPSTX.WIRE
wire gpsurx_int; // gpsu.INT.GPSRX.WIRE
wire hdmi_int; // hdmi.INT.VIDFRAME.WIRE
wire edidslvscope_int; // edidslvscope.INT.EDIDSLVSCOPE.WIRE
wire rtc_int; // rtc.INT.RTC.WIRE
wire spio_int; // spio.INT.SPIO.WIRE
wire gpio_int; // gpio.INT.GPIO.WIRE
wire sdio_int; // sdio.INT.SDCARD.WIRE
wire w_bus_int; // buspic.INT.BUS.WIRE
wire gck_pps; // gck.INT.PPS.WIRE
wire oled_int; // oled.INT.OLED.WIRE
wire pmic_int; // pmic.INT.MIC.WIRE
wire zip_cpu_int; // zip.INT.ZIP.WIRE
// }}}
////////////////////////////////////////////////////////////////////////
//
// Component declarations
// {{{
// These declarations come from the @MAIN.DEFNS keys found in the
// various components comprising the design.
//
// Definitions for the flash debug port
// Verilator lint_off UNUSED
wire flash_dbg_trigger;
wire [31:0] flash_debug;
// Verilator lint_on UNUSED
// I2C Controller
// {{{
// Verilator lint_off UNUSED
localparam I2CCPU_WIDTH=(2 == 0) ? 1 : 2;
wire i2c_valid, i2c_ready, i2c_last;
wire [7:0] i2c_data;
wire [I2CCPU_WIDTH-1:0] i2c_id;
wire [31:0] i2c_debug;
// Verilator lint_on UNUSED
// }}}
reg [30-1:0] r_buserr_addr;
`ifndef GPSTRK_ACCESS
reg [31:0] r_subseconds_data;
`endif
reg r_adcclk_ack;
////////////////////////////////////////////////////////////////////////
//
// EXBUS: USB-UART interface declarations
// {{{
//
wire [7:0] wbu_rx_data, wbu_tx_data;
wire wbu_rx_stb;
wire wbu_tx_stb, wbu_tx_busy;
// Verilator lint_off UNUSED
wire [0:0] ex_reset;
wire [1:0] ex_gpio;
// Verilator lint_on UNUSED
// }}}
// I2C Controller
// {{{
// Verilator lint_off UNUSED
localparam EDID_WIDTH=(2 == 0) ? 1 : 2;
wire edid_valid, edid_ready, edid_last;
wire [7:0] edid_data;
wire [EDID_WIDTH-1:0] edid_id;
wire [31:0] edid_debug;
// Verilator lint_on UNUSED
// }}}
wire w_gpsu_cts_n, w_gpsu_rts_n;
assign w_gpsu_cts_n=1'b1;
// Verilator lint_off UNUSED
`ifdef VERILATOR
wire i_hdmiclk;
`endif
wire hdmidbg_ce, hdmidbg_trigger;
wire [31:0] hdmiclr_debug;
// Verilator lint_on UNUSED
// Verilator lint_off UNUSED
wire [31:0] edidslv_dbg;
// Verilator lint_on UNUSED
reg r_txclk_ack;
reg r_rxeth0ck_ack;
// Verilator lint_off UNUSED
reg rtc_pps;
reg [26:0] rtc_pps_counter;
// Verilator lint_on UNUSED
// Verilator lint_off UNUSED
wire [SDRAMAUX_WIDTH-1:0] ddr3_aux_out;
wire [31:0] ddr3_debug;
// Verilator lint_on UNUSED
wire i2cdma_ready;
reg [31:0] r_pwrcount_data;
////////////////////////////////////////////////////////////////////////
//
// I2S Audio signal definitions
// {{{
wire w_i2saudio_en;
// Verilator lint_off UNUSED
//
// These wires may or may not be connected to anything ...
wire w_audio_out_valid, w_audio_out_ready, w_audio_out_last;
wire [23:0] w_audio_out_data;
//
// w_audio_in... comes from the microphone (if present)
wire w_audio_in_valid, w_audio_in_ready,
w_audio_in_last;
wire [23:0] w_audio_in_data;
wire [31:0] w_i2saudio_debug;
// Verilator lint_on UNUSED
// }}}
wire tb_pps;
// Ethernet (RGMII) control
// {{{
// Verilator lint_off UNUSED
wire [47:0] net_hwmac, net_last_ping_hwmac;
wire [31:0] net_ip_addr, net_last_ping_ipaddr;
wire netcpurx_valid, netcpurx_ready;
wire [31:0] netcpurx_data;
wire [1:0] netcpurx_bytes;
wire netcpurx_last, netcpurx_abort;
wire netcputx_valid, netcputx_ready,
netcputx_last, netcputx_abort;
wire [31:0] netcputx_data;
wire [1:0] netcputx_bytes;
wire net_dbg_valid, net_dbg_ready,
net_dbg_last;
wire [31:0] net_dbg_data;
wire [1:0] net_dbg_bytes;
wire net_high_speed;
wire net_debug_clk;
wire [31:0] net_debug;
wire ign_rxpkt_net_ready;
// Verilator lint_on UNUSED
// }}}
// Definitions in support of the GPS driven RTC
// This clock step is designed to match 100000000 Hz
localparam [31:0] RTC_CLKSTEP = 32'h002af31d;
wire rtc_ppd;
wire rtc_pps;
wire [5-1:0] w_btn;
wire [8-1:0] w_led;
wire sd_reset;
// SDIO SD Card definitions
// Verilator lint_off UNUSED
wire [31:0] w_sdio_sdwb_debug;
wire s_sdio_ready,
m_sdio_valid, m_sdio_last;
reg [31:0] sdio_debug;
wire [31:0] m_sdio_data;
// assign sdio_debug = i_sdio_debug;
// Verilator lint_on UNUSED
wire i_net_tx_clk;
wire ck_pps;
wire gps_pps, gps_led, gps_locked, gps_tracking;
wire [63:0] gps_now, gps_err, gps_step;
wire [1:0] gps_dbg_tick;
// Verilator lint_off UNUSED
wire[31:0] mdio_debug;
// Verilator lint_on UNUSED
// BUILDTIME doesnt need to include builddate.v a second time
// `include "builddate.v"
// OLEDBW
// {{{
// Verilator lint_off UNUSED
wire [1:0] w_oled_csn;
wire ign_oled_valid, ign_oled_last,
ign_oled_id;
wire [7:0] ign_oled_data;
wire [31:0] oled_debug;
// Verilator lint_on UNUSED
// }}}
////////////////////////////////////////////////////////////////////////
//
// ZipSystem/ZipCPU connection definitions
// {{{
`ifndef VERILATOR
wire cpu_prof_stb;
wire [27+$clog2(128/8)-1:0] cpu_prof_addr;
wire [31:0] cpu_prof_ticks;
`endif
// All we define here is a set of scope wires
// Verilator lint_off UNUSED
wire raw_cpu_dbg_stall, raw_cpu_dbg_ack;
wire [31:0] zip_debug;
wire zip_trigger;
// Verilator lint_on UNUSED
wire [ZIP_INTS-1:0] zip_int_vector;
// }}}
// }}}
////////////////////////////////////////////////////////////////////////
//
// Declaring interrupt vector wires
// {{{
// These declarations come from the various components having
// PIC and PIC.MAX keys.
//
wire [14:0] sys_int_vector;
wire [14:0] alt_int_vector;
wire [14:0] bus_int_vector;
// }}}
////////////////////////////////////////////////////////////////////////
//
// Declare bus signals
// {{{
////////////////////////////////////////////////////////////////////////
// Bus wbwide
// {{{
// Wishbone definitions for bus wbwide, component i2c
// Verilator lint_off UNUSED
wire wbwide_i2cm_cyc, wbwide_i2cm_stb, wbwide_i2cm_we;
wire [26:0] wbwide_i2cm_addr;
wire [127:0] wbwide_i2cm_data;
wire [15:0] wbwide_i2cm_sel;
wire wbwide_i2cm_stall, wbwide_i2cm_ack, wbwide_i2cm_err;
wire [127:0] wbwide_i2cm_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component edid
// Verilator lint_off UNUSED
wire wbwide_edidm_cyc, wbwide_edidm_stb, wbwide_edidm_we;
wire [26:0] wbwide_edidm_addr;
wire [127:0] wbwide_edidm_data;
wire [15:0] wbwide_edidm_sel;
wire wbwide_edidm_stall, wbwide_edidm_ack, wbwide_edidm_err;
wire [127:0] wbwide_edidm_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component hdmi
// Verilator lint_off UNUSED
wire wbwide_hdmi_cyc, wbwide_hdmi_stb, wbwide_hdmi_we;
wire [26:0] wbwide_hdmi_addr;
wire [127:0] wbwide_hdmi_data;
wire [15:0] wbwide_hdmi_sel;
wire wbwide_hdmi_stall, wbwide_hdmi_ack, wbwide_hdmi_err;
wire [127:0] wbwide_hdmi_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component i2cdma
// Verilator lint_off UNUSED
wire wbwide_i2cdma_cyc, wbwide_i2cdma_stb, wbwide_i2cdma_we;
wire [26:0] wbwide_i2cdma_addr;
wire [127:0] wbwide_i2cdma_data;
wire [15:0] wbwide_i2cdma_sel;
wire wbwide_i2cdma_stall, wbwide_i2cdma_ack, wbwide_i2cdma_err;
wire [127:0] wbwide_i2cdma_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component sdio
// Verilator lint_off UNUSED
wire wbwide_sdio_cyc, wbwide_sdio_stb, wbwide_sdio_we;
wire [26:0] wbwide_sdio_addr;
wire [127:0] wbwide_sdio_data;
wire [15:0] wbwide_sdio_sel;
wire wbwide_sdio_stall, wbwide_sdio_ack, wbwide_sdio_err;
wire [127:0] wbwide_sdio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component oled
// Verilator lint_off UNUSED
wire wbwide_oledm_cyc, wbwide_oledm_stb, wbwide_oledm_we;
wire [26:0] wbwide_oledm_addr;
wire [127:0] wbwide_oledm_data;
wire [15:0] wbwide_oledm_sel;
wire wbwide_oledm_stall, wbwide_oledm_ack, wbwide_oledm_err;
wire [127:0] wbwide_oledm_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component wbu_arbiter
// Verilator lint_off UNUSED
wire wbwide_wbu_arbiter_cyc, wbwide_wbu_arbiter_stb, wbwide_wbu_arbiter_we;
wire [26:0] wbwide_wbu_arbiter_addr;
wire [127:0] wbwide_wbu_arbiter_data;
wire [15:0] wbwide_wbu_arbiter_sel;
wire wbwide_wbu_arbiter_stall, wbwide_wbu_arbiter_ack, wbwide_wbu_arbiter_err;
wire [127:0] wbwide_wbu_arbiter_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component zip
// Verilator lint_off UNUSED
wire wbwide_zip_cyc, wbwide_zip_stb, wbwide_zip_we;
wire [26:0] wbwide_zip_addr;
wire [127:0] wbwide_zip_data;
wire [15:0] wbwide_zip_sel;
wire wbwide_zip_stall, wbwide_zip_ack, wbwide_zip_err;
wire [127:0] wbwide_zip_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component crossflash
// Verilator lint_off UNUSED
wire wbwide_crossflash_cyc, wbwide_crossflash_stb, wbwide_crossflash_we;
wire [26:0] wbwide_crossflash_addr;
wire [127:0] wbwide_crossflash_data;
wire [15:0] wbwide_crossflash_sel;
wire wbwide_crossflash_stall, wbwide_crossflash_ack, wbwide_crossflash_err;
wire [127:0] wbwide_crossflash_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component crossbus
// Verilator lint_off UNUSED
wire wbwide_crossbus_cyc, wbwide_crossbus_stb, wbwide_crossbus_we;
wire [26:0] wbwide_crossbus_addr;
wire [127:0] wbwide_crossbus_data;
wire [15:0] wbwide_crossbus_sel;
wire wbwide_crossbus_stall, wbwide_crossbus_ack, wbwide_crossbus_err;
wire [127:0] wbwide_crossbus_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component bkram
// Verilator lint_off UNUSED
wire wbwide_bkram_cyc, wbwide_bkram_stb, wbwide_bkram_we;
wire [26:0] wbwide_bkram_addr;
wire [127:0] wbwide_bkram_data;
wire [15:0] wbwide_bkram_sel;
wire wbwide_bkram_stall, wbwide_bkram_ack, wbwide_bkram_err;
wire [127:0] wbwide_bkram_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbwide, component ddr3
// Verilator lint_off UNUSED
wire wbwide_ddr3_cyc, wbwide_ddr3_stb, wbwide_ddr3_we;
wire [26:0] wbwide_ddr3_addr;
wire [127:0] wbwide_ddr3_data;
wire [15:0] wbwide_ddr3_sel;
wire wbwide_ddr3_stall, wbwide_ddr3_ack, wbwide_ddr3_err;
wire [127:0] wbwide_ddr3_idata;
// Verilator lint_on UNUSED
// }}}
// Bus wbflash
// {{{
// Wishbone definitions for bus wbflash, component crossflash
// Verilator lint_off UNUSED
wire wbflash_crossflash_cyc, wbflash_crossflash_stb, wbflash_crossflash_we;
wire [22:0] wbflash_crossflash_addr;
wire [31:0] wbflash_crossflash_data;
wire [3:0] wbflash_crossflash_sel;
wire wbflash_crossflash_stall, wbflash_crossflash_ack, wbflash_crossflash_err;
wire [31:0] wbflash_crossflash_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbflash, component sdio
// Verilator lint_off UNUSED
wire wbflash_sdio_cyc, wbflash_sdio_stb, wbflash_sdio_we;
wire [22:0] wbflash_sdio_addr;
wire [31:0] wbflash_sdio_data;
wire [3:0] wbflash_sdio_sel;
wire wbflash_sdio_stall, wbflash_sdio_ack, wbflash_sdio_err;
wire [31:0] wbflash_sdio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbflash, component flash
// Verilator lint_off UNUSED
wire wbflash_flash_cyc, wbflash_flash_stb, wbflash_flash_we;
wire [22:0] wbflash_flash_addr;
wire [31:0] wbflash_flash_data;
wire [3:0] wbflash_flash_sel;
wire wbflash_flash_stall, wbflash_flash_ack, wbflash_flash_err;
wire [31:0] wbflash_flash_idata;
// Verilator lint_on UNUSED
// }}}
// Bus wb32
// {{{
// Wishbone definitions for bus wb32, component crossbus
// Verilator lint_off UNUSED
wire wb32_crossbus_cyc, wb32_crossbus_stb, wb32_crossbus_we;
wire [11:0] wb32_crossbus_addr;
wire [31:0] wb32_crossbus_data;
wire [3:0] wb32_crossbus_sel;
wire wb32_crossbus_stall, wb32_crossbus_ack, wb32_crossbus_err;
wire [31:0] wb32_crossbus_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component adcclk
// Verilator lint_off UNUSED
wire wb32_adcclk_cyc, wb32_adcclk_stb, wb32_adcclk_we;
wire [11:0] wb32_adcclk_addr;
wire [31:0] wb32_adcclk_data;
wire [3:0] wb32_adcclk_sel;
wire wb32_adcclk_stall, wb32_adcclk_ack, wb32_adcclk_err;
wire [31:0] wb32_adcclk_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component buildtime
// Verilator lint_off UNUSED
wire wb32_buildtime_cyc, wb32_buildtime_stb, wb32_buildtime_we;
wire [11:0] wb32_buildtime_addr;
wire [31:0] wb32_buildtime_data;
wire [3:0] wb32_buildtime_sel;
wire wb32_buildtime_stall, wb32_buildtime_ack, wb32_buildtime_err;
wire [31:0] wb32_buildtime_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component buserr
// Verilator lint_off UNUSED
wire wb32_buserr_cyc, wb32_buserr_stb, wb32_buserr_we;
wire [11:0] wb32_buserr_addr;
wire [31:0] wb32_buserr_data;
wire [3:0] wb32_buserr_sel;
wire wb32_buserr_stall, wb32_buserr_ack, wb32_buserr_err;
wire [31:0] wb32_buserr_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component buspic
// Verilator lint_off UNUSED
wire wb32_buspic_cyc, wb32_buspic_stb, wb32_buspic_we;
wire [11:0] wb32_buspic_addr;
wire [31:0] wb32_buspic_data;
wire [3:0] wb32_buspic_sel;
wire wb32_buspic_stall, wb32_buspic_ack, wb32_buspic_err;
wire [31:0] wb32_buspic_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component gpio
// Verilator lint_off UNUSED
wire wb32_gpio_cyc, wb32_gpio_stb, wb32_gpio_we;
wire [11:0] wb32_gpio_addr;
wire [31:0] wb32_gpio_data;
wire [3:0] wb32_gpio_sel;
wire wb32_gpio_stall, wb32_gpio_ack, wb32_gpio_err;
wire [31:0] wb32_gpio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component pwrcount
// Verilator lint_off UNUSED
wire wb32_pwrcount_cyc, wb32_pwrcount_stb, wb32_pwrcount_we;
wire [11:0] wb32_pwrcount_addr;
wire [31:0] wb32_pwrcount_data;
wire [3:0] wb32_pwrcount_sel;
wire wb32_pwrcount_stall, wb32_pwrcount_ack, wb32_pwrcount_err;
wire [31:0] wb32_pwrcount_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component rtcdate
// Verilator lint_off UNUSED
wire wb32_rtcdate_cyc, wb32_rtcdate_stb, wb32_rtcdate_we;
wire [11:0] wb32_rtcdate_addr;
wire [31:0] wb32_rtcdate_data;
wire [3:0] wb32_rtcdate_sel;
wire wb32_rtcdate_stall, wb32_rtcdate_ack, wb32_rtcdate_err;
wire [31:0] wb32_rtcdate_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component rxeth0ck
// Verilator lint_off UNUSED
wire wb32_rxeth0ck_cyc, wb32_rxeth0ck_stb, wb32_rxeth0ck_we;
wire [11:0] wb32_rxeth0ck_addr;
wire [31:0] wb32_rxeth0ck_data;
wire [3:0] wb32_rxeth0ck_sel;
wire wb32_rxeth0ck_stall, wb32_rxeth0ck_ack, wb32_rxeth0ck_err;
wire [31:0] wb32_rxeth0ck_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component spio
// Verilator lint_off UNUSED
wire wb32_spio_cyc, wb32_spio_stb, wb32_spio_we;
wire [11:0] wb32_spio_addr;
wire [31:0] wb32_spio_data;
wire [3:0] wb32_spio_sel;
wire wb32_spio_stall, wb32_spio_ack, wb32_spio_err;
wire [31:0] wb32_spio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component subseconds
// Verilator lint_off UNUSED
wire wb32_subseconds_cyc, wb32_subseconds_stb, wb32_subseconds_we;
wire [11:0] wb32_subseconds_addr;
wire [31:0] wb32_subseconds_data;
wire [3:0] wb32_subseconds_sel;
wire wb32_subseconds_stall, wb32_subseconds_ack, wb32_subseconds_err;
wire [31:0] wb32_subseconds_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component txclk
// Verilator lint_off UNUSED
wire wb32_txclk_cyc, wb32_txclk_stb, wb32_txclk_we;
wire [11:0] wb32_txclk_addr;
wire [31:0] wb32_txclk_data;
wire [3:0] wb32_txclk_sel;
wire wb32_txclk_stall, wb32_txclk_ack, wb32_txclk_err;
wire [31:0] wb32_txclk_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(SIO), component version
// Verilator lint_off UNUSED
wire wb32_version_cyc, wb32_version_stb, wb32_version_we;
wire [11:0] wb32_version_addr;
wire [31:0] wb32_version_data;
wire [3:0] wb32_version_sel;
wire wb32_version_stall, wb32_version_ack, wb32_version_err;
wire [31:0] wb32_version_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(DIO), component edid
// Verilator lint_off UNUSED
wire wb32_edids_cyc, wb32_edids_stb, wb32_edids_we;
wire [11:0] wb32_edids_addr;
wire [31:0] wb32_edids_data;
wire [3:0] wb32_edids_sel;
wire wb32_edids_stall, wb32_edids_ack, wb32_edids_err;
wire [31:0] wb32_edids_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb32(DIO), component gck
// Verilator lint_off UNUSED
wire wb32_gck_cyc, wb32_gck_stb, wb32_gck_we;