【发布时间】:2014-06-13 21:07:59
【问题描述】:
我正在尝试制作一个 BCD 转换器来显示 0 到 9999 之间的数字,我需要使用移位运算符来实现双 Dabble 算法。但是我不能在没有遇到我不知道的警告的情况下开始编码,我仍然是一个初学者,所以请忽略我犯的任何愚蠢的错误。我首先实现了算法。我从未使用过移位运算符,所以我可能做得不对,请帮忙,这是我的代码
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity algorithm is
Port (x: in unsigned (15 downto 0);
y: out unsigned (15 downto 0));
end algorithm;
architecture Behavioral of algorithm is
begin
y <= x sll 16;
end Behavioral;
还有错误
Xst:647 - Input <x> is never used. This port will be preserved and left unconnected
if it belongs to a top-level block or it belongs to a sub-block and the hierarchy of
this sub-block is preserved.
即使我实现了这个
y
我收到此错误
Xst:647 - Input <x<15>> is never used. This port will be preserved and left
unconnected if it belongs to a top-level block or it belongs to a sub-block
and the hierarchy of this sub-block is preserved.
我在这里做错了什么?
【问题讨论】:
-
Double dabble 意味着一个 bcd 累加器,被清除以便 dabble 工作。有一个二进制值一次左移到 bcd 累加器位。首先将 bcd 累加器向左移动一位,然后将最右边的位置设置为二进制值最左侧的值,然后将二进制值向左移动一位。然后对于 bcd 累加器中的每个 bcd 数字位置,您测试该值,如果它大于 4(“100”),则添加 3(“0011”)。移位、测试、有条件地添加所有二进制位。想想进程中的 for 循环。
-
@DavidKoontz 我想要一个可以正确合成的代码,所以我不想使用循环,我在某处读到它被合成但是当在 FPGA 上实现时,它被强行制成一个计数器,所以这是一个不好的做法。这就是为什么我需要 sll 的东西,而我在合成 sll 时遇到了太多问题。当我什至无法让 sll 操作员工作时,我应该如何将其向左移动:/ 我迷路了!
-
你可以合成一个循环,老实说。循环通过综合展开,需要静态迭代方案。请参阅Convert 8bit binary number to BCD in VHDL 了解几种实现方式,包括具有最少硬件的展开循环。这些都没有使用 SLL,而是使用切片和串联或组件连接。首先得到一个模拟的工作算法。
标签: vhdl