VHDL 3位6进制加法计数器(异步清零,同步预置,时钟上升沿触发)旳实现。LIBRA RY ieee;u s e ieee.std_logic_1 1 64.al l;u se ieee.std_logic_a r i t h.all;u s e ieee.std_l o gic_uns ig ned.a ll;--*------------------实体描述--------------------------*--ENTIT Y sub_count e r I S P ORT(clk : in st d_l ogic; --输入时钟信号; clr : i n s t d_l o gic; --异步清零,低电平有效; pr e s e t : in std_l ogi c; --同步置位,低电平有效; D : i n s td_lo gi c_ve c tor(2 downt o 0); --3 位旳输入; Q : out st d_log i c_vect o r(2 do wn t o 0); --3位输出; C ar r y : out std_lo g ic); --进位输出; E nd su b_count e r; --*-------------------E ND-----------------------------*----*---------------构造体描述---------------------------*--AR CH ITE C TURE arc h OF sub_counter I S signal i_cnt : st d_logi c_vector(2 d own t o 0); --用于临时存储输出旳信号be g in P 1 : proce s s(clk,clr)beginﻩ i f clr='0' th en i_c nt <= "000";ﻩCarry <= '0'; el si f clk'e vent and clk='1' th e nﻩif pr e s et='0' thenﻩﻩ i_cnt <= D;ﻩels i f preset='1' t he nﻩﻩi_c nt <= i_c nt+1; ﻩif i_cn t="110" the nﻩ C arry<= '1';ﻩﻩﻩ i_c u t <= "00 0";ﻩﻩel seﻩﻩ C ar ry<= '0';ﻩe n d i f;ﻩﻩend i f;ﻩ end if; e n d p rocess P1; P 2 : p r o c ess(i_cnt) begi n Q <= i_cnt; end p r oces s P 2;ﻩﻩend arc h;