我正在尝试创建一个FSM,但我得到的错误无法解决多个常量驱动程序
这是我的代码:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.all;
entity fsm is
port(
reset,clk : in std_logic;
dataout: out std_logic_vector(7 downto 0)
);
end entity fsm;
architecture bhv_fsm of fsm is
type FSM_TYPE is (standby, ready, encryption, decryption);
signal pre_state, next_state : FSM_TYPE;
signal cmd, cancel, busy, acquirekey : std_logic;
signal controller: std_logic_vector(3 downto 0);
signal dout: std_logic_vector(7 downto 0);
begin
controller <= cmd & cancel & busy & acquirekey;
P1: process(clk, reset) is
begin
dataout <= "00000000";
if reset='1' then
next_state <= standby;
elsif rising_edge(clk) then
pre_state <= next_state;
end if;
end process P1;
LC1_LC2: process(pre_state, next_state) is
variable timer: integer :=0;
begin
dataout <= (others => '0');
next_state <= pre_state;
case pre_state is
when standby =>
if (controller = "0000") then
next_state <= ready;
end if;
when ready =>
if(timer<10) then
if (controller = "1000") then
next_state <= encryption;
timer:=0;
controller <= "0010";
timer:=timer+1;
elsif (controller = "0000") then
next_state <= decryption;
timer:=0;
controller <= "0010";
end if;
timer:=timer+1;
else
next_state <= standby;
end if;
when encryption =>
if(controller = "1110") then
next_state <= ready;
elsif(controller = "1011") then
dataout <= dout;
next_state <= ready;
end if;
-- cmd cancel busy acquire
when decryption =>
if(controller = "0110")then
next_state <= ready;
elsif(controller = "0011") then
dataout <= dout;
next_state <= ready;
end if;
end case;
end process LC1_LC2;
end architecture bhv_fsm;
这些是错误:
错误(10028):无法解析net的多个常量驱动程序 fsm.vhd(33)
的“next_state.standby”错误(10029):fsm.vhd(22)
的常量驱动程序错误(10028):无法解析net的多个常量驱动程序 fsm.vhd(33)
的“next_state.ready”错误(10028):无法解析net的多个常量驱动程序 fsm.vhd(33)
的“next_state.encryption”错误(10028):无法解析net的多个常量驱动程序 fsm.vhd(33)
的“next_state.decryption”错误(10028):无法解析net的多个常量驱动程序 “控制器[3]”在fsm.vhd(21)
错误(10029):fsm.vhd(33)
处的常量驱动程序错误(10028):无法解析net的多个常量驱动程序 “控制器[2]”在fsm.vhd(21)
错误(10028):无法解析net的多个常量驱动程序 “控制器[1]”在fsm.vhd(21)
错误(10028):无法解析net的多个常量驱动程序 “控制器[0]”在fsm.vhd(21)
答案 0 :(得分:1)
当您合成VHDL时,每个进程都会变成一块硬件,驱动由该进程驱动的任何信号。如果您从多个过程中驱动信号,那么最终会有一个以上的硬件驱动该信号;该信号来自多个地方。换句话说,你有一个短路。
这通常不是您想要的行为,通常不是逻辑合成器准备创建的行为。您的代码就是这种情况:
您的代码中有三个concurent进程。这一个:
controller <= cmd & cancel & busy & acquirekey;
驱动信号controller
;这一个:
P1: process(clk, reset) is
驱动信号dataout
,next_state
和pre_state
;这一个:
LC1_LC2: process(pre_state, next_state) is
也可以驱动信号controller
,next_state
和data_out
。
因此,信号controller
,next_state
和data_out
来自多个进程;这些信号将由多个硬件驱动。你的合成器不喜欢这个,我很确定这不是你想要的。
你不是在写软件。 VHDL是硬件描述语言。你需要考虑更多的硬件。
我不知道你的设计意图;我只能“怀疑”。但是,我怀疑你根本不需要这一行:
dataout <= "00000000";
我怀疑这些界限:
if reset='1' then
next_state <= standby;
应该是:
if reset='1' then
pre_state <= standby;
我怀疑你根本不需要这条线:
controller <= cmd & cancel & busy & acquirekey;