在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 6919|回复: 15

[求助] 怎么在状态机中加计数器?

[复制链接]
发表于 2010-4-5 10:54:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
我想在状态机的单个状态中加入计数器进行计数,达到一定数值后跳转,该怎么写,求教!
发表于 2010-4-5 17:10:24 | 显示全部楼层
Case B_state
if cnt=0 then
  This_st<=B_state;
  cnt<=cnt+1;
elsif cnt=20 then
  This_st<=Jump_state;
  cnt<=0;
else
   This_st<=B_state;
   cnt<=cnt+1;
end

这个模式就是用计数器进行跳转的
 楼主| 发表于 2010-4-6 14:12:42 | 显示全部楼层
好的,我试试,多谢了
 楼主| 发表于 2010-4-8 18:10:00 | 显示全部楼层
好像还是不行,我写的程序其中有计算器的一个分支是这样:
s1:begin        if (din==1'b1)
        begin
        Ns=cs;
                if(cnt==5'b0)//第50行

                cnt<=cnt+1;
                else if(cnt==5'b00100)//52行
                begin
                Ns=s2;
                cnt<=0;
                end
                else
                begin
                cnt<=cnt+1;
                Ns=cs;
                end
                end
        else
        Ns=s2;
end
结果报了一大推没见过的错误:
error:HDLCompilers:52 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 50 Illegal operand(s) of binary operator '=='Parsing C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v: 0.03

ERROR:HDLCompilers:71 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 50 Illegal condition expression in if statement
ERROR:HDLCompilers:106 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 51 Illegal left hand side of nonblocking assignment
ERROR:HDLCompilers:52 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 51 Illegal operand(s) of binary operator '+'
ERROR:HDLCompilers:107 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 51 Illegal right hand side of nonblocking assignment
ERROR:HDLCompilers:52 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 52 Illegal operand(s) of binary operator '=='
ERROR:HDLCompilers:71 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 52 Illegal condition expression in if statement
ERROR:HDLCompilers:106 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 55 Illegal left hand side of nonblocking assignment
ERROR:HDLCompilers:106 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 59 Illegal left hand side of nonblocking assignment
ERROR:HDLCompilers:52 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 59 Illegal operand(s) of binary operator '+'
ERROR:HDLCompilers:107 - "C:/Xilinx92i/MYEXERCISE/DDR/statemachine.v" line 59 Illegal right hand side of nonblocking assignment
发表于 2010-4-8 18:35:26 | 显示全部楼层
你把阻塞和非阻塞赋值放一起了
发表于 2010-4-8 20:38:55 | 显示全部楼层
赋值问题
 楼主| 发表于 2010-4-9 15:03:48 | 显示全部楼层
不是这个问题,我试过了
发表于 2010-4-9 16:20:19 | 显示全部楼层
先改了,再把error 贴出来
 楼主| 发表于 2010-4-10 15:56:31 | 显示全部楼层
改过以后问题,还是一样哦
发表于 2010-4-13 08:59:47 | 显示全部楼层
会不会是不能在同一个进程中对同一个值(cnt)进行重复赋值呢?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

X

小黑屋| 手机版| 关于我们| 联系我们| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2025-5-31 07:14 , Processed in 0.022753 second(s), 7 queries , Gzip On, MemCached On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表