Hardwarebeschreibungssprachen: Unterschied zwischen den Versionen
Beagle (Diskussion | Beiträge) |
Beagle (Diskussion | Beiträge) |
||
Zeile 639: | Zeile 639: | ||
Das vollständige Skript der aus dem Downloadbereich: | Das vollständige Skript der aus dem Downloadbereich: | ||
− | * [http://www. | + | * [http://www.tu-ilmenau.de/fileadmin/media/mne_ess/vorlesung_hbs.pdf Skript] |
Die angeblich fehlenden Folien zum Beantworten der Fragen: | Die angeblich fehlenden Folien zum Beantworten der Fragen: |
Version vom 17. Dezember 2010, 10:58 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: | 25.02.2011 |
Zeit: | 09:00 - 10:30 |
Ort: | Sr HU 211/212 |
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)
<source lang="VHDL"> with addr select -- entspricht einem Multiplexer (HBS 4-12) q = a when "00", b when "11", c when others; </source>
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>
Bsp.: <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>
while-Schleifen
<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;
(int_var := vec2int(vec_var)) </source>
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>
7. Vorlesung
Interne Behandlung von Signalen und Variablen
<source lang="vhdl"> sig <= <waveform>, ... waveform = <expr.>[after time] | unaffected </source>
Transaktionslisten
- (current_time + time, value)
- delta - Delay: 1/unendlich, Summe = (1/unendlich)
wählt Aktion2 <source lang="vhdl"> signal x : std_logic := 0; process (...) begin x <= '1'; if (x = '1') then -- Aktion1 else -- Aktion2 end if; end process </source>
wählt Aktion1 <source lang="vhdl"> process (...) variable x : std_logic := 0; begin x := '1'; if (x = '1') then -- Aktion1 else -- Aktion2 end if; end process; </source>
Simulationsablauf
Initialisierung
- Wertzuweisungen
- Simulationtime = 0
- alle Prozesse anstarten
Aktualisierung
- Bestimmung von next_time und next_event aus der Transaktions + Weckliste
- current_time auf next_time
- => Ausführen der Transaktionen, Wertzuweisungen + Aktivierung von Prozessen
- Löschen der aktiven Transaktionen
Ausführen der Prozesse
- aller aktivierten Prozesse
- Weränderung erst nach Prozess-Stop
- (Schleife aus Aktualisierung & Ausführen von Prozesse)
Simulationsende
- alle Transktionslisten leer
- keine Events mehr ausführen
- Signale stabil
- Zeitlimit
Bsp.: <source lang="vhdl"> constant check_periode : time := 250ns; begin process begin clk <= 0; wait for clock_period/2; clk <= 1; wait for clock_periode/2; end process; </source>
Alternativ <source lang="vhdl"> clk <= not clk after 125ns; </source>
Verzögerungsmodelle bei Signalzuweisungen
<source lang="vhdl"> <sig> <= [<inertial(default)|transport>]<waveform>,... </source>
Bsp.: <source lang="vhdl"> begin a <= '0', '1' after 10ns, 'o' after 30ns, '1' after 50ns, '0' after 58ns; b <= '0', '1' after 15ns; c <= inertial a and b after 12ns; d <= transport a and b after 12ns; e <= reject 8ns inertial not a after 10ns;
process(clk) variable num, sum integer range 0 to 15 := 0; begin if (clk = '1' and clkevent) then veq_q0 <= sum; num := num + 1; sum := num + 1; veq_q1 <= sum; end if; end process;
signal num, sum : integer range 0 to 15 := 0; process(clk) begin if (clk = '1' and clkevent) then veq_q0 <= sum; num <= num + 1; sum <= num + 1; veq_q1 <= sum; end if; end process; </source>
8. Vorlesung
Kapitel 5: Entwurfsbeispiele
Latch (HBS_5-3) Definition: Ein Latch (engl. für Schnappschloss, Auffangregister), oder auch als zustandsgesteuertes Flipflop bezeichnet, ist eine bestimmte Ausführung eines elektronischen 1-Bit-Datenspeichers und bildet(e) die Grundlage für weite Bereiche der Digital-Hardware, insbesondere innerhalb CPU- und Peripherie-Chips.
Im Gegensatz zu taktflankengesteuerten Flipflops ist ein Latch während der gesamten aktiven Taktphase transparent, d. h. Eingangsänderungen können den Ausgang sofort beeinflussen.
entity LATCH is port (d, en : in bit; q : out bit); end LATCH; architecture test1 of LATCH is beagin process (en, d) begin if en = '1' then q <= d; -- else -- q <= q; end if; end process; end test1;
architecture test2 of LATCH is begin process (clk, d) begin case clk is when '1' => q <= d; when '0' => null; end process; end test2;
architecture test3 of LATCH is signal temp : bit; begin process (en, d) begin if en = '1' then q <= temp; else temp <= d; end if; end process; end test3;
architecture test4 of LATCH is begin process (en, d) variable temp : bit; begin temp := 0; if en = '1' then temp <= d; end if; q <= temp; end process; end test4;
architecture test5 of LATCH is begin process (en, d) variable temp : bit; begin temp := 0; if en = '1' then temp <= d; else temp := not temp; end if; q <= temp; end process; end test5;
FLip Flops Definition: Ein Flipflop (engl. flip-flop), meist auch bistabile Kippstufe oder bistabiles Kippglied genannt, ist eine elektronische Schaltung, die zwei stabile Zustände einnehmen und diese speichern kann.
Das Flipflop ist eine einfache elektronische Schaltung, welche eine Datenmenge von einem Bit über eine lange Zeit speichern kann. Es ist fundamentaler Bestandteil vieler elektronischer Schaltungen (sequentieller Schaltkreise) – von der Quarzuhr bis zum Mikroprozessor. Daneben ist es in vieltausend- bis milliardenfacher Ausführung in Computerspeicherchips (statischen Speicherbausteinen) enthalten.
Asynchrones Reset D-Flip Flop Library ieee; use ieee.std_logic_1164.all; entitiy FF is port (clk : in std_logic; reset : in std_logic; d : in std_logic; q : out std_logic); end FF; architecture rtl of FF begin process (clk, reset) begin if reset = '0' then q <= 0; elsif (clk = '1' and clk'event) then q <= d; end if; end process; end rtl;
Alternative für Simulation wait until clk'event and clk = '1' if rising_edge(clk) (falling)
Synchrones Reset Preset D-FlipFlop architecture rtl2 of FF is begin process(clk) begin if (clk = '0' and clk'event) then if (reset = '0' then q <= '0': elsif preset = '0' then q <= '1'; elsif enable = '1' then q <= d; else null; end if; end if; end process; end rtl2;
Zähler
Johnson-Zähler
Library ieee; use idee.std_logic_1164.all; entity johnson is port (clk : in std_logic; sum : out std_logic_vector (3 downto 0); end johnson; architecture rtl of johnson is begin process(clk) variable count : std_logic_vector (3 downto 0); begin if (clk = '1' and clk'event) then for i in 3 downto 1 loop count(i) := count(i-1); end loop; count(0) := not count(3); end if; sum <= count; end process; end rtl;
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