Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger types 0x5 and 0xF #706

Merged

Conversation

silabs-oysteink
Copy link
Contributor

Implemented trigger type 0x5 (exception trigger) and 0xF (disabled trigger).

  • WARL handling of both tdata1 and tdata2 to ensure no invalid combination of tdata1 and tdata2 can occure.
  • Exception trigger uses same logic as single step debug entry to allow for exception side effects to happen before debug entry is done.

Signed-off-by: Oystein Knauserud [email protected]

…igger).

- WARL handling of both tdata1 and tdata2 to ensure no invalid combination of tdata1 and tdata2 can occure.
- Exception trigger uses same logic as single step debug entry to allow for exception side effects to happen before debug entry is done.

Signed-off-by: Oystein Knauserud <[email protected]>
@silabs-oysteink silabs-oysteink added the Component:RTL For issues in the RTL (e.g. for files in the rtl directory) label Nov 29, 2022
@@ -811,6 +813,7 @@ module cv32e40x_core import cv32e40x_pkg::*;
// Debug
.trigger_match_if_o ( trigger_match_if ),
.trigger_match_ex_o ( trigger_match_ex ),
.etrigger_wb_o ( etrigger_wb ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align brackets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -243,11 +297,30 @@ import cv32e40x_pkg::*;
(tdata1_rdata[idx][MCONTROL6_U] && (priv_lvl_ex_i == PRIV_LVL_U));

// Enable LSU address matching
assign lsu_addr_match_en[idx] = lsu_valid_ex_i && ((tdata1_rdata[idx][MCONTROL6_LOAD] && !lsu_we_ex_i) || (tdata1_rdata[idx][MCONTROL6_STORE] && lsu_we_ex_i));
assign lsu_addr_match_en[idx] = lsu_valid_ex_i && (tdata1_rdata[idx][TDATA1_TTYPE_HIGH:TDATA1_TTYPE_LOW] == TTYPE_MCONTROL6) &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not consistent with IF trigger match handling. Make sure that the (tdata1_rdata[idx][TDATA1_TTYPE_HIGH:TDATA1_TTYPE_LOW] == TTYPE_MCONTROL6) classification is done on the same type of signal, so for example on trigger_match_* signals.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved classification to align with IF and WB

@@ -669,6 +669,14 @@ parameter logic [31:0] TDATA1_RST_VAL = {
parameter MCONTROL6_STORE = 1;
parameter MCONTROL6_LOAD = 0;

parameter ETRIGGER_M = 9;
parameter ETRIGGER_U = 7;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// tdata2 contains a legal value for etrigger.

// Detect if any cleared bits in ETRIGGER_TDATA2_MASK are set in tdata2
if (0) begin //|(tdata2_rdata_o & (~ETRIGGER_TDATA2_MASK))) begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (0) ???

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fixing this also fix the case we discussed (i.e. keeping type DISABLED when trying to switch to a type that is incomptabile with values in tdata1 and tdata2?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this should definitely not have propagated here, this came from some debugging and slipped through.

tdata1_n = tdata1_rdata_o;
tdata2_n = tdata2_rdata_o;

if (csr_wdata_i[TDATA1_TTYPE_HIGH:TDATA1_TTYPE_LOW] == TTYPE_MCONTROL6) begin
Copy link
Contributor

@Silabs-ArjanB Silabs-ArjanB Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn''t such code only be done when there is an actual write to tdata1? Same question with respect to code related to tdata_2. No need maybe to change the code, but do add a remark that the _n data is not used without the worresponding _we signals

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, added qualifiers for tdata1_we_i and tdata2_we_i

// Only set the etrigger_in_wb flag when wb_valid is true (WB is not halted or killed).
// If a higher priority event than taking an exception (NMI, external debug or interrupts) are present, wb_valid_i will be
// suppressed by either halt_wb followed by kill_wb (debug), or kill_wb (NMI/interrupt).
assign etrigger_in_wb = etrigger_wb_i && wb_valid_i;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this expression also contain ex_wb_pipe_i.instr_valid like all other *_in_wb signals?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ex_wb_pipe_i.instr_valid is already implied by wb_valid_i as that signal is only set when (ex_wb_pipe_i.instr_valid && !halt_wb && !kill_wb).

@@ -988,6 +999,7 @@ module cv32e40x_controller_fsm import cv32e40x_pkg::*;
ctrl_fsm_o.kill_ex = 1'b1;
// Ebreak that causes debug entry should not be killed, otherwise RVFI will skip it
// Trigger match should also be signalled as not killed (all write enables are suppressed in ID), otherwise RVFI/ISS will not attempt to execute and detect trigger
// Exception trigger match should have nothing in WB, excepted instruction finished the previous cycle and set mepc and mcause due to the exception.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As always when claiming that something 'should be' the case, please check it with an assertion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is checked by the a_etrigger_dpc_write in cs_registers_sva. It check for !wb_valid the cycle after an etrigger has been taken. I added a check for !ex_wb_pipe.instr_valid just to make it more clear.

// and to ensure only one instruction can retire during single step
if (pending_single_step) begin
if (pending_single_step || etrigger_in_wb) begin
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add an assertion that etrigger_in_wb implies exception_in_wb

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added assertion

Signed-off-by: Oystein Knauserud <[email protected]>
@Silabs-ArjanB Silabs-ArjanB merged commit e652677 into openhwgroup:master Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component:RTL For issues in the RTL (e.g. for files in the rtl directory)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants