Forum: FPGA, VHDL & Co. Länge eines Strings


von Thomas B. (thomas1)


Lesenswert?

Guten Tag

In eine anderen Forum bin ich auf folgenden Eintrag gestossen:

Make 'toto' a variable of type LINE, from package STD.TEXTIO.
Then you can copy any string into it using the WRITE procedure:

variable toto: LINE; -- initialised to empty!
...
if A=0 then
WRITE(toto, t1);
else
WRITE(toto, t2);
end if;

Don't forget that the WRITE procedure adds things to the end
of the string stored in 'toto', so that it grows ever longer.
To reset it back to "empty", simply:

DEALLOCATE(toto);

Which leads us to an attractive procedure that has the effect
of copying any string into a LINE variable, having first
cleared that variable:

procedure put(L: inout LINE; S: in STRING) is
begin
DEALLOCATE(L);
WRITE(L, S);
end;

Now, of course, you have the problem of how to make use of
the string contents of the line variable. Given a variable
L of type LINE, you can...
* get hold of the whole string contents:
report "Message is " & L.ALL;
* take a slice of it, just like a string:
variable c: CHARACTER;
...
c := L(1);
* find its length:
if L'LENGTH > 50 then ...

Allerdings funktioniert bei mir das Attribut 'LENGTH sowie die Procedur 
DEALLOCATE nicht! Die STD-Library habe ich eingebunden und auch das File 
STD.TEXTIO.ALL.
Hat jemand eine andere Lösung, die Anzahl Zeichen in einer Line zu 
ermitteln, sowie die Line zu löschen?

Gruss
Thomas

von ich (Gast)


Lesenswert?

Sprache?
Compiler?
Platform?

von Thomas B. (thomas1)


Lesenswert?

Sorry, das nahm ich alles als gegeben an.

VHDL mit ISE.

von Rick Dangerus (Gast)


Lesenswert?

Thomas B. schrieb:
> VHDL mit ISE

siehe z.B.:
XST User Guide   UG627 (v 11.3) September 16, 2009
Chapter 7: XST VHDL Language Support

Nicht alles was VHDL kann wird von XST unterstützt.

Rick

von D. I. (Gast)


Lesenswert?

Rick Dangerus schrieb:
> Thomas B. schrieb:
>> VHDL mit ISE
>
> siehe z.B.:
> XST User Guide   UG627 (v 11.3) September 16, 2009
> Chapter 7: XST VHDL Language Support
>
> Nicht alles was VHDL kann wird von XST unterstützt.
>
> Rick

Naja man verwendet solche Konstrukte aber gerne in einer Testbench ;)

von Thomas B. (thomas1)


Lesenswert?

Dann sind diese Konstrukte also nicht synthesefähig!
Ja, dann werde ich einen anderen Weg suchen müssen.

Momentan mache ich den String einfach genügend lang, aber mit konstanter 
Länge, dann kann ich ihn löschen und seine Länge weiss ich auch.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.