Starting work on a simple cartridge
In order to get through bootstrap process
This commit is contained in:
30
rtl/cart.sv
Normal file
30
rtl/cart.sv
Normal file
@@ -0,0 +1,30 @@
|
||||
module cart (
|
||||
input wire clk,
|
||||
input wire nreset,
|
||||
input wire nrd_i,
|
||||
input wire nwr_i,
|
||||
input wire ncs_i,
|
||||
input wire [15:0] addr_i,
|
||||
inout wire [ 7:0] data_io
|
||||
);
|
||||
|
||||
logic cs;
|
||||
logic [ 7:0] rom_rdata;
|
||||
|
||||
assign cs = ~ncs_i;
|
||||
|
||||
assign data_io = (cs & ~nrd_i) ? rom_rdata : 'Z;
|
||||
|
||||
rom #(
|
||||
.FILE_NAME("tetris.gb"),
|
||||
.ADDR_W (14),
|
||||
.DATA_W (8)
|
||||
) rom_inst (
|
||||
.clk (clk),
|
||||
.nreset (nreset),
|
||||
.cs_i (cs),
|
||||
.address_i(addr_i[13:0]),
|
||||
.rdata_o (rom_rdata)
|
||||
);
|
||||
|
||||
endmodule : cart
|
||||
32
rtl/gb.sv
32
rtl/gb.sv
@@ -1,16 +1,16 @@
|
||||
// Top level gb module
|
||||
module gb (
|
||||
input logic clk,
|
||||
input logic nreset,
|
||||
input wire clk,
|
||||
input wire nreset,
|
||||
|
||||
// Cartridge bus
|
||||
output logic cart_clk_o,
|
||||
output logic cart_nreset_o,
|
||||
output logic cart_nrd_o,
|
||||
output logic cart_nwr_o,
|
||||
output logic cart_ncs_o,
|
||||
output logic [15:0] cart_addr_o,
|
||||
input logic [ 7:0] cart_data_i
|
||||
output wire cart_clk_o,
|
||||
output wire cart_nreset_o,
|
||||
output wire cart_nrd_o,
|
||||
output wire cart_nwr_o,
|
||||
output wire cart_ncs_o,
|
||||
output wire [15:0] cart_addr_o,
|
||||
inout wire [ 7:0] cart_data_io
|
||||
|
||||
);
|
||||
|
||||
@@ -31,6 +31,9 @@ logic [ 7:0] hiram_rdata;
|
||||
logic vram_sel;
|
||||
logic [ 7:0] vram_rdata;
|
||||
|
||||
logic cart_sel;
|
||||
logic [ 7:0] cart_rdata;
|
||||
|
||||
cpu cpu_inst (
|
||||
.clk (clk),
|
||||
.nreset (nreset),
|
||||
@@ -56,11 +59,13 @@ assign rom_enable_r = '1;
|
||||
assign rom_sel = rom_enable_r & ~(|cpu_addr[15:8]);
|
||||
assign vram_sel = (cpu_addr[15:13] == 3'b100);
|
||||
assign hiram_sel = (&cpu_addr[15:7]) & ~(&cpu_addr[6:0]);
|
||||
assign cart_sel = (~cpu_addr[15]) & (~cpu_addr[14]) & (~rom_sel);
|
||||
|
||||
assign cpu_rdata = rom_rdata |
|
||||
vram_rdata |
|
||||
hiram_rdata |
|
||||
cpu_ppu_rdata;
|
||||
cpu_ppu_rdata |
|
||||
cart_rdata;
|
||||
|
||||
rom #(
|
||||
.FILE_NAME("DMG_ROM.bin"),
|
||||
@@ -100,6 +105,13 @@ ram #(
|
||||
.wdata_i (cpu_wdata)
|
||||
);
|
||||
|
||||
assign cart_rdata = cart_sel ? cart_data_io : '0;
|
||||
|
||||
assign cart_clk_o = clk;
|
||||
assign cart_nreset_o = nreset;
|
||||
assign cart_nrd_o = 1'b0;
|
||||
assign cart_nwr_o = 1'b1;
|
||||
assign cart_ncs_o = ~cart_sel;
|
||||
assign cart_addr_o = cpu_addr;
|
||||
|
||||
endmodule : gb
|
||||
Reference in New Issue
Block a user