Hardware Reference
In-Depth Information
type tZTyp is ( zStop p, zStart , zDaten , zParitaet );
dem Bitzähler und dem Paritätsbit. Der Bitzähler sei ein 3-Bit-Vektor für die
Darstellung vorzeichenfreier Zahlen:
type tZustand is record
z: tZTyp;
idx: tUnsigned( 2 downto 0 );
P: std_logic;
end record ;
Die Übergangsfunktion berechnet aus dem Ist-Zustand und aus den Werten
der Eingabesignale
Start
und
x
den Folge-Zustand:
function fz(Start:std_logic; x: tByte; z_in: tZustand)
return tZustand is
variable z: tZustand:=z_in;
begin
case z.z is
when zStopp => z.idx := "000" ; z.P := '0';
if Start= '1' then z.z := zStart; end if ;
when zStart => z.idx := "000" ; z.P := '0' ; z.z := zDaten;
when zDaten => z.idx := z.idx+ "1" ; z.P := z.P xor x(int(z.idx));
if z.idx= "000" then z.z := zParitaet; end if ;
when zParitaet => z.idx := "000" ; z.P := '0' ; z.z := zStopp;
end case ;
return z;
end function ;
Das zu versendende Signal TxD« wird aus dem Zustand und den zu versen-
denden Daten gebildet. Im Zustand »zStart« ist es »0«, im Zustand »zDaten«
gleich dem von idx ausgewählten Datenbit, im Zustand »zParitaet« gleich dem
berechneten Paritätsbit und sonst »1«:
functio n f_TxD(x: tByte; z: tZustand) return std_logic is
begin
case z.z is
when zStart => return '0' ;
when zDaten => return x(int(z.idx));
when zParitaet => return z.P;
when others
=> return '1' ;
end case ;
end function ;
Das Busy-Signal ist im Zustand »zStopp« eins und sonst null:
functio n f_Busy(z: tZustand) return std_logic is
begin
if z.z=zStopp then return '1'; else return '0' ; end if ;
end function ;
)
WEB-Projekt:P3.4/UART2_pack.vhdl
 
Search WWH ::




Custom Search