mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-25 07:06:52 +01:00
fixed fast PI read, added PI R/W fifo debug info
This commit is contained in:
parent
2e4fd2b200
commit
0a06fd26a5
@ -355,7 +355,8 @@ module mcu_top (
|
||||
REG_DD_SECTOR_INFO,
|
||||
REG_DD_DRIVE_ID,
|
||||
REG_VENDOR_SCR,
|
||||
REG_VENDOR_DATA
|
||||
REG_VENDOR_DATA,
|
||||
REG_DEBUG
|
||||
} reg_address_e;
|
||||
|
||||
logic bootloader_skip;
|
||||
@ -627,6 +628,13 @@ module mcu_top (
|
||||
REG_VENDOR_DATA: begin
|
||||
reg_rdata <= vendor_scb.data_rdata;
|
||||
end
|
||||
|
||||
REG_DEBUG: begin
|
||||
reg_rdata <= {
|
||||
28'd0,
|
||||
n64_scb.pi_debug
|
||||
};
|
||||
end
|
||||
endcase
|
||||
end
|
||||
end
|
||||
|
@ -250,7 +250,6 @@ module n64_pi (
|
||||
logic [15:0] read_fifo_rdata;
|
||||
|
||||
logic read_fifo_wait;
|
||||
logic [15:0] read_fifo_buffer;
|
||||
|
||||
n64_pi_fifo read_fifo_inst (
|
||||
.clk(clk),
|
||||
@ -269,7 +268,10 @@ module n64_pi (
|
||||
|
||||
always_ff @(posedge clk) begin
|
||||
read_fifo_read <= 1'b0;
|
||||
read_fifo_buffer <= read_fifo_rdata;
|
||||
|
||||
if (reset) begin
|
||||
n64_scb.pi_debug[1:0] <= 2'b00;
|
||||
end
|
||||
|
||||
if (reset || !pi_reset || alel_op) begin
|
||||
read_fifo_wait <= 1'b0;
|
||||
@ -279,16 +281,20 @@ module n64_pi (
|
||||
if (read_op) begin
|
||||
if (read_fifo_empty) begin
|
||||
read_fifo_wait <= 1'b1;
|
||||
n64_scb.pi_debug[0] <= 1'b1;
|
||||
if (read_fifo_wait) begin
|
||||
n64_scb.pi_debug[1] <= 1'b1;
|
||||
end
|
||||
end else begin
|
||||
read_fifo_read <= 1'b1;
|
||||
n64_pi_dq_out <= read_fifo_buffer;
|
||||
n64_pi_dq_out <= read_fifo_rdata;
|
||||
end
|
||||
end
|
||||
|
||||
if (!read_fifo_empty && read_fifo_wait) begin
|
||||
read_fifo_read <= 1'b1;
|
||||
read_fifo_wait <= 1'b0;
|
||||
n64_pi_dq_out <= read_fifo_buffer;
|
||||
n64_pi_dq_out <= read_fifo_rdata;
|
||||
end
|
||||
end
|
||||
|
||||
@ -330,6 +336,10 @@ module n64_pi (
|
||||
always_ff @(posedge clk) begin
|
||||
write_fifo_write <= 1'b0;
|
||||
|
||||
if (reset) begin
|
||||
n64_scb.pi_debug[3:2] <= 2'b00;
|
||||
end
|
||||
|
||||
if (reset) begin
|
||||
write_fifo_wait <= 1'b0;
|
||||
end
|
||||
@ -338,6 +348,10 @@ module n64_pi (
|
||||
if (write_op) begin
|
||||
if (write_fifo_full) begin
|
||||
write_fifo_wait <= 1'b1;
|
||||
n64_scb.pi_debug[2] <= 1'b1;
|
||||
if (write_fifo_wait) begin
|
||||
n64_scb.pi_debug[3] <= 1'b1;
|
||||
end
|
||||
end else begin
|
||||
write_fifo_write <= 1'b1;
|
||||
write_fifo_wdata <= n64_pi_dq_in;
|
||||
|
@ -51,6 +51,8 @@ interface n64_scb ();
|
||||
logic [31:0] cfg_wdata [0:1];
|
||||
logic [31:0] cfg_version;
|
||||
|
||||
logic [3:0] pi_debug;
|
||||
|
||||
modport controller (
|
||||
input n64_reset,
|
||||
input n64_nmi,
|
||||
@ -86,7 +88,9 @@ interface n64_scb ();
|
||||
input cfg_cmd,
|
||||
input cfg_rdata,
|
||||
output cfg_wdata,
|
||||
output cfg_version
|
||||
output cfg_version,
|
||||
|
||||
input pi_debug
|
||||
);
|
||||
|
||||
modport pi (
|
||||
@ -105,7 +109,9 @@ interface n64_scb ();
|
||||
|
||||
input flashram_read_mode,
|
||||
|
||||
input cfg_unlock
|
||||
input cfg_unlock,
|
||||
|
||||
output pi_debug
|
||||
);
|
||||
|
||||
modport flashram (
|
||||
|
@ -519,6 +519,10 @@ void cfg_process (void) {
|
||||
dd_set_sd_disk_info(args[0], args[1]);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
args[0] = fpga_reg_get(REG_DEBUG);
|
||||
break;
|
||||
|
||||
default:
|
||||
cfg_set_error(CFG_ERROR_UNKNOWN_CMD);
|
||||
return;
|
||||
|
@ -51,7 +51,8 @@ typedef enum {
|
||||
REG_DD_SECTOR_INFO,
|
||||
REG_DD_DRIVE_ID,
|
||||
REG_VENDOR_SCR,
|
||||
REG_VENDOR_DATA
|
||||
REG_VENDOR_DATA,
|
||||
REG_DEBUG
|
||||
} fpga_reg_t;
|
||||
|
||||
|
||||
|
@ -275,6 +275,13 @@ static void usb_rx_process (void) {
|
||||
}
|
||||
break;
|
||||
|
||||
case '?':
|
||||
p.rx_state = RX_STATE_IDLE;
|
||||
p.response_pending = true;
|
||||
p.response_info.data_length = 4;
|
||||
p.response_info.data[0] = fpga_reg_get(REG_DEBUG);
|
||||
break;
|
||||
|
||||
default:
|
||||
p.rx_state = RX_STATE_IDLE;
|
||||
p.response_pending = true;
|
||||
|
@ -193,6 +193,7 @@ class SC64Serial:
|
||||
|
||||
class SC64:
|
||||
class __Address(IntEnum):
|
||||
MEMORY = 0x0000_0000
|
||||
SDRAM = 0x0000_0000
|
||||
FLASH = 0x0400_0000
|
||||
BUFFER = 0x0500_0000
|
||||
@ -205,6 +206,7 @@ class SC64:
|
||||
SHADOW = 0x04FE_0000
|
||||
|
||||
class __Length(IntEnum):
|
||||
MEMORY = 0x0500_2980
|
||||
SDRAM = (64 * 1024 * 1024)
|
||||
FLASH = (16 * 1024 * 1024)
|
||||
BUFFER = (8 * 1024)
|
||||
@ -390,7 +392,7 @@ class SC64:
|
||||
self.__link.execute_cmd(cmd=b'U', args=[datatype, len(data)], data=data, response=False)
|
||||
|
||||
def download_memory(self) -> bytes:
|
||||
return self.__read_memory(self.__Address.SDRAM, self.__Length.SDRAM + self.__Length.FLASH)
|
||||
return self.__read_memory(self.__Address.MEMORY, self.__Length.MEMORY)
|
||||
|
||||
def upload_rom(self, data: bytes, use_shadow: bool=True) -> None:
|
||||
rom_length = len(data)
|
||||
@ -711,8 +713,9 @@ class EnumAction(argparse.Action):
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='SC64 control software')
|
||||
parser.add_argument('--backup-firmware', help='backup SC64 firmware and write it to specified file')
|
||||
parser.add_argument('--update-firmware', help='update SC64 firmware from specified file')
|
||||
parser.add_argument('--backup-firmware', metavar='file', help='backup SC64 firmware and write it to specified file')
|
||||
parser.add_argument('--update-firmware', metavar='file', help='update SC64 firmware from specified file')
|
||||
parser.add_argument('--bootloader', metavar='file', help='update SC64 bootloader (not recommended, use --update-firmware instead)')
|
||||
parser.add_argument('--reset-state', action='store_true', help='reset SC64 internal state')
|
||||
parser.add_argument('--print-state', action='store_true', help='print SC64 internal state')
|
||||
parser.add_argument('--boot', type=SC64.BootMode, action=EnumAction, help='set boot mode')
|
||||
@ -720,16 +723,15 @@ if __name__ == '__main__':
|
||||
parser.add_argument('--cic', type=SC64.CICSeed, action=EnumAction, help='force CIC seed to set value')
|
||||
parser.add_argument('--rtc', action='store_true', help='update clock in SC64 to system time')
|
||||
parser.add_argument('--no-shadow', action='store_false', help='do not put last 128 kB of ROM inside flash memory (can corrupt non EEPROM saves)')
|
||||
parser.add_argument('--rom', help='upload ROM from specified file')
|
||||
parser.add_argument('--rom', metavar='file', help='upload ROM from specified file')
|
||||
parser.add_argument('--save-type', type=SC64.SaveType, action=EnumAction, help='set save type')
|
||||
parser.add_argument('--save', help='upload save from specified file')
|
||||
parser.add_argument('--backup-save', help='download save and write it to specified file')
|
||||
parser.add_argument('--ddipl', help='upload 64DD IPL from specified file')
|
||||
parser.add_argument('--disk', action='append', help='path to 64DD disk (.ndd format), can be specified multiple times')
|
||||
parser.add_argument('--save', metavar='file', help='upload save from specified file')
|
||||
parser.add_argument('--backup-save', metavar='file', help='download save and write it to specified file')
|
||||
parser.add_argument('--ddipl', metavar='file', help='upload 64DD IPL from specified file')
|
||||
parser.add_argument('--disk', metavar='file', action='append', help='path to 64DD disk (.ndd format), can be specified multiple times')
|
||||
parser.add_argument('--isv', action='store_true', help='enable IS-Viewer64 support')
|
||||
parser.add_argument('--debug', action='store_true', help='run debug loop (required for 64DD and IS-Viewer64)')
|
||||
parser.add_argument('--download-memory', help='download whole memory space and write it to specified file')
|
||||
parser.add_argument('--bootloader', help='bootloader')
|
||||
parser.add_argument('--download-memory', metavar='file', help='download whole memory space and write it to specified file')
|
||||
|
||||
if (len(sys.argv) <= 1):
|
||||
parser.print_help()
|
||||
|
Loading…
Reference in New Issue
Block a user