-5
\$\begingroup\$

I see syntax quit similar to this very frequently:

4'd0

Sometimes it is associated with an assign statement:

assign S0 = 2'b00;

I tried searching online however I could not find any sources.

\$\endgroup\$
  • 1
    \$\begingroup\$ It is very hard for me to believe that the answer to this question was at all difficult to locate online. \$\endgroup\$ – Elliot Alderson Mar 2 at 2:03
  • 1
    \$\begingroup\$ Actually, it would be hard to search for if you didn't know what is was called. But any basic tutorial would show this. \$\endgroup\$ – dave_59 Mar 2 at 5:36
3
\$\begingroup\$

This is simply how a value is given. 4'd0 is a 4-bit value, given in base 10 (decimal), with value 0. 2'b00 is a 2-bit value, given in binary, with value 0.

The following four values are equivalent and all equal to fifteen:

4'b1111 (binary)
4'd15 (decimal)
4'hf (hexadecimal)
4'o17 (octal)
\$\endgroup\$
  • \$\begingroup\$ That makes sooo much sense! But when do you normally use them? For example, if I wanted to assign a [4:0] bit array to the value of 1101 would I do something similar to S0 [4:0] = 4'b1101? Where each bit S[0] - S[3] would contain each binary number 1101 respectively? \$\endgroup\$ – Code4life Mar 2 at 9:58
  • \$\begingroup\$ @Code4life Yes, precisely. \$\endgroup\$ – Andrey Akhmetov Mar 2 at 16:20
0
\$\begingroup\$

These are integer literal constants defined in section 5.7.1 of the IEEE 1800-2017 LRM. Anyone using Verilog/SystemVerilog should have a free copy available at https://ieeexplore.ieee.org/browse/standards/get-program/page/series?id=80

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.