问题描述
尽管尝试使用不同的方式键入程序,但我还是遇到很多错误,但是大多数时候还是使用逻辑思维。问题是,我之前从未尝试过将不同的东西组合在一起,因此存在无法编译的问题。有一个相当大的要求,我可以对其进行逻辑处理,但是在编码方面需要帮助。可以引导我吗?谢谢。
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity tracking7 is
port ( sensor : in std_logic;
reset_bar : in std_logic;
D3,D2,D1,D0 : in std_logic;
q : out std_logic;
led : out std_logic;
a4,b4,c4,d4,e4,f4,g4 : out std_logic);
end tracking7;
architecture flow of tracking7 is
signal input : std_logic_vector (3 downto 0); --VECTORS FOR INTERNAL
signal output : std_logic_vector (6 downto 0); --USE IN DECODER STATEMENTS
signal count_sig: unsigned (3 downto 0);
begin
input <= (D3,D0);
WITH input SELECT
output <= "0000001" when "0000",--disPLAY 0
"1001111" when "0001",--disPLAY 1
"0010010" when "0010",--disPLAY 2
"0000110" when "0011",--disPLAY 3
"1001100" when "0100",--disPLAY 4
"0100100" when "0101",--disPLAY 5
"0100000" when "0110",--disPLAY 6
"0001111" when "0111",--disPLAY 7
"0000000" when "1000",--disPLAY 8
"0000100" when "1001",--disPLAY 9
"0001000" when "1010",--disPLAY A
"1100000" when "1011",--disPLAY B
"0110001" when "1100",--disPLAY C
"1000100" when "1101",--disPLAY D
"0110000" when "1110",--disPLAY E
"0111000" when "1111",--disPLAY F
"1111111" when others; --BLANK disPLAY
process ( sensor,reset_bar)
begin
if (reset_bar = '1') then count_sig <= count_sig;
elsif falling_edge (sensor) then if (count_sig = D3& D2& D1& D0) then
count_sig <= "0000";
else
count_sig <= count_sig + 1;
end if;
end if;
end process;
process (D3,D0)
begin
if (q = D3&D2&D1&D0)
then led <= '1'; --LED light up when reach ref no
else
led<= '0';
end if;
end process;
a4 <= output(6);
b4 <= output(5);
c4 <= output(4);
d4 <= output(3);
e4 <= output(2);
f4 <= output(1);
g4 <= output(0);
q <= std_logic_vector (count_sig);
end flow;
也许是关于我的代码的简要说明,基本上是设计用于检测制服数量的库存管理系统 返回到保管箱。用户可以设置要检测的任意数量的制服 输入:D3D2D1D0。设计具有以下规格的系统-
- 达到参考编号后,LED会亮起,并且计数在 即使激活了输入传感器,该参考编号也是如此。显示数量 在七段显示器上检测到的制服和参考值 在另一个显示器上。 例如:如果参考号码是15
- 激活重置后,led和七个段应反映最新 检测到的制服状态。
请告知!
解决方法
问题是q = D3&D2&D1&D0
无效。 &字符在VHDL中执行串联,因此您实际上是在尝试将std_logic类型与四位信号进行比较。这在VHDL中是非法的。您需要使用and关键字将信号组合在一起。但是,这需要在if语句中的表达式外部进行。这样的事情应该起作用:
and_d <= D3 and D2 and D1 and D0;
process (and_q) is
begin
if (q = and_d) then
led <= '1'; --LED light up when reach ref no
else
led <= '0';
end if;
end process;
您还可以在过程块中使用变量来组合Dn位:
process (D3,D2,D1,D0) is
variable and_q : std_logic;
begin
and_q := D3 and D2 and D1 and D0;
if (q = and_d) then
led <= '1'; --LED light up when reach ref no
else
led <= '0';
end if;
end process;