数字信号处理的FPGA实现(第三版)的例子
实现了一个31bit流水线加法器。设计运行速度316.46MHz
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_arith.all;
- use ieee.std_logic_unsigned.all;
- entity test is
- generic (
- WIDTH :integer :=31;
- WIDTH1 :integer :=15; --LSB
- WIDTH2 :integer :=16 --MSB
- );
- port (
- x,y :in std_logic_vector( WIDTH-1 downto 0);
- sum :out std_logic_vector( WIDTH-1 downto 0);
- LSBs_Carry :out std_logic;
- clk :in std_logic
- );
- end entity;
- architecture rtl of test is
-
- signal l1,l2,s1 :std_logic_vector(WIDTH1-1 downto 0); --LSBs of inputs
- signal r1 :std_logic_vector(WIDTH1 downto 0); --LSBs of inputs
- signal l3,l4,r2,s2 :std_logic_vector(WIDTH2-1 downto 0); --MSBs of inputs
- begin
- process
- begin
- wait until clk = '1';
- --split LSBs form input x, y
- l1 <= x(WIDTH1-1 downto 0);
- l2 <= y(WIDTH1-1 downto 0);
- --split MSBs from input x,y
- l3 <= x(WIDTH-1 downto WIDTH1);
- l4 <= y(WIDTH-1 downto WIDTH1);
- --first stage of the adder
- r1 <= ('0' & l1) + ('0' & l2);
- r2 <= l3 + l4;
- --second stage of the adder
- s1 <= r1(WIDTH1-1 downto 0); --这里这句看不出来有什么用处
- --add result von MSBs (x+y) and carry form LSBs
- s2 <= r1(WIDTH1) + r2;
- end process;
- LSBs_Carry <= r1(WIDTH1); --add a test signal
-
- sum <= s1 & s2;
- end rtl;
综合后的时序报告
看上面的结果,最大也就252.91MHz。和他说的316.46MHz还有一段差距呢。(不最大我看的对不对?)
请问这红色的地方该如何修改?
综合过的RTL图如下
如何能看出这是流水线呢?
第一个clk,将输入分成2部分
第二个clk,分别得到低位和高位的和
第三个clk,得到和
这样用三个周期才能得到结果,怎么还会更快呢?
如果直接用altera的IP一个周期就可以得到结果了
希望各位可以赐教!
|