--
ist Kommentarwork
verwenden-- synthesis translate_off <simulation only> -- synthesis translate_on
Das folgende ist mixbar
component
verwenden)process
verwenden)Mögliches Design: combinatorial circuit ⇒ Register (D-FF Array) ⇒ combinatorial circuit ⇒ Register (D-FF Array) ⇒ …
library
/use
(is nach jedem entity wieder weg)entity
(Schnitstelle)architecture
(Implementierung der Schnitstelle (entity))configuration
(Auswahl wenn mehrere architectures eine entity beschreiben)bit
std_logic
(in std_logic_1164)'U'
: Uninitialized'X'
: Unknown, conflict'0'
: '1'
: 'Z'
: High Impedance'W'
: Weak unknown, conflict'L'
: Weak logic 0
'H'
: Weak logic 1
'-'
: Don't caretype <a_name> is array(0 to 7) of std_vector;
signal a : std_logic; signal b : std_logic := '0'; signal c : std_logic_vector(0 to 7); signal d : std_logic_vector(7 downto 0) := "10101100";
constant A : integer := 42; constant B : real := 4.2;
variable a : integer; variable b : integer := 42; variable c, d : integer; b := 1337;
Deklaration in
a <= b; a <= '0'; c <= "11110101";
library <name>;
library ieee;
library lib entity ... end; -- lib is now unknown
use <library>.<package>[.<declaration>|.all]; use work.<package>[.<declaration>|.all];
library lib use lib.pack; ... pack.decl
library lib use lib.pack.decl; ... decl
library lib use lib.pack.all; ... decl
Schnittstelle
entity <e_name> is [generic(...);] port(...); end <e_name>;
Generic = Parametriesierbare Schnittstelle
Wird das Modul (beschrieben durch die entity) instanziiert, wirken die konstanten generic
Parameter wie Funktions Parameter. Z.B. breiter eines Addierers.
Ein Port kann sein
in
out
inout
entity EntityFoo is port( a: in std_logic; b: out std_logic; ); end EntityFoo;
[<as_name> :] assert <OK_condition> [report "..."] [servity note|warning|eror|failure] ;
entity EntityFoo is port( a: in std_logic; b: out std_logic; ); begin -- synthesis translate_off check1 : assert a = '1' report "Nope! Nope! Nope!"; -- synthesis translate_on end EntityFoo;
Verhalten
architecture <a_name> of <e_name> is <signal delcarations> <type delcarations> begin <VHDL Instructions> end <a_name>;
architecture ArchitectureBar of EntityFoo is begin b <= a; end ArchitectureBar;
Von out
Signalen kann nicht gelesen werden ⇒ Hilfssignale
Eine Entity hat mehrere Architectures.
Definiert wie die Entity jetzt verwendet werden soll: Reihenfolge der Ports/Generics für die Port/Generic maps. Die Reihung muss vollständig sein.
component <e_name> [generic(...);] port(...); end component;
architecture structure of latch is component nor_gate port( a: in bit; b: in bit; c: out bit ); end component; begin n1: nor_gate port map(r, nq, q); n2: nor_gate port map(s, q, nq); end structure;
[<p_name> :] process[(<sensitivity list)] <declarations> begin <sequential statements> end process [<p_name>];
Zugriff auf gesetzte Werte
wait
Prozess muss eines von beiden verwenden (XOR)
wait
Ohne eins er follgenden geht ein Prozess in Dauerschleife:
wait;
… wait for 10 ns
ist OK
Erlaubt
Nicht erlaubt
if clock'event and clock = '1' then .... if rising_edge(clock) then ... if falling_edge(clock) then ...
Synchronisation ohne Reset (sensitivity list: clock)
if rising_edge(clock) then ... end if;
Synchronisation mit asynchronem Reset (sensitivity list: reset & clock)
if reset='1' then ... elseif rising_edge(clock) then ... end if;
Synchronisation mit synchronem Reset (sensitivity list: clock)
if rising_edge(clock) then if reset = '1' then ... else ... end if; end if;
Erzeuge eine Instanz der Entität mit konkreten Ports/Generic Parametern.
<c_name> : <e_name> [generic map(...)] port map(...);
Achtung: kein ;
zwischen drinn.
generic map(1, 2, 3) generic map(a => 1, b => 2, c=> 3) port map(1, 2, 3) port map(a => sig1, b => sig2, c=> sig3)
architecture structure of latch is component nor_gate port( a: in bit; b: in bit; c: out bit ); end component; begin n1: nor_gate port map(r, nq, q); n2: nor_gate port map(s, q, nq); end structure;
Conditional Signal Assignment
Reihenfolge wichtig
bar: a <= x when b = '0' else y when b = '1' else z;
else
)Selected Signal Assignment
bar: with b select a <= x when '0', y when '1', z when others;
vectorName(<bit br>)
,
als Trennerif b = '0' then a <= x; elsif b = '1' then a <= y; else a <= z; end if;
;
als Trennerelsif
ohne ecase b is wehen '0' => a <= x; wehen '1' => a <= y; wehen others => a <= z; end case;
;
als Trenner