Forum: FPGA, VHDL & Co. VHDL: records und deren Initialisierung


von berndl (Gast)


Lesenswert?

Hallo zusammen,

ich habe in einem package folgendes definiert:
1
   type t_sent_in is
2
   record
3
      cfg : std_logic_vector (31 downto 0);
4
      data : std_logic_vector (31 downto 0);
5
      secsns : std_logic_vector (31 downto 0);
6
      ser_data : std_logic_vector (31 downto 0);
7
      ser_cfg : std_logic_vector (31 downto 0);
8
   end record;
9
   constant C_SENT_IN : t_sent_in := (
10
      (others => '0'),
11
      (others => '0'),
12
      (others => '0'),
13
      (others => '0'),
14
      (others => '0')
15
   );
16
   type t_sent_in_4ch is array (0 to 3) of t_sent_in;
(In der 'constant' sollen spaeter mal sinnvolle Defaultwerte stehen, 
hier einfach mal alles genullt). Im Toplevel das package eingebunden. 
Jetzt im Toplevel die Signaldeklaration mit Initialisierung:
1
   signal sent_in_regs : t_sent_in_4ch := (C_SENT_IN, C_SENT_IN, C_SENT_IN, C_SENT_IN);
Frage: Geht das einfacher/generischer? Ich habe mit 'signal sent_in_regs 
: t_sent_in_4ch := (others => (others => '0'))' sowie 'signal 
sent_in_regs : t_sent_in_4ch := (others => (others => C_SENT_IN))' 
rumgespielt, da hat GHDL aber rumgezickt...

Versteht jemand mein Problem :o) und hat 'nen guten Tipp dazu?

von berndl (Gast)


Lesenswert?

argh...

wieso findet man eigentlich immer nach dem Posting die Loesung?

Deklaration mit
1
   signal sent_in_regs : t_sent_in_4ch := (others => C_SENT_IN);
ist genau das was ich will und funktioniert. Also bitte alles ignorieren 
was ich hier geschwurbelt habe...

von Duke Scarring (Gast)


Lesenswert?

berndl schrieb:
> wieso findet man eigentlich immer nach dem Posting die Loesung?
Murphy? Bzw. irgendwas aus dem Umfeld von Murphy.

berndl schrieb:
> constant C_SENT_IN : t_sent_in := (
>       (others => '0'),
>       (others => '0'),
>       (others => '0'),
>       (others => '0'),
>       (others => '0')
>    );

Ich schreib die record-Elemente lieber explizit hin:
1
constant C_SENT_IN : t_sent_in := (
2
       cfg      => (others => '0'),
3
       data     => (others => '0'),
4
       secsns   => (others => '0'),
5
       ser_data => (others => '0'),
6
       ser_cfg  => (others => '0')
7
    );
Das ist wartungsfreundlicher.

Duke

von berndl (Gast)


Lesenswert?

Duke Scarring schrieb:
> Ich schreib die record-Elemente lieber explizit hin:constant C_SENT_IN :
> t_sent_in := (
>        cfg      => (others => '0'),
>        data     => (others => '0'),
>        secsns   => (others => '0'),
>        ser_data => (others => '0'),
>        ser_cfg  => (others => '0')
>     );
> Das ist wartungsfreundlicher.

stimmt, guter Tipp! Danke

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.