-
Notifications
You must be signed in to change notification settings - Fork 15
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
Further Verilator lint fixes #22
Conversation
cbf7fc7
to
1533e71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a lot of changes - and I am not super sure the behavior stays the same (e.g. line 347). Generally, could we do a LEC before/after such chnages? If you have already done that please do let me know. Thanks,
I'm used to making these changes through code review. I'll mark this PR as draft until I get a chance to resolve the conflicts and look at equivalence checking. |
1533e71
to
fbbdc30
Compare
Thanks, I appreciate it. And I agree normally it would be done early in the design phase after code review, etc. However we are pretty late in the game already in this case and a little extra caution is probably a good thing. |
Ok, I ran JasperGold's Sequential Equivalence Checker on the This is the output of the check:
|
That's excellent, thanks. Will approve and merge then. |
I noticed the PR is still in draft status - any remaining conflict? |
No conflicts as far as I'm aware, just forgot to mark as ready to review yesterday. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
About 'int typecasting (range_ok in cheri_trvk_stage) and cheri_regfile - why are we casting those to int (which I think is signed by default)? The intention in both places is to do unsigned math. It may not matter here is the data width is less than 32-bit however it seems unnecessary confusion to me.
fbbdc30
to
aba2ee9
Compare
Yes, you are right. SystemVerilog makes it a bit difficult to do casting to compound types like diff --git a/rtl/cheri_pkg.sv b/rtl/cheri_pkg.sv
index 8ca19314..0ef0c0d3 100644
--- a/rtl/cheri_pkg.sv
+++ b/rtl/cheri_pkg.sv
@@ -42,6 +42,9 @@ package cheri_pkg;
parameter logic [2:0] OTYPE_SENTRY = 3'd1;
parameter logic [2:0] OTYPE_UNSEALED = 3'd0;
+ // For ease of casting
+ typedef int unsigned u_int_t;
+
// Compressed (regFile) capability type
typedef struct packed {
logic valid;
diff --git a/rtl/cheri_regfile.sv b/rtl/cheri_regfile.sv
index 5ab1d81d..199e3e5c 100644
--- a/rtl/cheri_regfile.sv
+++ b/rtl/cheri_regfile.sv
@@ -142,8 +142,8 @@ module cheri_regfile import cheri_pkg::*; #(
assign rf_cap[i] = rf_cap_q[i];
end
- assign rcap_a = (int'(raddr_a_i) < NCAPS) ? rf_cap[raddr_a_i] : NULL_REG_CAP;
- assign rcap_b = (int'(raddr_b_i) < NCAPS) ? rf_cap[raddr_b_i] : NULL_REG_CAP;
+ assign rcap_a = (u_int_t'(raddr_a_i) < NCAPS) ? rf_cap[raddr_a_i] : NULL_REG_CAP;
+ assign rcap_b = (u_int_t'(raddr_b_i) < NCAPS) ? rf_cap[raddr_b_i] : NULL_REG_CAP;
if (CheriPPLBC) begin : g_regrdy
diff --git a/rtl/cheri_trvk_stage.sv b/rtl/cheri_trvk_stage.sv
index 78cf24dd..0025f549 100644
--- a/rtl/cheri_trvk_stage.sv
+++ b/rtl/cheri_trvk_stage.sv
@@ -61,7 +61,7 @@ module cheri_trvk_stage #(
assign tsmap_addr_o = tsmap_ptr[15:5];
// not a sealling cap and pointing to valid TSMAP range
- assign range_ok = (int'(tsmap_ptr[31:5]) <= TSMapSize) &&
+ assign range_ok = (u_int_t'(tsmap_ptr[31:5]) <= TSMapSize) &&
~((in_cap_q.cperms[4:3]==2'b00) && (|in_cap_q.cperms[2:0]));
assign tsmap_cs_o = (cpu_op_valid_q[0] | tbre_op_valid_q[0]) & cap_good_q[0]; What do you think? It does add an extra |
That should work. However, why do we need typecasting in those cases? Does it help resolve any ambiguities (I can't quite see it) or there is some kind of blanket lint policy regarding arithmetics? If not I'd rather have less code.. |
I'm not sure if it resolves any ambiguities but it stops Verilator from complaining that we are comparing two values of different bit width. Unsigned integers are 32 bits while |
aba2ee9
to
902d6bc
Compare
I force pushed to resolve the conflicts in |
Hopefully not trying to be obnoxious here.. But I am disagreeing with enforcing this linting rule. verilog/sv is fairly clear about the behavior in this case (0-expand to the widest operand first then perform comparison). As such, the change is unnecessary and would make the code more complex and less readable. |
@marnovandermaas, also if we really want to match width explicitly, wouldn't something like 32'({tsmap_ptr[31:5]}) work? That way at least we stay unsigned and don't have to define a new type.. |
These cause width lint errors from Verilator
This fixes a lint error from Verilator
This fixes a lint error in Verilator
This fixes an unused lint error in Verilator
These outputs include the alert outputs and the scramble request. This fixes undriven output lint errors in Verilator.
902d6bc
to
1639102
Compare
Ok, I've removed these changes. I can always add some lint waivers for these particular cases. |
Thanks - should be merged into main now. |
Found these issues while compiling CHERIoT Ibex with Verilator. It mainly fixes width mismatches and unused variables.
This PR does not remove all unused variables, there is one remaining width issue and two unoptimized flat issues.