ddipl enable separation

This commit is contained in:
Polprzewodnikowy 2022-07-01 18:25:39 +02:00
parent beb927aef3
commit 5cb0bb1581
7 changed files with 235 additions and 221 deletions

View File

@ -33,6 +33,9 @@
<Source name="../../rtl/n64/n64_cfg.sv" type="Verilog" type_short="Verilog"> <Source name="../../rtl/n64/n64_cfg.sv" type="Verilog" type_short="Verilog">
<Options VerilogStandard="System Verilog"/> <Options VerilogStandard="System Verilog"/>
</Source> </Source>
<Source name="../../rtl/n64/n64_dd.sv" type="Verilog" type_short="Verilog">
<Options VerilogStandard="System Verilog"/>
</Source>
<Source name="../../rtl/n64/n64_flashram.sv" type="Verilog" type_short="Verilog"> <Source name="../../rtl/n64/n64_flashram.sv" type="Verilog" type_short="Verilog">
<Options VerilogStandard="System Verilog"/> <Options VerilogStandard="System Verilog"/>
</Source> </Source>
@ -61,7 +64,7 @@
<Options VerilogStandard="System Verilog"/> <Options VerilogStandard="System Verilog"/>
</Source> </Source>
<Source name="../../rtl/sd/sd_crc_7.sv" type="Verilog" type_short="Verilog"> <Source name="../../rtl/sd/sd_crc_7.sv" type="Verilog" type_short="Verilog">
<Options VerilogStandard="System Verilog" top_module="sd_crc_7"/> <Options VerilogStandard="System Verilog"/>
</Source> </Source>
<Source name="../../rtl/sd/sd_scb.sv" type="Verilog" type_short="Verilog"> <Source name="../../rtl/sd/sd_scb.sv" type="Verilog" type_short="Verilog">
<Options VerilogStandard="System Verilog"/> <Options VerilogStandard="System Verilog"/>

View File

@ -471,9 +471,10 @@ module mcu_top (
REG_CFG_SCR: begin REG_CFG_SCR: begin
reg_rdata <= { reg_rdata <= {
22'd0, 21'd0,
n64_scb.eeprom_16k_mode, n64_scb.eeprom_16k_mode,
n64_scb.eeprom_enabled, n64_scb.eeprom_enabled,
n64_scb.ddipl_enabled,
n64_scb.dd_enabled, n64_scb.dd_enabled,
n64_scb.flashram_enabled, n64_scb.flashram_enabled,
n64_scb.sram_banked, n64_scb.sram_banked,
@ -620,6 +621,7 @@ module mcu_top (
n64_scb.eeprom_16k_mode <= 1'b0; n64_scb.eeprom_16k_mode <= 1'b0;
n64_scb.eeprom_enabled <= 1'b0; n64_scb.eeprom_enabled <= 1'b0;
n64_scb.dd_enabled <= 1'b0; n64_scb.dd_enabled <= 1'b0;
n64_scb.ddipl_enabled <= 1'b0;
n64_scb.flashram_enabled <= 1'b0; n64_scb.flashram_enabled <= 1'b0;
n64_scb.sram_banked <= 1'b0; n64_scb.sram_banked <= 1'b0;
n64_scb.sram_enabled <= 1'b0; n64_scb.sram_enabled <= 1'b0;
@ -673,6 +675,7 @@ module mcu_top (
{ {
n64_scb.eeprom_16k_mode, n64_scb.eeprom_16k_mode,
n64_scb.eeprom_enabled, n64_scb.eeprom_enabled,
n64_scb.ddipl_enabled,
n64_scb.dd_enabled, n64_scb.dd_enabled,
n64_scb.flashram_enabled, n64_scb.flashram_enabled,
n64_scb.sram_banked, n64_scb.sram_banked,
@ -681,7 +684,7 @@ module mcu_top (
n64_scb.rom_write_enabled, n64_scb.rom_write_enabled,
bootloader_skip, bootloader_skip,
n64_scb.bootloader_enabled n64_scb.bootloader_enabled
} <= reg_wdata[9:0]; } <= reg_wdata[10:0];
end end
REG_CFG_DATA_0: begin REG_CFG_DATA_0: begin

View File

@ -9,226 +9,228 @@ module n64_dd (
output logic irq output logic irq
); );
const bit [10:0] M_C2_BUFFER = 11'h000; assign irq = 1'b0;
const bit [10:0] M_SECTOR_BUFFER = 11'h400;
typedef enum bit [10:0] { // const bit [10:0] M_C2_BUFFER = 11'h000;
R_DATA = 11'h500, // const bit [10:0] M_SECTOR_BUFFER = 11'h400;
R_CMD_SR = 11'h508,
R_TRK_CUR = 11'h50C,
R_BM_SCR = 11'h510,
R_RESET = 11'h520,
R_SEC_SIZ = 11'h528,
R_SEC_INFO = 11'h530,
R_ID = 11'h540
} e_reg_id;
typedef enum bit [3:0] { // typedef enum bit [10:0] {
BM_CONTROL_START_BUFFER_MANAGER = 4'd15, // R_DATA = 11'h500,
BM_CONTROL_BUFFER_MANAGER_MODE = 4'd14, // R_CMD_SR = 11'h508,
BM_CONTROL_BUFFER_MANAGER_RESET = 4'd12, // R_TRK_CUR = 11'h50C,
BM_CONTROL_BLOCK_TRANSFER = 4'd9, // R_BM_SCR = 11'h510,
BM_CONTROL_MECHANIC_INTERRUPT_RESET = 4'd8 // R_RESET = 11'h520,
} e_bm_control_id; // R_SEC_SIZ = 11'h528,
// R_SEC_INFO = 11'h530,
// R_ID = 11'h540
// } e_reg_id;
// typedef enum bit [0:0] { // typedef enum bit [3:0] {
// S_IDLE, // BM_CONTROL_START_BUFFER_MANAGER = 4'd15,
// S_WAIT // BM_CONTROL_BUFFER_MANAGER_MODE = 4'd14,
// } e_state; // BM_CONTROL_BUFFER_MANAGER_RESET = 4'd12,
// BM_CONTROL_BLOCK_TRANSFER = 4'd9,
// BM_CONTROL_MECHANIC_INTERRUPT_RESET = 4'd8
// } e_bm_control_id;
// e_state state; // // typedef enum bit [0:0] {
// // S_IDLE,
// // S_WAIT
// // } e_state;
// // e_state state;
// // always_comb begin
// // dd.sector_address = bus.address[7:1];
// // dd.sector_address_valid = bus.request && bus.address[11:8] == M_SECTOR_BUFFER[11:8];
// // dd.sector_write = bus.write && dd.sector_address_valid;
// // dd.sector_wdata = bus.wdata;
// // end
// always_comb begin // always_comb begin
// dd.sector_address = bus.address[7:1]; // bus.rdata = 16'd0;
// dd.sector_address_valid = bus.request && bus.address[11:8] == M_SECTOR_BUFFER[11:8]; // if (bus.ack) begin
// dd.sector_write = bus.write && dd.sector_address_valid; // if (bus.address[10:8] == M_SECTOR_BUFFER[10:8]) begin
// dd.sector_wdata = bus.wdata; // if (bus.address[1]) begin
// bus.rdata = dd.sector_rdata[15:0];
// end else begin
// bus.rdata = dd.sector_rdata[31:16];
// end
// end else begin
// case (bus.address[10:0])
// R_DATA: bus.rdata = dd.data;
// R_CMD_SR: bus.rdata = {
// 1'b0,
// dd.bm_transfer_data,
// 1'b0,
// dd.bm_transfer_c2,
// 1'b0,
// dd.bm_interrupt,
// dd.cmd_interrupt,
// dd.disk_inserted,
// dd.cmd_pending,
// dd.hard_reset,
// 1'b0,
// 1'b0,
// 1'b0,
// 1'b0,
// 1'b0,
// dd.disk_changed
// };
// R_TRK_CUR: bus.rdata = {1'd0, {2{dd.index_lock}}, dd.head_track};
// R_BM_SCR: bus.rdata = {6'd0, dd.bm_micro_error, 9'd0};
// R_ID: bus.rdata = {dd.drive_id};
// default: bus.rdata = 16'd0;
// endcase
// end
// end
// end // end
always_comb begin // always_comb begin
bus.rdata = 16'd0; // reg_bus.rdata = 16'd0;
if (bus.ack) begin // if (reg_bus.address[10:8] == M_SECTOR_BUFFER[10:8]) begin
if (bus.address[10:8] == M_SECTOR_BUFFER[10:8]) begin // end else begin
if (bus.address[1]) begin // case (reg_bus.address[10:0])
bus.rdata = dd.sector_rdata[15:0]; // R_DATA: reg_bus.rdata = dd.data;
end else begin // R_CMD_SR: reg_bus.rdata = {
bus.rdata = dd.sector_rdata[31:16]; // 1'b0,
end // dd.bm_transfer_data,
end else begin // 1'b0,
case (bus.address[10:0]) // dd.bm_transfer_c2,
R_DATA: bus.rdata = dd.data; // 1'b0,
R_CMD_SR: bus.rdata = { // dd.bm_interrupt,
1'b0, // dd.cmd_interrupt,
dd.bm_transfer_data, // dd.disk_inserted,
1'b0, // dd.cmd_pending,
dd.bm_transfer_c2, // dd.hard_reset,
1'b0, // 1'b0,
dd.bm_interrupt, // 1'b0,
dd.cmd_interrupt, // 1'b0,
dd.disk_inserted, // 1'b0,
dd.cmd_pending, // 1'b0,
dd.hard_reset, // dd.disk_changed
1'b0, // };
1'b0, // R_TRK_CUR: reg_bus.rdata = {1'd0, {2{dd.index_lock}}, dd.head_track};
1'b0, // R_BM_SCR: reg_bus.rdata = {6'd0, dd.bm_micro_error, 9'd0};
1'b0, // R_ID: reg_bus.rdata = {dd.drive_id};
1'b0, // default: reg_bus.rdata = 16'd0;
dd.disk_changed // endcase
}; // end
R_TRK_CUR: bus.rdata = {1'd0, {2{dd.index_lock}}, dd.head_track}; // end
R_BM_SCR: bus.rdata = {6'd0, dd.bm_micro_error, 9'd0};
R_ID: bus.rdata = {dd.drive_id};
default: bus.rdata = 16'd0;
endcase
end
end
end
always_comb begin // always_ff @(posedge sys.clk) begin
reg_bus.rdata = 16'd0; // bus.ack <= 1'b0;
if (reg_bus.address[10:8] == M_SECTOR_BUFFER[10:8]) begin // dd.bm_interrupt_ack <= 1'b0;
end else begin
case (reg_bus.address[10:0])
R_DATA: reg_bus.rdata = dd.data;
R_CMD_SR: reg_bus.rdata = {
1'b0,
dd.bm_transfer_data,
1'b0,
dd.bm_transfer_c2,
1'b0,
dd.bm_interrupt,
dd.cmd_interrupt,
dd.disk_inserted,
dd.cmd_pending,
dd.hard_reset,
1'b0,
1'b0,
1'b0,
1'b0,
1'b0,
dd.disk_changed
};
R_TRK_CUR: reg_bus.rdata = {1'd0, {2{dd.index_lock}}, dd.head_track};
R_BM_SCR: reg_bus.rdata = {6'd0, dd.bm_micro_error, 9'd0};
R_ID: reg_bus.rdata = {dd.drive_id};
default: reg_bus.rdata = 16'd0;
endcase
end
end
always_ff @(posedge sys.clk) begin // if (dd.hard_reset_clear) begin
bus.ack <= 1'b0; // dd.hard_reset <= 1'b0;
dd.bm_interrupt_ack <= 1'b0; // end
// if (dd.cmd_ready) begin
// dd.data <= dd.cmd_data;
// dd.cmd_pending <= 1'b0;
// dd.cmd_interrupt <= 1'b1;
// end
// if (dd.bm_start_clear) begin
// dd.bm_start_pending <= 1'b0;
// end
// if (dd.bm_stop_clear) begin
// dd.bm_stop_pending <= 1'b0;
// end
// if (dd.bm_clear) begin
// dd.bm_pending <= 1'b0;
// end
// if (dd.bm_ready) begin
// dd.bm_interrupt <= 1'b1;
// end
// if (bus.real_address == (M_C2_BUFFER + ({dd.sector_size[7:1], 1'b0} * 3'd4)) && bus.read_op) begin
// dd.bm_pending <= 1'b1;
// end
// if (bus.real_address == (M_SECTOR_BUFFER + {dd.sector_size[7:1], 1'b0}) && (bus.read_op || bus.write_op)) begin
// dd.bm_pending <= 1'b1;
// end
// if (bus.real_address == (M_BASE + R_CMD_SR) && bus.read_op) begin
// dd.bm_interrupt <= 1'b0;
// dd.bm_interrupt_ack <= 1'b1;
// end
if (dd.hard_reset_clear) begin // if (sys.reset || sys.n64_hard_reset) begin
dd.hard_reset <= 1'b0; // dd.hard_reset <= 1'b1;
end // dd.cmd_pending <= 1'b0;
if (dd.cmd_ready) begin // dd.cmd_interrupt <= 1'b0;
dd.data <= dd.cmd_data; // dd.bm_start_pending <= 1'b0;
dd.cmd_pending <= 1'b0; // dd.bm_stop_pending <= 1'b0;
dd.cmd_interrupt <= 1'b1; // dd.bm_pending <= 1'b0;
end // dd.bm_interrupt <= 1'b0;
if (dd.bm_start_clear) begin // state <= S_IDLE;
dd.bm_start_pending <= 1'b0; // end else begin
end // case (state)
if (dd.bm_stop_clear) begin // S_IDLE: begin
dd.bm_stop_pending <= 1'b0; // if (bus.request) begin
end // state <= S_WAIT;
if (dd.bm_clear) begin // bus.ack <= 1'b1;
dd.bm_pending <= 1'b0; // if (bus.write) begin
end // case (bus.address[10:0])
if (dd.bm_ready) begin // R_DATA: begin
dd.bm_interrupt <= 1'b1; // dd.data <= bus.wdata;
end // end
if (bus.real_address == (M_C2_BUFFER + ({dd.sector_size[7:1], 1'b0} * 3'd4)) && bus.read_op) begin
dd.bm_pending <= 1'b1;
end
if (bus.real_address == (M_SECTOR_BUFFER + {dd.sector_size[7:1], 1'b0}) && (bus.read_op || bus.write_op)) begin
dd.bm_pending <= 1'b1;
end
if (bus.real_address == (M_BASE + R_CMD_SR) && bus.read_op) begin
dd.bm_interrupt <= 1'b0;
dd.bm_interrupt_ack <= 1'b1;
end
if (sys.reset || sys.n64_hard_reset) begin // R_CMD_SR: begin
dd.hard_reset <= 1'b1; // dd.cmd <= bus.wdata[7:0];
dd.cmd_pending <= 1'b0; // dd.cmd_pending <= 1'b1;
dd.cmd_interrupt <= 1'b0; // end
dd.bm_start_pending <= 1'b0;
dd.bm_stop_pending <= 1'b0;
dd.bm_pending <= 1'b0;
dd.bm_interrupt <= 1'b0;
state <= S_IDLE;
end else begin
case (state)
S_IDLE: begin
if (bus.request) begin
state <= S_WAIT;
bus.ack <= 1'b1;
if (bus.write) begin
case (bus.address[10:0])
R_DATA: begin
dd.data <= bus.wdata;
end
R_CMD_SR: begin // R_BM_SCR: begin
dd.cmd <= bus.wdata[7:0]; // dd.sector_num <= bus.wdata[7:0];
dd.cmd_pending <= 1'b1; // if (bus.wdata[BM_CONTROL_START_BUFFER_MANAGER]) begin
end // dd.bm_start_pending <= 1'b1;
// dd.bm_stop_pending <= 1'b0;
// dd.bm_transfer_mode <= bus.wdata[BM_CONTROL_BUFFER_MANAGER_MODE];
// dd.bm_transfer_blocks <= bus.wdata[BM_CONTROL_BLOCK_TRANSFER];
// end
// if (bus.wdata[BM_CONTROL_BUFFER_MANAGER_RESET]) begin
// dd.bm_start_pending <= 1'b0;
// dd.bm_stop_pending <= 1'b1;
// dd.bm_transfer_mode <= 1'b0;
// dd.bm_transfer_blocks <= 1'b0;
// dd.bm_pending <= 1'b0;
// dd.bm_interrupt <= 1'b0;
// end
// if (bus.wdata[BM_CONTROL_MECHANIC_INTERRUPT_RESET]) begin
// dd.cmd_interrupt <= 1'b0;
// end
// end
R_BM_SCR: begin // R_RESET: begin
dd.sector_num <= bus.wdata[7:0]; // if (bus.wdata == 16'hAAAA) begin
if (bus.wdata[BM_CONTROL_START_BUFFER_MANAGER]) begin // dd.hard_reset <= 1'b1;
dd.bm_start_pending <= 1'b1; // dd.cmd_pending <= 1'b0;
dd.bm_stop_pending <= 1'b0; // dd.cmd_interrupt <= 1'b0;
dd.bm_transfer_mode <= bus.wdata[BM_CONTROL_BUFFER_MANAGER_MODE]; // dd.bm_start_pending <= 1'b0;
dd.bm_transfer_blocks <= bus.wdata[BM_CONTROL_BLOCK_TRANSFER]; // dd.bm_stop_pending <= 1'b0;
end // dd.bm_pending <= 1'b0;
if (bus.wdata[BM_CONTROL_BUFFER_MANAGER_RESET]) begin // dd.bm_interrupt <= 1'b0;
dd.bm_start_pending <= 1'b0; // end
dd.bm_stop_pending <= 1'b1; // end
dd.bm_transfer_mode <= 1'b0;
dd.bm_transfer_blocks <= 1'b0;
dd.bm_pending <= 1'b0;
dd.bm_interrupt <= 1'b0;
end
if (bus.wdata[BM_CONTROL_MECHANIC_INTERRUPT_RESET]) begin
dd.cmd_interrupt <= 1'b0;
end
end
R_RESET: begin // R_SEC_SIZ: begin
if (bus.wdata == 16'hAAAA) begin // dd.sector_size <= bus.wdata[7:0];
dd.hard_reset <= 1'b1; // end
dd.cmd_pending <= 1'b0;
dd.cmd_interrupt <= 1'b0;
dd.bm_start_pending <= 1'b0;
dd.bm_stop_pending <= 1'b0;
dd.bm_pending <= 1'b0;
dd.bm_interrupt <= 1'b0;
end
end
R_SEC_SIZ: begin // R_SEC_INFO: begin
dd.sector_size <= bus.wdata[7:0]; // dd.sectors_in_block <= bus.wdata[15:8];
end // dd.sector_size_full <= bus.wdata[7:0];
// end
// endcase
// end
// end
// end
R_SEC_INFO: begin // S_WAIT: begin
dd.sectors_in_block <= bus.wdata[15:8]; // state <= S_IDLE;
dd.sector_size_full <= bus.wdata[7:0]; // end
end // endcase
endcase // end
end // end
end
end
S_WAIT: begin
state <= S_IDLE;
end
endcase
end
end
endmodule endmodule

View File

@ -154,6 +154,9 @@ module n64_pi (
write_port <= PORT_REG; write_port <= PORT_REG;
reg_bus.dd_select <= 1'b1; reg_bus.dd_select <= 1'b1;
end end
end
if (n64_scb.ddipl_enabled) begin
if (n64_pi_dq_in >= 16'h0600 && n64_pi_dq_in < 16'h0640) begin if (n64_pi_dq_in >= 16'h0600 && n64_pi_dq_in < 16'h0640) begin
read_port <= PORT_MEM; read_port <= PORT_MEM;
write_port <= PORT_NONE; write_port <= PORT_NONE;

View File

@ -11,6 +11,7 @@ interface n64_scb ();
logic flashram_enabled; logic flashram_enabled;
logic flashram_read_mode; logic flashram_read_mode;
logic dd_enabled; logic dd_enabled;
logic ddipl_enabled;
logic eeprom_enabled; logic eeprom_enabled;
logic eeprom_16k_mode; logic eeprom_16k_mode;
@ -52,6 +53,7 @@ interface n64_scb ();
output sram_banked, output sram_banked,
output flashram_enabled, output flashram_enabled,
output dd_enabled, output dd_enabled,
output ddipl_enabled,
output eeprom_enabled, output eeprom_enabled,
output eeprom_16k_mode, output eeprom_16k_mode,
@ -94,12 +96,14 @@ interface n64_scb ();
input sram_banked, input sram_banked,
input flashram_enabled, input flashram_enabled,
input flashram_read_mode, input flashram_read_mode,
input dd_enabled input dd_enabled,
input ddipl_enabled
); );
// modport dd ( modport dd (
input n64_reset,
// ); input n64_nmi
);
modport flashram ( modport flashram (
output flashram_read_mode, output flashram_read_mode,

View File

@ -45,18 +45,16 @@ module n64_top (
.n64_pi_ad(n64_pi_ad) .n64_pi_ad(n64_pi_ad)
); );
assign n64_dd_irq = 1'b0; n64_dd n64_dd_inst (
.clk(clk),
.reset(reset),
// n64_dd n64_dd_inst ( .reg_bus(reg_bus),
// .clk(clk),
// .reset(reset),
// .reg_bus(reg_bus), .n64_scb(n64_scb),
// .n64_scb(n64_scb), .irq(n64_dd_irq)
);
// .irq(n64_dd_irq)
// );
n64_flashram n64_flashram_inst ( n64_flashram n64_flashram_inst (
.clk(clk), .clk(clk),

View File

@ -93,8 +93,9 @@ typedef enum {
#define CFG_SCR_SRAM_BANKED (1 << 5) #define CFG_SCR_SRAM_BANKED (1 << 5)
#define CFG_SCR_FLASHRAM_ENABLED (1 << 6) #define CFG_SCR_FLASHRAM_ENABLED (1 << 6)
#define CFG_SCR_DD_ENABLED (1 << 7) #define CFG_SCR_DD_ENABLED (1 << 7)
#define CFG_SCR_EEPROM_ENABLED (1 << 8) #define CFG_SCR_DDIPL_ENABLED (1 << 8)
#define CFG_SCR_EEPROM_16K (1 << 9) #define CFG_SCR_EEPROM_ENABLED (1 << 9)
#define CFG_SCR_EEPROM_16K (1 << 10)
#define CFG_CMD_DONE (1 << 0) #define CFG_CMD_DONE (1 << 0)
#define CFG_CMD_ERROR (1 << 1) #define CFG_CMD_ERROR (1 << 1)