[rtl] RRAM bkdr#30740
Conversation
439dfd2 to
1f0d7d1
Compare
rswarbrick
left a comment
There was a problem hiding this comment.
Various requests for documentation comments (sorry) but this looks like a sensible implementation.
| localparam int unsigned RramDataWidth = rram_ctrl_pkg::DataWidth; | ||
| localparam int unsigned RramKeySize = rram_ctrl_pkg::KeySize; | ||
| localparam int unsigned RramAddrW = rram_ctrl_pkg::AddrW; | ||
| localparam int unsigned RramStagesPerCycle = RramDataWidth / rram_ctrl_pkg::GfMultCycles; |
There was a problem hiding this comment.
What happens if this doesn't divide cleanly? (And do we care?)
There was a problem hiding this comment.
Its a requirement of the gfmultiplier hardware module. so it must be a clean division
| localparam int unsigned RramAddrW = rram_ctrl_pkg::AddrW; | ||
| localparam int unsigned RramStagesPerCycle = RramDataWidth / rram_ctrl_pkg::GfMultCycles; | ||
| localparam int unsigned RramNumRoundsHalf = crypto_dpi_prince_pkg::NumRoundsHalf; | ||
| localparam int unsigned RramDataByteWidth = $clog2(RramDataWidth / 8); |
There was a problem hiding this comment.
What happens if this doesn't divide cleanly? Do you want a +7 here? (Or maybe a check in the constructor? "These parameters don't make sense, so you can't make the class today")
There was a problem hiding this comment.
RramDataWidth is always a multiple of a byte.
But I guess I can add a check to verify the parameters
| // Initialize the class instance. | ||
| // `extra_bits_per_subword` is the width of any additional metadata that is not captured in the | ||
| // secded package. |
There was a problem hiding this comment.
Can all the arguments be documented? (Possibly just by pointing to the base class)
There was a problem hiding this comment.
added. Most of them are actually not used
| mult_out = operand[RramDataWidth-1] ? (operand << 1) ^ | ||
| rram_ctrl_pkg::ScrambleIPoly : (operand << 1); |
There was a problem hiding this comment.
I know that not everyone agrees about indentation, but this looks wrong to me: surely we shouldn't out-dent the middle of a ternary case?
There was a problem hiding this comment.
this looks indeed horrible:) sorry, I will fix it!
| end | ||
| endfunction | ||
|
|
||
| static function bit [RramDataWidth-1:0] rram_gf_mult2(bit [RramDataWidth-1:0] operand); |
There was a problem hiding this comment.
This function needs a documentation comment (which should describe the operand argument as well as the point of the function)
There was a problem hiding this comment.
This is just the inner part of the gfmultiplier. I also don't really know what it is doing in detail. I took it over from flash_ctrl
| static function bit [RramStagesPerCycle-1:0][RramDataWidth-1:0] rram_gen_matrix( | ||
| bit [RramDataWidth-1:0] seed, | ||
| bit init); | ||
| bit [RramStagesPerCycle-1:0][RramDataWidth-1:0] matrix_out; |
There was a problem hiding this comment.
It might be nice to use a typedef for this type?
|
|
||
| matrix_out[0] = init ? seed : rram_gf_mult2(seed); | ||
|
|
||
| matrix_out[RramStagesPerCycle-1:1] = '0; |
There was a problem hiding this comment.
Does this line have any effect?
| // Compute the tweak for the xex cipher. tweak = GfMult128(addr, addr_key) | ||
| static function bit [RramDataWidth-1:0] rram_galois_multiply(bit [RramKeySize-1:0] addr_key, | ||
| bit [RramAddrW-1:0] addr); | ||
| bit [RramStagesPerCycle-1:0][RramDataWidth-1:0] current_matrix; |
There was a problem hiding this comment.
That current_matrix and mult_out probably need their scopes moved to inside the loop?
There was a problem hiding this comment.
yes that would be cleaner. let me do that
| return total_product; | ||
| endfunction | ||
|
|
||
| function bit [RramDataWidth-1:0] rram_scramble_data(bit [RramDataWidth-1:0] data, |
There was a problem hiding this comment.
This function needs documenting.
| return scrambled_data ^ mask; | ||
| endfunction | ||
|
|
||
| function bit [RramDataWidth-1:0] rram_descramble_data(bit [RramDataWidth-1:0] data, |
There was a problem hiding this comment.
This function needs documenting.
1f0d7d1 to
252c9e0
Compare
This bkdr util is required to preload the RRAM or to examine certain memory location during tests. Signed-off-by: Michael Gautschi <mgautschi@lowrisc.org>
252c9e0 to
402fc3f
Compare
As per RFC , Earlgrey will be extended with support for RRAM based non-volatile memory.
This PR adds the backdoor access to the RRAM. This is used in some DV tests to either preload the RRAM with the firmware, or to examine certain memory locations during a test.
This PR is based on #30412