What does X"46" represents in VHDL code ?

Status
Not open for further replies.

shsshs

Newbie level 5
Joined
Jul 25, 2010
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
turkiye
Activity points
1,356
I am new in Fpga. I am studing vhdl. I saw code like that

type CHAR_RAM_TYPE is array(0 to 39) of std_logic_vector(7 downto 0);

signal charRAM : CHAR_RAM_TYPE := ( 0=>x"41", 1=>x"6E", 2=>x"64", 3=>x"79", 4=>x"FE", 5=>x"47", 20=>x"31", 21=>x"34", 22=>x"2F", 23=>x"30", 24=>x"36", 25=>x"2F", 26=>x"30", 27=>x"37", others=>x"A0");

the thing that I want to ask is that does this representation X"46" mean "0 1 0 0 0 1 1 0" ? And does X show hegzadecimal?

thanks for help
moreover I want to help for lcd driver. I read some and am expecting leading information about lcd driver from your help. thnks.
 

Re: help for fpga

Hi - yes the X means that the following numbers in the quotes are hexadecimal. Note that each digit represents exactly 4 bits. Section 4.d in this tutorial may be helpful for you.

However, can somebody clarify the way the initial assignment of that signal is being done? I have never seen it done that way. Does that simply mean that index 0 is assigned x41, index 1 is assigned x6E, so on and so forth and all indexes that aren't explicitly assigned are set to xA0?
 
Re: help for fpga

when I synthesize the code it does not give any error. As a result of this I decide that this representation and assignment are correct.
 

Re: help for fpga

@uoficowboy: you are right. And about the initialization method used,this is a normal method of initializing arrays or vectors. The "others" key word is used to assign a value to all other bits or indexes the specified value.
For example,
signal x : std_logic_vector(3 downto 0) := (1 => '1', others => '0');
The initialized value in x is "0010".

I hope it is clear now.


--vipin
https://vhdlguru.blogspot.com/
 

Re: help for fpga

shsshs said:
the thing that I want to ask is that does this representation X"46" mean "0 1 0 0 0 1 1 0" ? And does X show hegzadecimal?

Yes. X (or x) means it represents a hex string. You can also use B/b for binary:

s <= B"00101111";

or octal:

s <= O"8452";

there are also some neat things you can do using underscores to make it more readable:

s <= B"0010_1111";
s <= X"0A_8F_77_FF";

Also, for integers, you can create literals in any base using # (in the range 2-16):

my_int <= 16#AAF0#; --literal AAF0 in base 16
my_int <= 2#1101#; --literal 13
my_int <= 14#AA654#; --you do the math
 

Re: help for fpga

if you are new to FPGA... try verilog... its less wordy and easy.... but its my opinion and i am not trying to offend any one
 

Re: help for fpga

thanks for all helps. I understand clearly

I know little bit verilog from my univercity but in my internship , I am responsible to learn and apply on fpga with vhdl... But I have been using fpga for two weeks and I think it is funny and easy... my fpga is spartan 3 AN -XC3S700AN. there is a lot of facility to learn I have used rs232 and vga. and I am stilll working on vga it is funny
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…