如何制作vhdl Mealy状态机?

问题描述 投票:0回答:1

“我正在为VHDL(modelsim)状态机(Mealy的机器)编程我在互联网上找到了此代码,但是如果启动它,则会出现以下错误,请提前帮助我:“

**错误:D:/modelsim_ase/esercizi/prova.vhd(32):靠近“ <=”:(vcom-1576)期望=>或'|'要么 '!'。**错误:D:/modelsim_ase/esercizi/prova.vhd(46):靠近“ <=”:(vcom-1576),期望=>或'|'要么 '!'。**错误:D:/modelsim_ase/esercizi/FSM.vhd(85):VHDL编译器正在退出

行:当其他=> next_state <=(其他<='x');

“代码如下:”

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

VHDL

-五态Mealy FSM示例

library ieee;

使用ieee.std_logic_1164.all;

实体粉是

端口(时钟,重置:在std_logic中;

data_out:out std_logic;

data_in:在std_logic_vector中(从1到0));

结束粉;

粉状的建筑表现是>

type state_values是(st0,st1,st2,st3,st4);

信号状态,下一个状态:状态值;

开始

-FSM寄存器

statereg:进程(时钟,重置)

开始

如果(重置='0')则

pres_state <= st0;

elsif(clock'event and clock ='1')then

pres_state <= next_state;

如果结束;

结束过程状态寄存器;

-FSM组合块

fsm:进程(状态,数据输入)

开始

case pres_state是]

当st0 =>

case data_in是

当«00»=> next_state <= st0;

当«01»=> next_state <= st4;

当«10»=> next_state <= st1;

当«11»=> next_state <= st2;

当其他人=> next_state <=(其他人<='x');

结束案例;

何时st1 =>

case data_in是

当«00»=> next_state <= st0;

当«10»=> next_state <= st2;

当其他人=> next_state <= st1;

结束案例;

当st2 =>

case data_in是

当«00»=> next_state <= st1;

当«01»=> next_state <= st1;

当«10»=> next_state <= st3;

当«11»=> next_state <= st3;

当其他人=> next_state <=(其他人<='x');

结束案例;

当st3 =>

case data_in是

当«01»=> next_state <= st4;

当«11»=> next_state <= st4;

当其他人=> next_state <= st3;

结束案例;

当st4 =>

case data_in是

当«11»=> next_state <= st4;

当其他人=> next_state <= st0;

结束案例;

当其他人=> next_state <= st0;

结束案例;

结束进程fsm;

-使用pres_state w / data_in的平均输出定义

输出:进程(状态,数据输入)

开始

case pres_state是]

当st0 =>

case data_in是

当«00»=> data_out <='0';

当其他人=> data_out <='1';

结束案例;

当st1 => data_out <='0';

当st2 =>

case data_in是

当«00»=> data_out <='0';

当«01»=> data_out <='0';

当其他人=> data_out <='1';

结束案例;

当st3 => data_out <='1';

当st4 =>

case data_in是

当«10»=> data_out <='1';

当«11»=> data_out <='1';

当其他人=> data_out <='0';

结束案例;

当其他人=> data_out <='0';

结束案例;

最终过程输出;

结束行为

“我正在编程一个VHDL(modelsim)状态机(Mealy的机器),我在Internet上找到了此代码,但是如果启动它会给我以下错误,请提前帮助我:” **错误:D: / ...

您已经在仅包含其他字符的聚合中转置了“ =>”符号:

when others => next_state <= (others <= 'x');

如果适合在此处使用汇总分配(不是),则箭头应指向相反的方向(=>),如下所示。还请注意,单引号中的项目区分大小写,并且所有std_ulogic / std_logic字母均为大写,因此应为'X'(也显示)。

when others => next_state <= (others => 'X');

由于next_state的类型为state_values,我认为应该改为:

when others => next_state <= st0;

此外,您的其他一些代码也很有趣,或者您正在使用某些语言的替代字符(«00»)。与其相反,如果您的键盘上带有“字符:

,我建议您使用“ 00”
case data_in is
  when "00" => next_state <= st1;
state vhdl fpga
1个回答
0
投票

您已经在仅包含其他字符的聚合中转置了“ =>”符号:

© www.soinside.com 2019 - 2024. All rights reserved.