[aes,dv] Allow aes_reseed_vseq resets when passing new sideload key - #29907
rswarbrick wants to merge 1 commit into
Conversation
b665440 to
27f9c7e
Compare
27f9c7e to
3377672
Compare
3377672 to
7dea75a
Compare
7dea75a to
147a518
Compare
147a518 to
5053ab2
Compare
|
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 |
There was a problem hiding this comment.
Don't we need a !cfg.under_reset here too?
There was a problem hiding this comment.
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 #( | |||
There was a problem hiding this comment.
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));
endtaskThere was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
It'd be better to add the sideload_valid_path string to the debug message
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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(), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
All other helper methods are declared as local except for that one and pass_new_sideload_key. Is it done on purpose?
There was a problem hiding this comment.
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>
5053ab2 to
be9a2d1
Compare
|
@martin-velay: Thank you very much for the careful review. I think everything should be addressed now and I'd really appreciate another look. |
Now that all the previous PRs have been merged, this one is finally ready for review!