Skip to content

Commit

Permalink
lm32: sync to upstream v3.6 sources
Browse files Browse the repository at this point in the history
 - feature: support for dynamically switching EBA to DEBA via a GPIO.
 - bug: EA now reports instruction that caused the data abort, rather than
   next instruction.
  • Loading branch information
mwalle authored and Sebastien Bourdeauducq committed Jul 20, 2011
1 parent 40a2656 commit 1529646
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 10 deletions.
34 changes: 26 additions & 8 deletions cores/lm32/rtl/lm32_cpu.v
Expand Up @@ -19,6 +19,11 @@
// Title : Top-level of CPU.
// Dependencies : lm32_include.v
//
// Version 3.8
// 1. Feature: Support for dynamically switching EBA to DEBA via a GPIO.
// 2. Bug: EA now reports instruction that caused the data abort, rather than
// next instruction.
//
// Version 3.4
// 1. Bug Fix: In a tight infinite loop (add, sw, bi) incoming interrupts were
// never serviced.
Expand Down Expand Up @@ -75,6 +80,11 @@ module lm32_cpu (
clk_n_i,
`endif
rst_i,
`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
at_debug,
`endif
`endif
// From external devices
`ifdef CFG_INTERRUPTS_ENABLED
interrupt,
Expand Down Expand Up @@ -215,6 +225,12 @@ input clk_n_i; // Inverted clock
`endif
input rst_i; // Reset

`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
input at_debug; // GPIO input that maps EBA to DEBA
`endif
`endif

`ifdef CFG_INTERRUPTS_ENABLED
input [`LM32_INTERRUPT_RNG] interrupt; // Interrupt pins
`endif
Expand Down Expand Up @@ -543,7 +559,6 @@ reg rotate_x;
`endif
wire direction_d; // Which direction to shift in
reg direction_x;
reg direction_m;
wire [`LM32_WORD_RNG] shifter_result_m; // Result of shifter
`endif
`ifdef CFG_MC_BARREL_SHIFT_ENABLED
Expand Down Expand Up @@ -763,6 +778,11 @@ lm32_instruction_unit #(
// ----- Inputs -------
.clk_i (clk_i),
.rst_i (rst_i),
`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
.at_debug (at_debug),
`endif
`endif
// From pipeline
.stall_a (stall_a),
.stall_f (stall_f),
Expand Down Expand Up @@ -800,7 +820,6 @@ lm32_instruction_unit #(
.i_dat_i (I_DAT_I),
.i_ack_i (I_ACK_I),
.i_err_i (I_ERR_I),
.i_rty_i (I_RTY_I),
`endif
`ifdef CFG_HW_DEBUG_ENABLED
.jtag_read_enable (jtag_read_enable),
Expand Down Expand Up @@ -2352,9 +2371,6 @@ begin
exception_m <= `FALSE;
load_m <= `FALSE;
store_m <= `FALSE;
`ifdef CFG_PL_BARREL_SHIFT_ENABLED
direction_m <= `FALSE;
`endif
write_enable_m <= `FALSE;
write_idx_m <= {`LM32_REG_IDX_WIDTH{1'b0}};
condition_met_m <= `FALSE;
Expand Down Expand Up @@ -2478,9 +2494,6 @@ begin
`endif
end
m_bypass_enable_m <= m_bypass_enable_x;
`ifdef CFG_PL_BARREL_SHIFT_ENABLED
direction_m <= direction_x;
`endif
load_m <= load_x;
store_m <= store_x;
`ifdef CFG_FAST_UNCONDITIONAL_BRANCH
Expand Down Expand Up @@ -2512,6 +2525,10 @@ begin
`ifdef CFG_DEBUG_ENABLED
if (exception_x == `TRUE)
if ((dc_re == `TRUE)
`ifdef CFG_ALTERNATE_EBA
|| (at_debug == `TRUE)
`endif

|| ((debug_exception_x == `TRUE)
&& (non_debug_exception_x == `FALSE)))
branch_target_m <= {deba, eid_x, {3{1'b0}}};
Expand Down Expand Up @@ -2582,6 +2599,7 @@ begin
`endif
`ifdef CFG_BUS_ERRORS_ENABLED
if ( (stall_m == `FALSE)
&& (data_bus_error_exception == `FALSE)
&& ( (load_q_m == `TRUE)
|| (store_q_m == `TRUE)
)
Expand Down
31 changes: 29 additions & 2 deletions cores/lm32/rtl/lm32_instruction_unit.v
Expand Up @@ -42,6 +42,9 @@
// : instruction cache) to lock up in to an infinite loop due to a
// : instruction bus error when EBA was set to instruction inline
// : memory.
// Version : 3.8
// : Feature: Support for dynamically switching EBA to DEBA via a
// : GPIO.
// =============================================================================

`include "lm32_include.v"
Expand All @@ -54,6 +57,11 @@ module lm32_instruction_unit (
// ----- Inputs -------
clk_i,
rst_i,
`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
at_debug,
`endif
`endif
// From pipeline
stall_a,
stall_f,
Expand Down Expand Up @@ -91,7 +99,6 @@ module lm32_instruction_unit (
i_dat_i,
i_ack_i,
i_err_i,
i_rty_i,
`endif
`ifdef CFG_HW_DEBUG_ENABLED
jtag_read_enable,
Expand Down Expand Up @@ -162,6 +169,12 @@ localparam addr_offset_msb = (addr_offset_lsb+addr_offset_width-1);
input clk_i; // Clock
input rst_i; // Reset

`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
input at_debug; // GPIO input that maps EBA to DEBA
`endif
`endif

input stall_a; // Stall A stage instruction
input stall_f; // Stall F stage instruction
input stall_d; // Stall D stage instruction
Expand Down Expand Up @@ -202,7 +215,6 @@ input irom_we_xm; // Indicates if memory o
input [`LM32_WORD_RNG] i_dat_i; // Instruction Wishbone interface read data
input i_ack_i; // Instruction Wishbone interface acknowledgement
input i_err_i; // Instruction Wishbone interface error
input i_rty_i; // Instruction Wishbone interface retry
`endif

`ifdef CFG_HW_DEBUG_ENABLED
Expand Down Expand Up @@ -336,6 +348,10 @@ reg bus_error_f; // Indicates if a bus er
reg jtag_access; // Indicates if a JTAG WB access is in progress
`endif

`ifdef CFG_ALTERNATE_EBA
reg alternate_eba_taken;
`endif

/////////////////////////////////////////////////////
// Functions
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -547,7 +563,18 @@ always @(posedge clk_i `CFG_RESET_SENSITIVITY)
begin
if (rst_i == `TRUE)
begin
`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
if (at_debug == `TRUE)
pc_f <= (`CFG_DEBA_RESET-4)/4;
else
pc_f <= (`CFG_EBA_RESET-4)/4;
`else
pc_f <= (`CFG_EBA_RESET-4)/4;
`endif
`else
pc_f <= (`CFG_EBA_RESET-4)/4;
`endif
pc_d <= {`LM32_PC_WIDTH{1'b0}};
pc_x <= {`LM32_PC_WIDTH{1'b0}};
pc_m <= {`LM32_PC_WIDTH{1'b0}};
Expand Down
16 changes: 16 additions & 0 deletions cores/lm32/rtl/lm32_top.v
Expand Up @@ -36,6 +36,11 @@ module lm32_top (
// ----- Inputs -------
clk_i,
rst_i,
`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
at_debug,
`endif
`endif
// From external devices
`ifdef CFG_INTERRUPTS_ENABLED
interrupt,
Expand Down Expand Up @@ -98,6 +103,12 @@ module lm32_top (
input clk_i; // Clock
input rst_i; // Reset

`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
input at_debug; // GPIO input that maps EBA to DEBA
`endif
`endif

`ifdef CFG_INTERRUPTS_ENABLED
input [`LM32_INTERRUPT_RNG] interrupt; // Interrupt pins
`endif
Expand Down Expand Up @@ -223,6 +234,11 @@ lm32_cpu cpu (
.clk_n_i (clk_n),
`endif
.rst_i (rst_i),
`ifdef CFG_DEBUG_ENABLED
`ifdef CFG_ALTERNATE_EBA
.at_debug (at_debug),
`endif
`endif
// From external devices
`ifdef CFG_INTERRUPTS_ENABLED
.interrupt (interrupt),
Expand Down

0 comments on commit 1529646

Please sign in to comment.