LICZNIK
ENT3TY counter IS PORT (d: IN BIT VECTOR (3 DOWNTO 0); q: OUT INTEGER RANGĘ 0 TO 4) ; END counter, |
ENT1TY coaatcrt IS PORT (d: IN INTEGER RANGĘ 0 TO 255; clk, elear, ld, enable, updown: IN BIT; qa, qb, qc, qd, qe, qf: OUT INTEGER RANGĘ OTO 255); END conntcra; |
ARCHITECTURE archi OF courter IS BEGIN PROCESS (d) VAR1ABLE n: INTEGER; BEGIN n 0; |
ARCHITECTURE arch OF countere IS BEGIN — An eaable eona ter |
FOR i IN d’RANGE LOOP IF d(i) = ‘1’ THEN n = n+ 1; END IF; END LOOP; |
PROCESS (clk) VARIABLE cal: INTEGER RANGĘ 0 TO 255; BEGIN , IF (clk’EVENT AND clk = ‘1’) THEN H0£j) IFenable = ‘1’ THEN ^ ent ent + 1; |
q <= n; END PROCESS; |
END IF; END IF; |
END archi; |
qa <= ent; END PROCESS; |
PRZYKŁADY LICZNIKÓW 2 |
PRZYKŁADY LICZNIKÓW 3 |
— A synchrOBOBS load coanter |
— A synebronotts elear coanter |
PROCESS (clk) VARIABLE cat: INTEGER RANGĘ 0 TO 255; BEGIN IF (clk’EVENT AND clk = ‘ł’) THEN ™c=Dt‘°™ L°W ELSE ent := ent + 1; END IF; END IF; |
PROCESS (clk) VARIABLE cat: INTEGER RANGĘ 0 TO 255; BEGIN IF (dk’EVENT AND clk = ‘1’) THEN IF elear = ‘0’ THEN ent := 0; ELSE ent := ent + 1; ENDIF'; ENDIF; |
qb <= ent; END PROCESS; |
qd <= ent; END PROCESS; |
— An ap_down co aster |
— A synchronons load elear coanter |
PROCESS (clk) VARIABLE cat: INTEGER RANGĘ 0 TO 255; VARIABLE directioa: INTEGER; BEGIN fF (up_down = ‘1’) TTfEN dircction r= 1; ELSE directioa r= -1; ENDIF; |
PROCESS (clk) BEGIN IF (clk’EVENT AND clk = ‘1) THEN IF dear = 'O5 THEN ent := 0; ELSE IF ld = ‘0’ THEN ent := d; ELSE ent := ent + 1; |
j IF (clkłEVENT AND clk * ‘1’) THEN cat cat + dbrectioa; END IF; |
ENDIF; END IF; |
qc <= cat; END PROCESS; |
qc < : ent; END PROCESS; |
3 4 |
\