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] Rework register interface #1053
Conversation
hw/ip/aes/rtl/aes_control.sv
Outdated
@@ -374,10 +404,11 @@ module aes_control #( | |||
|
|||
// Detect new key, new input, output read | |||
// Edge detectors are cleared by the FSM | |||
assign key_init_new_d = dec_key_gen ? '0 : key_init_new_q | key_init_qe_i; | |||
assign key_init_clear = (key_init_sel_o == KEY_INIT_CLEAR) & (&key_init_we_o); | |||
assign key_init_new_d = dec_key_gen | key_init_clear ? '0 : key_init_new_q | key_init_qe_i; |
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 personally prefer to parenthesize any compound conditions or assignments, even if the order of operations is correct, just to avoid silly editing/copy-paste errors that could occur later, but I believe this way is allowed by the style guide.
I am suggesting: ... = (dec_key_gen | key_init_clear) ? '0 : (key_init_new_q | key_init_qe_i);
But I am pretty liberal with parentheses, maybe too much so.
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 think that is a valid point. I added the parentheses.
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 with a handful of nits/clarifications. I appreciate how much cleaner it looks with the for loops in some of the sections.
d34597c
to
2dab587
Compare
Thanks @cdgori for your feedback. I implemented your suggestions. |
data_out_we_o = 1'b1; | ||
data_out_clear_we_o = 1'b1; | ||
end | ||
end else if (key_clear_i || data_in_clear_i || data_out_clear_i) 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.
Is the signal pulse or level?
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.
Nevermind I found the code below (they are level)
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.
It seems like this would work better as a wo
where the qe
was used to do the clearing, else
SW will need to write first to 1
then to 0
, no?
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.
It seems like this would work better as a
wo
where theqe
was used to do the clearing, else
SW will need to write first to1
then to0
, no?
Right. But the signals shouldn't be pulse as those signal used in other state too. But having it write-only and let hardware clear them if they are processed is good as I mentioned below.
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 will make it wo
for software, this makes sense.
But to clarify:
- Software only needs to write
1
(already now). The hardware will then clear it back to0
. - The hardware should not use the
qe
signal to trigger the clearing as pointed out by @eunchan. Writes to theTRIGGER
register are not ignored when the unit is not idle. If the unit is busy while e.g. software triggers a clear of the input register, this clear would not be triggered after finishing operation when using theqe
signal.
output logic data_in_clear_o, | ||
output logic data_in_clear_we_o, | ||
output logic data_out_clear_o, |
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 could trigger the CSR test failure as TRIGGER
register has RW for software access. @weicaiyang @sriyerg to give us clear answer.
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 @eunchan for your reviewn and the comment. Do you suggest to make TRIGGER
write-only for software?
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.
If that works. Yes :)
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.
You can merge as it is. It can be done in following PR after getting the answer from DV engineers,
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.
Alright. I'll merge it now.
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.
Actually, I would need the green light from someone with write permission. Would you mind @eunchan?
2dab587
to
82ea5a0
Compare
hw/ip/aes/doc/_index.md
Outdated
2. Clear the configured initial key by overwriting the Initial Key registers {{< regref "KEY0" >}} - {{< regref "KEY7" >}}. | ||
3. Clear the previous input data by overwriting the Input Data registers {{< regref "DATA_IN0" >}} - {{< regref "DATA_IN3" >}}. | ||
4. Clear the internal key registers and the Output Data register by setting the KEY_CLEAR and DATA_OUT_CLEAR bits in {{< regref "TRIGGER" >}} to `1`. | ||
2. Clear all key registers as well as the Input Data and the Output Data registers by setting the KEY_CLEAR, DATA_IN_CLEAR and DATA_OUT_CLEAR bits in {{< regref "TRIGGER" >}} to `1`. |
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.
just a .md
pro tip: you can number them all 1.
and markdown will keep track of the emnumeration.
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.
Let's get pro then ;-) I changed it here and will keep it in mind for future changes to the doc.
data_out_we_o = 1'b1; | ||
data_out_clear_we_o = 1'b1; | ||
end | ||
end else if (key_clear_i || data_in_clear_i || data_out_clear_i) 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.
It seems like this would work better as a wo
where the qe
was used to do the clearing, else
SW will need to write first to 1
then to 0
, no?
82ea5a0
to
3db2f8e
Compare
I added another commit to change the software access permissions of the The reason I made the trigger register |
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
This commit modifies the input data and initial key registers as well as the control FSM to allow the hardware to clear those registers based on the content of the trigger register. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
Software does not need to be able to read back the content of the trigger register. This commit removes read access for software. Signed-off-by: Pirmin Vogel <vogelpi@lowrisc.org>
8b48540
to
16b082c
Compare
Thanks @eunchan for approving. I am merging this now. |
This PR contains a series of commits to implement the following two main changes:
Hand in hand with these changes goes a restructuring/cleanup of the AES core (not the cipher, but the
aes_core.sv
file connecting the data paths with the registers).The changes have been successfully tested using my Verilator test framework.