我刚开始VHDL编程,现在要写一个BCD到7段的解码器。我正在做一个行为设计(这是必需的),但现在我在如何编码显示上遇到了麻烦。
我知道如何编码这个解码器只有一个输入和一个输出,但是我们有第二个输出,称为DIGEN_L,它用作我们的显示器。这是一个有效的低总线输出,使我们的电路板上的7段显示的每一个数字。
他告诉我们只需将其设置为'01110‘,这样第四位数始终为on,其他三位数为off。
我不知道如何将DIGEN_L编码到我的代码中,也不知道上面的语句实际上是什么意思(代码明智)。有人能帮上忙吗?如果在这个问题上需要任何澄清,评论和我将编辑。
下面是我的代码:
library IEEE;
ise IEEE.std_logic_1164.all;
library unisim;
use unisim.vcomponents.all;
entity decoder is
port( BCD: in STD_LOGIC_VECTOR (3 downto 0);
( SEGS_L: out STD_LOGIC_VECTOR(5 downto 0);
( DIGEN_L: out STD_LOGIC_VECTOR(3 downto 0));
end decoder;
architecture decoder_arc of decoder is
begin
process(BCD)
begin
DIGEN_L <= "0111";
case BCD is
when "0000"=> SEGS_L <="1111110"; -- '0'
when "0001"=> SEGS_L <="0110000"; -- '1'
when "0010"=> SEGS_L <="1101101"; -- '2'
when "0011"=> SEGS_L <="1111001"; -- '3'
when "0100"=> SEGS_L <="0110011"; -- '4'
when "0101"=> SEGS_L <="1011011"; -- '5'
when "0110"=> SEGS_L <="1011111"; -- '6'
when "0111"=> SEGS_L <="1110000"; -- '7'
when "1000"=> SEGS_L <="1111111"; -- '8'
when "1001"=> SEGS_L <="1111011"; -- '9'
when others=> SEGS_L <="-";
end case;
end process;
end decoder_arc;发布于 2015-12-04 07:40:55
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
ENTITY seven_segment IS
port(BCD: in std_logic_vector(3 downto 0);
clk,reset: in std_logic;
sseg: out std_logic_vector(6 downto 0));
END seven_segment;
ARCHITECTURE SSD OF seven_segment IS
signal temp: unsigned(6 downto 0);
BEGIN
process(clk,temp)
BEGIN
if reset = '1' OR BCD > "1001" then
temp <= (others => '0');
elsif rising_edge(clk) then
-- abcdefg
elsif BCD = "0000" then temp <= "1111110"; -- 0
elsif BCD = "0001" then temp <= "0110000"; -- 1
elsif BCD = "0010" then temp <= "1101101"; -- 2
elsif BCD = "0011" then temp <= "1111001"; -- 3
elsif BCD = "0100" then temp <= "0110011"; -- 4
elsif BCD = "0101" then temp <= "1011011"; -- 5
elsif BCD = "0110" then temp <= "1011111"; -- 6
elsif BCD = "0111" then temp <= "1110000"; -- 7
elsif BCD = "1000" then temp <= "1111111"; -- 8
elsif BCD = "1001" then temp <= "1111011"; -- 9
end if;
sseg <= std_logic_vector(temp);
END process;
END SSD;https://stackoverflow.com/questions/21508949
复制相似问题