SummerCart64/fw/rtl/system/system.sv

73 lines
1.5 KiB
Systemverilog
Raw Normal View History

2021-08-18 13:54:07 +02:00
interface if_system (
input in_clk,
input n64_reset,
input n64_nmi
);
2021-08-05 19:50:29 +02:00
logic clk;
logic sdram_clk;
logic reset;
2021-08-18 13:54:07 +02:00
logic n64_soft_reset;
logic n64_hard_reset;
2021-08-05 19:50:29 +02:00
2021-08-18 13:54:07 +02:00
modport internal (
2021-08-05 19:50:29 +02:00
input in_clk,
2021-08-18 13:54:07 +02:00
input n64_reset,
input n64_nmi,
2021-08-05 19:50:29 +02:00
output clk,
output sdram_clk,
2021-08-18 13:54:07 +02:00
output reset,
output n64_soft_reset,
output n64_hard_reset
2021-08-05 19:50:29 +02:00
);
modport sys (
input clk,
2021-08-18 13:54:07 +02:00
input reset,
input n64_soft_reset,
input n64_hard_reset
2021-08-05 19:50:29 +02:00
);
modport sdram (
input sdram_clk
);
endinterface
2021-08-18 13:54:07 +02:00
module system (if_system.internal sys);
2021-08-05 19:50:29 +02:00
2021-08-18 13:54:07 +02:00
logic locked;
logic external_reset;
logic [1:0] n64_reset_ff;
logic [1:0] n64_nmi_ff;
2021-08-05 19:50:29 +02:00
intel_pll intel_pll_inst (
2021-08-18 13:54:07 +02:00
.inclk0(sys.in_clk),
.c0(sys.clk),
.c1(sys.sdram_clk),
2021-08-05 19:50:29 +02:00
.locked(locked)
);
2021-08-21 04:35:40 +02:00
generate
if (sc64::DEBUG_ENABLED) begin
intel_snp intel_snp_inst (
.source(external_reset),
.source_clk(sys.clk)
);
end
endgenerate
2021-08-18 13:54:07 +02:00
always_ff @(posedge sys.clk) begin
n64_reset_ff <= {n64_reset_ff[0], sys.n64_reset};
n64_nmi_ff <= {n64_nmi_ff[0], sys.n64_nmi};
end
always_comb begin
sys.reset = ~locked | external_reset;
sys.n64_hard_reset <= ~n64_reset_ff[1];
sys.n64_soft_reset <= ~n64_nmi_ff[1];
end
2021-08-05 19:50:29 +02:00
endmodule