Arrays 多输入状态表法

Arrays 多输入状态表法,arrays,multidimensional-array,vhdl,state-machine,Arrays,Multidimensional Array,Vhdl,State Machine,我是VHDL的新手。在我的一个作业中,我需要使用VHDL在状态表方法中实现一个状态机。因此,我为Architecture实体编写了以下代码: 十、 Y是输入位基本上这是一台摩尔机器,它接受两个输入,输出一个位 architecture Table of SM1_2 is type StateTable is array(integer range<>,bit range<>,bit range<>) of integer; type OutTab

我是VHDL的新手。在我的一个作业中,我需要使用VHDL在状态表方法中实现一个状态机。因此,我为Architecture实体编写了以下代码:

十、 Y是输入位基本上这是一台摩尔机器,它接受两个输入,输出一个位

   architecture Table of SM1_2 is
  type StateTable is array(integer range<>,bit range<>,bit range<>) of integer;
  type OutTable is array(integer range<>) of bit;
  signal State,NextState : integer := 0;
  constant ST: StateTable(0 to 3,'0' to '1','0' to '1'):=
    ((3,0,1,0),(2,0,1,1),(3,0,1,1),(2,0,1,0));
  constant OT: OutTable(0 to 3):=
  ('0','1','1','0');
begin                               --Concurrent Statements
  NextState <= ST(State,X,Y);       --Next state from state table
  Z <= OT(State);  
SM1_2的架构表为 类型StateTable是整数的数组(整数范围、位范围、位范围); 类型OutTable是位的数组(整数范围); 信号状态,NextState:整数:=0; 常量ST:StateTable(0到3,'0'到'1','0'到'1'):= ((3,0,1,0),(2,0,1,1),(3,0,1,1),(2,0,1,0)); 常数OT:输出表(0到3):= ('0','1','1','0'); begin——并发语句
NextState将
状态表
类型声明为
整数
类型的多维数组:

type StateTable is array(integer range<>,bit range<>,bit range<>) of integer;
因此,请尝试在常量值中添加级别,如:

constant ST: StateTable(0 to 3,'0' to '1','0' to '1'):=
  (((3, 0), (1, 0)), 
   ((2, 0), (1, 1)), 
   ((3, 0), (1, 1)), 
   ((2, 0), (1, 0)));
创建常量时可以使用索引值,以便更清楚地了解为数组中的不同元素指定了哪些值:

constant ST: StateTable(0 to 3,'0' to '1','0' to '1'):=
  (0 => ('0' => ('0' => 3, '1' => 0),
         '1' => ('0' => 1, '1' => 0)),
   1 => ('0' => ('0' => 2, '1' => 0),
         '1' => ('0' => 1, '1' => 1)),
   2 => ('0' => ('0' => 3, '1' => 0),
         '1' => ('0' => 1, '1' => 1)),
   3 => ('0' => ('0' => 2, '1' => 0),
         '1' => ('0' => 1, '1' => 0)));

您还可以使用嵌套数组构建状态表:

constant state_cnt : positive := 4;
type t_inputtable is array (bit range <>, bit range <>) of natural range 0 to state_cnt-1;
type_t_statetable is array (natural range 0 to state_cnt-1) of t_inputtable;

constant statetable is t_statetable := (
--state   X,   Y   next state
  0 => (('0', '0') => 0,
        ('0', '1') => 1,
        ('1', '0') => 2,
        others => 0),
  1 => (('0', '0') => 0,
        ('0', '1') => 3,
        ('1', '0') => 2,
        others => 1),
  -- ...
  );

 nextState <= statetable(State)(X, Y);
恒定状态:正:=4;
类型t_可输入为自然范围0到状态_cnt-1的数组(位范围,位范围);
type_t_statetable是t_可输入的数组(自然范围0到state_cnt-1);
常量statetable是t_statetable:=(
--X州,Y州下一个州
0 => (('0', '0') => 0,
('0', '1') => 1,
('1', '0') => 2,
其他=>0),
1 => (('0', '0') => 0,
('0', '1') => 3,
('1', '0') => 2,
其他=>1),
-- ...
);

下一个状态我的猜测是,要么X或Y是整数,而不是位,但是如果没有其余的声明,或者没有哪行包含错误的提示,我们只能在黑暗中拍摄。尽可能简化源代码,同时仍显示错误,并将其发布。只需编辑即可@BrianDrummond你能看一下吗?NextState不应该初始化,它不是寄存器。@Paebbels你能告诉我为什么吗?我在哪里初始化了它?信号
状态
映射到一个寄存器,在大多数平台上可以有一个初始值和一个重置值。信号/线路
NextState
是一个组合信号。这些信号在实际硬件中不能有初始值。您的语句
信号状态,NextState:integer:=0将值0指定给NextState,但不指定给State,因此交换名称或为每个信号名称使用一行。不默认纯导线也更适合模拟:现在可以看到未连接的信号,因为它们是用“U”初始化的。经验法则:只有映射到寄存器的信号才有默认值。非常感谢@莫滕齐尔默
constant state_cnt : positive := 4;
type t_inputtable is array (bit range <>, bit range <>) of natural range 0 to state_cnt-1;
type_t_statetable is array (natural range 0 to state_cnt-1) of t_inputtable;

constant statetable is t_statetable := (
--state   X,   Y   next state
  0 => (('0', '0') => 0,
        ('0', '1') => 1,
        ('1', '0') => 2,
        others => 0),
  1 => (('0', '0') => 0,
        ('0', '1') => 3,
        ('1', '0') => 2,
        others => 1),
  -- ...
  );

 nextState <= statetable(State)(X, Y);
type t_outputtable is record
  next : natural range 0 to state_cnt-1;
  O1 : bit;
  O2 : bit;
end record;
type t_inputtable is array (bit range <>, bit range <>) of t_outputtable;
type_t_statetable is array (natural range 0 to state_cnt-1) of t_inputtable;

nextState <= statetable(State)(X, Y).next;
Output1 <= statetable(State)(X, Y).O1;