Blöcke: Zähler, Multiplexer, Dekoder, ...
Blöcke werden über Signale miteinander verbunden
with/select
when/else
if/then
case/is
<=
Y <= S; Y <= A or B; -- Falsch A => Y; -- Falsch
boolean
bit
std_logic
boolean\verb
true, false
bit
0, 1
std_logic:
0, 1, Z, -, L, H, X, W
signale <signalname>: typ; signal x0, x1, x2, x3: bit; signal EN: std_logic; signal on_of: boolean;Bei Verknüpfungen müssen einzelne Signale vom selben Typ sein
0: starke 0 1: starke 1 Z: hochohmig -: don't care U: unbekannt X: konflikt L: Schwache 0 H: Schwache 1 W: Schwaches X
signal <signalname>: typ (<lower> to <upper>); signal <signalname>: typ (<upper> downto <lower>); signal x: bit_vector(0 to 7); signal a: std_logic_vector(2 to 4); signal r: bit_vector(3 downto 0);
c <= a or b;
c <= ('1', '0', '0', '0');
c <= "1000";
library ieee; use ieee.std_logic_1164.all use ieee.std_logic_unsigned.all
in
out
inout
entity <blockname> is
port
(
<signalnamen>: <richtung> <typ>;
<signalnamen>: <richtung> <typ>;
<signalnamen>: <richtung> <typ>
);
end;
entity multiplexer is
port
(
a0, a1, a2, a3: in bit;
b0, b1, b2, b3: in bit;
s: in bit;
y0, y1, y2, y3: out bit;
);
end;
entity counter is
port
(
clk: in bit;
rst: in bit;
q: out bit_vector (3 downto 0)
);
end;
architecture <beschreibungsname> of <blockname> is -- locale signale begin -- functionsbeschreibung end;
architecture mymux of multiplexer is
signal a, b, y: bit_vector (0 to 3);
begin
a <= (a0, a1, a2, a3);
b <= (b0, b1, b2, b3);
y <= a when (s='0') else b;
y0 <= y(0);
y1 <= y(1);
y2 <= y(2);
y3 <= y(3);
end mymux
architecture verhalten of multiplexer is
signal a, b, y: bit_vector (0 to 3);
begin
a <= (a0, a1, a2, a3);
b <= (b0, b1, b2, b3);
y <= a when (s='0') else b;
y0 <= y(0);
y1 <= y(1);
y2 <= y(2);
y3 <= y(3);
end verhalten
Wird:
architecture mymux of multiplexer is
signal a, b, y: bit_vector (0 to 3);
begin
a <= (a0, a1, a2, a3);
b <= (b0, b1, b2, b3);
y <= a when (s='0') else b;
y0 <= y(0);
y1 <= y(1);
y2 <= y(2);
y3 <= y(3);
end mymux
process <empfindlichkeitsliste> -- lokale signale begin -- sequentielle umgebung end process;
architecture verhalten of counter is
signal qint: std_logic_vector ( 3 downto 0);
begin
process (reset, clk)
begin
if (reset='0') then
quint <= x"0";
elseif (clk='1') and clk'event
then
qint <= qint+1;
end if;
end process;
q<=qint;
end;
Variablen im Prozess
process ..
variable V std_logic_vector (3 downto 0);
begin
V := ...
end;
not
and
or
nand
nor
xor
not
+
-
=
/=
<
<=
>
>=
with/select
with <auswahlsignal> select
ergebnis <= <Verkn"upfung_1> when <auswahlwert_1>,
<Verkn"upfung_2> when <auswahlwert_2>,
<Verkn"upfung_n> when others;
when/else
<ergebnis> <= <Verkn"upfung_1> when <Bedingung_1>,
else <Verkn"upfung_2> when <Bedingung_2>,
else <Vern"upfung_n>;
if/then
if <Bedingung_1> then <Sequentielle Anweisungen 1>; elseif <Bedingung_2> then <Sequentielle Anweisungen 2>; elseif <Bedingung_3> then <Sequentielle Anweisungen 3>; else <Sequentielle Anweisungen n>; end if;Bedingung muss vom Typ Boolean sein
case/is
case <testsignal> is
when <Wert_1> => <Sequentielle Anweisungen 1>;
when <Wert_2> => <Sequentielle Anweisungen 2>;
when <Wert_3> => <Sequentielle Anweisungen 3>;
when others => <Sequentielle Anweisungen n>;
end case;