interi 发表于 2010-6-26 01:40:22

哪位大虾帮忙找找这个状态机程序的错(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

我是新手请多指教

ups 发表于 2010-6-26 03:36:34

两个process中有相同变量的赋值吧。

HDL 发表于 2010-6-26 04:51:30

谢谢喽!!!

UFP 发表于 2010-6-26 05:36:48

把沿的变化放在elsif后也不好吧

Sunlife 发表于 2015-6-17 10:46:07


两个process中有相同变量的赋值吧。
页: [1]
查看完整版本: 哪位大虾帮忙找找这个状态机程序的错(VHDL)