Altera Coding Style 之 比较器

一、两种情况

比较器的使用可以归类为2种情况:== 和 <。不等于和大于实际上只是上述的一个反运算。

… The == comparator is implemented in general logic cells. The < comparator can be implemented using the carry chain or general logic cells.

==会综合成组合逻辑,<可能综合成组合逻辑,也可能综合成进位链。

二、优劣比较

独立测试时,进位链会比组合逻辑快;但是在大的工程当中,由于约束的关系,进位链的结构有时反而显得慢。

对于 6-input 的ALUT,每次可以比较3比特;对于 4-input LUT,每次只能比较1比特。

三、风格引导

1、综合成组合逻辑

      wire [6:0] a, b;

      wire alb = a < b;

2、综合成进位链

      wire [6:0] a, b;

      wire [7:0] tmp = a – b;

      wire alb = tmp[7];

      显然,alb 为1时说明a比b小。

       还有这样一段话:

       … If you have any information about the range of the input, you have “don’t care” values that you can use to optimize the design. Bacause this information is not available to the synthesis tool, you can often reduce the device area required to implement the comparator with specific hand implementation of the logic.

四、一个例子

        确定数值范围的例子:

T`7EKD(M]K40F%DI9TI5F{S

 

posted on 2012-08-16 15:59  freshair_cn  阅读(328)  评论(0编辑  收藏  举报

导航