Skip to content

Commit

Permalink
SM83: Zero upper address lines after each mem cyc
Browse files Browse the repository at this point in the history
  • Loading branch information
msinger committed Feb 21, 2021
1 parent ee47ddb commit b3a7b45
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
37 changes: 29 additions & 8 deletions src/cpu/sm83_control.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1554,8 +1554,13 @@ module sm83_control(
m2 && t2,
m2 && t3:;

/* Read register F into ALU flags */
m2 && t4: af_to_alu(Z|N|H|C);
m2 && t4: begin
/* Read register F into ALU flags */
af_to_alu(Z|N|H|C);

/* Apply address latch to address bus for write cycle */
ctl_io_adr_we = 1; /* posedge */
end

m3 && t1: begin
/* Write data latch into ALU operand A */
Expand Down Expand Up @@ -2050,8 +2055,13 @@ module sm83_control(
m2 && t2,
m2 && t3:;

/* Read register F into ALU flags */
m2 && t4: af_to_alu(Z|N|H|C);
m2 && t4: begin
/* Read register F into ALU flags */
af_to_alu(Z|N|H|C);

/* Apply address latch to address bus for write cycle */
ctl_io_adr_we = 1; /* posedge */
end

m3 && t1: begin
/* Write data latch into ALU operands with shift */
Expand Down Expand Up @@ -2163,8 +2173,13 @@ module sm83_control(
m2 && t2,
m2 && t3:;

/* Read register F into ALU flags */
m2 && t4: af_to_alu(Z|N|H|C);
m2 && t4: begin
/* Read register F into ALU flags */
af_to_alu(Z|N|H|C);

/* Apply address latch to address bus for write cycle */
ctl_io_adr_we = 1; /* posedge */
end

m3 && t1: begin
/* Write data latch into ALU operand B */
Expand Down Expand Up @@ -2397,7 +2412,10 @@ module sm83_control(
dl_to_alu_bsel();
end

m2 && t4:;
m2 && t4: begin
/* Apply address latch to address bus for write cycle */
ctl_io_adr_we = 1; /* posedge */
end

m3 && t1: begin
/* Write data latch into ALU operand A */
Expand Down Expand Up @@ -2500,7 +2518,10 @@ module sm83_control(
dl_to_alu_bsel();
end

m2 && t4:;
m2 && t4: begin
/* Apply address latch to address bus for write cycle */
ctl_io_adr_we = 1; /* posedge */
end

m3 && t1: begin
/* Write data latch into ALU operand A */
Expand Down
9 changes: 8 additions & 1 deletion src/cpu/sm83_io.sv
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ module sm83_io
endcase
end

always_ff @(posedge clk) if (al_we) aout = ain;
always_ff @(posedge clk) begin
/* Zero upper address lines after each memory cycle */
if (t4)
aout[ADR_WIDTH-1:8] = 0;

if (al_we)
aout = ain;
end

/* Emulate latch behaviour for data input.
* Input data is already latched at IO port, but only for one tick (during T4). */
Expand Down

0 comments on commit b3a7b45

Please sign in to comment.