rd <= 1;
end
2: begin
+ `EXEC_INC_PC;
+ end
+ 3: begin
address <= {registers[`REG_SPH],registers[`REG_SPL]} - 1;
wdata <= registers[`REG_PCH];
wr <= 1;
end
- 3: begin
+ 4: begin
address <= {registers[`REG_SPH],registers[`REG_SPL]} - 2;
wdata <= registers[`REG_PCL];
wr <= 1;
end
- 4: begin /* nothing happens on the bus next cycle! */ end
5: begin
`EXEC_NEWCYCLE; /* do NOT increment the PC */
end
end
3: begin
cycle <= 4;
- registers[`REG_PCH] <= tmp2;
end
4: begin
cycle <= 5;
- registers[`REG_PCL] <= tmp;
+ registers[`REG_PCH] <= tmp2;
end
5: begin
{registers[`REG_SPH],registers[`REG_SPL]} <=
{registers[`REG_SPH],registers[`REG_SPL]} - 2;
+ registers[`REG_PCL] <= tmp;
cycle <= 0;
end
endcase
wire idata = data;
assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
- always @(wr or rd)
- begin
- if (decode && rd)
+ always @(posedge rd)
+ if (decode)
odata <= rom[address];
- end
endmodule
module InternalRAM(
input [15:0] address,
inout [7:0] data,
+ input clk,
input wr, rd);
reg [7:0] ram [8191:0];
wire idata = data;
assign data = (rd && decode) ? odata : 8'bzzzzzzzz;
- always @(rd or wr)
+ reg [13:0] diq;
+ initial
+ for (diq = 0; diq < 8191; diq = diq + 1)
+ ram[diq] = 8'h43;
+
+ always @(negedge clk)
begin
if (decode && rd)
- odata <= ram[address];
- else if (decode && wr)
- ram[address] <= idata;
+ odata <= ram[address[12:0]];
+ if (decode && wr)
+ ram[address[12:0]] <= data;
end
endmodule
InternalRAM ram(
.address(addr),
.data(data),
+ .clk(clk),
.wr(wr),
.rd(rd));
endmodule