FC2無料カウンターFC2無料カウンターFC2無料カウンターFC2無料カウンターFC2無料カウンターFC2無料カウンターFC2無料カウンターFC2無料カウンター (cache)FPGAの部屋 Divider Generator を使ってみた

FPGAやCPLDの話題やFPGA用のツールの話題などです。 マニアックです。 日記も書きます。

FPGAの部屋

FPGAの部屋の有用と思われるコンテンツのまとめサイトを作りました。Xilinx ISEの初心者の方には、FPGAリテラシーおよびチュートリアルのページをお勧めいたします。

Divider Generator を使ってみた

割り算器が必要になったので、ISE12.2のCore GeneratorのDivider Generator を使って割り算コアを生成してみた。
ProjectメニューのNew Source..からIP(CORE Generator & Architecture Wizard) を選択し、File Name:をdivider_perとして、割り算器を生成する。下が、Divider Generator の設定。
divider_IP_1_101001.png

Dividend and Quotient Widthが23ビット、Divisor Widthが15ビットだ。Remainder TypeはRemainderで、Clocks per Divisonは1にしてある。Operand SignはUnsigned で、Control SignalsはCE を追加してある。
このパラメータで割り算器を生成した。これだけではインプリメントとシミュレーションができないので、トップファイルとテストベンチを追加した。
まずは、トップファイルのDivider_test.vhd から下に示す。

-- Divider Test(Divider_test.vhd)

library IEEE;
use IEEE.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity Divider_test is
    port (
        clk: IN std_logic;
        ce: IN std_logic;
        rfd: OUT std_logic;
        dividend: IN std_logic_VECTOR(22 downto 0);
        quotient: OUT std_logic_VECTOR(22 downto 0);
        fractional: OUT std_logic_VECTOR(14 downto 0)
    );
end Divider_test;

architecture RTL of Divider_test is
component divider_per
    port (
    clk: IN std_logic;
    ce: IN std_logic;
    rfd: OUT std_logic;
    dividend: IN std_logic_VECTOR(22 downto 0);
    divisor: IN std_logic_VECTOR(14 downto 0);
    quotient: OUT std_logic_VECTOR(22 downto 0);
    fractional: OUT std_logic_VECTOR(14 downto 0));
end component;

signal divisor: std_logic_VECTOR(14 downto 0);
begin
    divider_per_inst : divider_per port map (
        clk => clk,
        ce => ce,
        rfd => rfd,
        dividend => dividend,
        divisor => divisor,
        quotient => quotient,
        fractional => fractional
    );
    divisor <= "110000000000000";
end RTL;


次にテストベンチ・ファイルのDivider_test_tb.vhdを下に示す。

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
 
ENTITY Divider_test_tb IS
END Divider_test_tb;
 
ARCHITECTURE behavior OF Divider_test_tb IS 
 
    -- Component Declaration for the Unit Under Test (UUT)
 
    COMPONENT Divider_test
    PORT(
         clk : IN  std_logic;
         ce : IN  std_logic;
         rfd : OUT  std_logic;
         dividend : IN  std_logic_vector(22 downto 0);
         quotient : OUT  std_logic_vector(22 downto 0);
         fractional : OUT  std_logic_vector(14 downto 0)
        );
    END COMPONENT;
    

   --Inputs
   signal clk : std_logic := '0';
   signal ce : std_logic := '0';
   signal dividend : std_logic_vector(22 downto 0) := (others => '0');

     --Outputs
   signal rfd : std_logic;
   signal quotient : std_logic_vector(22 downto 0);
   signal fractional : std_logic_vector(14 downto 0);

   -- Clock period definitions
   constant clk_period : time := 40 ns;
 
BEGIN
 
    -- Instantiate the Unit Under Test (UUT)
   uut: Divider_test PORT MAP (
          clk => clk,
          ce => ce,
          rfd => rfd,
          dividend => dividend,
          quotient => quotient,
          fractional => fractional
        );

   -- Clock process definitions
   clk_process :process
   begin
        clk <= '0';
        wait for clk_period/2;
        clk <= '1';
        wait for clk_period/2;
   end process;
 

    -- Stimulus process
    stim_proc: process
    begin
        ce <= '0';
        dividend <= "00000000000000000000000";    
        wait for clk_period*2;    
        ce <= '1';
        dividend <= "00000000110000000000000";
        wait for clk_period*2;    
        ce <= '1';
        dividend <= "00000011100000000000000";
        
        wait for clk_period*10;

        wait;
    end process;

END;


これで、とりあえずインプリメントをしてみた。無事に終了したが、Summaryには何も表示されない?
divider_IP_2_101001.png

なんででしょうか?
FPGA Editorで見てみると、FPGA内部では確かにIOとスライスが使用されている。
divider_IP_3_101001.png

次にシミュレーションを行ってみた。ISimによるシミュレーション波形を下に示す。
divider_IP_4_101001.png

rfdが1のままだった。rfdが0になることはない。rfdは入力データがコアにサンプルされるタイミングを表す。Divider Generator の設定で、Clocks per Divisonは1だったので、rfdは1クロックごとに入力データをサンプルできるはずなので、1のままなのだろう?この設定では、Dividend and Quotient Widthが23ビットなので、割り算データが出力されるレイテンシは上のシミュレーション波形のカーソルから1usec、25クロックである。データシートでもDividend and Quotient Width + 2クロックなので、25クロックとなり同一である。

次に、Clocks per Divisonを8にしてみた。
divider_IP_5_101001.png

これで、シミュレーションしてみたのが下の波形だ。
divider_IP_6_101001.png

今度は、rfdが8クロックごとに1になっていて、そこでサンプルされたデータが、1.04usec、26クロック後に割り算されて出力されている。データシートではClocks per Divisonが1以上の時は、Dividend and Quotient Width + 3クロックなので等しい。
当然、Clocks per Divisonが8の方がリソースは食わないはず。。。これで、この用途には十分だと思う。

Core Generatorの割り算器を確かめてみた。レイテンシは、Dividend and Quotient Width + 数クロックかかるということがわかった。
  1. 2010年10月01日 12:50 |
  2. Core Generator
  3. | トラックバック:0
  4. | コメント:0

コメント

コメントの投稿


管理者にだけ表示を許可する

トラックバック URL
http://marsee101.blog19.fc2.com/tb.php/1605-f1f3a93f
この記事にトラックバックする(FC2ブログユーザー)
FC2 Analyzer