哪位大虾帮忙找找这个状态机程序的错(VHDL)
本帖最后由 fpgaw 于 2010-11-19 09:42 编辑library ieee;
use ieee.std_logic_1164.all;
entity moore2 is port(
clk, rst: in std_logic;
id: in std_logic_vector(3 downto 0);
y: out std_logic_vector(2 downto 0));
end moore2;
architecture archmoore2 of moore2 is
signal state,next_state: std_logic_vector(2 downto 0);
constant state0: std_logic_vector(2 downto 0) := "000";
constant state1: std_logic_vector(2 downto 0) := "010";
constant state2: std_logic_vector(2 downto 0) := "011";
constant state3: std_logic_vector(2 downto 0) := "110";
constant state4: std_logic_vector(2 downto 0) := "111";
begin
a:process(clk,rst)
begin
if (rst='1') then
state<=state0;
elsif(clk'event and clk='1')then
state<=next_state;
end if;
end process ;
b: process (state, rst)
begin
if (rst='1') then
state <= state0;
end if;
case state is
when state0 =>
if id = x"3" then
next_state <= state1;
else
next_state <= state0;
end if;
when state1 =>
next_state <= state2;
when state2 =>
if id = x"7" then
next_state <= state3;
else
next_state <= state2;
end if;
when state3 =>
if id < x"7" then
next_state <= state0;
elsif id = x"9" then
next_state <= state4;
else
next_state <= state3;
end if;
when state4 =>
if id = x"b" then
next_state <= state0;
else
next_state <= state4;
end if;
when others =>
next_state <= state0;
end case;
end process;
y <= state(2 downto 0);
end archmoore2;
用quartus编译后的错误信息:
Error: Can't resolve multiple constant drivers for net "state" at moore2.vhd(22)
Error: Constant driver at moore2.vhd(30)
Error: Can't elaborate top-level user hierarchy
我是新手请多指教 两个process中有相同变量的赋值吧。 谢谢喽!!! 把沿的变化放在elsif后也不好吧
两个process中有相同变量的赋值吧。
页:
[1]