tags:

views:

47

answers:

2

Hi,

I am just studying some VHDL code and for the initialisation of a constant it says the following:

constant address: integer := 16#8E#;

I have never seen this kind of definition before. Does anybody know how this translates to an ordinary number in decimal?

Thanks!

+3  A: 

16#8E# means 8E in base 16 (ie hexidecimal). For binary, you could write 2#10001110# for the same number. Once you know this, getting the decimal version should be easy.

Marty
+1  A: 

To expand further (if you have the VHDL LRM, you can read the gory details in section 13.4.2) you can put any base (between 2 and 16 inclusive) before the first # and an exponent after the second #. You can also put _s in to separate sets of numbers.

The exponent is always expressed in base 10 and cannot be negative. Example (the VHDL highlighting leaves a little to be desired!)

entity test_numbers is
end entity test_numbers;
architecture a1 of test_numbers is
begin 
    process is
    begin  -- process
    report integer'image(16#FF#);  -- 255
    report integer'image(10#1_000#);  -- 1000
    report integer'image(10#1#e3);  -- 1000 another way
    report integer'image(2#1#e10);  -- 1024
    report integer'image(4#100#);  -- 16
    wait;
    end process;
end architecture a1;

reports:

# Loading work.test_numbers(a1)
# ** Note: 255
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1000
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1000
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 1024
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
# ** Note: 16
#    Time: 0 ns  Iteration: 0  Instance: /test_numbers
Martin Thompson