vhdl 初学者 菜鸟问题 本人用vhdl做一个七段数码管驱动cc4511
我编的源程序:
library ieee;
use ieee.std_logic_1164.all;
entity cc4511 is --BCD七段数码管 显示驱动的端口描述
port( lt, bi, le: in std_logic;
insign :in std_logic_vector(3 downto 0); --输入端口DBCA
outsign :out std_logic_vector(6 downto 0)); --输出端口abcdefg
end cc4511;
architecture logic of 4511 is
process(lt,bi,le,insign)
begin
if (lt='0') then
outsign<="1111111";
elsif (bi='0') then --lt='1' and bi='0'
outsign<="0000000";
elsif (le='0') then --lt='1'and bi='1' and le='0'
--DCBA 译码部分
case insign is
when "0000"=> outsign<="1111110"; --****0
when "0001"=> outsign<="0110000"; --****1
when "0010"=> outsign<="1101101"; --****2
when "0011"=> outsign<="1111001"; --****3
when "0100"=> outsign<="0110011"; --****4
when "0101"=> outsign<="1011011"; --****5
when "0110"=> outsign<="0011111"; --6
when "0111"=> outsign<="1110000"; --7
when "1000"=> outsign<="1111111"; --8
when "1001"=> outsign<="1110011"; --****9
when others => outsign<="0000000"; ----消隐
end case;
end if;
end process;
end logic;
---还有锁存不会做****
谢谢 malcolmlin 和 烟雨楼中飞雪剑 的回答。我还有一些问题不过没有锁存功能,还有竞争冒险也没有解决……
我加进锁存功能,可是该怎么样改进才没有竞争冒险呢?
实体结构程序如下:
architecture logic of cc4511 is
begin
process(lt,bi,le,insign)
variable tem:std_logic_vector(6 downto 0);
begin
if (lt='0') then
tem:="1111111";
outsign<=tem;
elsif (bi='0') then
tem:="0000000";
outsign<=tem;
elsif (le='0') then
case insign is
when "0000"=> tem:="1111110";
when "0001"=> tem:="0110000";
when "0010"=> tem:="1101101";
when "0011"=> tem:="1111001";
when "0100"=> tem:="0110011";
when "0101"=> tem:="1011011";
when "0110"=> tem:="0011111";
when "0111"=> tem:="1110000";
when "1000"=> tem:="1111111";
when "1001"=> tem:="1110011";
&nb 展开
我复制了你给你程序,在quartus下运行时发生了几个错误和几个警告,已经改正过来了,你看看自己对着改下,基本上你写的挺好的,就是有些细节考虑的不是很周到,而且错误也很原始,像结构体后面少了个begin,呵呵,不够细心,附上仿真图,你看看效果吧,有问题在交流,我也是个初学者……
library ieee;
use ieee.std_logic_1164.all;
entity cc4511 is --BCD七段数码管 显示驱动的端口描述
port( lt, bi, le: in std_logic;
insign :in std_logic_vector(3 downto 0); --输入端口DBCA
outsign :out std_logic_vector(6 downto 0)); --输出端口abcdefg
end cc4511;
architecture logic of cc4511 is
begin
process(lt,bi,le,insign)
begin
if (lt='0') then
outsign<="1111111";
elsif (bi='0') then --lt='1' and bi='0'
outsign<="0000000";
elsif (le='0') then --lt='1'and bi='1' and le='0'
--DCBA 译码部分
case insign is
when "0000"=> outsign<="1111110"; --****0
when "0001"=> outsign<="0110000"; --****1
when "0010"=> outsign<="1101101"; --****2
when "0011"=> outsign<="1111001"; --****3
when "0100"=> outsign<="0110011"; --****4
when "0101"=> outsign<="1011011"; --****5
when "0110"=> outsign<="0011111"; --6
when "0111"=> outsign<="1110000"; --7
when "1000"=> outsign<="1111111"; --8
when "1001"=> outsign<="1110011"; --****9
when others => outsign<="0000000"; ----消隐
end case;
else outsign<="0000000";
end if;
end process;
end logic;
use ieee.std_logic_1164.all;
entity cc4511 is
port( lt, bi, le: in std_logic;
insign :in std_logic_vector(3 downto 0);
outsign :out std_logic_vector(6 downto 0));
end entity cc4511;
architecture logic1 of cc4511 is
begin
process(lt,bi,le,insign)
begin
if (lt='0') then
outsign<="1111111";
elsif (bi='0') then
outsign<="0000000";
elsif (le='0') then
case insign is
when "0000"=> outsign<="1111110"; --****0
when "0001"=> outsign<="0110000"; --****1
when "0010"=> outsign<="1101101"; --****2
when "0011"=> outsign<="1111001"; --****3
when "0100"=> outsign<="0110011"; --****4
when "0101"=> outsign<="1011011"; --****5
when "0110"=> outsign<="0011111"; --6
when "0111"=> outsign<="1110000"; --7
when "1000"=> outsign<="1111111"; --8
when "1001"=> outsign<="1110011"; --****9
when others => outsign<="0000000"; ----xiaoying
end case;
end if;
end process;
end architecture logic1; 能仿真,但是有逻辑竞争,所以不保证能在硬件上实现。关于你说的锁存,如果IF语句没有ELSE的话,就能实现锁存。我是初学者,解释错了的话请提出来,让我也学学。