reset : IN STD_LOGIC; q , qb : OUT STD_LOGIC); END async_rd f;
ARCHITETURE rtl1 OF async_rd ff IS BEGIN
PROCESS (clk, reset) BEGIN
IF( reset = '0' ) THEN q <= '0'; qb <='1';
ELSIF ( clk ' EVENT AND clk = '1' ) THEN q <=d;
qb <= NOT d; END IF; END PROCESS; END rtl1;
10.24 用VHDL语言描述一个5进制加法计数器。
解:引脚定义:
reset 复位信号,低电平有效 en 计数控制 clk 时钟
qa,qb,qc, 计数器输出
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL; USE IEEE.STD_LOGIC_UNSIGNED.ALL; ENTITY count5 IS
PORT(clk,reset,en: in STD_LOGIC; qa,qb,qc: out STD_LOGIC); END count5;
ARCHITECTURE behave OF count5 IS
SIGNAL count_3: STD_LOGIC_VECTOR(2 downto 0); BEGIN
qa<=count_3(0); qb<=count_3(1); qc<=count_3(2); PROCESS(clk,reset) BEGIN
IF (reset='0') THEN count_3<=\;
ELSIF(clk'event AND clk='1') THEN IF(en='1') THEN
IF(count_3=\ count_3<=\; ELSE
count_3<=count_3+'1'; END IF; END IF; END IF; END PROCESS;
END behave;
10.25分析下面的VHDL语言程序,说明该程序描述的是什么逻辑功能的电路。 程序引脚定义: Reset--复位
en --计数控制 clk --时钟
qa,qb,qc,qd --计数器输出
LIBRARY ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity count12 is
port(clk,reset,en: in std_logic; qa,qb,qc,qd: out std_logic); end count12;
architecture behave of count12 is
signal count_4: std_logic_vector(3 downto 0); begin
qa<=count_4(0); qb<=count_4(1); qc<=count_4(2); qd<=count_4(3); process(clk,reset) begin
if (reset='0') then count_4<=\;
elsif(clk'event and clk='1') then if(en='1') then
if(count_4=\ count_4<=\; else
count_4<=count_4+'1'; end if; end if; end if; end process; end behave;
解:该程序描述的是一个同步十二进制加法计数器。
相关推荐: