Hello,

I can’t understand how this expression “c {1, WIDTHx {1b0}}” how can 2 ^ WIDTH accomplish this?

It is found in the Decoder component and in the example of the 7-segment display 2 ^ WIDTH = 8, but how is this possible?

Thank you

Hello,

I can’t understand how this expression “c {1, WIDTHx {1b0}}” how can 2 ^ WIDTH accomplish this?

It is found in the Decoder component and in the example of the 7-segment display 2 ^ WIDTH = 8, but how is this possible?

Thank you

This expression is the equivalent to the C/Java/other programming expression 1<<WIDTH.

When WIDTH is 1, the output will be c{1b1, 1b0} = 2b10 = 2 = 2^1

When WIDTH is 4, the output will be c{1b1, 4b0000} = 5b10000 = 16 = 2^4

Thanks,

Now with a little more experience I understand how it works.

In one of my modules, however, I used “the directive” I don’t know if it is called so in lucid “$pow(2, WIDTH)” which seems more intuitive to me, I don’t think it introduces errors in particular cases?

I believe the $pow() function didn’t exist when I wrote the 7-seg example which is why I did it the bit-wise way. I’d definitely recommend the $pow() function over the bit-wise method for clarity now. They both are only good for constants and should be interchangeable.