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 24 and 37

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

Rev 24 Rev 37
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 nr_stages  : integer := 96;
 
  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";
Line 253... Line 252...
        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 1536 => when 1024 => when 512 =>
          when 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 330... Line 329...
        ----------------------------------------
        ----------------------------------------
        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 1536 =>  core_p_sel <= "11"; write(Lw, string'("  Full pipeline selected"));
          when nr_bits_total =>  core_p_sel <= "11"; write(Lw, string'("  Full pipeline selected"));
          when 1024 =>  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 512  =>  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 425... Line 424...
        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+(2*(base_width-1)))*clk_period);
        write(Lw, (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 458... Line 457...
        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+(2*(base_width-1)))*clk_period);
        write(Lw, (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 491... Line 490...
        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+(2*(base_width-1)))*clk_period);
        write(Lw, (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 524... Line 523...
        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+(2*(base_width-1)))*clk_period);
        write(Lw, (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 570... Line 569...
        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+(2*(base_width-1)))*clk_period*7*exponent_width)/4);
        write(Lw, ((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 611... Line 610...
        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+(2*(base_width-1)))*clk_period);
        write(Lw, (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;

powered by: WebSVN 2.1.0

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