mirror of
https://github.com/sxpert/hp-saturn
synced 2025-01-13 20:01:10 +01:00
add some more debugging functionnality
segregate reading of the rom in it's own little world
This commit is contained in:
parent
006b663147
commit
b3d72c1d3b
3 changed files with 68 additions and 10 deletions
|
@ -124,7 +124,7 @@ always @(posedge i_clk) begin
|
|||
|
||||
/*
|
||||
* generates the registers string
|
||||
*
|
||||
* 0123456789012
|
||||
* PC: xxxxx Carry: x h: @E@ rp: x RSTK7: xxxxx
|
||||
* P: x HST: bbbb ST: bbbbbbbbbbbbbbbb RSTK6: xxxxx
|
||||
* A: xxxxxxxxxxxxxxxx R0: xxxxxxxxxxxxxxxx RSTK5: xxxxx
|
||||
|
@ -139,21 +139,55 @@ always @(posedge i_clk) begin
|
|||
// $display("DEBUGGER %0d: [%d] debugger %0d", i_phase, i_cycle_ctr, registers_ctr);
|
||||
case (registers_state)
|
||||
`DBG_REG_PC_STR:
|
||||
case (registers_reg_ptr)
|
||||
5'd0: begin; registers_str[registers_ctr] <= "P"; registers_reg_ptr <= registers_reg_ptr + 5'd1; end
|
||||
5'd1: begin; registers_str[registers_ctr] <= "C"; registers_reg_ptr <= registers_reg_ptr + 5'd1; end
|
||||
5'd2: begin; registers_str[registers_ctr] <= ":"; registers_reg_ptr <= registers_reg_ptr + 5'd1; end
|
||||
5'd3: begin; registers_str[registers_ctr] <= " "; registers_reg_ptr <= 5'b0; registers_state <= `DBG_REG_PC_VALUE; end
|
||||
endcase
|
||||
begin
|
||||
case (registers_reg_ptr)
|
||||
5'd0: registers_str[registers_ctr] <= "P";
|
||||
5'd1: registers_str[registers_ctr] <= "C";
|
||||
5'd2: registers_str[registers_ctr] <= ":";
|
||||
5'd3: registers_str[registers_ctr] <= " ";
|
||||
endcase
|
||||
registers_reg_ptr <= registers_reg_ptr + 5'd1;
|
||||
if (registers_reg_ptr == 5'd3) begin
|
||||
registers_reg_ptr <= 5'd0;
|
||||
registers_state <= `DBG_REG_PC_VALUE;
|
||||
end
|
||||
end
|
||||
`DBG_REG_PC_VALUE:
|
||||
begin
|
||||
registers_str[registers_ctr] <= hex[pc[(4-registers_reg_ptr)*4+:4]];
|
||||
registers_reg_ptr <= registers_reg_ptr + 1;
|
||||
if (registers_reg_ptr == 5'd4) begin
|
||||
registers_reg_ptr <= 5'd0;
|
||||
registers_state <= `DBG_REG_PC_SPACES;
|
||||
end
|
||||
end
|
||||
`DBG_REG_PC_SPACES:
|
||||
begin
|
||||
registers_str[registers_ctr] <= " ";
|
||||
registers_reg_ptr <= registers_reg_ptr + 1;
|
||||
if (registers_reg_ptr == 5'd12) begin
|
||||
registers_reg_ptr <= 5'd0;
|
||||
registers_state <= `DBG_REG_CARRY_STR;
|
||||
end
|
||||
end
|
||||
`DBG_REG_CARRY_STR:
|
||||
begin
|
||||
case (registers_reg_ptr)
|
||||
5'd0: registers_str[registers_ctr] <= "C";
|
||||
5'd1: registers_str[registers_ctr] <= "a";
|
||||
5'd2: registers_str[registers_ctr] <= "r";
|
||||
5'd3: registers_str[registers_ctr] <= "r";
|
||||
5'd4: registers_str[registers_ctr] <= "y";
|
||||
5'd5: registers_str[registers_ctr] <= ":";
|
||||
5'd6: registers_str[registers_ctr] <= " ";
|
||||
endcase
|
||||
registers_reg_ptr <= registers_reg_ptr + 5'd1;
|
||||
if (registers_reg_ptr == 5'd6) begin
|
||||
registers_reg_ptr <= 5'd0;
|
||||
registers_state <= `DBG_REG_END;
|
||||
end
|
||||
end
|
||||
|
||||
`DBG_REG_END: begin end
|
||||
default: begin $display("ERROR, unknown register state %0d", registers_state); end
|
||||
endcase
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
`define DBG_REG_PC_STR 0
|
||||
`define DBG_REG_PC_VALUE 1
|
||||
`define DBG_REG_PC_SPACES 2
|
||||
`define DBG_REG_CARRY_STR 3
|
||||
`define DBG_REG_END 31
|
||||
`endif
|
|
@ -66,21 +66,44 @@ initial begin
|
|||
local_dp = 20'b0;
|
||||
end
|
||||
|
||||
/*
|
||||
* special cases for reading the rom
|
||||
*/
|
||||
|
||||
wire [0:0] do_pc_read;
|
||||
wire [0:0] do_dp_read;
|
||||
|
||||
assign do_pc_read = (last_cmd == `BUSCMD_PC_READ);
|
||||
assign do_dp_read = (last_cmd == `BUSCMD_DP_READ);
|
||||
assign do_read = do_pc_read || do_dp_read;
|
||||
|
||||
wire [`ROMBITS-1:0] access_pointer;
|
||||
|
||||
assign access_pointer = do_pc_read?local_pc[`ROMBITS-1:0]:local_dp[`ROMBITS-1:0];
|
||||
|
||||
always @(posedge i_clk) begin
|
||||
if (i_bus_clk_en && i_bus_is_data && do_read)
|
||||
o_bus_nibble_out <= rom_data[access_pointer];
|
||||
end
|
||||
|
||||
/*
|
||||
* general case
|
||||
*/
|
||||
|
||||
always @(posedge i_clk) begin
|
||||
|
||||
if (i_bus_clk_en) begin
|
||||
if (i_bus_is_data) begin
|
||||
/* do things with the bits...*/
|
||||
case (last_cmd)
|
||||
`BUSCMD_PC_READ:
|
||||
begin
|
||||
o_bus_nibble_out <= rom_data[local_pc[`ROMBITS-1:0]];
|
||||
// o_bus_nibble_out <= rom_data[local_pc[`ROMBITS-1:0]];
|
||||
local_pc <= local_pc + 1;
|
||||
|
||||
end
|
||||
`BUSCMD_DP_READ:
|
||||
begin
|
||||
o_bus_nibble_out <= rom_data[local_dp[`ROMBITS-1:0]];
|
||||
// o_bus_nibble_out <= rom_data[local_dp[`ROMBITS-1:0]];
|
||||
local_dp <= local_dp + 1;
|
||||
end
|
||||
`BUSCMD_PC_WRITE: local_pc <= local_pc + 1;
|
||||
|
|
Loading…
Reference in a new issue