【发布时间】:2014-12-29 15:44:53
【问题描述】:
我正在使用 VHDL 实现一个简单的 FSM。 我用 VHDL 编写了这段代码,但出现了这个错误:“未解析的信号 NS 有多个来源”。我深入查看了代码,但无法找出错误 谁能帮我解决这个问题?
library ieee ;
use ieee.std_logic_1164.all ;
entity MeallyMachine is
port(
x,res,clk:in std_logic;
z1,z2:out std_logic
);
end MooreMachine;
architecture M1 of MooreMachine is
type state_type is(s0,s1,s2,s3);
signal PS,NS:state_type;
begin
ETAT:process(PS,x)
begin
case PS is
when s0=> if (x='0') then
NS<=s0;
elsif (x='1') then
NS<=s1;
end if;
when s1=> if (x='0') then
NS<=s1;
elsif (x='1') then
NS<=s2;
end if;
when s2=> if (x='0') then
NS<=s2;
elsif (x='1') then
NS<=s3;
end if;
when s3=> if (x='0') then
NS<=s3;
elsif (x='1') then
NS<=s0;
end if;
end case;
end process ETAT;
Sortie:process(PS,x)
begin
case PS is
when s0=>
z1<='1';
if (x='0') then
z2<='0';
elsif (x='1') then
z2<='1';
end if;
when s1=>
z1<='1';
if (x='0') then
z2<='0';
elsif (x='1') then
z2<='1';
end if;
when s2=> z1<='0';
if (x='0') then
z2<='0';
elsif (x='1') then
z2<='1';
end if;
when s3=> z1<='1';
if (x='0') then
z2<='0';
elsif (x='1') then
z2<='1';
end if;
end case;
end process Sortie;
Horloge:process(clk,res,NS)
begin
if (res='0') then
NS<=s0;
elsif (rising_edge(clk)) then
PS<=NS;
end if;
end process Horloge;
end M1;
【问题讨论】:
-
我猜你忘了在实体和架构的末尾将
MooreMachine更改为MealyMachine。可能不是问题,但不是很好;-) -
就是这样。感谢您的关注:)