Moore机设计:例1 architecture beh of statmach is type state type is(s0, s1) 采用枚举法设置状态 signal st: state type 表达当前的状态 begin process((ck)-设置时钟控制模块 begin if reset-l' then st<=s0;-异步复位 elsif clk' event and clk='l'then-边沿检测
architecture beh of statmach is type state_type is (s0,s1); --采用枚举法设置状态 signal st: state_type; --表达当前的状态 begin process(clk) --设置时钟控制模块 begin if reset='1' then st<=s0;--异步复位 elsif clk'event and clk='1' then --边沿检测 Moore机设计:例1
Moore机设计:例1 case st is-根据现态决定下一状态 when so=>st<=sl when s1=>if input= then st<=s0 end if: end case, end if: end process; output<=I when st=sl else0'7 根据状态决定输出 end beh
case st is --根据现态决定下一状态 when s0 => st<=s1; when s1 => if input='1' then st<=s0; end if; end case; end if; end process; output<='1' when st=s1 else'0'; --根据状态决定输出 end beh; Moore机设计:例1
Moore机设计:例2 例2 Moore状态机的设计 该状态机有5个状态,转换图如下所示:其中 输入控制ID为4位二进制数,在图中表达为 16进制数; D=3 S0/00 S1/10 S2/11 D=7 ID= b D=7 S4/11(S3/10 D=9
例2 Moore状态机的设计 该状态机有5个状态,转换图如下所示:其中 输入控制ID为4位二进制数,在图中表达为 16进制数; Moore机设计:例2
Moore机设计:例2 library ieee use ieee std logic 1164. all; entity moore2 is port(clk, rst: in std logic; id: in std logic vector (3 downto O); y: out std logic vector(I downto 0)); end moore
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(1 downto 0)); end moore2; Moore机设计:例2
Moore机设计:例2 architecture beh of moore2 is signal st:: std logic vector(2 downto0);-状态表达 各状态命名并根据输出的特点进行赋值 constant so: std logic vector(2 downto 0): =0009 constant sl:std_logic_vector(2 downto 0): ="010 constant s2: std logic vector(2 downto 0): =011 constant s3: std logic vector(2 downto 0): =110 constant s4: std logic vector (2 downto 0): =111 begin
architecture beh of moore2 is signal st: std_logic_vector(2 downto 0);--状态表达 --各状态命名并根据输出的特点进行赋值 constant s0:std_logic_vector(2 downto 0):="000"; constant s1:std_logic_vector(2 downto 0):="010"; constant s2:std_logic_vector(2 downto 0):="011"; constant s3:std_logic_vector(2 downto 0):="110"; constant s4:std_logic_vector(2 downto 0):="111"; begin Moore机设计:例2