7

The datasheet lists something like this:

[0x01f] EPRXREG
EPRXLock[3:0] = 4'd5;
EPRXReLock[3:0] = 4'd5

I understand that it is an 8-bit register at address 0x01f, it contains 2 fields and each of them is 4 bits wide ([3:0] and the 4 in 4'd5). But what is 'd5?

Other registers have

4'd12  1'b0  4'h4  4'hF  7'd32
TonyM
  • 22,898
  • 4
  • 39
  • 64
xealits
  • 237
  • 3
  • 7

2 Answers2

12

4'd5 indicates a four-bit value, expressed in decimal as 5. It's the same as 4'b101 (1012 = 510).

Likewise, 4'hF is a four-bit value indicating 0xF in hex; octal may also be seen (e.g. 4'hF can also be denoted as 4'o17)

nanofarad
  • 19,972
  • 2
  • 51
  • 77
3

This is the notation used for values in Verilog.

The part before the ' indicates the number of bits in the value - so 4' means it is a 4-bit value.

The part after the ' indicates the actual value. There is a prefix indicating the number base, which will be b for binary, o for octal (rarely used), d for decimal, or h for hexadecimal. (Exactly how to read values in binary, octal, decimal or hex is a separate question, which can easily be found online in any beginner's programming tutorial.)

Note that good style is usually that bitfields/flags are specified as b, so that the status of each flag can easily be seen. Other values can be set in whatever number base makes sense for the value.

The number base can also be preceded by s to say that it is signed (typically sd for signed decimal) where required, where values can be positive or negative. By default the number is unsigned (positive or zero only). This gets a little more confusing for negative values because the - sign precedes the entire value, so an 8-bit signed value set to -23 would be -8'sd23 and not 8'sd-23 as you might expect.

Graham
  • 6,150
  • 13
  • 20