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

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

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 13465|回复: 9

请问Veriolg中1和1'b1有什么不同??

[复制链接]
发表于 2009-2-24 15:51:13 | 显示全部楼层 |阅读模式

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

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

x
我在写Verilog的时候,刚开始使用下面语句
reg [3:0] wrptr,rdptr;

if(wrptr+1 == rdptr)
   begin
         .....
  end
仿真错误,

改成如下语句
if(wrptr+1'b1 == rdptr)
   begin
         .....
  end
仿真就正确了,请问为什么呢 1和1'b1有什么不同呢,在if语句中。
我知道如果是计数器
counter<=counter+1;
counter<=counter+1'b1;
这两个是相同的吧~~

谢谢
发表于 2009-2-24 17:04:53 | 显示全部楼层
I think it is a bug of your simulator. Which tool do you use? I tried the following code in vcs and found no error.


// filename: one.v
// vcs -o one one.v
module one;
   reg [3:0] wrptr,rdptr;

   initial
     if(wrptr+1 == rdptr)
       begin
      $display("ok");      
       end
   
endmodule
 楼主| 发表于 2009-2-24 17:32:16 | 显示全部楼层
thanks

the tool is modelsim 6.1f

i found that many verison of modelsim have different kinds of bug, sucks!!
发表于 2009-2-24 17:43:27 | 显示全部楼层
you are welcome.

It is hard to call this behavior a bug, because it isn't specified by IEEE. The EDA company has full freedom to implement it. But in order to keep you code portable between different tools, try to  code as accurately as possible. It can save you several hours later.

By the way, vcs has a lot of bugs too.
 楼主| 发表于 2009-2-25 09:27:27 | 显示全部楼层


原帖由 humann 于 2009-2-24 17:43 发表


It is hard to call this behavior a bug, because it isn't specified by IEEE. The EDA company has full freedom to implement it. But in order to keep you code portable between differe ...



yeah, it took me almost half a day to debug this.

thanks again  ,good luck to you ~~~~~
发表于 2009-2-25 11:27:08 | 显示全部楼层
1'b1 is better, no other defination.

If 1, diff simulator can have diff explanation.
 楼主| 发表于 2009-2-25 13:31:48 | 显示全部楼层
thanks~~~
发表于 2009-2-25 13:39:26 | 显示全部楼层
1 means 32'b00000000000000000000000000000001 , it is different from 1'b1;
when you user rptr + 1 the result will be 32 bit wide it maybe different from wptr.
发表于 2009-2-25 15:38:19 | 显示全部楼层


原帖由 xudeqiang 于 2009-2-25 13:39 发表
1 means 32'b00000000000000000000000000000001 , it is different from 1'b1;
when you user rptr + 1 the result will be 32 bit wide it maybe different from wptr.



You are right.

Verilog is a weak-typed language. It is the most important difference between verilog and vhdl. The compiler do some type conversion silently, It allows a program in verilog "easy" to write and  hard to debug.
发表于 2009-2-25 17:36:21 | 显示全部楼层

response

I think this mistake can caused by two reasons . One is just the debug of simulator tools, the other just the 1 is 32-bit wide,in contrast, 1'b1 is just the one-bit.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

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

GMT+8, 2024-11-16 18:07 , Processed in 0.023825 second(s), 8 queries , Gzip On, Redis On.

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