Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Working with strings and characters in VHDL.

Status
Not open for further replies.

amisin

Junior Member level 1
Joined
Oct 5, 2011
Messages
16
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Location
Meerut, Uttar Pradesh, India
Activity points
1,431
I have to access each element of a string via a character. So for that I will be using a for loop, but how do we access a specific element of a string. like for string str(1 to 8), if I wish to assign, str(4) to the character variable chr, how exactly we do that?

Code:
for loopcounter in 0 to 63 loop -- one end loop pending at end.
TestValueCharacter := O_LogisticCode(loopcounter + 1);
if(TestValueCharacter = '0') then
TestValueReal := 0;
elsif(TestValueCharacter = '1') then
TestValueReal := 1;
elsif(TestValueCharacter = '2') then
TestValueReal := 2;
elsif(TestValueCharacter = '3') then
TestValueReal := 3;
end if;

Here TestValueCharater is of character type, and TestValueReal is of real type. And O_LogisticCode is a string.
 

O_LogisticCode(loopcounter+1) := some_char.

I dont understand exactly what your problem is. You're doing the reverse with the current code.

Btw, to assign real values, you need to assign them like this:

TestValueReal := 1.0;
etc.

you need the .0, otherwise it thinks it is an integer.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top