[otp_ctrl,lint] Write a range select explicitly, not using >>
The right shift in otp_ctrl_part_buf.sv was being used to convert
an (N+1)-bit long byte address (that we happen to know is even) to an
N-bit long halfword address. The right shift, combined with Verilog's
truncation rules, mean that it functioned as a range select to grab
just the bottom N bits.
Verilator complains about such things (it treats the assignment of N+1
bits to an N-bit variable as a width mismatch). Here, it's easy to
sort out: just write the range select explicitly.
We have an equivalent situation in otp_ctrl_part_unbuf.sv (although
this was inlining the right shift into the branches of a conditional
expression). Make this match too.
Signed-off-by: Rupert Swarbrick <rswarbrick@lowrisc.org>
diff --git a/hw/ip/otp_ctrl/rtl/otp_ctrl_part_buf.sv b/hw/ip/otp_ctrl/rtl/otp_ctrl_part_buf.sv
index d505f78..4ab5b75 100644
--- a/hw/ip/otp_ctrl/rtl/otp_ctrl_part_buf.sv
+++ b/hw/ip/otp_ctrl/rtl/otp_ctrl_part_buf.sv
@@ -576,7 +576,7 @@
// shift the addresses appropriately.
logic [OtpByteAddrWidth-1:0] addr_calc;
assign addr_calc = OtpByteAddrWidth'({cnt_q, {$clog2(ScrmblBlockWidth/8){1'b0}}}) + addr_base;
- assign otp_addr_o = addr_calc >> OtpAddrShift;
+ assign otp_addr_o = addr_calc[OtpByteAddrWidth-1:OtpAddrShift];
// Always transfer 64bit blocks.
assign otp_size_o = OtpSizeWidth'(unsigned'(ScrmblBlockWidth / OtpWidth) - 1);
diff --git a/hw/ip/otp_ctrl/rtl/otp_ctrl_part_unbuf.sv b/hw/ip/otp_ctrl/rtl/otp_ctrl_part_unbuf.sv
index 4f07028..346162c 100644
--- a/hw/ip/otp_ctrl/rtl/otp_ctrl_part_unbuf.sv
+++ b/hw/ip/otp_ctrl/rtl/otp_ctrl_part_unbuf.sv
@@ -302,8 +302,10 @@
// Note that OTP works on halfword (16bit) addresses, hence need to
// shift the addresses appropriately.
- assign otp_addr_o = (otp_addr_sel == DigestAddr) ? (DigestOffset >> OtpAddrShift) :
- {tlul_addr_q, 2'b00} >> OtpAddrShift;
+ logic [OtpByteAddrWidth-1:0] addr_calc;
+ assign addr_calc = (otp_addr_sel == DigestAddr) ? DigestOffset : {tlul_addr_q, 2'b00};
+ assign otp_addr_o = addr_calc[OtpByteAddrWidth-1:OtpAddrShift];
+
// Request 32bit except in case of the digest.
assign otp_size_o = (otp_addr_sel == DigestAddr) ?
OtpSizeWidth'(unsigned'(ScrmblBlockWidth / OtpWidth - 1)) :