-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmain.v
1844 lines (1757 loc) · 52.2 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: ./main.v
//
// Project: OpenArty, an entirely open SoC based upon the Arty platform
//
// DO NOT EDIT THIS FILE!
// Computer Generated: This file is computer generated by AUTOFPGA. DO NOT EDIT.
// DO NOT EDIT THIS FILE!
//
// CmdLine: autofpga autofpga -d -o . allclocks.txt global.txt icape.txt version.txt buserr.txt pic.txt pwrcount.txt spio.txt clrspio.txt rtcgps.txt rtcdate.txt wbuconsole.txt bkram.txt spansion.txt sdram.txt zipmaster.txt mdio.txt enet.txt gps.txt wboledrgb.txt mem_flash_bkram.txt mem_bkram_only.txt mem_sdram_bkram.txt
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017-2020, 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
//
//
// 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 ALLCLOCKS_PRESENT
`define WBUBUS_MASTER
// And then for the independent peripherals
`define GPSTRK_ACCESS
`define OLEDRGB_ACCESS
`define INCLUDE_ZIPCPU
`define CFG_ACCESS
`define GPSUART_ACCESS
`define BUSPIC_ACCESS
`define FLASH_ACCESS
`define BUSCONSOLE_ACCESS
`define CLRLED_ACCESS
`define SPIO_ACCESS
`define RTC_ACCESS
`define BKRAM_ACCESS
`define PWRCOUNT_ACCESS
`define NETCTRL_ACCESS
//
//
// 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//
`ifdef FLASH_ACCESS
`define FLASHCFG_ACCESS
`endif // FLASH_ACCESS
`ifdef RTC_ACCESS
`define RTCDATE_ACCESS
`endif // RTC_ACCESS
`ifdef ALLCLOCKS_PRESENT
`define ETHERNET_ACCESS
`endif // ALLCLOCKS_PRESENT
`ifdef ALLCLOCKS_PRESENT
`define SDRAM_ACCESS
`endif // ALLCLOCKS_PRESENT
//
// End of dependency list
//
//
//
// Any include files
//
// These are drawn from anything with a MAIN.INCLUDE definition.
//
//
// 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 GPS 1PPS signal port
i_gps_pps,
// Ethernet control (packets) lines
// i_eth_tx_clk and i_eth_rx_clk come from allclocks.txt
o_eth_rstn, i_eth_col, i_eth_crs, i_eth_rx_dv,
i_eth_rxd, i_eth_rxerr,
o_eth_tx_en, o_eth_txd,
// OLEDRGB control interface (roughly SPI)
o_oledrgb_sck, o_oledrgb_cs_n, o_oledrgb_mosi,
o_oledrgb_dcn, o_oledrgb_reset_n,
o_oledrgb_vccen, o_oledrgb_pmoden,
i_eth_rx_clk,
// SDRAM ports
o_sdram_cyc, o_sdram_stb, o_sdram_we,
o_sdram_addr, o_sdram_data, o_sdram_sel,
i_sdram_stall, i_sdram_ack, i_sdram_data,
i_sdram_err,
i_cpu_reset,
// The GPS-UART
i_gpsu_rx, o_gpsu_tx,
// The Universal QSPI Flash
o_qspi_cs_n, o_qspi_sck, o_qspi_dat, i_qspi_dat, o_qspi_mod,
i_eth_tx_clk,
// UART/host to wishbone interface
i_wbu_uart_rx, o_wbu_uart_tx,
no_clk,
// CLRLED interface
o_clr_ledr, o_clr_ledg, o_clr_ledb,
// SPIO interface
i_sw, i_btn, o_led,
// The ethernet MDIO wires
o_mdclk, o_mdio, o_mdwe, i_mdio);
//
// 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
localparam [31:0] GPSCLOCK_DEFAULT_STEP = 32'had373298;
//
//
// Variables/definitions needed 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 = 155189248;
`else
localparam RESET_ADDRESS = 134217728;
`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
localparam ICAPE_LGDIV=3;
//
// WBUBUS parameters
//
// Baudrate : 1000000
// Clock : 81247960
localparam [23:0] BUSUART = 24'h51; // 1000000 baud
localparam DBGBUSBITS = $clog2(BUSUART);
//
// Maximum command is 6 bytes, where each byte takes 10 baud clocks
// and each baud clock requires DBGBUSBITS to represent. Here,
// we'll add one more for good measure.
localparam DBGBUSWATCHDOG_RAW = DBGBUSBITS + 9;
localparam DBGBUSWATCHDOG = (DBGBUSWATCHDOG_RAW > 19)
? DBGBUSWATCHDOG_RAW : 19;
//
// 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 GPS Clock
input wire i_gps_pps;
// Ethernet control
output wire o_eth_rstn;
input wire i_eth_col, i_eth_crs, i_eth_rx_dv;
input wire [3:0] i_eth_rxd;
input wire i_eth_rxerr;
output wire o_eth_tx_en;
output wire [3:0] o_eth_txd;
// OLEDRGB interface
output wire o_oledrgb_sck, o_oledrgb_cs_n,
o_oledrgb_mosi,
o_oledrgb_dcn, o_oledrgb_reset_n,
o_oledrgb_vccen, o_oledrgb_pmoden;
// With no ethernet included, this clock will be unused
// Verilator lint_off UNUSED
input wire i_eth_rx_clk;
// Verilator lint_on UNUSED
// SDRAM I/O declarations
output wire o_sdram_cyc,
o_sdram_stb, o_sdram_we;
output wire [(27-1):0] o_sdram_addr;
output wire [(32-1):0] o_sdram_data;
output wire [(32/8)-1:0] o_sdram_sel;
//
input wire i_sdram_ack;
input wire i_sdram_stall;
input wire [(32-1):0] i_sdram_data;
// Verilator lint_off UNUSED
input wire i_sdram_err;
// Verilator lint_on UNUSED
input wire i_cpu_reset;
input wire i_gpsu_rx;
output wire o_gpsu_tx;
// The Universal QSPI flash
output wire o_qspi_cs_n, o_qspi_sck;
output wire [3:0] o_qspi_dat;
input wire [3:0] i_qspi_dat;
output wire [1:0] o_qspi_mod;
// With no ethernet included, this clock will be unused
// Verilator lint_off UNUSED
input wire i_eth_tx_clk;
// Verilator lint_on UNUSED
input wire i_wbu_uart_rx;
output wire o_wbu_uart_tx;
// This clock is unused in main, AutoFPGA still wants it though
// Verilator lint_off UNUSED
input wire no_clk;
// Verilator lint_on UNUSED
// SPIO interface
output wire [3:0] o_clr_ledr, o_clr_ledg, o_clr_ledb;
// SPIO interface
input wire [4-1:0] i_sw;
input wire [4-1:0] i_btn;
output wire [4-1:0] o_led;
// Ethernet control (MDIO)
output wire o_mdclk, o_mdio, o_mdwe;
input wire i_mdio;
// 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 ck_pps; // gck.INT.PPS.WIRE
wire nettx_int; // netp.INT.NETTX.WIRE
wire netrx_int; // netp.INT.NETRX.WIRE
wire oledrgb_int; // oledrgb.INT.OLED.WIRE
wire zip_cpu_int; // zip.INT.ZIP.WIRE
wire gpsutx_int; // gpsu.INT.GPSTX.WIRE
wire gpsutxf_int; // gpsu.INT.GPSTXF.WIRE
wire gpsurx_int; // gpsu.INT.GPSRX.WIRE
wire gpsurxf_int; // gpsu.INT.GPSRXF.WIRE
wire w_bus_int; // buspic.INT.BUS.WIRE
wire uarttxf_int; // uart.INT.UARTTXF.WIRE
wire uartrxf_int; // uart.INT.UARTRXF.WIRE
wire uarttx_int; // uart.INT.UARTTX.WIRE
wire uartrx_int; // uart.INT.UARTRX.WIRE
wire spio_int; // spio.INT.SPIO.WIRE
wire rtc_int; // rtc.INT.RTC.WIRE
//
// Component declarations
//
// These declarations come from the @MAIN.DEFNS keys found in the
// various components comprising the design.
//
wire gps_pps, gps_led, gps_locked, gps_tracking;
wire [63:0] gps_now, gps_err, gps_step;
wire [1:0] gps_dbg_tick;
wire [31:0] gps_dbg;
wire tb_pps;
//
wire [31:0] netp_debug;
`include "builddate.v"
// ZipSystem/ZipCPU connection definitions
// All we define here is a set of scope wires
wire [31:0] zip_debug;
wire zip_trigger;
wire [ZIP_INTS-1:0] zip_int_vector;
wire w_gpsu_cts_n, w_gpsu_rts_n;
assign w_gpsu_cts_n=1'b1;
// BUILDTIME doesnt need to include builddate.v a second time
// `include "builddate.v"
// Definitions for the flash debug port
wire flash_dbg_trigger;
wire [31:0] flash_debug;
`ifndef GPSTRK_ACCESS
reg [31:0] r_subseconds_data;
`endif
reg [28-1:0] r_buserr_addr;
//
//
// UART interface
//
//
wire [7:0] wbu_rx_data, wbu_tx_data;
wire wbu_rx_stb;
wire wbu_tx_stb, wbu_tx_busy;
wire w_ck_uart, w_uart_tx;
// Definitions for the WB-UART converter. We really only need one
// (more) non-bus wire--one to use to select if we are interacting
// with the ZipCPU or not.
wire [0:0] wbubus_dbg;
`ifndef INCLUDE_ZIPCPU
//
// The bus-console depends upon the zip_dbg wires. If there is no
// ZipCPU defining them, we'll need to define them here anyway.
//
wire zip_dbg_stall, zip_dbg_ack;
wire [31:0] zip_dbg_data;
`endif
// Console definitions
wire w_console_rx_stb, w_console_tx_stb, w_console_busy;
wire [6:0] w_console_rx_data, w_console_tx_data;
wire [31:0] uart_debug;
`ifndef PWRCOUNT_ACCESS
reg [8:0] clrled_counter;
`else
wire [8:0] clrled_counter;
`endif
wire [31:0] clrled0_data, clrled1_data,
clrled2_data, clrled3_data;
reg r_clrled_ack;
reg [31:0] r_clrled_data;
// Definitions in support of the GPS driven RTC
// This clock step is designed to match 81247960 Hz
localparam [31:0] RTC_CLKSTEP = 32'h0034dcca;
wire rtc_ppd, rtc_pps;
reg r_rtc_ack;
reg [31:0] r_pwrcount_data;
//
// Declaring interrupt vector wires
//
// These declarations come from the various components having
// PIC and PIC.MAX keys.
//
wire [14:0] bus_int_vector;
wire [14:0] alt_int_vector;
wire [14:0] sys_int_vector;
//
//
// Define bus wires
//
//
// Bus wb
// Wishbone definitions for bus wb, component zip
// Verilator lint_off UNUSED
wire wb_zip_cyc, wb_zip_stb, wb_zip_we;
wire [26:0] wb_zip_addr;
wire [31:0] wb_zip_data;
wire [3:0] wb_zip_sel;
wire wb_zip_stall, wb_zip_ack, wb_zip_err;
wire [31:0] wb_zip_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component wbu_arbiter
// Verilator lint_off UNUSED
wire wb_wbu_arbiter_cyc, wb_wbu_arbiter_stb, wb_wbu_arbiter_we;
wire [26:0] wb_wbu_arbiter_addr;
wire [31:0] wb_wbu_arbiter_data;
wire [3:0] wb_wbu_arbiter_sel;
wire wb_wbu_arbiter_stall, wb_wbu_arbiter_ack, wb_wbu_arbiter_err;
wire [31:0] wb_wbu_arbiter_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component buildtime
// Verilator lint_off UNUSED
wire wb_buildtime_cyc, wb_buildtime_stb, wb_buildtime_we;
wire [26:0] wb_buildtime_addr;
wire [31:0] wb_buildtime_data;
wire [3:0] wb_buildtime_sel;
wire wb_buildtime_stall, wb_buildtime_ack, wb_buildtime_err;
wire [31:0] wb_buildtime_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component buserr
// Verilator lint_off UNUSED
wire wb_buserr_cyc, wb_buserr_stb, wb_buserr_we;
wire [26:0] wb_buserr_addr;
wire [31:0] wb_buserr_data;
wire [3:0] wb_buserr_sel;
wire wb_buserr_stall, wb_buserr_ack, wb_buserr_err;
wire [31:0] wb_buserr_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component buspic
// Verilator lint_off UNUSED
wire wb_buspic_cyc, wb_buspic_stb, wb_buspic_we;
wire [26:0] wb_buspic_addr;
wire [31:0] wb_buspic_data;
wire [3:0] wb_buspic_sel;
wire wb_buspic_stall, wb_buspic_ack, wb_buspic_err;
wire [31:0] wb_buspic_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component pwrcount
// Verilator lint_off UNUSED
wire wb_pwrcount_cyc, wb_pwrcount_stb, wb_pwrcount_we;
wire [26:0] wb_pwrcount_addr;
wire [31:0] wb_pwrcount_data;
wire [3:0] wb_pwrcount_sel;
wire wb_pwrcount_stall, wb_pwrcount_ack, wb_pwrcount_err;
wire [31:0] wb_pwrcount_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component rtcdate
// Verilator lint_off UNUSED
wire wb_rtcdate_cyc, wb_rtcdate_stb, wb_rtcdate_we;
wire [26:0] wb_rtcdate_addr;
wire [31:0] wb_rtcdate_data;
wire [3:0] wb_rtcdate_sel;
wire wb_rtcdate_stall, wb_rtcdate_ack, wb_rtcdate_err;
wire [31:0] wb_rtcdate_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component spio
// Verilator lint_off UNUSED
wire wb_spio_cyc, wb_spio_stb, wb_spio_we;
wire [26:0] wb_spio_addr;
wire [31:0] wb_spio_data;
wire [3:0] wb_spio_sel;
wire wb_spio_stall, wb_spio_ack, wb_spio_err;
wire [31:0] wb_spio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component subseconds
// Verilator lint_off UNUSED
wire wb_subseconds_cyc, wb_subseconds_stb, wb_subseconds_we;
wire [26:0] wb_subseconds_addr;
wire [31:0] wb_subseconds_data;
wire [3:0] wb_subseconds_sel;
wire wb_subseconds_stall, wb_subseconds_ack, wb_subseconds_err;
wire [31:0] wb_subseconds_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(SIO), component version
// Verilator lint_off UNUSED
wire wb_version_cyc, wb_version_stb, wb_version_we;
wire [26:0] wb_version_addr;
wire [31:0] wb_version_data;
wire [3:0] wb_version_sel;
wire wb_version_stall, wb_version_ack, wb_version_err;
wire [31:0] wb_version_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(DIO), component clrled
// Verilator lint_off UNUSED
wire wb_clrled_cyc, wb_clrled_stb, wb_clrled_we;
wire [26:0] wb_clrled_addr;
wire [31:0] wb_clrled_data;
wire [3:0] wb_clrled_sel;
wire wb_clrled_stall, wb_clrled_ack, wb_clrled_err;
wire [31:0] wb_clrled_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(DIO), component gck
// Verilator lint_off UNUSED
wire wb_gck_cyc, wb_gck_stb, wb_gck_we;
wire [26:0] wb_gck_addr;
wire [31:0] wb_gck_data;
wire [3:0] wb_gck_sel;
wire wb_gck_stall, wb_gck_ack, wb_gck_err;
wire [31:0] wb_gck_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(DIO), component oledrgb
// Verilator lint_off UNUSED
wire wb_oledrgb_cyc, wb_oledrgb_stb, wb_oledrgb_we;
wire [26:0] wb_oledrgb_addr;
wire [31:0] wb_oledrgb_data;
wire [3:0] wb_oledrgb_sel;
wire wb_oledrgb_stall, wb_oledrgb_ack, wb_oledrgb_err;
wire [31:0] wb_oledrgb_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(DIO), component gtb
// Verilator lint_off UNUSED
wire wb_gtb_cyc, wb_gtb_stb, wb_gtb_we;
wire [26:0] wb_gtb_addr;
wire [31:0] wb_gtb_data;
wire [3:0] wb_gtb_sel;
wire wb_gtb_stall, wb_gtb_ack, wb_gtb_err;
wire [31:0] wb_gtb_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(DIO), component netp
// Verilator lint_off UNUSED
wire wb_netp_cyc, wb_netp_stb, wb_netp_we;
wire [26:0] wb_netp_addr;
wire [31:0] wb_netp_data;
wire [3:0] wb_netp_sel;
wire wb_netp_stall, wb_netp_ack, wb_netp_err;
wire [31:0] wb_netp_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(DIO), component rtc
// Verilator lint_off UNUSED
wire wb_rtc_cyc, wb_rtc_stb, wb_rtc_we;
wire [26:0] wb_rtc_addr;
wire [31:0] wb_rtc_data;
wire [3:0] wb_rtc_sel;
wire wb_rtc_stall, wb_rtc_ack, wb_rtc_err;
wire [31:0] wb_rtc_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb(DIO), component wb_sio
// Verilator lint_off UNUSED
wire wb_sio_cyc, wb_sio_stb, wb_sio_we;
wire [26:0] wb_sio_addr;
wire [31:0] wb_sio_data;
wire [3:0] wb_sio_sel;
wire wb_sio_stall, wb_sio_ack, wb_sio_err;
wire [31:0] wb_sio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component flashcfg
// Verilator lint_off UNUSED
wire wb_flashcfg_cyc, wb_flashcfg_stb, wb_flashcfg_we;
wire [26:0] wb_flashcfg_addr;
wire [31:0] wb_flashcfg_data;
wire [3:0] wb_flashcfg_sel;
wire wb_flashcfg_stall, wb_flashcfg_ack, wb_flashcfg_err;
wire [31:0] wb_flashcfg_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component gpsu
// Verilator lint_off UNUSED
wire wb_gpsu_cyc, wb_gpsu_stb, wb_gpsu_we;
wire [26:0] wb_gpsu_addr;
wire [31:0] wb_gpsu_data;
wire [3:0] wb_gpsu_sel;
wire wb_gpsu_stall, wb_gpsu_ack, wb_gpsu_err;
wire [31:0] wb_gpsu_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component uart
// Verilator lint_off UNUSED
wire wb_uart_cyc, wb_uart_stb, wb_uart_we;
wire [26:0] wb_uart_addr;
wire [31:0] wb_uart_data;
wire [3:0] wb_uart_sel;
wire wb_uart_stall, wb_uart_ack, wb_uart_err;
wire [31:0] wb_uart_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component cfg
// Verilator lint_off UNUSED
wire wb_cfg_cyc, wb_cfg_stb, wb_cfg_we;
wire [26:0] wb_cfg_addr;
wire [31:0] wb_cfg_data;
wire [3:0] wb_cfg_sel;
wire wb_cfg_stall, wb_cfg_ack, wb_cfg_err;
wire [31:0] wb_cfg_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component mdio
// Verilator lint_off UNUSED
wire wb_mdio_cyc, wb_mdio_stb, wb_mdio_we;
wire [26:0] wb_mdio_addr;
wire [31:0] wb_mdio_data;
wire [3:0] wb_mdio_sel;
wire wb_mdio_stall, wb_mdio_ack, wb_mdio_err;
wire [31:0] wb_mdio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component wb_dio
// Verilator lint_off UNUSED
wire wb_dio_cyc, wb_dio_stb, wb_dio_we;
wire [26:0] wb_dio_addr;
wire [31:0] wb_dio_data;
wire [3:0] wb_dio_sel;
wire wb_dio_stall, wb_dio_ack, wb_dio_err;
wire [31:0] wb_dio_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component netb
// Verilator lint_off UNUSED
wire wb_netb_cyc, wb_netb_stb, wb_netb_we;
wire [26:0] wb_netb_addr;
wire [31:0] wb_netb_data;
wire [3:0] wb_netb_sel;
wire wb_netb_stall, wb_netb_ack, wb_netb_err;
wire [31:0] wb_netb_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component bkram
// Verilator lint_off UNUSED
wire wb_bkram_cyc, wb_bkram_stb, wb_bkram_we;
wire [26:0] wb_bkram_addr;
wire [31:0] wb_bkram_data;
wire [3:0] wb_bkram_sel;
wire wb_bkram_stall, wb_bkram_ack, wb_bkram_err;
wire [31:0] wb_bkram_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component flash
// Verilator lint_off UNUSED
wire wb_flash_cyc, wb_flash_stb, wb_flash_we;
wire [26:0] wb_flash_addr;
wire [31:0] wb_flash_data;
wire [3:0] wb_flash_sel;
wire wb_flash_stall, wb_flash_ack, wb_flash_err;
wire [31:0] wb_flash_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wb, component sdram
// Verilator lint_off UNUSED
wire wb_sdram_cyc, wb_sdram_stb, wb_sdram_we;
wire [26:0] wb_sdram_addr;
wire [31:0] wb_sdram_data;
wire [3:0] wb_sdram_sel;
wire wb_sdram_stall, wb_sdram_ack, wb_sdram_err, sdram_err;
assign wb_sdram_err = sdram_err;
wire [31:0] wb_sdram_idata;
// Verilator lint_on UNUSED
// Bus wbu
// Wishbone definitions for bus wbu, component wbu
// Verilator lint_off UNUSED
wire wbu_wbu_cyc, wbu_wbu_stb, wbu_wbu_we;
wire [27:0] wbu_wbu_addr;
wire [31:0] wbu_wbu_data;
wire [3:0] wbu_wbu_sel;
wire wbu_wbu_stall, wbu_wbu_ack, wbu_wbu_err;
wire [31:0] wbu_wbu_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbu, component wbu_arbiter
// Verilator lint_off UNUSED
wire wbu_wbu_arbiter_cyc, wbu_wbu_arbiter_stb, wbu_wbu_arbiter_we;
wire [27:0] wbu_wbu_arbiter_addr;
wire [31:0] wbu_wbu_arbiter_data;
wire [3:0] wbu_wbu_arbiter_sel;
wire wbu_wbu_arbiter_stall, wbu_wbu_arbiter_ack, wbu_wbu_arbiter_err;
wire [31:0] wbu_wbu_arbiter_idata;
// Verilator lint_on UNUSED
// Wishbone definitions for bus wbu, component zip
// Verilator lint_off UNUSED
wire wbu_zip_cyc, wbu_zip_stb, wbu_zip_we;
wire [27:0] wbu_zip_addr;
wire [31:0] wbu_zip_data;
wire [3:0] wbu_zip_sel;
wire wbu_zip_stall, wbu_zip_ack, wbu_zip_err;
wire [31:0] wbu_zip_idata;
// Verilator lint_on UNUSED
//
// Peripheral address decoding
//
//
// BUS-LOGIC for wb
//
//
// wb Bus logic to handle SINGLE slaves
//
reg r_wb_sio_ack;
reg [31:0] r_wb_sio_data;
assign wb_sio_stall = 1'b0;
initial r_wb_sio_ack = 1'b0;
always @(posedge i_clk)
r_wb_sio_ack <= (wb_sio_stb);
assign wb_sio_ack = r_wb_sio_ack;
always @(posedge i_clk)
casez( wb_sio_addr[2:0] )
3'h0: r_wb_sio_data <= wb_buildtime_idata;
3'h1: r_wb_sio_data <= wb_buserr_idata;
3'h2: r_wb_sio_data <= wb_buspic_idata;
3'h3: r_wb_sio_data <= wb_pwrcount_idata;
3'h4: r_wb_sio_data <= wb_rtcdate_idata;
3'h5: r_wb_sio_data <= wb_spio_idata;
3'h6: r_wb_sio_data <= wb_subseconds_idata;
3'h7: r_wb_sio_data <= wb_version_idata;
// No default: SIZE = 8, [Guru meditation: 3 != 3]
endcase
assign wb_sio_idata = r_wb_sio_data;
//
// Now to translate this logic to the various SIO slaves
//
// In this case, the SIO bus has the prefix wb_sio
// and all of the slaves have various wires beginning
// with their own respective bus prefixes.
// Our goal here is to make certain that all of
// the slave bus inputs match the SIO bus wires
assign wb_buildtime_cyc = wb_sio_cyc;
assign wb_buildtime_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h0); // 0x0000000
assign wb_buildtime_we = wb_sio_we;
assign wb_buildtime_data= wb_sio_data;
assign wb_buildtime_sel = wb_sio_sel;
assign wb_buserr_cyc = wb_sio_cyc;
assign wb_buserr_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h1); // 0x0000004
assign wb_buserr_we = wb_sio_we;
assign wb_buserr_data= wb_sio_data;
assign wb_buserr_sel = wb_sio_sel;
assign wb_buspic_cyc = wb_sio_cyc;
assign wb_buspic_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h2); // 0x0000008
assign wb_buspic_we = wb_sio_we;
assign wb_buspic_data= wb_sio_data;
assign wb_buspic_sel = wb_sio_sel;
assign wb_pwrcount_cyc = wb_sio_cyc;
assign wb_pwrcount_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h3); // 0x000000c
assign wb_pwrcount_we = wb_sio_we;
assign wb_pwrcount_data= wb_sio_data;
assign wb_pwrcount_sel = wb_sio_sel;
assign wb_rtcdate_cyc = wb_sio_cyc;
assign wb_rtcdate_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h4); // 0x0000010
assign wb_rtcdate_we = wb_sio_we;
assign wb_rtcdate_data= wb_sio_data;
assign wb_rtcdate_sel = wb_sio_sel;
assign wb_spio_cyc = wb_sio_cyc;
assign wb_spio_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h5); // 0x0000014
assign wb_spio_we = wb_sio_we;
assign wb_spio_data= wb_sio_data;
assign wb_spio_sel = wb_sio_sel;
assign wb_subseconds_cyc = wb_sio_cyc;
assign wb_subseconds_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h6); // 0x0000018
assign wb_subseconds_we = wb_sio_we;
assign wb_subseconds_data= wb_sio_data;
assign wb_subseconds_sel = wb_sio_sel;
assign wb_version_cyc = wb_sio_cyc;
assign wb_version_stb = wb_sio_stb && (wb_sio_addr[ 2: 0] == 3'h7); // 0x000001c
assign wb_version_we = wb_sio_we;
assign wb_version_data= wb_sio_data;
assign wb_version_sel = wb_sio_sel;
//
// wb Bus logic to handle 7 DOUBLE slaves
//
//
reg [1:0] r_wb_dio_ack;
// # dlist = 7, nextlg(#dlist) = 3
reg [2:0] r_wb_dio_bus_select;
reg [31:0] r_wb_dio_data;
// DOUBLE peripherals are not allowed to stall.
assign wb_dio_stall = 1'b0;
// DOUBLE peripherals return their acknowledgments in two
// clocks--always, allowing us to collect this logic together
// in a slave independent manner. Here, the acknowledgment
// is treated as a two stage shift register, cleared on any
// reset, or any time the cycle line drops. (Dropping the
// cycle line aborts the transaction.)
initial r_wb_dio_ack = 0;
always @(posedge i_clk)
if (i_reset || !wb_dio_cyc)
r_wb_dio_ack <= 0;
else
r_wb_dio_ack <= { r_wb_dio_ack[0], (wb_dio_stb) };
assign wb_dio_ack = r_wb_dio_ack[1];
// Since it costs us two clocks to go through this
// logic, we'll take one of those clocks here to set
// a selection index, and then on the next clock we'll
// use this index to select from among the vaious
// possible bus return values
always @(posedge i_clk)
casez(wb_dio_addr[5:3])
3'b000: r_wb_dio_bus_select <= 3'd0;
3'b001: r_wb_dio_bus_select <= 3'd1;
3'b010: r_wb_dio_bus_select <= 3'd2;
3'b011: r_wb_dio_bus_select <= 3'd3;
3'b100: r_wb_dio_bus_select <= 3'd4;
3'b101: r_wb_dio_bus_select <= 3'd5;
3'b110: r_wb_dio_bus_select <= 3'd6;
default: r_wb_dio_bus_select <= 0;
endcase
always @(posedge i_clk)
casez(r_wb_dio_bus_select)
3'd0: r_wb_dio_data <= wb_clrled_idata;
3'd1: r_wb_dio_data <= wb_gck_idata;
3'd2: r_wb_dio_data <= wb_oledrgb_idata;
3'd3: r_wb_dio_data <= wb_gtb_idata;
3'd4: r_wb_dio_data <= wb_netp_idata;
3'd5: r_wb_dio_data <= wb_rtc_idata;
3'd6: r_wb_dio_data <= wb_sio_idata;
default: r_wb_dio_data <= wb_sio_idata;
endcase
assign wb_dio_idata = r_wb_dio_data;
assign wb_clrled_cyc = wb_dio_cyc;
assign wb_clrled_stb = wb_dio_stb && ((wb_dio_addr[ 5: 3] & 3'h7) == 3'h0); // 0x0000000
assign wb_clrled_we = wb_dio_we;
assign wb_clrled_addr= wb_dio_addr;
assign wb_clrled_data= wb_dio_data;
assign wb_clrled_sel = wb_dio_sel;
assign wb_gck_cyc = wb_dio_cyc;
assign wb_gck_stb = wb_dio_stb && ((wb_dio_addr[ 5: 3] & 3'h7) == 3'h1); // 0x0000020 - 0x000002f
assign wb_gck_we = wb_dio_we;
assign wb_gck_addr= wb_dio_addr;
assign wb_gck_data= wb_dio_data;
assign wb_gck_sel = wb_dio_sel;
assign wb_oledrgb_cyc = wb_dio_cyc;
assign wb_oledrgb_stb = wb_dio_stb && ((wb_dio_addr[ 5: 3] & 3'h7) == 3'h2); // 0x0000040 - 0x000004f
assign wb_oledrgb_we = wb_dio_we;
assign wb_oledrgb_addr= wb_dio_addr;
assign wb_oledrgb_data= wb_dio_data;
assign wb_oledrgb_sel = wb_dio_sel;
assign wb_gtb_cyc = wb_dio_cyc;
assign wb_gtb_stb = wb_dio_stb && ((wb_dio_addr[ 5: 3] & 3'h7) == 3'h3); // 0x0000060 - 0x000007f
assign wb_gtb_we = wb_dio_we;
assign wb_gtb_addr= wb_dio_addr;
assign wb_gtb_data= wb_dio_data;
assign wb_gtb_sel = wb_dio_sel;
assign wb_netp_cyc = wb_dio_cyc;
assign wb_netp_stb = wb_dio_stb && ((wb_dio_addr[ 5: 3] & 3'h7) == 3'h4); // 0x0000080 - 0x000009f
assign wb_netp_we = wb_dio_we;
assign wb_netp_addr= wb_dio_addr;
assign wb_netp_data= wb_dio_data;
assign wb_netp_sel = wb_dio_sel;
assign wb_rtc_cyc = wb_dio_cyc;
assign wb_rtc_stb = wb_dio_stb && ((wb_dio_addr[ 5: 3] & 3'h7) == 3'h5); // 0x00000a0 - 0x00000bf
assign wb_rtc_we = wb_dio_we;
assign wb_rtc_addr= wb_dio_addr;
assign wb_rtc_data= wb_dio_data;
assign wb_rtc_sel = wb_dio_sel;
assign wb_sio_cyc = wb_dio_cyc;
assign wb_sio_stb = wb_dio_stb && ((wb_dio_addr[ 5: 3] & 3'h7) == 3'h6); // 0x00000c0 - 0x00000df
assign wb_sio_we = wb_dio_we;
assign wb_sio_addr= wb_dio_addr;
assign wb_sio_data= wb_dio_data;
assign wb_sio_sel = wb_dio_sel;
assign wb_flashcfg_err= 1'b0;
assign wb_gpsu_err= 1'b0;
assign wb_uart_err= 1'b0;
assign wb_cfg_err= 1'b0;
assign wb_mdio_err= 1'b0;
assign wb_dio_err= 1'b0;
assign wb_netb_err= 1'b0;
assign wb_bkram_err= 1'b0;
assign wb_flash_err= 1'b0;
// info: @ERROR.WIRE sdram_err != wb_sdram
// info: @ERROR.WIRE for sdram, = sdram_err, doesn't match the buses wire wb_sdram_err
assign wb_sdram_err = sdram_err;
//
// Connect the wb bus components together using the wbxbar()
//
//
wbxbar #(
.NM(2), .NS(10), .AW(27), .DW(32),
.SLAVE_ADDR({
// Address width = 27
// Address LSBs = 2
// Slave name width = 8
{ 27'h4000000 }, // sdram: 0x10000000
{ 27'h2400000 }, // flash: 0x09000000
{ 27'h2000000 }, // bkram: 0x08000000
{ 27'h1c00000 }, // netb: 0x07000000
{ 27'h1800000 }, // wb_dio: 0x06000000
{ 27'h1400000 }, // mdio: 0x05000000
{ 27'h1000000 }, // cfg: 0x04000000
{ 27'h0c00000 }, // uart: 0x03000000
{ 27'h0800000 }, // gpsu: 0x02000000
{ 27'h0400000 } // flashcfg: 0x01000000
}),
.SLAVE_MASK({
// Address width = 27
// Address LSBs = 2
// Slave name width = 8
{ 27'h4000000 }, // sdram
{ 27'h7c00000 }, // flash
{ 27'h7c00000 }, // bkram
{ 27'h7c00000 }, // netb
{ 27'h7c00000 }, // wb_dio
{ 27'h7c00000 }, // mdio
{ 27'h7c00000 }, // cfg
{ 27'h7c00000 }, // uart
{ 27'h7c00000 }, // gpsu
{ 27'h7c00000 } // flashcfg
}),
.OPT_DBLBUFFER(1'b1))
wb_xbar(
.i_clk(i_clk), .i_reset(i_reset),
.i_mcyc({
wb_wbu_arbiter_cyc,
wb_zip_cyc
}),
.i_mstb({
wb_wbu_arbiter_stb,
wb_zip_stb
}),
.i_mwe({
wb_wbu_arbiter_we,
wb_zip_we
}),
.i_maddr({
wb_wbu_arbiter_addr,
wb_zip_addr
}),
.i_mdata({
wb_wbu_arbiter_data,
wb_zip_data
}),
.i_msel({
wb_wbu_arbiter_sel,
wb_zip_sel
}),
.o_mstall({
wb_wbu_arbiter_stall,
wb_zip_stall
}),
.o_mack({
wb_wbu_arbiter_ack,
wb_zip_ack
}),
.o_mdata({
wb_wbu_arbiter_idata,
wb_zip_idata
}),
.o_merr({
wb_wbu_arbiter_err,
wb_zip_err
}),
// Slave connections
.o_scyc({
wb_sdram_cyc,
wb_flash_cyc,
wb_bkram_cyc,
wb_netb_cyc,
wb_dio_cyc,
wb_mdio_cyc,
wb_cfg_cyc,
wb_uart_cyc,
wb_gpsu_cyc,
wb_flashcfg_cyc
}),
.o_sstb({
wb_sdram_stb,
wb_flash_stb,
wb_bkram_stb,
wb_netb_stb,
wb_dio_stb,
wb_mdio_stb,
wb_cfg_stb,
wb_uart_stb,
wb_gpsu_stb,
wb_flashcfg_stb
}),
.o_swe({
wb_sdram_we,
wb_flash_we,
wb_bkram_we,
wb_netb_we,
wb_dio_we,
wb_mdio_we,
wb_cfg_we,
wb_uart_we,
wb_gpsu_we,
wb_flashcfg_we
}),
.o_saddr({
wb_sdram_addr,
wb_flash_addr,
wb_bkram_addr,
wb_netb_addr,
wb_dio_addr,
wb_mdio_addr,
wb_cfg_addr,
wb_uart_addr,
wb_gpsu_addr,
wb_flashcfg_addr
}),
.o_sdata({
wb_sdram_data,
wb_flash_data,
wb_bkram_data,
wb_netb_data,
wb_dio_data,
wb_mdio_data,
wb_cfg_data,
wb_uart_data,
wb_gpsu_data,
wb_flashcfg_data
}),
.o_ssel({
wb_sdram_sel,
wb_flash_sel,
wb_bkram_sel,
wb_netb_sel,
wb_dio_sel,
wb_mdio_sel,
wb_cfg_sel,