Skip to content

Commit

Permalink
Minimize imports in an effort to lower simulation setup time
Browse files Browse the repository at this point in the history
These changes represent a 21% reduction of execution time for the 460 test cases in hdl-modules repo: https://github.com/hdl-modules/hdl-modules
For some small testbenches, the reduction is as much as 42%.
Note that this repo contains only small to medium sized testbenches (1-10 seconds, with most around 1-4 seconds).

This is all using the GHDL simulator with GCC backend on Linux. With ModelSim Intel FPGA starter edition 2020.1, the reductions is negligible (1-2%).

This change:

1. Stop using "context" in all VUnit packages.
   In most packages, importing with context includes a lot more than what is actually used.

2. Stop using "use work.x_pkg.all" in cases where only 1-3 things are used from the package.
   Instead, one explicit "use" clause for the things that are actually used.

   * Not done for the most common packages (run_pkg, check_pkg, logger_pkg).

   * Not done for includes from very small packages.

3. For packages that have head and body in different files, move all imports to the head file.
   As they were, split between the files, there was a lot of overlap of imports, and it what hard to get an overview of what is actually imported and what is actually used.

The first point represents roughly 80% of the performance gain.

Note that in order to reach the performance gains listed above, the corresponding changes have to be made to all testbenches and simulation code in the user repo also.
If the testbench includes "vunit_context", "com_context" etc, the performance gains will not be realized since everything will be imported anyway.
  • Loading branch information
LukasVik authored and LarsAsplund committed Mar 4, 2024
1 parent a52fd21 commit 594a2c0
Show file tree
Hide file tree
Showing 70 changed files with 279 additions and 287 deletions.
9 changes: 0 additions & 9 deletions vunit/vhdl/check/src/check.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use std.textio.all;
use work.checker_pkg.all;
use work.string_ops.all;
use work.location_pkg.all;
use work.integer_vector_ptr_pkg.all;

package body check_pkg is
type boolean_vector is array (natural range <>) of boolean;

Expand Down
8 changes: 6 additions & 2 deletions vunit/vhdl/check/src/check_api.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

use std.textio.all;

use work.checker_pkg.all;
use work.logger_pkg.all;
use work.event_common_pkg.any_event_t;
use work.event_common_pkg.notify;
use work.integer_vector_ptr_pkg.all;
use work.log_levels_pkg.all;
use work.logger_pkg.logger_t;
use work.string_ops.all;
use work.event_common_pkg.all;
use work.string_ptr_pkg.all;

package check_pkg is
Expand Down
14 changes: 4 additions & 10 deletions vunit/vhdl/com/src/com.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@
library ieee;
use ieee.std_logic_1164.all;

context work.vunit_context;

use work.queue_pkg.all;
use work.queue_2008p_pkg.all;
use work.queue_pool_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.string_ptr_pkg.all;
use work.codec_pkg.all;
use work.com_support_pkg.all;
use work.com_messenger_pkg.all;
use work.com_common_pkg.all;
use work.com_messenger_pkg.all;
use work.com_support_pkg.all;
use work.logger_pkg.all;
use work.queue_pkg.all;
use work.queue_pool_pkg.all;

use std.textio.all;

Expand Down
8 changes: 3 additions & 5 deletions vunit/vhdl/com/src/com_api.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ library ieee;
use ieee.std_logic_1164.all;

use work.com_types_pkg.all;
use work.queue_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.string_ptr_pkg.all;
use work.id_pkg.all;
use work.event_private_pkg.all;
use work.id_pkg.id_t;
use work.event_private_pkg.new_basic_event;
use work.event_private_pkg.com_net_event;

package com_pkg is
-- Global predefined network. See network_t description in com_types.vhd for
Expand Down
9 changes: 5 additions & 4 deletions vunit/vhdl/com/src/com_common.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
library ieee;
use ieee.std_logic_1164.all;

use work.com_messenger_pkg.all;
use work.com_types_pkg.all;
use work.event_common_pkg.all;
use work.event_private_pkg.all;
use work.com_messenger_pkg.messenger_t;
use work.com_types_pkg.com_status_t;
use work.event_common_pkg.notify;
use work.event_common_pkg.is_active;
use work.event_private_pkg.basic_event_t;

package com_common_pkg is
shared variable messenger : messenger_t;
Expand Down
5 changes: 2 additions & 3 deletions vunit/vhdl/com/src/com_debug_codec_builder.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

library vunit_lib;
context vunit_lib.vunit_context;

use std.textio.all;

use work.string_ops.all;

package com_debug_codec_builder_pkg is
-----------------------------------------------------------------------------
-- Encoding support
Expand Down
1 change: 0 additions & 1 deletion vunit/vhdl/com/src/com_messenger.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use work.com_support_pkg.all;
use work.queue_pkg.all;
use work.queue_pool_pkg.all;
use work.string_ptr_pkg.all;
use work.codec_pkg.all;
use work.logger_pkg.all;
use work.log_levels_pkg.all;
use work.id_pkg.all;
Expand Down
3 changes: 2 additions & 1 deletion vunit/vhdl/com/src/com_support.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

context work.vunit_context;
use work.com_types_pkg.all;
use work.logger_pkg.all;
use work.string_ops.all;

package com_support_pkg is

Expand Down
2 changes: 1 addition & 1 deletion vunit/vhdl/com/src/com_types.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use work.queue_pkg.all;
use work.queue_2008p_pkg.all;
use work.queue_pool_pkg.all;
use work.dict_pkg.all;
use work.event_private_pkg.all;
use work.event_private_pkg.basic_event_t;

package com_types_pkg is

Expand Down
1 change: 1 addition & 0 deletions vunit/vhdl/core/src/core_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use std.textio.all;

use work.stop_pkg;
use work.integer_vector_ptr_pkg.all;
use work.string_ptr_pkg.all;
Expand Down
14 changes: 0 additions & 14 deletions vunit/vhdl/data_types/src/dict_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,6 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

library ieee;
use ieee.std_logic_1164.all;
use ieee.math_complex.all;
use ieee.numeric_bit.all;
use ieee.numeric_std.all;

use work.string_ptr_pkg.all;
use work.string_ptr_pool_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.integer_vector_ptr_pool_pkg.all;
use work.codec_pkg.all;
use work.data_types_private_pkg.all;
use work.queue_pkg.all;

package body dict_pkg is
constant int_pool : integer_vector_ptr_pool_t := new_integer_vector_ptr_pool;
constant str_pool : string_ptr_pool_t := new_string_ptr_pool;
Expand Down
11 changes: 5 additions & 6 deletions vunit/vhdl/data_types/src/dict_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ use ieee.math_complex.all;
use ieee.numeric_bit.all;
use ieee.numeric_std.all;

use work.string_ptr_pkg.all;
use work.string_ptr_pool_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.integer_vector_ptr_pool_pkg.all;
use work.codec_pkg.all;
use work.data_types_private_pkg.all;
use work.queue_pkg.all;
use work.integer_array_pkg.all;
use work.byte_vector_ptr_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.integer_vector_ptr_pool_pkg.all;
use work.queue_pkg.all;
use work.string_ptr_pkg.all;
use work.string_ptr_pool_pkg.all;

package dict_pkg is
type dict_t is record
Expand Down
4 changes: 0 additions & 4 deletions vunit/vhdl/data_types/src/integer_array_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use std.textio.all;
use work.codec_pkg.all;
use work.codec_builder_pkg.all;

package body integer_array_pkg is
type binary_file_t is file of character;

Expand Down
4 changes: 4 additions & 0 deletions vunit/vhdl/data_types/src/integer_array_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use std.textio.all;

use work.codec_builder_pkg.all;
use work.codec_pkg.all;
use work.integer_vector_ptr_pkg.all;

package integer_array_pkg is
Expand Down
7 changes: 3 additions & 4 deletions vunit/vhdl/data_types/src/integer_vector_ptr_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
-- into a singleton datastructure of integer vector access types.
--

use work.types_pkg.all;
use work.external_integer_vector_pkg.all;

use work.codec_pkg.all;
use work.codec_builder_pkg.all;
use work.codec_pkg.all;
use work.external_integer_vector_pkg.all;
use work.types_pkg.all;

package integer_vector_ptr_pkg is

Expand Down
1 change: 0 additions & 1 deletion vunit/vhdl/data_types/src/integer_vector_ptr_pool_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ library ieee;
use ieee.std_logic_1164.all;

use work.integer_vector_ptr_pkg.all;
use work.queue_pkg.all;

package integer_vector_ptr_pool_pkg is
type integer_vector_ptr_pool_t is record
Expand Down
3 changes: 1 addition & 2 deletions vunit/vhdl/data_types/src/queue_pkg-2008p.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ library ieee;
use ieee.fixed_pkg.all;
use ieee.float_pkg.all;

use work.queue_pkg.all;
use work.codec_2008p_pkg.all;
use work.codec_builder_2008p_pkg.all;
use work.data_types_private_pkg.all;
use work.queue_pkg.all;

package queue_2008p_pkg is
procedure push (
Expand Down
6 changes: 0 additions & 6 deletions vunit/vhdl/data_types/src/queue_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

library ieee;
use ieee.math_real.all;
use ieee.math_complex.all;
use work.codec_pkg.all;
use work.codec_builder_pkg.all;

package body queue_pkg is
constant tail_idx : natural := 0;
constant head_idx : natural := 1;
Expand Down
11 changes: 8 additions & 3 deletions vunit/vhdl/data_types/src/queue_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,19 @@
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

library ieee;
use ieee.std_logic_1164.all;
use ieee.math_complex.all;
use ieee.math_real.all;
use ieee.numeric_bit.all;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;

use work.codec_builder_pkg.all;
use work.codec_pkg.all;
use work.data_types_private_pkg.all;
use work.integer_array_pkg.integer_array_t;
use work.integer_array_pkg.null_integer_array;
use work.integer_vector_ptr_pkg.all;
use work.string_ptr_pkg.all;
use work.integer_array_pkg.all;
use work.data_types_private_pkg.all;

package queue_pkg is
type queue_t is record
Expand Down
6 changes: 3 additions & 3 deletions vunit/vhdl/data_types/src/string_ptr_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
--

use work.types_pkg.all;
use work.codec_builder_pkg.decode;
use work.codec_builder_pkg.integer_code_length;
use work.codec_pkg.encode;
use work.external_string_pkg.all;

use work.codec_pkg.all;
use work.codec_builder_pkg.all;

package string_ptr_pkg is

type string_ptr_t is record
Expand Down
1 change: 0 additions & 1 deletion vunit/vhdl/data_types/src/string_ptr_pool_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ library ieee;
use ieee.std_logic_1164.all;

use work.string_ptr_pkg.all;
use work.queue_pkg.all;
use work.integer_vector_ptr_pkg.all;

package string_ptr_pool_pkg is
Expand Down
3 changes: 2 additions & 1 deletion vunit/vhdl/dictionary/src/dictionary.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use std.textio.all;

use work.string_ops.all;
use work.logger_pkg.all;
use std.textio.all;

package dictionary is
subtype frozen_dictionary_t is string;
Expand Down
4 changes: 0 additions & 4 deletions vunit/vhdl/logging/src/common_log_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use work.ansi_pkg.all;
use work.log_levels_pkg.all;
use work.string_ops.upper;

package body common_log_pkg is
constant is_original_pkg : boolean := true;

Expand Down
4 changes: 4 additions & 0 deletions vunit/vhdl/logging/src/common_log_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

use std.textio.all;

use work.ansi_pkg.all;
use work.log_levels_pkg.all;
use work.string_ops.upper;

package common_log_pkg is
-- Deferred constant set to true in the native implementation of the package.
-- Must be set to false in alternative implementations.
Expand Down
1 change: 1 addition & 0 deletions vunit/vhdl/logging/src/file_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use std.textio.all;

use work.integer_vector_ptr_pkg.all;
use work.string_ptr_pkg.all;
use work.common_log_pkg.all;
Expand Down
11 changes: 0 additions & 11 deletions vunit/vhdl/logging/src/log_handler_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use std.textio.all;

library vunit_lib;
use vunit_lib.string_ptr_pkg.all;
use vunit_lib.integer_vector_ptr_pkg.all;

use work.ansi_pkg.all;
use work.string_ops.upper;
use work.file_pkg.all;
use work.common_log_pkg.all;

package body log_handler_pkg is

constant display_handler_id_number : natural := 0;
Expand Down
7 changes: 7 additions & 0 deletions vunit/vhdl/logging/src/log_handler_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use std.textio.all;

use work.ansi_pkg.all;
use work.common_log_pkg.all;
use work.file_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.log_levels_pkg.all;
use work.string_ops.upper;
use work.string_ptr_pkg.all;

package log_handler_pkg is
type deprecated_log_format_t is (
Expand Down
4 changes: 0 additions & 4 deletions vunit/vhdl/logging/src/log_levels_pkg-body.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use work.string_ptr_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.core_pkg.all;

package body log_levels_pkg is

type levels_t is record
Expand Down
4 changes: 3 additions & 1 deletion vunit/vhdl/logging/src/log_levels_pkg.vhd
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
--
-- Copyright (c) 2014-2024, Lars Asplund lars.anders.asplund@gmail.com

use work.string_ptr_pkg.all;
use work.ansi_pkg.all;
use work.core_pkg.all;
use work.integer_vector_ptr_pkg.all;
use work.string_ptr_pkg.all;

package log_levels_pkg is

Expand Down
Loading

0 comments on commit 594a2c0

Please sign in to comment.