2021-02-01 00:40:56 +01:00
|
|
|
`include "../constants.vh"
|
|
|
|
|
|
|
|
module n64_bank_decoder (
|
2021-02-14 21:56:50 +01:00
|
|
|
input i_clk,
|
|
|
|
|
|
|
|
input i_address_high_op,
|
|
|
|
input [15:0] i_n64_pi_ad,
|
|
|
|
|
2021-02-01 00:40:56 +01:00
|
|
|
output reg [3:0] o_bank,
|
2021-02-14 21:56:50 +01:00
|
|
|
output reg o_prefetch,
|
2021-02-27 15:56:46 +01:00
|
|
|
output reg o_ddipl_pi_request,
|
|
|
|
output reg o_sram_pi_request,
|
|
|
|
output reg o_flashram_pi_request,
|
2021-02-14 21:56:50 +01:00
|
|
|
|
2021-02-01 00:40:56 +01:00
|
|
|
input i_ddipl_enable,
|
|
|
|
input i_sram_enable,
|
|
|
|
input i_flashram_enable,
|
2021-02-27 15:56:46 +01:00
|
|
|
input i_eeprom_pi_enable,
|
2021-02-14 21:56:50 +01:00
|
|
|
input i_sd_enable
|
2021-02-01 00:40:56 +01:00
|
|
|
);
|
|
|
|
|
2021-02-14 21:56:50 +01:00
|
|
|
always @(posedge i_clk) begin
|
|
|
|
if (i_address_high_op) begin
|
|
|
|
o_bank <= `BANK_INVALID;
|
|
|
|
o_prefetch <= 1'b1;
|
2021-02-27 15:56:46 +01:00
|
|
|
o_ddipl_pi_request <= 1'b0;
|
|
|
|
o_sram_pi_request <= 1'b0;
|
|
|
|
o_flashram_pi_request <= 1'b0;
|
2021-02-14 21:56:50 +01:00
|
|
|
|
|
|
|
casez (i_n64_pi_ad)
|
|
|
|
16'b0000011000??????: begin // DDIPL
|
|
|
|
if (i_ddipl_enable) begin
|
|
|
|
o_bank <= `BANK_SDRAM;
|
2021-02-27 15:56:46 +01:00
|
|
|
o_ddipl_pi_request <= 1'b1;
|
2021-02-14 21:56:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
16'b000010000000000?: begin // SRAM / FlashRAM
|
2021-02-27 15:56:46 +01:00
|
|
|
if (i_flashram_enable) begin
|
|
|
|
o_bank <= `BANK_SDRAM;
|
|
|
|
o_flashram_pi_request <= 1'b1;
|
2021-02-14 21:56:50 +01:00
|
|
|
end else if (i_sram_enable) begin
|
|
|
|
o_bank <= `BANK_SDRAM;
|
2021-02-27 15:56:46 +01:00
|
|
|
o_sram_pi_request <= 1'b1;
|
2021-02-14 21:56:50 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
16'b000100??????????: begin // ROM
|
|
|
|
o_bank <= `BANK_SDRAM;
|
|
|
|
end
|
|
|
|
|
|
|
|
16'b0001111000000000: begin // CART
|
|
|
|
o_bank <= `BANK_CART;
|
|
|
|
o_prefetch <= 1'b0;
|
|
|
|
end
|
|
|
|
|
|
|
|
16'b0001111000000001: begin // EEPROM
|
2021-02-27 15:56:46 +01:00
|
|
|
if (i_eeprom_pi_enable) begin
|
2021-02-14 21:56:50 +01:00
|
|
|
o_bank <= `BANK_EEPROM;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
16'b0001111000000010: begin // SD
|
|
|
|
if (i_sd_enable) begin
|
|
|
|
o_bank <= `BANK_SD;
|
|
|
|
o_prefetch <= 1'b0;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
default: begin end
|
|
|
|
endcase
|
2021-02-01 00:40:56 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
endmodule
|