Beruflich Dokumente
Kultur Dokumente
Sept. 2005
Topics
Sept. 2005
Sept. 2005
Sept. 2005
Generics
Sept. 2005
More on Generics
Within a structural model there are two ways in
which the values of generic constants of lower
level components can be specified:
in the component declaration
in the component instantiation
Sept. 2005
Sept. 2005
Configuration
Structural models may employ different levels of
abstraction.
Each component in a structural model may be
described as a behavioral or a structural model.
Configuration allows stepwise refinement in a
design cycle.
Configuration represents resource binding.
Description-synthesis design method.
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
Sept. 2005
2
3
2
3
Features of Overloading
Sept. 2005
Continued
function INTVAL(VAL: BIT_VECTOR) return INTEGER is
variable SUM: INTEGER := 0;
begin
for N in VALLOW to VALHIGH loop
if VAL(N) = 1 then
SUM := SUM + (2**N);
end if;
end loop;
return SUM;
end INTVAL;
Sept. 2005
Overloaded + In A Package
PACKAGE math IS
FUCNTION +(1, r: BIT_VECTOR) return INTEGER;
END math;
PACKAGE BODY math is
FUNCTION vector_to_int(S: BIT_VECTOR) RETURN INTEGER IS
VARIABLE result: INTEGER := 0; --- this function is local to
VARIABLE prod: INTEGER := 1; --- the package
BEGIN
3FOR i IN sRANGE LOOP
3
IF s(i) = 1 THEN
result := result + prod;
END IF;
prod := prod * 2;
END LOOP;
RETURN result;
END vector_to_int;
Sept. 2005
Continued
FUNCTION +(1, r: BIT_VECTOR) RETURN INTEGER IS
BEGIN
RETURN(vector_to_int(1) + vector_to_int(r));
END;
END math;
USE WORK.math.ALL;
ENTITY adder IS PORT(a, b: IN BIT_VECTOR(0 TO 7);
c: IN INTEGER; dout: OUT INTEGER);
END adder;
ARCHITECTURE test OF adder IS
SIGNAL internal: INTEGER;
BEGIN
internal <= a + b; --- which + ?
dout <= c + internal; --- which + ?
END test;
Sept. 2005
Sept. 2005
Sept. 2005
Libraries
Sept. 2005
Sept. 2005
Sept. 2005
FiniteStateMachinesandVHDL
StateProcesses
StateCoding
FSMTypes
Medvedev
Moore
Mealy
RegisteredOutput
Sept. 2005
1.One"State"Process
FSM_FF:
process (CLK, RESET)
begin
if RESET='1' then
STATE <= START ;
elsif CLK'event and CLK='1' then
case STATE is
when START => if X=GO_MID then
STATE <= MIDDLE ;
end if ;
when MIDDLE => if X=GO_STOP then
STATE <= STOP ;
end if ;
when STOP => if X=GO_START then
STATE <= START ;
end if ;
when others => STATE <= START ;
end case ;
end if ;
end process FSM_FF ;
Sept. 2005
2.Two"State"Processes
Sept. 2005
3.HowManyProcesses?
StructureandReadability
Asynchronouscombinatoricsynchronousstoringelements
=>2processes
FSMstateschangewithspecialinputchanges
=>1processmorecomprehensible
GraphicalFSM(withoutoutputequations)resemblesonestateprocess
=>1process
Simulation
Errordetectioneasierwithtwostateprocesses
=>2processes
Synthesis
2stateprocessescanleadtosmallergenericnetlist
andthereforetobettersynthesisresults
=>2processes
Sept. 2005
4.StateEncoding
Stateencodingresponsible
forsafetyofFSM
START
-> "00 "
MIDDLE -> "01 "
STOP
-> "10 "
Defaultencoding:binary
Speedoptimizeddefault
encoding:onehot
if{ld(#ofstates)ENTIER[ld(#ofstates)]}=>unsafeFSM!
Sept. 2005
5.ExtensionofCaseStatement
case STATE is
when START =>
when MIDDLE =>
when STOP
=>
Addingthe"whenothers"choice
whenothers=>
end case ;
Notsimulatable;
inRTLthereexistnoothervaluesforSTATE
Notnecessarilysafe;
somesynthesistoolswillignore"whenothers"choice
Sept. 2005
6.ExtensionofTypeDeclaration
case STATE is
when START =>
when MIDDLE =>
when STOP
=>
whenDUMMY=>
-- or when others
end case ;
{2**(ENTIER[ld(n)])-n}dummystates
(n=20=>12dummystates)
Changingtoonehotcoding=>unnecessaryhardware
(n=20=>12unnecessaryFlipFlops)
Sept. 2005
Addingdummyvalues
Advantages:
Nowsimulatable
SafeFSMafter
synthesis
7.HandCoding
case STATE is
when START =>
when MIDDLE =>
when STOP
=>
when others
=>
end case ;
Sept. 2005
Definingconstants
Controlofencoding
SafeFSM
Simulatable
Portabledesign
Moreeffort
8.FSM:Medvedev
Theoutputvectorresemblesthestatevector:Y=S
TwoProcesses
architecture RTL of MEDVEDEV is
...
begin
REG: process (CLK, RESET)
begin
-- State Registers Inference
end process REG ;
Y <= S ;
end RTL ;
Sept. 2005
OneProcess
architecture RTL of MEDVEDEV is
...
begin
REG: process (CLK, RESET)
begin
-- State Registers Inference with Logic Block
end process REG ;
Y <= S ;
end RTL ;
9.MedvedevExample
begin
NEXT_STATE <= STATE;
case STATE is
when START => if (A or B)=`0` then
NEXTSTATE <= MIDDLE ;
end if ;
when MIDDLE => if (A and B)=`1` then
NEXTSTATE <= STOP ;
end if ;
when STOP => if (A xor B)=`1` then
NEXTSTATE <= START ;
end if ;
when others => NEXTSTATE <= START ;
end case ;
end process CMB ;
-- concurrent signal assignments for output
Sept. 2005
10.WaveformMedvedevExample
Sept. 2005
11.FSM:Moore
Theoutputvectorisafunctionofthestatevector:Y=f(S)
ThreeProcesses
TwoProcesses
Sept. 2005
4.5.12MooreExample
Sept. 2005
13.WaveformMooreExample
Sept. 2005
14.FSM:Mealy
Theoutputvectorisafunctionofthestatevector
andtheinputvector:Y=f(X,S)
ThreeProcesses
architecture RTL of MEALY is
...
begin
REG: -- Clocked Process
CMB: -- Combinational Process
OUTPUT: process (STATE, X)
begin
-- Output Logic
end process OUTPUT ;
end RTL ;
Sept. 2005
TwoProcesses
architecture RTL of MEALY is
...
begin
MED: process (CLK, RESET)
begin
-- State Registers Inference with Next State Logic
end process MED ;
OUTPUT: process (STATE, X)
begin
-- Output Logic
end process OUTPUT ;
end RTL ;
15.MealyExample
Sept. 2005
16.WaveformMealyExample
(Y,Z)changeswithinput=>Mealymachine
Notethe"spikes"ofYandZinthewaveform
FSMhastobemodeledcarefullyinordertoavoidspikesinnormaloperation.
Sept. 2005
17.ModellingAspects
Medvedevistooinflexible
Mooreispreferredbecauseofsafeoperation
Mealymoreflexible,butdangerof
Spikes
Unnecessarylongpaths(maximumclockperiod)
Combinationalfeedbackloops
Sept. 2005
1.8RegisteredOutput
Avoidinglongpathsanduncertaintiming
Withoneadditionalclockperiod
Withoutadditionalclockperiod(Mealy)
Sept. 2005
19.RegisteredOutputExample(1)
Sept. 2005
20.WaveformRegisteredOutputExample(1)
OneclockperioddelaybetweenSTATEandoutputchanges.
Inputchangeswithclockedgeresultinanoutputchange.
(Dangerofunmeantvalues)
Sept. 2005
21.RegisteredOutputExample(2)
Sept. 2005
2.2WaveformRegisteredOutputExample(2)
NodelaybetweenSTATEandoutputchanges.
Sept. 2005