集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2488|回复: 4

哪位大虾帮忙找找这个状态机程序的错(VHDL)

[复制链接]
interi 发表于 2010-6-26 01:40:22 | 显示全部楼层 |阅读模式
本帖最后由 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[2]" 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 下一条

QQ|小黑屋|手机版|Archiver|fpga论坛|fpga设计论坛 ( 京ICP备20003123号-1 )

GMT+8, 2025-6-21 08:42 , Processed in 0.116750 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表