【发布时间】:2013-06-04 18:31:34
【问题描述】:
我正在 vhdl - 比较器上创建小芯片块。
用途:QuartusII、ModelSim,在 Cyclone ii 上进行仿真。
INPUT:
IN_FIRST: in UNSIGNED(255 downto 0);
IN_SECOND: in UNSIGNED(255 downto 0);
OUTPUT:
OUT_IS_RIGHT_RESULT: out STD_LOGIC; -- IN_SECOND < IN_FIRST
我有一些不同的并行和顺序实现。但在某些情况下,并行工作比顺序更糟糕。 而且我找不到最佳方法。
一些不同的实现:
使用生成 (time-18.5ns)
architecture ComparatorArch of Comparator is
signal T: UNSIGNED(7 downto 0) := (others => 'U');
signal H: UNSIGNED(7 downto 0) := (others => 'U');
begin
generateG: for i in 7 downto 0 generate
T(i) <= '1' when (IN_FIRST((i + 1) * 32 - 1 downto i * 32) > IN_SECOND((i + 1) * 32 - 1 downto i * 32)) else '0';
H(i) <= '1' when (IN_FIRST((i + 1) * 32 - 1 downto i * 32) < IN_SECOND((i + 1) * 32 - 1 downto i * 32)) else '0';
end generate generateG;
OUT_TARG <= T;
OUT_HASH <= H;
OUT_IS_RIGHT_RESULT <= (T(7) or ((not T(7)) and ((not H(7)) and
(T(6) or ((not T(6)) and ((not H(6)) and
(T(5) or ((not T(5)) and ((not H(5)) and
(T(4) or ((not T(4)) and ((not H(4)) and
(T(3) or ((not T(3)) and ((not H(3)) and
(T(2) or ((not T(2)) and ((not H(2)) and
(T(1) or ((not T(1)) and ((not H(1)) and T(0))))))))))))))))))))));
end ComparatorArch;
最后一部分 - 这是比较 T 和 H 的逻辑表示。
处理中(时间-35ns)
architecture ComparatorArch of Comparator is
begin
mainP: process(IN_READY) begin
if (rising_edge(IN_READY) and IN_READY = '1') then
if (IN_SECOND < IN_FIRST) then
OUT_IS_RIGHT_RESULT <= '1';
else
OUT_IS_RIGHT_RESULT <= '0';
end if;
end if;
end process;
end ComparatorArch;
可能有人知道更好的方法。
如果我改变它就不起作用
if (rising_edge(IN_READY) and IN_READY = '1') then
到
if (IN_READY = '1') then
为什么?
我在例子中研究了一些基本的东西,并意识到芯片有特殊输入数据大小的逻辑和计算块。 它比较或计算大小从最小值到特定最大值的信号的逻辑运算常量时间。 它同时比较 BIT/BIT 或 BIT_VECTOR(7 down to 0)/BIT_VECTOR(7 down to 0) - 大约 9ns。为什么这么久?谁能解释一下?
【问题讨论】:
-
我只是依稀看懂你的符号,但我曾经设计过IC。构建相等/不相等比较器时,您需要逐位比较,然后组合成对的结果,然后组合成对的对等。这样,门延迟与 log N 成正比。如果你“菊花链”另一方面,比较单个位的结果,您会得到与 N 成正比的延迟。
标签: performance vhdl modelsim