集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 1059|回复: 1

求助,状态机工作不正常

[复制链接]
tulipyyf 发表于 2011-11-26 20:47:14 | 显示全部楼层 |阅读模式
reg[2:0] state;
reg[2:0] next_state;
//状态编码(8个状态)
parameter
state0=3'b000,
state1=3'b001,
state2=3'b010,
state3=3'b011,
state4=3'b100,
state5=3'b101,
state6=3'b110,
state7=3'b111;

//由主时钟(60)产生AD时钟(7.5)
always @(posedge clk)
        cnt<=cnt+1;
assign AD_clock=~cnt[2];                //8分频输出

//*******************************************************************
//产生状态机动作时序
always @(posedge AD_clock)
        cntZ<=cntZ+1;
assign ZT_clock=~cntZ[1];                //4分频输出   1.875MHz
       

//*******************************************************************
//有限状态机切换时间       8*4=32   posedge ZT_clock posedge rst_4128 or
always @(posedge ZT_clock,posedge rst_4128)
        begin       
                if(rst_4128)
                        state<=state0;               
                else
                        state<=next_state;       
        end
               
//*******************************************************************
//状态机转换(框架程序)
always @( state )
begin
        next_state=3'bx;       

        case(state)
        state0:begin
                        next_state=state1;
                end

        state1:begin       
                        next_state=state2;
                end

        state2:begin       
                        next_state=state3;
                end


        state3:begin       
                        next_state=state4;
                end

        state4:begin       
                        next_state=state5;
                end


        state5:begin       
                        next_state=state6;
                end

        state6:begin       
                        next_state=state7;
                end

        state7:begin
                        next_state=state7;        //循环       
                end

        endcase


end


我的目的是rst_4128复位一次,状态机执行一次完整的流程(),但是实际上状态机完成了N次流程,请各位帮帮忙看看那里出现问题了,我用的是LC4128 ,刚接触CPLD。着急等待解决。
I2C 发表于 2011-12-3 03:52:18 | 显示全部楼层
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-4 18:36 , Processed in 0.079066 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表