加载中…
个人资料
  • 博客等级:
  • 博客积分:
  • 博客访问:
  • 关注人气:
  • 获赠金笔:0支
  • 赠出金笔:0支
  • 荣誉徽章:
正文 字体大小:

always语句综合详解

(2011-10-10 13:30:54)
标签:

锁存器

组合电路

alwaysw语句

逻辑综合

寄存器

杂谈

分类: Dreamywork

想说的有两点:

1.always的综合

2.always与assign之间的关系

先来说第一个

always的综合中,如果if语句中所有的可能性都顾虑到了,会生成组合电路,即使在output中明明写着reg out;那都是浮云,无论怎么综合都不会出现寄存器的。

如果always语句中的if没有被所有情况都有提及,那么输出必然出现锁存器,ena与clk被连接到一起了。

如果always语句中所有if都被遍历,可是在else中有

else

begin

out = out;

end

那么,将被一样的综合成unsafed latch。要注意一下。

如果敏感信号列表里面没有提及所有提供驱动的信号,综合结果同样没有锁存器的。原以为会有的。。。

再来说说always 和assign的关系

如果功能的表述一样的话,也是一样的结果。就像下面的第三个例子中也会出现锁存器~

像这样,在always的纯组合电路中没有reg产生的话,我还是比较推荐always的方法来写,if总比三目运算更明了~


module test (a,b,x,y);

input  [3:0] a,b;

output [3:0] x,y;

reg    [3:0] x,y;

always @(a or b)

begin

       if (a != b)

              begin

              x = a;

              y = b;

              end

end

endmodule

Warning: Latch y$latch has unsafe behavior

       Warning: Ports D and ENA on the latch are fed by the same signal b[3]

 

 

 

 

module test (a,b,x,y);

input  [3:0] a,b;

output [3:0] x,y;

reg    [3:0] x,y;

always @(a or b)

begin

       if (a != b)

              begin

              x = a;

              y = b;

              end

       else

              x = x;

              y = y;

end

endmodule

Warning: Latch y$latch has unsafe behavior

       Warning: Ports D and ENA on the latch are fed by the same signal b[3]

 

 

module test (a,b,x,y);

input [3:0] a,b;

output[3:0] x,y;

//reg   [3:0] x,y;

 

assign x = (a != b) ? a : x;

assign y = (a != b) ? b : y;

 

endmodule

Warning: Latch y$latch has unsafe behavior

       Warning: Ports D and ENA on the latch are fed by the same signal b[3]

http://s8/middle/5e9b181a4aeeb37cb9857&690


 

 

 

 

 

 

 

module test (a,b,x,y);

input  [3:0] a,b;

output [3:0] x,y;

 

reg    [3:0] x,y;

 

always @(a or b)

begin

       if (a != b)

              begin

              x = a;

              y = b;

              end

       else

              x = 0;

              y = 0;

end

module test (a,b,x,y);

input [3:0] a,b;

output[3:0] x,y;

//reg   [3:0] x,y;

 

assign x = (a != b) ? a : 4'd0;

assign y = (a != b) ? b : 4'd0;

 

endmodule

http://s16/middle/5e9b181a077e45233bcdf&690

 

0

阅读 收藏 喜欢 打印举报/Report
前一篇:IR-Drop Analysis
后一篇:MCMM的应用
  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有