打印

FPGA状态机实现单一功能模十计数器

[复制链接]
1779|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
269152492|  楼主 | 2011-12-9 21:50 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 269152492 于 2011-12-9 21:53 编辑

//Data:2011-11月
//功能:状态机实现单一功能模十计数器
module Fsm_Counter(counter,Fillout,clk);
output [3:0] counter;
output Fillout;
reg[3:0]counter;
reg Fillout;
input clk;
parameter State0=4'b0000,
     State1=4'b0001,
     State2=4'b0010,
     State3=4'b0011,
     State4=4'b0100,
     State5=4'b0101,
     State6=4'b0110,
     State7=4'b0111,
     State8=4'b1000,
     State9=4'b1001;
reg[3:0] next_State;
[email=always@(posedge]always@(posedge[/email] clk)
begin
  case(next_State)
   State0:next_State<=State1;
   State1:next_State<=State2;
   State2:next_State<=State3;
   State3:next_State<=State4;
   State4:next_State<=State5;
   State5:next_State<=State6;
   State6:next_State<=State7;
   State7:next_State<=State8;
   State8:next_State<=State9;
   State9:next_State<=State0;
   default:next_State<=State0;
  endcase
end
[email=always@(next_State]always@(next_State[/email])
begin
  case(next_State)
   State0:counter<=State0;
   State1:counter<=State1;
   State2:counter<=State2;
   State3:counter<=State3;
   State4:counter<=State4;
   State5:counter<=State5;
   State6:counter<=State6;
   State7:counter<=State7;
   State8:counter<=State8;
   State9:begin
     counter<=State9;
     Fillout<=1'b1;
     end
   default:counter<=State0;
  endcase
   end
endmodule

相关帖子

沙发
关羽不爱跑| | 2011-12-10 14:14 | 只看该作者
[email=always@(posedge]always@(posedge[/email] clk)
269152492 发表于 2011-12-9 21:50

没看明白?直接贴过来的?
一个状态机就可以实现吧。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

35

帖子

1

粉丝