8421码十进制计数器
发布时间:2024-10-23
发布时间:2024-10-23
8421码十进制计数器:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY GKY07P10 IS
PORT(clk,reset:IN STD_LOGIC;
q:OUT STD_LOGIC_VECTOR(3 DOWNTO 0));
END GKY07P10;
ARCHITECTURE struc OF GKY07P10 IS
SIGNAL q_temp:STD_LOGIC_VECTOR(3 DOWNTO 0);
BEGIN
PROCESS(clk)
BEGIN
IF(clk'EVENT AND clk='1')THEN
IF reset='1'THEN
q_temp<="0000";
ELSIF q_temp="1001"THEN
q_temp<="0000";
ELSE
q_temp<=q_temp+1;
END IF;
END IF;
END PROCESS;
q<=q_temp;
END struc;
从状态‘0000’到状态‘1001’,然后再跳回‘0000’,异步复位要立即复位。
分频器:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY GKY07P13 IS
PORT(clk,clear:IN STD_LOGIC;
clk_out:OUT STD_LOGIC);
END GKY07P13;
ARCHITECTURE struc OF GKY07P13 IS
SIGNAL temp:INTEGER RANGE 0 TO 11;
BEGIN
p1:PROCESS(clear,clk)
BEGIN
IF clear='0' THEN
temp<=0;
ELSIF clk'EVENT AND clk='1' THEN
IF temp=11 THEN
temp<=0;
ELSE
temp<=temp+1;
END IF;
END IF;
END PROCESS p1;
p2:PROCESS(temp)
BEGIN
IF temp<6 THEN
clk_out<='0';
ELSE
clk_out<='1';
END IF;
END PROCESS p2;
END struc;
很重要的一个器件,但是设计难度并不很高,首先是模为12的计数,然后是占空比50%。
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY LED IS
PORT(a:IN STD_LOGIC_VECTOR(3 DOWNTO 0);
b:OUT STD_LOGIC_VECTOR(6 DOWNTO 0));
END LED;
ARCHITECTURE LEDarch OF LED IS
BEGIN
PROCESS(a)
BEGIN
CASE a IS
WHEN"0000" => b <= "1111110"; --0
WHEN"0001" => b <= "0110000"; --1
WHEN"0010" => b <= "1101101"; --2
WHEN"0011" => b <= "1111001"; --3
WHEN"0100" => b <= "0110011"; --4
WHEN"0101" => b <= "1011011"; --5
WHEN"0110" => b <= "1011111"; --6
WHEN"0111" => b <= "1110000"; --7
WHEN"1000" => b <= "1111111"; --8
WHEN"1001" => b <= "1111011"; --9
WHEN OTHERS => b <="0000000";
END CASE; END PROCESS; END;
上一篇:牛顿第二定律应用的几种题型