【发布时间】:2017-04-16 17:43:22
【问题描述】:
这是我提出的另一个问题的一个分支。我将更深入地解释我正在尝试做什么以及它不喜欢什么。这是一个学校项目,不需要遵循标准。
我正在尝试制作 SIMON 游戏。现在,我想要做的是使用一个开关盒来控制级别,并且每个级别都应该更快(因此不同的分频器)。第一级应该是第一个频率,LED 的图案应该点亮和消失。在我放入开关盒之前,第一级是单独的(没有第二级的东西),它像应该的那样亮起来又消失了。我还使用了compare = 0 来比较输出和输入。 (用户应该按照他们看到的光模式打开开关)。这在第一级单独存在时有效,但现在它在开关盒中,它不喜欢compare。我不确定如何解决这个问题以便将输出与输入进行比较。
我得到的错误与以前相似:
错误 (10821):FP.vhd(75) 处的 HDL 错误:无法推断“比较”的寄存器,因为它的行为与任何支持的寄存器模型都不匹配
错误 (10821):FP.vhd(75) 处的 HDL 错误:无法推断“count[0]”的寄存器,因为它的行为与任何支持的寄存器模型都不匹配
错误 (10821):FP.vhd(75) 处的 HDL 错误:无法推断“count[1]”的寄存器,因为它的行为与任何支持的寄存器模型都不匹配
错误 (10821):FP.vhd(75) 处的 HDL 错误:无法推断“count[2]”的寄存器,因为它的行为与任何支持的寄存器模型都不匹配
错误 (10822):FP.vhd(80) 处的 HDL 错误:无法在此时钟沿实现分配寄存器
错误 (10822):FP.vhd(102) 处的 HDL 错误:无法在此时钟沿实现分配寄存器
错误 (12153):无法详细说明顶级用户层次结构
我也知道它不喜欢rising_edge(toggle),但我需要它才能使 LED 图案亮起和消失。
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_unsigned.all;
entity FP is
port(
clk, reset : in std_logic;
QF : out std_logic_vector (3 downto 0);
checkbtn : in std_logic;
Switch : in std_logic_vector(3 downto 0);
sel : in std_logic_vector (1 downto 0);
score : out std_logic_vector (6 downto 0)
);
end FP;
architecture behavior of FP is
signal time_count: integer:=0;
signal toggle : std_logic;
signal toggle1 : std_logic;
signal count : std_logic_vector (2 downto 0);
signal seg : std_logic_vector (3 downto 0);
signal compare : integer range 0 to 1:=0;
type STATE_TYPE is (level1, level2);
signal level : STATE_TYPE;
--signal input : std_logic_vector (3 downto 0);
--signal sev : std_logic_vector (6 downto 0);
begin
process (clk, reset, sel)
begin
if (reset = '0') then
time_count <= 0;
toggle <= '0';
elsif rising_edge (clk) then
case sel is
when "00" =>
if (time_count = 1249999) then
toggle <= not toggle;
time_count <= 0;
else
time_count <= time_count+1;
end if;
when "01" =>
if (time_count = 2499999) then
toggle1 <= not toggle1;
time_count <= 0;
else
time_count <= time_count+1;
end if;
when "10" =>
if (time_count = 4999999) then
toggle <= not toggle;
time_count <= 0;
else
time_count <= time_count+1;
end if;
when "11" =>
if (time_count = 12499999) then
toggle <= not toggle;
time_count <= 0;
else
time_count <= time_count+1;
end if;
end case;
end if;
end process;
Process (toggle, compare, switch)
begin
case level is
when level1 =>
if sel = "00" then
count <= "001";
seg <= "1000";
elsif (rising_edge (toggle)) then
count <= "001";
compare <= 0;
if (count = "001") then
count <= "000";
else
count <= "000";
end if;
end if;
if (switch = "1000") and (compare = 0) and (checkbtn <= '0') then
score <= "1111001";
level <= level2;
else
score <= "1000000";
level <= level1;
end if;
when level2 =>
if sel = "01" then
count <= "010";
seg <= "0100";
elsif (rising_edge (toggle1)) then
count <= "010";
compare <= 1;
if (count = "010") then
count <= "000";
else
count <= "000";
end if;
end if;
if (switch = "0100") and (compare = 1) and (checkbtn <= '0') then
score <= "0100100";
else
score <= "1000000";
level <= level1;
end if;
end case;
case count is
when "000"=>seg<="0000";
when "001"=>seg<="1000";
when "010"=>seg<="0100";
when "011"=>seg<="0110";
when "100"=>seg<="0011";
when others=>seg<="0000";
end case;
end process;
QF <= seg;
end behavior;
再次提前致谢!
【问题讨论】:
-
我在之前的编辑中修复了你的布局,但你恢复了它......我不知道你为什么这样做,但这是在浪费我的时间......
-
我编辑了我的问题,因为它之前略有不同。我写了另一个问题,但我被要求编辑我的旧问题,所以我这样做了。对不起
-
哦,可以发表评论了:) 所以我编辑了你的帖子。拥有正确预期的代码非常重要。我很快就会对我的答案进行编辑。
标签: vhdl fpga intel-fpga