Hardwarebeschreibungssprachen: Unterschied zwischen den Versionen
Beagle (Diskussion | Beiträge) |
Beagle (Diskussion | Beiträge) |
||
Zeile 76: | Zeile 76: | ||
</source> | </source> | ||
− | + | * process | |
− | + | * bedingte Signalzuweisung (condition signal assignment) | |
<source lang="VHDL"> | <source lang="VHDL"> |
Version vom 6. Dezember 2010, 15:16 Uhr
Hardwarebeschreibungssprachen (HBS) | |
---|---|
Vertiefungsrichtung | II/IHS |
Vorlesung | |
Vorlesender |
Dr.-Ing. Steffen Arlt |
Abschluß | |
Art | k.A. |
Vorteile der Nutzung von Hardwarebeschreibungssprachen, Erlernen der syntaktischen Grundelemente von VHDL, Überblick über gängige Simulations- und Synthesewerkzeuge, Unterschiede zur Hardwarebeschreibungssprache Verilog, Simulation von VHDL-Designs, Synthesegerechte VHDL-Modellierung, Alternative Beschreibungskonzepte (System C)
Prüfung
Klausur | |
---|---|
Termin | |
Datum: | 00.00.2011 |
Zeit: | 00:00 - 00:30 |
Ort: | --- |
Am Ende des Semester gibt es eine Klausur die über 90 Minuten geht.
Vorlesungsmitschriften
1. Vorlesung
2. Vorlesung
3. Vorlesung
4. Vorlesung
5. Vorlesung
Operatoren
logische Operatoren: and, or, nand, nor, xor, xnor, not
<source lang="vhdl"> x <= a xnor b; x_vec <= a_vec and b_vec; -- bei Vektoren Bitweise </source>
relative Operatoren: =, /=, <, <=, >, >=
arithmetische Operatoren: sign + - , +, -, &, *, /, mod, rem, **, abs()
Bsp.: <source lang="vhdl">
5 mod 3 = 2
- 5 mod 3 = 1
5 mod (-3) = -1
- 5 mod (-3) = -2
5 rem 3 = 2
- 5 rem 3 = -2
5 rem -3 = 2
- 5 rem -3 = -2 </source> Shift Operatoren: SLL, SRL, SLA, SRA, ROL, ROR
Nebenläufige Anweisungen
<source lang="VHDL"> architecture <concurrent decluration part> begin --concurrent VHDL begin concurrent part process (...) sequential decluration part begin sequential VHDL end process end --concurrent VHDL end </source>
- process
- bedingte Signalzuweisung (condition signal assignment)
<source lang="VHDL"> <sig_id> <= <waveform>/sig_value when <condition> else <condition> </source>
Bsp.: <source lang="VHDL"> q <= a when addr = "oo" else -- Vergleichbar if-then, elsif- else Konstruktion
b when addr = "11" else c; -- alternative: unaffected;)
</source>
- selektive Signalzuweisung (selected signal assignment) with addr select -- entspricht einem Multiplexer (HBS 4-12) q = a when "00", b when "11", c when others;
-> case-Konstrukt
<source lang="VHDL"> architecture Mux1 of MUX is -- Skizze (HBS 4-12) begin y <= (I(0) and not E and not S) or (I(0) and not E and S); end Mux1; architecture Mux2 of Muc is begin y <= (I(0) and not E) when s = '0' else (I(1) and not E);
architecture rtl1 or test is signal a,b,c,d,e : std_logic; begin d <= a and (b or c); e <= a or b; end rtl1; architecture rtl2 of test is begin process (a,b,c) variable var: std_logic; begin var := b or c; d <= a and var; end process; process (a,b) begin e <= a or b; end process; end rtl2; </source>
<source lang="VHDL"> process (a) wait until a = 1; wait on a; wait for 10ns;
wait for 2* period; wait until a = 1 for 10ns; </source>
Bsp.: Verzögerungsmodell <source lang="VHDL"> process (a) -- Skizze (HBS 4-13) begin c1 <= not a; end process;
process begin c2 <= not a; wait on a; end process;
process begin wait on a; c3 <= not a; end process;
process begin wait until a = '1'; c4 <= not a; end process;
process begin c5 <= not a; wait until a = '1' for 10ns; end process; </source>
Sequentielle Statements
<source lang="VHDL"> if addr = "00" then q <= a; elsif addr = "11" then q <= c; end if;
case addr is when "00" => q <= a; when "11" => q <= b; when others => q <= c; end case;
type alu_mod is (addr, sub, idle); -- Null-Anweisung variable sel: alu_mod; case sel is when add = c := a + b; when sub = c := a - b; when idle => null; end case; </source>
6. Vorlesung
Datei:HBS-6.pdf http://wikiii.de/wiki/Datei:HBS-6.pdf
Schleifen
- "loop" - Abbruch exit, next
bedingungslose Schleife <source lang="vhdl"> <label> : loop . . . end loop [<label>]; </source>
<source lang="vhdl"> elementar_loop : loop if i = 31 then exit; else i := i+1; q(i) <= '0'; end if; end loop elementar_loop; </source>
for-Schleifen <source lang="vhdl"> <label> : for <index> in <range> loop . . . end loop [<label>]; </source> Bsp.: <source lang="vhdl"> for i in 0 to 31 loop addr(i) <= '0'; end loop; </source>
<source lang="vhdl"> <label> : while <condition> loop . . . end loop; </source> Bsp.: <source lang="vhdl"> while i<5 loop q(i) <= data_in(i) i := i + 1; end loop; </source>
optionales & zusätzliches <source lang="vhdl"> [<label>] exit [<label>] [when]: next </source>
Unterprogramme (Subprograms)
- function, procedure - Operatoren, Datentypen, Konstanten, Konvertierung - lokal (in einer architecture), global (package) - rein sequenzielles VHDL - laut IEEE_1076.6 sind Signaldeklarationen nicht synthesefähig - Rekursion - nicht synthesefähig!
Funktionen - mehrere Übergabeparameter - ein Rückgabewert
<source lang="vhdl"> function <func_id> (<parameter_list>) return <type_id> is <variable. constant, type declaration>; begin <ssequential statements> return <id>; end [<func_id>];
Bsp.: <source lang="vhdl"> funtion vec2int (v:std_logic_vector) return integer is variable tmp: integer := 0; begin for i in v'range loop tmp : = tmp*2; if v(i) = '1' then tmp := tmp + 1; end if; end loop; return tmp; end vec2int; </source>
(int_var := vec2int(vec_var))
function overloading
<source lang="vhdl"> type tri_logic is ('0', '1', 'K'); function and (in_1: tri_logic; in_2: tri_logic) return tri_logic is begin if in_1 = '1' and in_2 = '1'then return '1'; elsif in_1 = '0' or in_2 = '0' then return '0'; else return 'K'; end if; end and; </source>
Zustände von Funktionen: pure, impure
Prozeduren - liefern keine Rückgabewerte: => nicht in Ausdrücken - mehrere Ü-Parameter möglich (in, out, inout) [in = ro] [out = wo] [inout = r/w]
<source lang="vhdl"> procedure <proc_id> (<param_list>] is <declaration> begin <sequ. VHDL> end [<proc_id>]; </source>
Bsp.: <source lang="vhdl"> procedure std_logicvec2int (v: in std_logic_vector; f: out boolean; result: out int) is variable tmp : integer := 0; begin result := 0; f := true; for i in v'range loop result := result*2; if v(i) = '1' then result := result + 1; f := false; end if; end loop; end std_logic2int; </source>
Assertion - Überprüfung von Bedingungen und Angaben von errors, warnings - Meldung wenn Bedingung "false" - default Meldung: "Assertion violution"
<source lang="vhdl"> assert <not condition> [report]["<text>"][severity]]serverity_level] { <note|warning|failure></source> -default für severity_level ist error
Bsp.: <source lang="vhdl"> assert (a = '1' and b = '1') report "a and b not equal '1' at same time" severity warning; </source>
Materialien
Das vollständige Skript der aus dem Downloadbereich:
Die angeblich fehlenden Folien zum Beantworten der Fragen:
Die Dokumentation eines vollständigen Softwareprojekts:
Die vollständigen Aufgaben aus dem Downloadbereich:
Literaturhinweise
Hunter, R.D., Johnson, T.T.: Indruction to VHDL. Springer US 1995 Sjoholm, St., Lindh, L.: VHDL for Designers. Prentice Hall 1996 Reichardt, J.: VHDL-Synthese. Oldenbourg 2003