cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
698 Views
Registered: ‎10-16-2018

Verilog Literals

Jump to solution

Hi @dgisselq ,

Could you pls, illustrate these two literals (Blue-Cirlced) :literals.JPG

What is dead_beaf !?  

What is 100_000_000 ?

Note : this picture from lsn_01

Thanks

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Scholar
Scholar
681 Views
Registered: ‎05-21-2015

@ahmed_alfadhel,

Let's step through those.  First, ,both example literals begin with a 32'.  This means they each have 32-bits to them.  One literal is then followed by an `h` indicating a hexadecimal number, while the other is followed by a `d` indicating a decimal number.  Further, Verilog allows underscores within numbers as separators and the parser just ignores them.  Hence, the two numbers might also be written as 0xdeadbeef or 100000000 in a more traditional software context.  Notice how these are harder to read--the 100,000,000 value in particular, because there are so many zeros in it.  The underscores really helped to make it legible, although they didn't adjust its value at all.

Dan

View solution in original post

4 Replies
Highlighted
Scholar
Scholar
682 Views
Registered: ‎05-21-2015

@ahmed_alfadhel,

Let's step through those.  First, ,both example literals begin with a 32'.  This means they each have 32-bits to them.  One literal is then followed by an `h` indicating a hexadecimal number, while the other is followed by a `d` indicating a decimal number.  Further, Verilog allows underscores within numbers as separators and the parser just ignores them.  Hence, the two numbers might also be written as 0xdeadbeef or 100000000 in a more traditional software context.  Notice how these are harder to read--the 100,000,000 value in particular, because there are so many zeros in it.  The underscores really helped to make it legible, although they didn't adjust its value at all.

Dan

View solution in original post

Highlighted
Explorer
Explorer
674 Views
Registered: ‎10-16-2018

@dgisselq 

What about the deadbeaf?

could it stands for sth before define it?

Thanks

 

0 Kudos
Highlighted
Scholar
Scholar
666 Views
Registered: ‎05-21-2015

Did you notice that all of the characters in 32'hdead_beef where between a and f?  These are valid hexadecimal characters.  This is a fun number to use since it can also be "read", but it is still a number.  Mapping it to decimal, I get 3,735,928,559.

Note that this is a literal, not a variable.  It begins with a # (i.e. 32).  Variables cannot begin with numbers.  Therefore it doesn't need to be "defined", but rather is a value in its own right.

Dan

Highlighted
Explorer
Explorer
662 Views
Registered: ‎10-16-2018

@dgisselq  ,

I am impressed by you. 

Great Thanks for you.

0 Kudos