Hardware Reference
In-Depth Information
Lösung zu Aufgabe 3.8
type tMem is array (natural range <>) of tUnsigned( 31 downto 0 );
variable Daten: tUnsigned( 31 downto 0 ):=( others => '0' );
variable Adresse: tUnsigned( 7 downto 0 );
variable Mem: tMem( 0 to 2 **Adresse'high- 1 );
Lösung zu Aufgabe 3.9
a) Definition des Verbunds:
type tZustand3SG is record
s:std_logic;
y: tUnsigned(
3 downto 0 );
end record ;
b) Initialisierungsprozedur:
procedure Init( signal x:
out tZustand3SG) is
begin
x<=(s => '0' , y=> "0000" );
end procedure ;
c) Zählprozedur:
procedure signal x:
inout tZustand3SG) is
begin
if x.s= '0' then
x.y <= x.y+ "1" ;
elsif x.s= '1' then
x.y <= x.y- "1" ;
end if ;
end procedure ;
d) Konvertierungsfunktion in eine
Zeichenkette:
function str(x: tZustand3SG)
return string is
begin
return "(s=" & str(x.s) &
", y=" & str(x.y) & ")" ;
end function ;
Count(
)WEB-Projekt:P3.2/Afg_tZustand3SG.vhdl
6.3.3 Ein- und Ausgabe
Lösung zu Aufgabe 3.10
Eine Get-Prozedur für einen eigenen Aufzählungstyp übernimmt am einfachs-
ten die Programmstruktur der Get-Prozedur für boolean:
procedure get(pstr: inout tPString; w: out tZustand) is
constant ptr:positive:=pstr.pta;
variable pos:natural;
begin
if pstr.Status=ok then
get_sym(pstr, pos, "Idle Start Run Ready " );
if pstr.Status=ok then
w := tZustand'val(pos);
return ;
end if ;
pstr.pta := ptr;
pstr.err_pos := ptr;
assign(pstr.err_msg, "Idle, Start, Run oder Ready erwartet" );
end if ;
end procedure ;
)
WEB-Projekt:P3.3/AfgEA_pack.vhdl
 
Search WWH ::




Custom Search