Skip to content

Commit 55f25d9

Browse files
Lars AsplundLarsAsplund
authored andcommitted
Fixes #95. Bug in parsing of the used_packages input to generate_codecs function.
1 parent 05f534d commit 55f25d9

5 files changed

Lines changed: 30 additions & 5 deletions

File tree

vunit/com/codec_generator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def generate_codecs(input_package_design_unit, codec_package_name, # pylint: di
3838
if '.' in used_package:
3939
if used_package.split('.')[0] not in libraries:
4040
libraries.append(used_package.split('.')[0])
41-
use_clauses += 'use %s.all;\n' % used_package
42-
else:
43-
use_clauses += 'use work.%s.all;\n' % used_package
41+
use_clauses += 'use %s.all;\n' % used_package
42+
else:
43+
use_clauses += 'use work.%s.all;\n' % used_package
4444
if len(libraries) != 0:
4545
use_clauses = 'library ' + ';\nlibrary '.join(libraries) + ';\n' + use_clauses
4646

vunit/vhdl/com/run.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
tb_com_lib = ui.add_library("tb_com_lib")
1515
tb_com_lib.add_source_files(join(root, 'test', '*.vhd'))
1616
pkg = tb_com_lib.package('custom_types_pkg')
17-
pkg.generate_codecs(codec_package_name='custom_codec_pkg', used_packages=['ieee.std_logic_1164'])
17+
pkg.generate_codecs(codec_package_name='custom_codec_pkg', used_packages=['ieee.std_logic_1164', 'constants_pkg', 'tb_com_lib.more_constants_pkg'])
1818
ui.main()

vunit/vhdl/com/test/constants.vhd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Test suite for com codec package
2+
--
3+
-- This Source Code Form is subject to the terms of the Mozilla Public
4+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
5+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
6+
--
7+
-- Copyright (c) 2015, Lars Asplund lars.anders.asplund@gmail.com
8+
9+
package constants_pkg is
10+
constant byte_msb_c : natural := 7;
11+
end package constants_pkg;

vunit/vhdl/com/test/custom_types.vhd

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ use ieee.float_pkg.all;
2020

2121
use std.textio.all;
2222

23+
use work.constants_pkg.all;
24+
use work.more_constants_pkg.all;
25+
2326
package custom_types_pkg is
2427
type enum1_t is (red, green, blue);
2528

@@ -86,7 +89,7 @@ package custom_types_pkg is
8689
type record9_msg_type_t is (foo, bar);
8790
type record9_t is record
8891
msg_type : record9_msg_type_t;
89-
slv : std_logic_vector(7 downto 0);
92+
slv : std_logic_vector(byte_msb_c downto byte_lsb_c);
9093
str : string(1 to 3);
9194
int_2d : int_2d_t(1 to 2, 4 downto -1);
9295
end record record9_t;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- Test suite for com codec package
2+
--
3+
-- This Source Code Form is subject to the terms of the Mozilla Public
4+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
5+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
6+
--
7+
-- Copyright (c) 2015, Lars Asplund lars.anders.asplund@gmail.com
8+
9+
package more_constants_pkg is
10+
constant byte_lsb_c : natural := 0;
11+
end package more_constants_pkg;

0 commit comments

Comments
 (0)