1
\$\begingroup\$

I have a register of around 120bits, where data is shifted in lsb first, at some point I want to assign it to smaller registers but instead of truncating the most significant bits, I'd like to truncate the least significant bits. In essence I want to keep the n most significant bits of a register.

The current way I'm doing it is for each register assign from MSB index of big register for a width of register width like:

rSmall1 <= rBig[BIG_REG_MSB_INDEX -: RSMALL1_WIDTH];
rSmall2 <= rBig[BIG_REG_MSB_INDEX -: RSMALL2_WIDTH];
[...]
rSmalln <= rBig[BIG_REG_MSB_INDEX -: RSMALLn_WIDTH];

While it works it clutters up pretty fast so, Is there a simpler way to do this same operation for any width of rSmalln?

asked Sep 17, 2018 at 15:40
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

There is no easier way to do this in Verilog. A logical shift right requires similar width parameters.

This would be easier using SystemVerilog's streaming operator which left justifies assignments.

bit [BIG_REG_MSB_INDEX:0] filler;
{{>>{rSmall1,Filler}} <= rBig;
{{>>{rSmall2,Filler}} <= rBig;
answered Sep 17, 2018 at 16:07
\$\endgroup\$
1
  • \$\begingroup\$ Guess I'll have to stick with what I have. System verilog not allowed per company rules. \$\endgroup\$ Commented Sep 17, 2018 at 16:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.