OpenCores
URL https://opencores.org/ocsvn/mult_booth_array/mult_booth_array/trunk

Subversion Repositories mult_booth_array

[/] [mult_booth_array/] [trunk/] [vhdl/] [tb_mult_booth_array.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 plutonium
library ieee;
2
use ieee.std_logic_1164.all;
3
use ieee.numeric_std.all;
4
use ieee.math_real.all;
5
 
6
entity tb_mult_booth_array is
7
  generic(
8
    word_size_a   : integer := 8;
9
    word_size_b   : integer := 8;
10
    use_pipelining : boolean := true
11
  );
12
end tb_mult_booth_array;
13
 
14
architecture tb_arch of tb_mult_booth_array is
15
 
16
        constant no_of_rows : integer := integer(floor(real(word_size_b+2)/2.0));
17
 
18
  signal clk : std_logic := '1';
19
  signal rst : std_logic;
20
 
21
  signal a : std_logic_vector(word_size_a-1 downto 0);
22
  signal b : std_logic_vector(word_size_b-1 downto 0);
23
  signal p_dut,p_ref,p_refd : std_logic_vector(word_size_a+word_size_b-1 downto 0);
24
 
25
begin
26
 
27
  clk <= not clk after 5 ns;
28
  rst <= '1', '0' after 10 ns;
29
 
30
        mult_booth_array_inst : entity work.mult_booth_array
31
  generic map (
32
    word_size_a   => word_size_a,
33
    word_size_b   => word_size_b,
34
    use_pipelining => use_pipelining
35
  )
36
  port map (
37
    clk_i => clk,
38
    rst_i => rst,
39
    ce_i  => '1',
40
    a_i   => a,
41
    b_i   => b,
42
    p_o   => p_dut
43
  );
44
 
45
 
46
  process
47
    variable seed1, seed2: positive;
48
    variable rand : real;
49
  begin
50
    a <= (others => '0');
51
    b <= (others => '0');
52
    loop
53
      uniform(seed1, seed2, rand);
54
      wait until clk'event and clk='0';
55
      a <= std_logic_vector(to_unsigned(integer(trunc(rand*real(2**word_size_a-1))),word_size_a));
56
      uniform(seed1, seed2, rand);
57
      b <= std_logic_vector(to_unsigned(integer(trunc(rand*real(2**word_size_b-1))),word_size_b));
58
        p_ref <= std_logic_vector(unsigned(a) * unsigned(b));
59
    end loop;
60
  end process;
61
 
62
        delay_ref: if use_pipelining generate
63
                ref_delay : entity work.register_chain generic map(word_size => word_size_a+word_size_b, delay => no_of_rows-1) port map(clk_i => clk, rst_i => rst, ce_i => '1', d_i => p_ref, q_o => p_refd);
64
        end generate;
65
 
66
        forward_ref: if not use_pipelining generate
67
                p_refd <= p_ref;
68
        end generate;
69
 
70
  process
71
    variable seed1, seed2: positive;
72
    variable rand : real;
73
  begin
74
    wait until rst'event and rst='0';
75
    for i in 0 to no_of_rows-1 loop
76
                wait until clk'event and clk='0';
77
        end loop;
78
    loop
79
        wait until clk'event and clk='0';
80
      assert (p_dut = p_refd) report "Test failure" severity warning;
81
    end loop;
82
  end process;
83
 
84
end architecture;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.