flashram fixes

This commit is contained in:
Polprzewodnikowy 2021-08-29 19:31:33 +02:00
parent be006aff10
commit 8a2a729a69
4 changed files with 13 additions and 9 deletions

View File

@ -285,7 +285,7 @@ void cfg_update_config (uint32_t *args) {
void cfg_set_save_type (uint8_t type) {
CFG->SCR &= ~(CFG_SCR_FLASHRAM_EN | CFG_SCR_SRAM_BANKED | CFG_SCR_SRAM_EN);
uint32_t save_offset = 0;
uint32_t save_offset = DEFAULT_SAVE_OFFSET;
switch (type) {
case 0: {

View File

@ -68,7 +68,7 @@ module cpu_flashram (
flashram.operation_done <= 1'b0;
if (bus.request) begin
if (!bus.address[5] && bus.wmask[0]) begin
if (!bus.address[7] && bus.wmask[0]) begin
flashram.operation_done <= bus.wdata[1];
end
end

View File

@ -44,7 +44,7 @@ module cpu_sdram (
bus.rdata = rdata;
end
sdram.write = current_word ? &bus.wmask[3:2] : &bus.wmask[1:0];
sdram.write = current_word ? &bus.wmask[1:0] : &bus.wmask[3:2];
sdram.address = {1'b0, bus.address[30:2], current_word, 1'b0};
sdram.wdata = current_word ? bus.wdata[15:0] : bus.wdata[31:16];
end

View File

@ -44,21 +44,25 @@ module n64_flashram (
logic [7:0] flashram_command;
logic flashram_erase_enabled;
logic [1:0][15:0] write_buffer [0:31];
logic [31:0] write_buffer [0:31];
logic [1:0] write_buffer_wmask;
logic [15:0] high_buffer;
always_comb begin
write_buffer_wmask = 2'b00;
if (bus.request && bus.write && !bus.address[16] && flashram_state == FS_BUFFER) begin
write_buffer_wmask[0] = bus.address[1];
write_buffer_wmask[1] = !bus.address[1];
write_buffer_wmask[0] = !bus.address[1];
write_buffer_wmask[1] = bus.address[1];
end
end
always_ff @(posedge sys.clk) begin
if (write_buffer_wmask[0]) high_buffer <= bus.wdata;
end
always @(posedge sys.clk) begin
flashram.rdata <= {write_buffer[flashram.address][1], write_buffer[flashram.address][0]};
if (write_buffer_wmask[0]) write_buffer[bus.address[6:2]][0] <= bus.wdata;
if (write_buffer_wmask[1]) write_buffer[bus.address[6:2]][1] <= bus.wdata;
flashram.rdata <= write_buffer[flashram.address];
if (write_buffer_wmask[1]) write_buffer[bus.address[6:2]] <= {high_buffer, bus.wdata};
end
always_comb begin