added tentative decoder stall support

This commit is contained in:
Raphael Jacquot 2019-02-12 08:21:32 +01:00
parent c7cc7f417b
commit 3136a4c37b
2 changed files with 17 additions and 7 deletions

View file

@ -10,7 +10,7 @@ module saturn_decoder(
i_cycles,
i_en_dbg,
i_en_dec,
// i_stalled,
i_stalled,
i_pc,
i_nibble,
o_inc_pc,
@ -24,7 +24,7 @@ input wire i_reset;
input wire [31:0] i_cycles;
input wire i_en_dbg;
input wire i_en_dec;
// input wire i_stalled;
input wire i_stalled;
input wire [19:0] i_pc;
input wire [3:0] i_nibble;
@ -55,8 +55,8 @@ end
*/
always @(posedge i_clk) begin
if (!i_reset && i_en_dbg)
if (!continue&ins_decoded) begin
if (!i_reset && i_en_dbg && !i_stalled)
if (!continue && ins_decoded) begin
`ifdef SIM
$write("%5h ", ins_addr);
if (ins_rtn) begin
@ -112,7 +112,7 @@ always @(posedge i_clk) begin
ins_decoded <= 0;
end else begin
if (i_en_dec) begin
if (i_en_dec && !i_stalled) begin
/*
* stuff that is always done
@ -167,6 +167,10 @@ always @(posedge i_clk) begin
* 01 RTN
* 02 RTNSC
* 03 RTNCC
* 04 SETHEX
* 05 SETDEC
* 06 RSTK=C
* 07 C=RSTK
*
*****************************************************************************/

View file

@ -77,7 +77,7 @@ saturn_decoder i_decoder (
.i_en_dbg (en_debugger),
.i_en_dec (en_inst_dec),
.i_pc (reg_pc),
// .i_stalled (stalled),
.i_stalled (stalled),
.i_nibble (nibble_in),
.o_inc_pc (inc_pc),
.o_dec_error (dec_error)
@ -145,6 +145,7 @@ always @(posedge clk) begin
en_inst_exec <= 0;
clock_end <= 0;
cycle_ctr <= ~0;
stalled <= 0;
max_cycle <= 50;
`ifndef SIM
led[7:0] <= reg_pc[7:0];
@ -158,13 +159,14 @@ end
reg [3:0] nibble_in;
reg [19:0] reg_pc;
reg stalled;
always @(posedge clk)
if (reset)
reg_pc <= ~0;
else begin
if (en_bus_send) begin
if (inc_pc)
if (inc_pc & !stalled)
reg_pc <= reg_pc + 1;
else
$display("not incrementing PC");
@ -175,6 +177,10 @@ always @(posedge clk)
`endif
nibble_in <= rom[reg_pc];
end
if (en_inst_exec) begin
if (cycle_ctr == 5) stalled <= 1;
if (cycle_ctr == 10) stalled <= 0;
end
end
assign halt = clock_end || dec_error;