SummerCart64/fw/rtl/SummerCart64.sv

144 lines
3.0 KiB
Systemverilog
Raw Normal View History

2021-08-01 15:32:48 +02:00
module SummerCart64 (
input i_clk,
input i_n64_reset,
input i_n64_nmi,
2021-08-12 21:07:47 +02:00
output o_n64_irq,
2021-08-01 15:32:48 +02:00
input i_n64_pi_alel,
input i_n64_pi_aleh,
input i_n64_pi_read,
input i_n64_pi_write,
inout [15:0] io_n64_pi_ad,
input i_n64_si_clk,
inout io_n64_si_dq,
output o_sdram_clk,
output o_sdram_cs,
output o_sdram_ras,
output o_sdram_cas,
output o_sdram_we,
output [1:0] o_sdram_ba,
output [12:0] o_sdram_a,
inout [15:0] io_sdram_dq,
2021-08-20 19:51:55 +02:00
output o_rtc_scl,
inout io_rtc_sda,
output o_usb_clk,
output o_usb_cs,
input i_usb_miso,
inout [3:0] io_usb_miosi,
input i_usb_pwren,
input i_uart_rxd,
output o_uart_txd,
input i_uart_cts,
output o_uart_rts,
2021-08-01 15:32:48 +02:00
output o_sd_clk,
inout io_sd_cmd,
inout [3:0] io_sd_dat,
2021-08-16 00:23:10 +02:00
output o_led
2021-08-01 15:32:48 +02:00
);
2021-08-18 13:54:07 +02:00
logic [7:0] gpio_o;
logic [7:0] gpio_i;
logic [7:0] gpio_oe;
2021-08-01 15:32:48 +02:00
2021-08-18 13:54:07 +02:00
if_system sys (
.in_clk(i_clk),
.n64_reset(i_n64_reset),
.n64_nmi(i_n64_nmi)
);
2021-08-20 19:51:55 +02:00
if_config cfg ();
2021-08-21 02:53:28 +02:00
if_dma dma ();
2021-08-28 04:15:24 +02:00
if_sdram sdram ();
2021-08-28 17:57:48 +02:00
if_flashram flashram ();
2021-09-06 12:59:37 +02:00
if_si si ();
2021-08-18 13:54:07 +02:00
system system_inst (
.sys(sys)
);
2021-08-01 15:32:48 +02:00
2021-08-21 02:53:28 +02:00
intel_gpio_ddro sdram_clk_ddro (
.outclock(sys.sdram.sdram_clk),
.din({1'b0, 1'b1}),
.pad_out(o_sdram_clk)
);
2021-08-20 19:51:55 +02:00
n64_soc n64_soc_inst (
.sys(sys),
.cfg(cfg),
2021-08-21 02:53:28 +02:00
.dma(dma),
2021-08-28 04:15:24 +02:00
.sdram(sdram),
2021-08-28 17:57:48 +02:00
.flashram(flashram),
2021-09-06 12:59:37 +02:00
.si(si),
2021-08-20 19:51:55 +02:00
.n64_pi_alel(i_n64_pi_alel),
.n64_pi_aleh(i_n64_pi_aleh),
.n64_pi_read(i_n64_pi_read),
.n64_pi_write(i_n64_pi_write),
.n64_pi_ad(io_n64_pi_ad),
.n64_si_clk(i_n64_si_clk),
.n64_si_dq(io_n64_si_dq),
.sdram_cs(o_sdram_cs),
.sdram_ras(o_sdram_ras),
.sdram_cas(o_sdram_cas),
.sdram_we(o_sdram_we),
.sdram_ba(o_sdram_ba),
.sdram_a(o_sdram_a),
.sdram_dq(io_sdram_dq)
);
2021-08-12 21:07:47 +02:00
cpu_soc cpu_soc_inst (
2021-08-18 13:54:07 +02:00
.sys(sys),
2021-08-20 19:51:55 +02:00
.cfg(cfg),
2021-08-21 02:53:28 +02:00
.dma(dma),
2021-08-28 04:15:24 +02:00
.sdram(sdram),
2021-08-28 17:57:48 +02:00
.flashram(flashram),
2021-09-06 12:59:37 +02:00
.si(si),
2021-08-18 13:54:07 +02:00
2021-08-12 21:07:47 +02:00
.gpio_o(gpio_o),
.gpio_i(gpio_i),
.gpio_oe(gpio_oe),
2021-08-18 13:54:07 +02:00
2021-08-20 19:51:55 +02:00
.i2c_scl(o_rtc_scl),
2021-08-18 13:54:07 +02:00
.i2c_sda(io_rtc_sda),
2021-08-12 21:07:47 +02:00
.usb_clk(o_usb_clk),
.usb_cs(o_usb_cs),
.usb_miso(i_usb_miso),
.usb_miosi(io_usb_miosi),
2021-08-18 13:54:07 +02:00
.usb_pwren(i_usb_pwren),
.uart_rxd(i_uart_rxd),
.uart_txd(o_uart_txd),
.uart_cts(i_uart_cts),
2021-08-20 19:51:55 +02:00
.uart_rts(o_uart_rts),
2021-08-18 13:54:07 +02:00
2021-08-20 19:51:55 +02:00
.sd_clk(o_sd_clk),
.sd_cmd(io_sd_cmd),
.sd_dat(io_sd_dat)
2021-08-12 21:07:47 +02:00
);
2021-08-01 15:32:48 +02:00
2021-08-26 00:43:29 +02:00
always_comb begin
o_led = gpio_oe[0] ? gpio_o[0] : 1'bZ;
o_n64_irq = gpio_oe[1] ? gpio_o[1] : 1'bZ;
end
always_ff @(posedge sys.clk) begin
gpio_i <= {4'b0000, i_n64_nmi, i_n64_reset, o_n64_irq, o_led};
end
2021-08-01 15:32:48 +02:00
endmodule