【发布时间】:2014-12-23 01:24:14
【问题描述】:
接下来的 ssd 过程是为了向我展示我为这两个用户所拥有的东西。代码 atm 似乎可以很好地为两个用户存储数据,并且可以在任何给定时间调用它。然而问题是我似乎无法改变这样一个事实,即每当我按下任一按钮时 - 以小数点 1 增加或减少任一用户的数字保持。无论如何,它都会更改第一个用户的号码。 switch(7) 是“1”还是“0”都没有关系。此外,我可以选择第二个用户,尽管我也无法对他进行任何更改-按钮仅影响第一个用户-。这是我的问题,我不知道为什么会发生这种情况,但我唯一的直觉是我这里有一个糟糕的设计。无论如何,下面是感兴趣和乐于助人的代码:
process (clk)
begin
if(switch(7) <= '1') then --first user
if(rising_edge(clk)) then
if(btn(0)='1' and lastButtonState(0) = '0') then--increase by 1
user0 <= user0 + "001";
end if;
lastButtonState(0) <= btn(0);
if(btn(1) = '1' and lastButtonState(1) = '0') then --decrease by 1
user0 <= user0 + "111";
end if;
lastButtonState(1) <= btn(1);
end if;
elsif (switch(6) = '1') then --second user
if(rising_edge(clk)) then
if(btn(0) = '1' and lastButtonState(0) = '0') then
user1 <= user1 + "001";
end if;
lastButtonState(0) <= btn(0);
if(btn(1) = '1' and lastButtonState(1) = '0') then
user1 <= user1 + "111";
end if;
lastButtonState(1) <= btn(1);
end if;
end if;
end process;
process (user0, user1, switch)
begin
if(switch(7) = '1') then
case user0 is
when "000" => a_to_g <= "0000001";
when "001" => a_to_g <= "1001111";
when "010" => a_to_g <= "0010010";
when "011" => a_to_g <= "0000110";
when "100" => a_to_g <= "1001100";
when "101" => a_to_g <= "0100100";
when "110" => a_to_g <= "0100000";
when others => a_to_g <= "0001111";
end case;
elsif (switch(6) = '1') then
case user1 is
when "000" => a_to_g <= "0000001";
when "001" => a_to_g <= "1001111";
when "010" => a_to_g <= "0010010";
when "011" => a_to_g <= "0000110";
when "100" => a_to_g <= "1001100";
when "101" => a_to_g <= "0100100";
when "110" => a_to_g <= "0100000";
when others => a_to_g <= "0001111";
end case;
end if;
end process;
【问题讨论】:
-
该代码有几个问题。但是,目前引起麻烦的具体问题可能是您实际上并未测试 Switch 7 = '1'。小于或等于,是的。等于,没有。
-
什么是ssd进程?固态驱动器还是七段显示器?请不要使用不常见的缩写。
-
您还可以标记 VHDL 中的任何语句,包括过程语句。这两个进程中的哪一个被认为是 ssd?什么是“密码ATM”?您的两个进程不包含Minimal, Complete, and Verifiable example。
标签: button if-statement vhdl store