-
Notifications
You must be signed in to change notification settings - Fork 815
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
[aes/dv] Randomly drive invalid AES operation values #24623
Conversation
Thanks @martin-velay for your help with debugging this :-) |
4383da6
to
71249fe
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.
Lots of nitty comments/questions but they needn't really gate this PR.
hw/ip/aes/dv/env/aes_env_cfg.sv
Outdated
// [1]: reseed error | ||
// [2]: mode error | ||
// [3]: key_len | ||
cfg_error_type_t config_error_type_en = 4'b1111; |
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 needn't gate the PR, but can't you do this with something like ... = '{op = 1'b1, rsd_rate = 1'b1, ...};
? It might be a bit easier to read and wouldn't need the comment either.
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.
Good idea! I've implemented the change for lines / types touches in this PR.
hw/ip/aes/dv/env/aes_message_item.sv
Outdated
solve has_config_error before cfg_error_type; | ||
if (has_config_error) { | ||
cfg_error_type inside {[1:15]}; | ||
config_error_type_en[0] == 0 -> cfg_error_type[0] == 0; |
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.
Can't this be expressed with names? So something like config_error_type_en.op == 0 -> cfg_error_type.op == 0
?
Even more tersely, I think you can do something like !(cfg_error_type & ~config_error_type_en)
, but that's probably getting ridiculously hard to understand...
FOLLOW-UP: Ah! I've just seen the lines this came from! I think I stand by my comments, but they needn't gate this PR.
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.
I went with the first proposal to be consistent and improve readability.
hw/ip/aes/dv/env/aes_message_item.sv
Outdated
end else begin | ||
this.aes_operation = 2'b01; // resovle to AES-ENC | ||
`uvm_info(`gfn, | ||
$sformatf("\n\t ---| Illegal operation value detected, resolving to default AES-ENC"), |
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.
Nit: I think you probably want "... detected. Resolving ..." to fix the grammar.
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.
Yep, thanks!
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.
Your changes are looking good, this PR can be approved according to me.
Note: the DV seems to be complicated to debug because of some bad practices, particularly regarding the sequence items which are gathering more information than it should. These objects should be broken up into multiple sequence items in the future. And also using enumerated values for some variables might help.
hw/ip/aes/dv/env/aes_message_item.sv
Outdated
$sformatf("\n\t ---| Illegal key length value detected, resolving to default AES-256"), | ||
UVM_MEDIUM) | ||
end | ||
if (item.reseed_rate inside {3'b001, 3'b010, 3'b100}) begin |
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.
That's not really related to this PR, but in general I think it would be better to move to enumerated values. This would make reading easier. But it's not blocking for this PR of course.
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.
I totally agree! I've changed this now for lines / member variables touches in this PR.
return str; | ||
endfunction // conver2string | ||
|
||
function string cfg_error_string(); |
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.
As the sequence item is not properly split originally, I agree with your change. But FYI, this convert2string function is defined by the UVM. That's convenient when you want to debug a sequence from anybody, you know that you can call this and print all the relevant info in a relevant format. In the future, we should break down the sequence items into sub-items and eventually gathering them into another sequence item.
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.
I agree with you. Thanks for providing some background on this Martin.
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Previously, the reseed rate wasn't correctly passed, resulting in confusing debug statements during configuration error tests. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
This commit properly randomizes the operation values to fix a coverage hole. Previously, the operation field of the main control register was only written with valid one-hot encoded values but not with invalid values leading to a small DV coverage hole. This resolves lowRISC#20941. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Previously, the basic convert2string() function called in different contexts (scoreboard, base sequence, etc.) would print information that is not available / meaningful in the scoreboard context such as the configuration error data and distributions. This commits splits the original function into multiple functions to enable controlling what to print in which context. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
71249fe
to
c07ec6c
Compare
Thanks @martin-velay and @rswarbrick for your review and the suggestions! I've implemented most of your feedback (see discussions). If you're happy with the changes, please feel free to approve & merge this @rswarbrick . |
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 looks good to me. A couple of (rather nitty) tweaks that might be worth doing, but I'm happy either way.
// [0]: op_error | ||
// [1]: reseed error | ||
// [2]: mode error | ||
// [3]: key_len |
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.
Nit: I don't think you need the comment about the indices any more?
Similarly for cfg_error_type
below.
@@ -7,7 +7,7 @@ class aes_seq_item extends uvm_sequence_item; | |||
`uvm_object_utils(aes_seq_item) | |||
|
|||
aes_item_type_e item_type; | |||
aes_op_e operation; | |||
bit [1:0] operation; |
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.
Nit: I know that this is unchanged with this commit, but the indentation looks a bit weird with the previous line. Maybe we should either be dropping a space on line 9 or adding some more spaces before "operation"?
Thanks @rswarbrick for your approval. I am merging this now as I need to move on. |
This PR contains a couple of commits to enable closing a small coverage hole.
The main commit is the last one. It properly randomizes the operation values. Previously, the operation field of the main control register was only written with valid one-hot encoded values but not with invalid values leading to a small DV coverage hole.
This resolves #20941.