-
Notifications
You must be signed in to change notification settings - Fork 792
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
[edn/dv] Fix failing err vseq #20808
Conversation
hw/ip/edn/rtl/edn_pkg.sv
Outdated
@@ -48,4 +48,13 @@ package edn_pkg; | |||
Error = 9'b010010001 // illegal state reached and hang | |||
} state_e; | |||
|
|||
typedef enum logic [8: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.
Could this enum go into edn_env_pkg
instead of being in the RTL directory? I think the uses are all on the DV side for now, at least.
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 thought the same. It would allow us to merge the change immediately. Once the RTL blocker is lifted, we can move the change back into the RTL package file and make the remaining RTL also use that to reduce code duplication.
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 a great idea, thanks to both of you.
if (cfg.boot_req_mode != MuBi4True && cfg.auto_req_mode == MuBi4True | ||
&& exp_state != AutoLoadIns) begin | ||
// Send INS cmd to start the auto/SW mode operation. | ||
// Don't use wr_cmd() since we don't want to wait for the ack. |
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.
Is there a way to tweak wr_cmd
to easily add a "don't wait for the ack" mode? (This is a genuine question: I haven't thought about it hard, and I notice that wr_cmd
is already reasonably complicated)
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.
Should be rather easy I think. I'll add a commit that implements this.
@@ -48,6 +49,7 @@ class edn_err_vseq extends edn_base_vseq; | |||
end | |||
|
|||
`uvm_info(`gfn, $sformatf("Waiting for main_sm to reach state %s", exp_state.name()), UVM_HIGH) | |||
transition_to_main_sm_state(exp_state, mode); |
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 wonder whether we should tweak the name to something more like start_main_sm_state_transition
or similar. That might make the fork
/ join none
behaviour a bit more obvious?
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.
Sure, that makes sense.
string state_path; | ||
logic [8:0] exp_state; | ||
state_ack_e exp_state; |
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 wonder whether it would make sense to extract the translation to using the enum into a separate commit. The resulting history might be a bit easier to follow.
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.
Sure, can do!
|
||
`uvm_info(`gfn, $sformatf("Waiting for ack_sm[%0d] to reach state %09b", | ||
endpoint_port, exp_state), UVM_HIGH) | ||
transition_to_ack_state(exp_state, mode); |
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.
Same question as above about switching to a name that's more like "start transition" for this task too.
if (cfg.boot_req_mode != MuBi4True) begin | ||
// Send INS cmd to start the auto/SW mode operation. | ||
wr_cmd(.cmd_type(edn_env_pkg::Sw), .acmd(csrng_pkg::INS), | ||
.clen(0), .flags(MuBi4False), .glen(0), .mode(mode)); |
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: Indentation (and on the following call to wr_cmd too)
// INS and GEN commands are only needed if we are not waiting for EndPointClear or DataWait. | ||
if (!exp_state inside {EndPointClear, DataWait}) 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.
Shouldn't this "if" surround the fork/join_none? (I realise that it's equivalent, but maybe switching them around would feel a bit cleaner?)
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.
Yes, that would be better, thanks.
@@ -102,9 +104,53 @@ class edn_err_vseq extends edn_base_vseq; | |||
) | |||
endtask | |||
|
|||
task transition_to_ack_state(state_ack_e exp_state, hw_req_mode_e mode); |
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 that the "await" tasks above are ordered main; ack. Could we switch the ordering of the "transition" tasks to match?
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'll swap the await tasks to make it alphabetically ordered. (at least for the two pairs)
This commit adds the enum type for all the ack sm states. This can be used to fix lowRISC#18968 in the following commit. Signed-off-by: Hakim Filali <[email protected]>
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.
LGTM, but I would move the ack_state_e
defintion into a DV package file for now. Thanks for working on this @h-filali !
endtask | ||
|
||
task transition_to_main_sm_state(state_e exp_state, edn_env_pkg::hw_req_mode_e mode); | ||
// Create background thread that transitions the ack sm to the expected state. |
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: the ack sm -> the main sm
// Notify the driver that the EDN was disabled. | ||
cfg.edn_vif.drive_edn_disable(1); | ||
// In Auto mode, minimize number of requests between reseeds and set the reseed command. | ||
if (cfg.auto_req_mode == MuBi4True) 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.
Here you could already use the mode
variable introduced above, right?
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.
Yes, you're right.
gen_cmd_type = edn_env_pkg::Sw; | ||
mode = edn_env_pkg::SwMode; | ||
if ((cfg.which_err_code == edn_ack_sm_err) || ($urandom_range(10, 1) < 8)) begin | ||
// Errors in ack_sm can be used to trigger transitions to the Error state in main_sm. |
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.
Maybe want to include the previous comment main_sm is more complex, so the random selection is biased towards it.
here to motivate the OR with the urandom
-expression?
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.
Makes sense, thanks!
This commit changes the hardcoded ack state values in the edn_err_vseq to the enum type values in the env_pkg.. Signed-off-by: Hakim Filali <[email protected]>
This commit adds the option to skip waiting for a command to be acknowledged in wr_cmd(). This is needed, since if we expect there to be an error in a test sequence we don't want to wait for the command to complete. Signed-off-by: Hakim Filali <[email protected]>
The edn_err_vseq test seems to be failing for multiple reasons. Mainly because of a hanging wr_cmd(). This test sequence used to always write the same couple of commands no matter in what state the error state is induced. This commit reworks the test sequence such that only those commands are issued that are really needed to get the EDN into the wanted ack/main SM state. This way we can avoid hangs because of unnecessary commands. Furthermore, the err sequence now waits for a random ack/main SM state for all types of errors. This used to be the case only for ack_sm, main_sm and counter errors. Signed-off-by: Hakim Filali <[email protected]>
ed5e216
to
a956848
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.
Thanks @rswarbrick and @vogelpi for your reviews! Some great inputs.
hw/ip/edn/rtl/edn_pkg.sv
Outdated
@@ -48,4 +48,13 @@ package edn_pkg; | |||
Error = 9'b010010001 // illegal state reached and hang | |||
} state_e; | |||
|
|||
typedef enum logic [8: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.
That's a great idea, thanks to both of you.
@@ -48,6 +49,7 @@ class edn_err_vseq extends edn_base_vseq; | |||
end | |||
|
|||
`uvm_info(`gfn, $sformatf("Waiting for main_sm to reach state %s", exp_state.name()), UVM_HIGH) | |||
transition_to_main_sm_state(exp_state, mode); |
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.
Sure, that makes sense.
@@ -102,9 +104,53 @@ class edn_err_vseq extends edn_base_vseq; | |||
) | |||
endtask | |||
|
|||
task transition_to_ack_state(state_ack_e exp_state, hw_req_mode_e mode); |
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'll swap the await tasks to make it alphabetically ordered. (at least for the two pairs)
// INS and GEN commands are only needed if we are not waiting for EndPointClear or DataWait. | ||
if (!exp_state inside {EndPointClear, DataWait}) 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.
Yes, that would be better, thanks.
gen_cmd_type = edn_env_pkg::Sw; | ||
mode = edn_env_pkg::SwMode; | ||
if ((cfg.which_err_code == edn_ack_sm_err) || ($urandom_range(10, 1) < 8)) begin | ||
// Errors in ack_sm can be used to trigger transitions to the Error state in main_sm. |
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.
Makes sense, thanks!
// Notify the driver that the EDN was disabled. | ||
cfg.edn_vif.drive_edn_disable(1); | ||
// In Auto mode, minimize number of requests between reseeds and set the reseed command. | ||
if (cfg.auto_req_mode == MuBi4True) 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.
Yes, you're right.
if (cfg.boot_req_mode != MuBi4True && cfg.auto_req_mode == MuBi4True | ||
&& exp_state != AutoLoadIns) begin | ||
// Send INS cmd to start the auto/SW mode operation. | ||
// Don't use wr_cmd() since we don't want to wait for the ack. |
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.
Should be rather easy I think. I'll add a commit that implements this.
string state_path; | ||
logic [8:0] exp_state; | ||
state_ack_e exp_state; |
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.
Sure, can do!
This commit fixes the failing edn_err_vseq.
For further information have a look at the individual commits.
This commit also does part of the clean up mentioned in #18968 because why not :D