Skip to content

[aes,dv] Allow aes_reseed_vseq resets when passing new sideload key - #29907

Open
rswarbrick wants to merge 1 commit into
lowRISC:masterfrom
rswarbrick:aes-pass-new-sideload-key-resets
Open

rswarbrick wants to merge 1 commit into
lowRISC:masterfrom
rswarbrick:aes-pass-new-sideload-key-resets

Conversation

@rswarbrick

@rswarbrick rswarbrick commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Now that all the previous PRs have been merged, this one is finally ready for review!

[aes,dv] Allow aes_reseed_vseq resets when passing new sideload key

To do so, we have to pull out the code that passes the new sideload
key and add checks for if reset is asserted, exiting the task early
when that happens.

@rswarbrick
rswarbrick requested review from nasahlpa and vogelpi April 26, 2026 19:48
@rswarbrick rswarbrick added Component:DV DV issue: testbench, test case, etc. IP:aes labels Apr 26, 2026
@rswarbrick
rswarbrick force-pushed the aes-pass-new-sideload-key-resets branch from b665440 to 27f9c7e Compare May 19, 2026 17:32
@rswarbrick
rswarbrick force-pushed the aes-pass-new-sideload-key-resets branch from 27f9c7e to 3377672 Compare May 26, 2026 19:14
@rswarbrick
rswarbrick force-pushed the aes-pass-new-sideload-key-resets branch from 3377672 to 7dea75a Compare August 12, 2026 21:46
@rswarbrick
rswarbrick force-pushed the aes-pass-new-sideload-key-resets branch from 7dea75a to 147a518 Compare September 1, 2026 13:32
@rswarbrick
rswarbrick marked this pull request as ready for review September 1, 2026 13:33
@rswarbrick
rswarbrick requested a review from a team as a code owner September 1, 2026 13:33
@rswarbrick
rswarbrick requested review from martin-velay and removed request for a team September 1, 2026 13:33
@rswarbrick
rswarbrick force-pushed the aes-pass-new-sideload-key-resets branch from 147a518 to 5053ab2 Compare September 17, 2026 16:39
@rswarbrick

Copy link
Copy Markdown
Contributor Author

Force-push rebases onto origin/master (it's been a couple of weeks).

end
// Detect if the sideload valid bit gets de-asserted while trying to enable sideload.
begin
while (sideload_valid && !sideload_enabled) begin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't we need a !cfg.under_reset here too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, because the first process in the fork will set sideload_enabled, which causes things to drop out. But the comment that explains things isn't very obvious: it took me a couple of minutes to figure out! I'm going to add an extra sentence that points in the other direction to make things more obvious.

@@ -173,6 +173,8 @@ class aes_base_vseq extends cip_base_vseq #(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All these tasks are looking very similar, would it be possible to "squash" them into something like that and add to all the under_reset thing?

protected virtual task set_ctrl_shadowed_field(uvm_reg_field field, uvm_reg_data_t value);
  if (field.get_mirrored_value() == value) return;

  field.set(value);
  csr_update(.csr(ral.ctrl_shadowed), .en_shadow_wr(1'b1), .blocking(1));
  if (cfg.under_reset) return;

  void'(field.predict(value));
endtask

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. Yes, very happily. Honestly, these tasks are a bit bonkers! I'll add a bit of text to the commit message that explains what's going on.

logic valid;

if (!uvm_hdl_check_path(sideload_valid_path)) begin
`uvm_fatal(`gfn, $sformatf("\n\t ----| PATH NOT FOUND"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It'd be better to add the sideload_valid_path string to the debug message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree. This code was already there, but I'm touching the line so it's an opportunity to improve things :-)

// Detect if the sideload valid bit gets de-asserted while trying to enable sideload.
begin
while (sideload_valid && !sideload_enabled) begin
cfg.clk_rst_vif.wait_clks_or_rst(1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Before the same thing was done on the negedge of the clk and now I think it's on the posedge. So the read and the write are both on the posedge, which might cause a race condition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops: good point! I'll move it back to the negative edge. Thanks.

end else begin
check_no_prng_reseed();
end
`uvm_info(get_name(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be preferable to make all the gfn replacements in one separate commit, or one dedicated PR? As it makes the code heterogeneous.

@rswarbrick rswarbrick Sep 19, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops! Definitely not preferable: this dates back to before I understood how get_full_name works for sequences. Fortunately, I've had the opportunity to learn a bit more about UVM since writing the code :-)

My preference is probably to use get_full_name instead of `gfn in any new code, but I agree that it's a bit silly to make things inconsistent in tasks that already exist. I'll switch back to the magic macro for both reasons!

UPDATE: There were several existing instances of get_name() in the virtual sequence. And it looks like these were all my fault. Boo. I'm switching them across to use gfn too.


// Do a backdoor read to get the value of the keymgr_key_i.valid port, treating 'x and 'z as
// invalid.
function bit snoop_sideload_valid();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All other helper methods are declared as local except for that one and pass_new_sideload_key. Is it done on purpose?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not really. The reason is rather embarrassing: the standard Emacs major mode for Verilog wrongly indents non-extern local methods. I have a horrible feeling that I'd forgotten to go through and make things consistent. I'll sort that now.

To do so, we have to pull out the code that passes the new sideload
key and add checks for if reset is asserted, exiting the task early
when that happens.

There are some loops that wait for an event by doing backdoor HDL
reads on negative edges of the clock. To do this tidily, I've added a
wait_n_clks_or_rst task to clk_rst_if (to match the wait_clks_or_rst
task that already existed).

One part of the changes in this commit is to add an "early exit on
reset" to aes_base_vseq::set_sideload. Since there are a couple of
equivalent tasks next to it, I've factored out the common code and
taught them about resets too.

Honestly, these tasks seem a bit strange to me: most of them have
their only call site in aes_base_vseq::setup_dut. This function
performs a chain of double-writes to the same register, one for each
field. This is a bit inefficient!

What's more, these sequence tasks do register prediction (presumably,
there was no scoreboard when it was originally written).

In both cases, the code is a bit awkward, but further changes to that
part of the sequence are probably out of scope for this commit.

Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
@rswarbrick
rswarbrick force-pushed the aes-pass-new-sideload-key-resets branch from 5053ab2 to be9a2d1 Compare September 19, 2026 21:23
@rswarbrick

Copy link
Copy Markdown
Contributor Author

@martin-velay: Thank you very much for the careful review. I think everything should be addressed now and I'd really appreciate another look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component:DV DV issue: testbench, test case, etc. IP:aes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants