FPGA有限状态机Moore Fsm

有限状态机(Finite-state machine, FSM)
Moore Machine
输出仅是当前状态的函数
Mealy Machine
输出是当前状态和输入的函数

有限状态机 ->状态转换

在这里插入图片描述

A->输入 Y->输出

我们设计一个如下图所示的有限状态机
在这里插入图片描述

reset=1 复位 状态=s0
状态为s0 时 输入为1 时 状态转换为s1
状态为s1 时 输入为0 时 状态转换为s2
状态为s2 时 输入为1 时 状态转换为s3
状态为s3 时 输入为0 时 状态转换为s0
other 情况不变

library ieee;

use ieee.std_logic_1164.all;

entity ztj is
	port(
		clk,inp,reset:in std_logic;
		outp :out std_logic_vector(3 downto 0)
	);
	
end entity;

architecture behave of ztj is
	type zt is (s0,s1,s2,s3);
	signal nowzt: zt;

begin
	 main_process: process(clk,reset)
			begin
			if reset ='1' then nowzt<=s0;
			elsif clk'event and clk='1' then
					if nowzt = s0 then 
						if inp = '1' then
							nowzt <= s1;
						end if;
					 elsif nowzt = s1 then 
						if inp = '0' then
							nowzt <= s2;
						end if;
					 elsif nowzt = s2 then 
						if inp = '1' then
							nowzt <= s3;
						end if;				 
					 elsif nowzt = s3 then 
						if inp = '0' then
							nowzt <= s0;
						end if;
					 end if;
			end if;
		end process;
		
		out_process:process(nowzt)
		begin
		case nowzt is
				when s0 => outp <= "0000";
				when s1 => outp <= "1001";
				when s2 => outp <= "1100";
				when s3 => outp <= "1111";
		 end case;
		end process;
end architecture;

vwf仿真波形图如下
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

牛郎恋刘娘,刘娘念牛郎

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值