赛灵思
直播中

廉雁捷

8年用户 263经验值
私信 关注
[问答]

LUT用作加法器或减法器

嗨,
我正在尽可能使用压缩逻辑来执行加法或减法。
我有两个8位数据,我想有时添加或有时减去这两个数字。
它看起来像是Elelment有一个叫做“CYINIT”的输入,根据它的值,它可以执行加法或减法。
我想知道这是否是我可以控制的东西,或者我如何为该工具编写一段代码来解释它,并使用相同的LUT来进行加法或子程序。
谢谢你,先生,
--Rudy

以上来自于谷歌翻译


以下为原文

Hi,
I am trying to use as packed logic as possible to carry out either an addition or subtraction.

I have two 8-bit data, and I would like to sometimes add or sometimes subtract these two numbers.

It looks like the carry Elelment has an input called: "CYINIT", which depending on its value it can either perform addition or subtraction.
I was wondering if that is something, I can control, or how can I write a piece of code for the tool to interpret it that way, and use the same LUTs to either do addition or subtrcation.

Thanks in advnace,
--Rudy

回帖(3)

刘秀英

2019-3-28 06:19:44
你好
查看CLB用户指南,
进位初始化 -  CYINIT进位初始化输入用于选择进位链中的第一位。
该引脚的值为0(对于加法),1(对于减法)或AX输入(对于动态第一进位)。
是否可以将实例化模板中的值CYINIT设置为“1”或“0”?
CARRY4 carry4_3(.O(o_3),. CO(co_3),。DI(di),。s(s),. c1(co_2 [3]),. CYINIT(1'b0));
--Hem
--------------------------------------------------
--------------------------------------------请注意 - 请注明
如果提供的信息有用,请回答“接受为解决方案”。给予您认为有用并回复导向的帖子。感谢K--
--------------------------------------------------
---------------------

以上来自于谷歌翻译


以下为原文

Hi
 
Looking at the CLB user guide,
 
Carry Initialize – CYINIT
The carry initialize input is used to select the first bit in a carry chain. The value for this pin is either 0 (for add), 1 (for subtract), or AX input (for the dynamic first carry bit).
 
Would that be possible to set the value CYINIT in the instantiation template as "1" or "0"?
 
CARRY4  carry4_3  (.O(o_3), .CO(co_3), .DI(di), .S(s), .CI(co_2[3]), .CYINIT(1'b0));
 
--Hem
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
举报

陈玉筠

2019-3-28 06:36:12
只需编写RTL代码,该工具即可完成。
进位链工作的方式是每个LUT接收A操作数的一位和B操作数的一位,产生部分和和进位,然后由进位链处理。
认识到A-B只是(A + ~B + 1),编码
分配= sub?
(A-B):( A + B);
将(可能)将“子”控制信号路由到每个LUT以反转B输入以及CIN输入(进行+1)。
尝试一下,看看它是否有效,然后再做更复杂的事情。
但请注意,“小”加法器不会发生这种情况;
根据合成设置,较小的加法器(通常小于4位)将实现为纯组合函数,而不使用进位链。
Avrum

以上来自于谷歌翻译


以下为原文

Just write the RTL code and the tool will take care of it. The way the carry chain works is that each LUT takes in one bit of the A operand and one bit of the B operand, generating partial sums and carries, which are then processed by the carry chain. Realizing that A-B is just (A+~B+1), coding
 
assign out = sub ? (A-B) : (A+B);
 
will (probably) route the "sub" control signal to each LUT to invert the B input as well as to the CIN input (to do the +1). Try it out and see if it works before you do anything more complicated.
 
Be aware, though, that this won't happen for "small" adders; depending on the synthesis settings, smaller adders (usually less than 4 bits) will be implemented as pure combinatorial functions, and not use the carry chain.
 
Avrum
举报

步雅芸

2019-3-28 06:47:19
好的,谢谢你的帮助。
--Rudy

以上来自于谷歌翻译


以下为原文

All right, thanks that helped.  
--Rudy 
举报

更多回帖

发帖
×
20
完善资料,
赚取积分