I created a module that accepts a wire [ 4 : 0 ]
as input, and I'm using several instances of this module. But, I'm getting:
Syntax error in instance port expression(s)
whenever I pass a value that contains A-F.
For example:
key_schedule i1(09); // works
key_schedule i1(0A); // doesn't work
key_schedule i1(15); // works
key_schedule i1(1D); // doesn't work
If anyone knows what's wrong, I'd appreciate their help.
Also, what happens if I'm passing a value "C", but I also have a wire called C
?
Verilog Number Format. The <base format> consist of an apostrophe ( ' ) followed by b (binary, base-2), d (decimal, base-10), o (octal, base-8) or h (hexadecimal, base-16) for integer numbers.
Assigning the Hexadecimal number in a variable There is no special type of data type to store Hexadecimal values in C programming, Hexadecimal number is an integer value and you can store it in the integral type of data types (char, short or int).
You might sometimes see this used with raw values, like #5 or #10, which means to wait 5 or 10 units of your timescale.
Hexadecimal is a numbering system with base 16. It can be used to represent large numbers with fewer digits. In this system there are 16 symbols or possible digit values from 0 to 9, followed by six alphabetic characters -- A, B, C, D, E and F.
Verilog treats all bare numeric literals as decimal. A
and D
are not legal decimal values.
For hexadecimal literals, you need to specify the literal type using 'h
:
key_schedule i1('h0A); // works
key_schedule i1('h1D); // works
Refer to the IEEE Std (1800-2009, for example), section "Numbers".
The following code compiles for me without errors on 2 different simulators (Incisive and VCS):
module tb;
key_schedule i1(5'h1A);
key_schedule i2('h1A);
endmodule
module key_schedule (input [4:0] in);
always @(in) $display(in);
endmodule
From http://www.asic-world.com/verilog/syntax1.html#Integer_Numbers
Verilog HDL allows integer numbers to be specified as
Syntax:
[size]'[radix][value];
Example:
8'h1D; # 8-bit hex value "1D"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With