Академический Документы
Профессиональный Документы
Культура Документы
SR-Latch
Gated SR-Latch
Q+ Qn+
SR =
Q Qn
00
01
11
10
00
11 01
00
10
01
01 01
00
00
11
00 00
00
00
10
10 00
00
10
C
Q
S
D-latch
Master-Slave Flipflop
Clk
C
Q
D
Clk
D
Clk
Edge-triggered Flipflop
Latches
Mux:
process(a,b,sel)
begin
if (sel=1) then
Clk
q<=a;
else
q<=b;
Sel
end if;
end process;
Latches
Latch:
process(D,clk)
Flip-flop
D
(a)
begin
if (clk=1) then
q<=D;
end if;
Clk
end process;
Clk
Clk
(Sel)
Flip-flop
process(clk)
Signal Attributes
signal s:bit;
s
begin
if (clk=1) and clkevent then
q<=d;
end if;
end process;
sevent
sactive
sstable(5 ns) =
squiet(5 ns) =
stransaction =
now
Signal Attributes
signal s:bit;
process(D,reset,clk)
sdelayed(5 ns)
slast_event
slast_active
slast_value
begin
if (reset=0) then
0
q<=0;
elsif (clk=1) then
Reset
q<=D;
Clk
end if;
end process;
Latch:
process(D,reset,clk)
D
Reset
begin
if (clk=1) then
if (reset=0) then
q<=0;
else
Reset
q<=D;
end if;
Clk
Clk
end if;
Clk
end process;
Synchronous reset
process(clk)
D
Reset
begin
q
Clk
Clk
Asynchronous reset
process(clk,reset)
begin
Registers
D(0 to N-1)
Q(0 to N-1)
Clk
if (reset=1) then
q<=0;
elsif (clk=1) and clkevent then
q<= D;
end if;
end process;
Structural description
USE work.all;
ENTITY d_register IS
generic( N:integer
);
port(
D:IN bit_vector(N-1 DOWNTO 0);
clk:IN bit;
Q:OUT bit_vector(N-1 DOWNTO 0));
END d_register;
ARCHITECTURE structure OF d_register IS
COMPONENT dflipflop -- IS is allowed in VHDL93
Not very efficient!!!
port(
D:IN bit;
clk:IN bit;
Q:OUT bit);
END COMPONENT; -- COMPONENT keyword may be skipped in VHDL93
BEGIN
U0:FOR i IN 0 TO N-1 GENERATE
R0:dflipflop PORT MAP (D(i),clk,Q(i));
END GENERATE ;
END d_register;
VERY efficient!!!
PROCESS(clk)
BEGIN
IF clkEVENT AND (clk=1) THEN
q<=D;
END IF;
END PROCESS;
END behave;
Data buses
En(0 to N-1)
D(0 to N-1)
Clk
If a signal has a bus resolution function associated with it, then the
signal may have multiple drivers
USE WORK.my_bus_resolution.ALL;
ENTITY bus IS
PORT (a, b, c : IN bit; z : OUT bit);
END bus;
Transaction queue
OR
Resolved
signal
AND
std_logic
variable res:std_logic:=Z;
begin
end loop;
return res;
end resolved;
( U,U,U,U,U,U,U,U,U), -- U
( U,X,X,X,X,X, X,X,-), -- X
VL
N connected Units
VOH
VSS
( U,X, 0, 1, Z,W,L,H,-), -- Z
( U,X, 0, 1,W,W,W,W,-), -- W
( U,X, 0, 1,L, W,L,W,-), -- L
( U,X, 0, 1,H,W,W,H,-), -- H
( U, -, -, -, -, -, -, -, -)); -- -
Voltage levels
Representation of 1s and 0s
VOH = 3.3V
VIH = 2.4V
VOH
VH
VOL
VL
H, 1
W, X
VIL = 0.8V
Noise Margin
TTL
VH>2.4 V, VL<0.8 V,
CMOS
VOL = 0.4V
Ri
VOH=3.3 V, VOL=0.4V
VL<10% of VDD -VSS
L, 0
Vi
Ri =
<0.8V
<10%
>0.8V,<2.4V
>10%, <90%
>2.4V
>90%
- TTL
- CMOS (% of VDD-VSS)
VDD
VL
<1kOhm
VOH
V=VOH
R=ROH
VL
>1kOhm, <1MOhm
VSS
0 - Forcing Zero
R
VDD
VH
VH
VDD
VOL
VH
VL
VOL
V=VOL
R=ROL
VH
VH
VSS
VSS
V<VL
R~10 Ohms
Z - High Impedance
R
VH
VDD
VOH
VL
R
VDD
VH
V=?
VL
VH
VL
V=?
VL
VSS
VDD
0
VH<V
R~10 kOhms
VSS
0
V=?
R~10 MOhms (TTL)
10 GOhms (CMOS)
Two-pole equivalent
Vres
R
VH
R1
R2
VL
V1
V2
Rres = R1||R2
VL<V<VH
R~10 Ohms
Vres = V1*R2/(R1+R2)+V2*R1/(R1+R2)
X - Forcing Unknown
X - Forcing Unknown
Vres
VDD
VDD
VL
VDD
VH
VOH
VSS
VSS
VH
R2
V1
V=?
VL
VOL
R1
V2
VH
VSS
VL
Vres
<0.8V
<10%
>0.8V,<2.4V
>10%, <90%
>2.4V
>90%
<1kOhm
>1kOhm, <1MOhm
Rres
Rres := Ri*Rres/(Ri+Rres)
Final check:
if Rres> 1 (MOhm) then return Z;
elsif Vres> 0.9*VDD then
if Rres> 1 (kOhm) then return H; else return 1; end if;
elsif Vres> 0.1*VDD then
if Rres> 1 (kOhm) then return W; else return X; end if;
else
if Rres> 1 (kOhm) then return L; else return 0; end if;
end if;
- TTL
- CMOS (% of VDD-VSS)
Appendix
Dataflow modeling
Concurrent statements:
Concurrent If-statements
Concurrent Case-statement
else 0;
-- D-latch
q<=D when clk=1 else q;
-- D-flipflop
Example
Example
signal t : wired_bus bus;
signal u : bit register;
Disconnect statement
entity tristate is
port(a0,a1,a2,a3,en:IN bit;
q0,q1,q2,q3:OUT bit);
end tristate;
architecture data_flow of tristate is
disconnect q0:bit after 1 ns;
disconnect others:bit after 2 ns;
-- disconnect all:bit after 2 ns;
begin
U0:block(en=1)
begin
q0 <= guarded a;
...
end block;
end data_flow;
Block syntax
Electrical Equivalents to
std_logic
X - Forcing Unknown
0 - Forcing Zero
R
VDD
VH
R
VDD
VH
VL
V
VL
VH
V=?
VOL
V
VL
VH
VSS
VL<V<VH
R~10 Ohms
VH
VSS
V<VL
R~10 Ohms
1 - Forcing One
Z - High Impedance
R
VH
VDD
V
VOH
VL
R
VDD
VH
VH
VL
V=?
V=?
VL
VL
VL
VSS
VSS
0
VH<V
R~10 Ohms
V=?
W - Weak Unknown
VDD
VH
R
VDD
VH
VH
V=?
VL
VOL
VL
VSS
R~10 kOhms
VSS
VDD
0
VL<V<VH
0
V<VL
R~10 kOhms
VSS
L
VSS
VDD
V
VOH
VL
VL
VSS
VDD
0
VH<V
R~10 kOhms