prim_lfsr Lint warning & assertion error
When using the prim_lfst with the followinig configuration: JitWordWidth = 4;
// These LFSR parameters have been generated with
// $ ./util/design/gen-lfsr-seed.py --width 32 --seed 691876113 --prefix ""
parameter int LfsrWidth = 32;
typedef logic [LfsrWidth-1:0] lfsr_seed_t;
typedef logic [LfsrWidth-1:0][$clog2(LfsrWidth)-1:0] lfsr_perm_t;
parameter lfsr_seed_t RndCnstLfsrSeedDefault = 32'h5bd24320;
parameter lfsr_perm_t RndCnstLfsrPermDefault = {
160'hd9d3ce99c388a7278730515baab2d7fd17807888
};
logic [JitWordWidth-1:0] lfsr_val;
prim_lfsr #(
.LfsrDw ( ast_pkg::LfsrWidth ),
.EntropyDw ( 1 ),
.StateOutDw ( JitWordWidth ),
.DefaultSeed ( ast_pkg::RndCnstLfsrSeedDefault ),
.StatePermEn ( 1'b1 ),
.StatePerm ( ast_pkg::RndCnstLfsrPermDefault ),
.ExtSeedSVA ( 1'b0 ) // ext seed is unused
) u_lfsr (
.clk_i ( clk_src_sys_i ),
.rst_ni ( rst_sys_n ),
.lfsr_en_i ( lfsr_en ),
.seed_en_i ( 1'b0 ),
.seed_i ( '0 ),
.entropy_i ( lfsr_data_in ),
.state_o ( lfsr_val )
);
I am getting the following Lint warning during compilation
Lint-[SVA-AECASR] Assertion evaluation can affect simulation results /tanap1/proj_cd14/opentitan/jlevy/ot_mr/nuvoton/design/ast_src/generated/prim_lfsr.sv, 429 prim_lfsr, "compute_next_state(coeffs, $past(entropy_i, 1), $past(lfsr_q, 1))" The assertion contains function call "compute_next_state(coeffs, $past(entropy_i, 1), $past(lfsr_q, 1))" which can have side effects. Shutting of this assertion may cause change in simulation behavior.
And the following Assert Error during the vcs run.
"/tanap1/proj_cd14/opentitan/jlevy/ot_mr/nuvoton/design/ast_src/generated/prim_lfsr.sv", 429: ast_tb.u_ast.u_entropy.u_lfsr.NextStateCheck_A: started at 122859130445ps failed at 122859140449ps Offending '(lfsr_q == compute_next_state(coeffs, $past(entropy_i, 1), $past(lfsr_q, 1)))' Error: "/tanap1/proj_cd14/opentitan/jlevy/ot_mr/nuvoton/design/ast_src/generated/prim_lfsr.sv", 429: ast_tb.u_ast.u_entropy.u_lfsr.NextStateCheck_A: at time 122859140449 ps 122859140000: (/tanap1/proj_cd14/opentitan/jlevy/ot_mr/nuvoton/design/ast_src/generated/prim_lfsr.sv:429) [ast_tb.u_ast.u_entropy.u_lfsr.NextStateCheck_A] [ASSERT FAILED] NextStateCheck_A
Why I am getting this assert?
@msfschaffner (as the author of the script)
huh... can't say i've ever seen this before... somehow the lfsr's output is not agreeing with what the assertion thinks it should be. But we've never seen this with any of the other lfsr's.
is there any way the design using this lfsr can be shared in the open and we can run some sims to check as well?
Will a wave file (fsdb) at the level of the prim_lfsr will help?
yeah that would definitely help. but i was hoping it could be something at the ast open source level?
then we can see if we're able to reproduce this in our environment.
On Tue, Apr 27, 2021 at 11:10 AM Jacob-Levy @.***> wrote:
Will a wave file (fsdb) at the level of the prim_lfsr will help?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/6332#issuecomment-827808861, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSS5LBK5GCJQSRLTAOLTK342TANCNFSM43UTEJIA .
Can not attached the vcd file (vcd->fsdb)... emailing it The prin_lfsr is not used in the OS part only on NTIL :(

It looks the ASSERT is failing when the rst_ni is still active ('0') and the lfsr_en_i goes to '1'. Does the ASSERTS need to be active during reset?
@arnonsha I moved the lfsr_en_i after the reset and the ASSERT issue is gone! Anyway, when the lfsr_en_i is set to '1' on the instant, the ASSERT get activated when rst_ni is '0'.
ah that sounds great! That sounds like there's a bug on our end... because if we are in reset, the assertion is supposed to be disabled.
On Wed, Apr 28, 2021 at 1:54 AM Jacob-Levy @.***> wrote:
@arnonsha https://github.com/arnonsha I have moved the lfsr_en_i after the reset and the ASSERT issue is gone! Anyway, when the lfsr_en_i is set to '1', the ASSERT always activated.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/6332#issuecomment-828279037, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSQWROTXY43GEDT4ATLTK7EMRANCNFSM43UTEJIA .
Are you familiar with this Lint warning?
Lint-[SVA-AECASR] Assertion evaluation can affect simulation results /tanap1/proj_cd14/opentitan/jlevy/ot_mr/nuvoton/design/ast_src/generated/prim_lfsr.sv, 429 prim_lfsr, "compute_next_state(coeffs, $past(entropy_i, 1), $past(lfsr_q, 1))" The assertion contains function call "compute_next_state(coeffs, $past(entropy_i, 1), $past(lfsr_q, 1))" which can have side effects. Shutting of this assertion may cause change in simulation behavior.
// check whether next state is computed correctly `ASSERT(NextStateCheck_A, lfsr_en_i && !seed_en_i |=> lfsr_q == // Line 439 compute_next_state(coeffs, $past(entropy_i,1), $past(lfsr_q,1)))
That is interesting, since all our assertion macros should by default be disabled when rst_ni == 0.
However, it looks like you have found a workaround for this assertion error, so let's stick with that for now.
As for the Lint-[SVA-AECASR] warning: I believe this is telling us that in cases where compute_next_state function is used both inside and outside of the assertion, this could lead to simulation side effects.
However, since this function is stateless (it is set to be automatic), and since it is only used inside this particular assertion, this should not be an issue and hence the warning can be waived.
I believe this has been resolved - feel free to reopen if that is not the case.