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

Subversion Repositories mod_sim_exp

[/] [mod_sim_exp/] [trunk/] [bench/] [vhdl/] [mod_sim_exp_core_tb.vhd] - Diff between revs 37 and 43

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 37 Rev 43
Line 61... Line 61...
 
 
entity mod_sim_exp_core_tb is
entity mod_sim_exp_core_tb is
end mod_sim_exp_core_tb;
end mod_sim_exp_core_tb;
 
 
architecture test of mod_sim_exp_core_tb is
architecture test of mod_sim_exp_core_tb is
  constant clk_period : time := 10 ns;
  constant CLK_PERIOD : time := 10 ns;
  signal clk          : std_logic := '0';
  signal clk          : std_logic := '0';
  signal reset        : std_logic := '1';
  signal reset        : std_logic := '1';
  file input          : text open read_mode is "src/sim_input.txt";
  file input          : text open read_mode is "src/sim_input.txt";
  file output         : text open write_mode is "out/sim_output.txt";
  file output         : text open write_mode is "out/sim_output.txt";
 
 
  ------------------------------------------------------------------
  ------------------------------------------------------------------
 
  -- Core parameters
 
  ------------------------------------------------------------------
 
  constant C_NR_BITS_TOTAL   : integer := 1536;
 
  constant C_NR_STAGES_TOTAL : integer := 96;
 
  constant C_NR_STAGES_LOW   : integer := 32;
 
  constant C_SPLIT_PIPELINE  : boolean := true;
 
 
 
  -- extra calculated constants
 
  constant NR_BITS_LOW : integer := (C_NR_BITS_TOTAL/C_NR_STAGES_TOTAL)*C_NR_STAGES_LOW;
 
  constant NR_BITS_HIGH : integer := C_NR_BITS_TOTAL-NR_BITS_LOW;
 
 
 
  ------------------------------------------------------------------
  -- Signals for multiplier core memory space
  -- Signals for multiplier core memory space
  ------------------------------------------------------------------
  ------------------------------------------------------------------
  signal core_rw_address   : std_logic_vector (8 downto 0);
  signal core_rw_address   : std_logic_vector (8 downto 0);
  signal core_data_in      : std_logic_vector(31 downto 0);
  signal core_data_in      : std_logic_vector(31 downto 0);
  signal core_fifo_din     : std_logic_vector(31 downto 0);
  signal core_fifo_din     : std_logic_vector(31 downto 0);
Line 103... Line 115...
------------------------------------------
------------------------------------------
clk_process : process
clk_process : process
begin
begin
  while (true) loop
  while (true) loop
    clk <= '0';
    clk <= '0';
    wait for clk_period/2;
    wait for CLK_PERIOD/2;
    clk <= '1';
    clk <= '1';
    wait for clk_period/2;
    wait for CLK_PERIOD/2;
  end loop;
  end loop;
end process;
end process;
 
 
------------------------------------------
------------------------------------------
-- Stimulus Process
-- Stimulus Process
Line 252... Line 264...
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("base width: "));
        write(Lw, string'("base width: "));
        write(Lw, base_width);
        write(Lw, base_width);
        writeline(output, Lw);
        writeline(output, Lw);
        case (base_width) is
        case (base_width) is
          when nr_bits_total => when nr_bits_high => when nr_bits_low =>
          when C_NR_BITS_TOTAL => when NR_BITS_HIGH => when NR_BITS_LOW =>
          when others =>
          when others =>
            write(Lw, string'("=> incompatible base width!!!")); writeline(output, Lw);
            write(Lw, string'("=> incompatible base width!!!")); writeline(output, Lw);
            assert false report "incompatible base width!!!" severity failure;
            assert false report "incompatible base width!!!" severity failure;
        end case;
        end case;
 
 
Line 329... Line 341...
        ----------------------------------------
        ----------------------------------------
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("----- Selecting pipeline: "));
        write(Lw, string'("----- Selecting pipeline: "));
        writeline(output, Lw);
        writeline(output, Lw);
        case (base_width) is
        case (base_width) is
          when nr_bits_total =>  core_p_sel <= "11"; write(Lw, string'("  Full pipeline selected"));
          when C_NR_BITS_TOTAL =>  core_p_sel <= "11"; write(Lw, string'("  Full pipeline selected"));
          when nr_bits_high =>  core_p_sel <= "10"; write(Lw, string'("  Upper pipeline selected"));
          when NR_BITS_HIGH =>  core_p_sel <= "10"; write(Lw, string'("  Upper pipeline selected"));
          when nr_bits_low  =>  core_p_sel <= "01"; write(Lw, string'("  Lower pipeline selected"));
          when NR_BITS_LOW  =>  core_p_sel <= "01"; write(Lw, string'("  Lower pipeline selected"));
          when others =>
          when others =>
            write(Lw, string'("  Invallid bitwidth for design"));
            write(Lw, string'("  Invallid bitwidth for design"));
            assert false report "impossible basewidth!" severity failure;
            assert false report "impossible basewidth!" severity failure;
        end case;
        end case;
        writeline(output, Lw);
        writeline(output, Lw);
Line 424... Line 436...
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => calc time is "));
        write(Lw, string'("  => calc time is "));
        write(Lw, string'(ToString(timer)));
        write(Lw, string'(ToString(timer)));
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => expected time is "));
        write(Lw, string'("  => expected time is "));
        write(Lw, (nr_stages_total+(2*(base_width-1)))*clk_period);
        write(Lw, (C_NR_STAGES_TOTAL+(2*(base_width-1)))*CLK_PERIOD);
        writeline(output, Lw);
        writeline(output, Lw);
        if (gt0(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
        if (gt0(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
          write(Lw, string'("  => gt0 is correct!")); writeline(output, Lw);
          write(Lw, string'("  => gt0 is correct!")); writeline(output, Lw);
        else
        else
          write(Lw, string'("  => Error: gt0 is incorrect!!!")); writeline(output, Lw);
          write(Lw, string'("  => Error: gt0 is incorrect!!!")); writeline(output, Lw);
Line 457... Line 469...
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => calc time is "));
        write(Lw, string'("  => calc time is "));
        write(Lw, string'(ToString(timer)));
        write(Lw, string'(ToString(timer)));
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => expected time is "));
        write(Lw, string'("  => expected time is "));
        write(Lw, (nr_stages_total+(2*(base_width-1)))*clk_period);
        write(Lw, (C_NR_STAGES_TOTAL+(2*(base_width-1)))*CLK_PERIOD);
        writeline(output, Lw);
        writeline(output, Lw);
        if (gt1(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
        if (gt1(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
          write(Lw, string'("  => gt1 is correct!")); writeline(output, Lw);
          write(Lw, string'("  => gt1 is correct!")); writeline(output, Lw);
        else
        else
          write(Lw, string'("  => Error: gt1 is incorrect!!!")); writeline(output, Lw);
          write(Lw, string'("  => Error: gt1 is incorrect!!!")); writeline(output, Lw);
Line 490... Line 502...
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => calc time is "));
        write(Lw, string'("  => calc time is "));
        write(Lw, string'(ToString(timer)));
        write(Lw, string'(ToString(timer)));
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => expected time is "));
        write(Lw, string'("  => expected time is "));
        write(Lw, (nr_stages_total+(2*(base_width-1)))*clk_period);
        write(Lw, (C_NR_STAGES_TOTAL+(2*(base_width-1)))*CLK_PERIOD);
        writeline(output, Lw);
        writeline(output, Lw);
        if (R(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
        if (R(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
          write(Lw, string'("  => (R)mod m is correct!")); writeline(output, Lw);
          write(Lw, string'("  => (R)mod m is correct!")); writeline(output, Lw);
        else
        else
          write(Lw, string'("  => Error: (R)mod m is incorrect!!!")); writeline(output, Lw);
          write(Lw, string'("  => Error: (R)mod m is incorrect!!!")); writeline(output, Lw);
Line 523... Line 535...
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => calc time is "));
        write(Lw, string'("  => calc time is "));
        write(Lw, string'(ToString(timer)));
        write(Lw, string'(ToString(timer)));
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => expected time is "));
        write(Lw, string'("  => expected time is "));
        write(Lw, (nr_stages_total+(2*(base_width-1)))*clk_period);
        write(Lw, (C_NR_STAGES_TOTAL+(2*(base_width-1)))*CLK_PERIOD);
        writeline(output, Lw);
        writeline(output, Lw);
        if (gt01(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
        if (gt01(base_width-1 downto 0) = data_read(base_width-1 downto 0)) then
          write(Lw, string'("  => gt01 is correct!")); writeline(output, Lw);
          write(Lw, string'("  => gt01 is correct!")); writeline(output, Lw);
        else
        else
          write(Lw, string'("  => Error: gt01 is incorrect!!!")); writeline(output, Lw);
          write(Lw, string'("  => Error: gt01 is incorrect!!!")); writeline(output, Lw);
Line 569... Line 581...
        waitclk(10);
        waitclk(10);
        write(Lw, string'("  => calc time is "));
        write(Lw, string'("  => calc time is "));
        write(Lw, string'(ToString(timer)));
        write(Lw, string'(ToString(timer)));
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => expected time is "));
        write(Lw, string'("  => expected time is "));
        write(Lw, ((nr_stages_total+(2*(base_width-1)))*clk_period*7*exponent_width)/4);
        write(Lw, ((C_NR_STAGES_TOTAL+(2*(base_width-1)))*CLK_PERIOD*7*exponent_width)/4);
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => Done"));
        write(Lw, string'("  => Done"));
        core_run_auto <= '0';
        core_run_auto <= '0';
        writeline(output, Lw);
        writeline(output, Lw);
 
 
Line 610... Line 622...
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => calc time is "));
        write(Lw, string'("  => calc time is "));
        write(Lw, string'(ToString(timer)));
        write(Lw, string'(ToString(timer)));
        writeline(output, Lw);
        writeline(output, Lw);
        write(Lw, string'("  => expected time is "));
        write(Lw, string'("  => expected time is "));
        write(Lw, (nr_stages_total+(2*(base_width-1)))*clk_period);
        write(Lw, (C_NR_STAGES_TOTAL+(2*(base_width-1)))*CLK_PERIOD);
        writeline(output, Lw);
        writeline(output, Lw);
 
 
      when 12 => -- check with result
      when 12 => -- check with result
        hread(L, result(base_width-1 downto 0), good_value);
        hread(L, result(base_width-1 downto 0), good_value);
        assert good_value report "Can not read result! (wrong lenght?)" severity failure;
        assert good_value report "Can not read result! (wrong lenght?)" severity failure;
Line 653... Line 665...
 
 
------------------------------------------
------------------------------------------
-- Multiplier core instance
-- Multiplier core instance
------------------------------------------
------------------------------------------
the_multiplier : mod_sim_exp.mod_sim_exp_pkg.mod_sim_exp_core
the_multiplier : mod_sim_exp.mod_sim_exp_pkg.mod_sim_exp_core
 
generic map(
 
  C_NR_BITS_TOTAL   => C_NR_BITS_TOTAL,
 
  C_NR_STAGES_TOTAL => C_NR_STAGES_TOTAL,
 
  C_NR_STAGES_LOW   => C_NR_STAGES_LOW,
 
  C_SPLIT_PIPELINE  => C_SPLIT_PIPELINE
 
)
port map(
port map(
  clk   => clk,
  clk   => clk,
  reset => reset,
  reset => reset,
-- operand memory interface (plb shared memory)
-- operand memory interface (plb shared memory)
  write_enable => core_write_enable,
  write_enable => core_write_enable,

powered by: WebSVN 2.1.0

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