【发布时间】:2013-12-26 20:46:49
【问题描述】:
我对 VHDL 非常陌生,正在尝试为学校的一个项目编写代码。我想要的是使用 LED 充当球的一维乒乓球游戏。请注意,我对 VHDL 没有结构化的理解,我通过在 VHDL 中查找状态机设计来编写以下代码并尝试提出自己的。我有一个异步 RESET 和两个异步输入,对应于每个球员按下按钮以返回球。它们是异步的,因为我希望玩家即使在一个时钟周期内按下按钮的时间很短,也能够将球返回。
在 Xilinx 10.1 中,仿真以我想要的方式运行,但是当我尝试综合时,这是以下代码的错误:
ERROR:Xst:827 - "C:/Users/Emre/LED_pong/pong.vhd" line 49: Signal present_state cannot be synthesized, bad synchronous description. The description style you are using to describe a synchronous element (register, memory, etc.) is not supported in the current software release.
当我删除包含 PAD1 和 PAD2 的 elsif 语句时,它会合成,但会失去其功能。
entity pong is
Port ( CLK : in STD_LOGIC;
RST : in STD_LOGIC;
PAD1 : in STD_LOGIC;
PAD2 : in STD_LOGIC;
LEDS : out STD_LOGIC_VECTOR (7 downto 0));
end pong;
architecture Behavioral of pong is
type state is ( P1_SERVE, A1, A2, A3, A4, A5, A6, A7,
B0, B1, B2, B3, B4, B5, B6, P2_SERVE,
WAIT_FOR_P1, WAIT_FOR_P2, P1_HIT_EARLY, P2_HIT_EARLY,
P1_SCORED, P2_SCORED );
signal present_state: state;
signal temp : STD_LOGIC_VECTOR (7 downto 0) := "00000000";
begin
process (CLK, RST, PAD1, PAD2) begin
if (RST = '1') then
temp <= "10000000";
present_state <= P1_SERVE;
elsif (rising_edge(CLK)) then
case present_state is
when P1_SERVE =>
temp <= "10000000";
when P2_SERVE =>
temp <= "00000001";
when P1_SCORED =>
temp <= "00000000";
present_state <= P2_SERVE;
when P2_SCORED =>
temp <= "00000000";
present_state <= P1_SERVE;
when A1 =>
temp <= "01000000";
present_state <= A2;
when A2 =>
temp <= "00100000";
present_state <= A3;
when A3 =>
temp <= "00010000";
present_state <= A4;
when A4 =>
temp <= "00001000";
present_state <= A5;
when A5 =>
temp <= "00000100";
present_state <= A6;
when A6 =>
temp <= "00000010";
present_state <= A7;
when A7 =>
temp <= "00000001";
present_state <= WAIT_FOR_P2;
when WAIT_FOR_P2 =>
temp <= "00000000";
present_state <= P2_SERVE;
when B6 =>
temp <= "00000010";
present_state <= B5;
when B5 =>
temp <= "00000100";
present_state <= B4;
when B4 =>
temp <= "00001000";
present_state <= B3;
when B3 =>
temp <= "00010000";
present_state <= B2;
when B2 =>
temp <= "00100000";
present_state <= B1;
when B1 =>
temp <= "01000000";
present_state <= B0;
when B0 =>
temp <= "10000000";
present_state <= WAIT_FOR_P1;
when WAIT_FOR_P1 =>
temp <= "00000000";
present_state <= P1_SERVE;
when P1_HIT_EARLY =>
temp <= "10000000";
present_state <= P2_SCORED;
when P2_HIT_EARLY =>
temp <= "00000001";
present_state <= P1_SCORED;
when others =>
null;
end case;
elsif (PAD1 = '1') then
case present_state is
when P1_SERVE =>
present_state <= A1;
when B0 =>
present_state <= P1_HIT_EARLY;
when WAIT_FOR_P1 =>
present_state <= A1;
when others =>
null;
end case;
elsif (PAD2 = '1') then
case present_state is
when P2_SERVE =>
present_state <= B6;
when A7 =>
present_state <= P2_HIT_EARLY;
when WAIT_FOR_P2 =>
present_state <= B6;
when others =>
null;
end case;
end if;
end process;
LEDS <= temp;
end Behavioral;
【问题讨论】:
标签: asynchronous vhdl