From 1b75dd9d7b30ae36187ca2422f7fcc15317c628a Mon Sep 17 00:00:00 2001 From: Yanghui Ou Date: Sun, 18 Jun 2023 22:12:31 -0700 Subject: [PATCH 1/7] Add a test case that breaks the test --- .../sim/test/DynamicSchedulePass_test.py | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/pymtl3/passes/sim/test/DynamicSchedulePass_test.py b/pymtl3/passes/sim/test/DynamicSchedulePass_test.py index 048d274e8..4eb64cd85 100644 --- a/pymtl3/passes/sim/test/DynamicSchedulePass_test.py +++ b/pymtl3/passes/sim/test/DynamicSchedulePass_test.py @@ -21,7 +21,6 @@ def _test_model( cls ): A.apply( GenDAGPass() ) A.apply( DynamicSchedulePass() ) A.apply( PrepareSimPass() ) - A.sim_reset() A.sim_eval_combinational() @@ -259,6 +258,39 @@ def construct( s ): return raise Exception("Should've thrown AssertionError") +def test_struct_with_list_field(): + + @bitstruct + class SomeMsg: + a: [ Bits8, Bits8 ] + b: [ Bits32, Bits32 ] + + class Top( Component ): + def construct( s ): + s.struct = Wire(SomeMsg) + s.a = Wire(32) + s.b = Wire(32) + + @update + def up_out(): + s.struct.a[0] @= 0 + s.struct.a[1] @= 1 + s.struct.b[0] @= 2 + s.struct.b[1] @= 3 + s.b @= s.a + 1 + + @update + def up_abcd(): + s.a @= s.struct.b[1] + 1 + + x = Top() + x.elaborate() + x.apply( GenDAGPass() ) + x.apply( DynamicSchedulePass() ) + x.apply( PrepareSimPass(print_line_trace=False) ) + x.sim_reset() + x.sim_tick() + def test_equal_top_level(): class A(Component): def construct( s ): From f7513e5aa832134ffa561323cde62d71205c861f Mon Sep 17 00:00:00 2001 From: "yo96@cornell.edu" Date: Sun, 18 Jun 2023 22:28:22 -0700 Subject: [PATCH 2/7] Attempt to fix the bug caused by bistrcut with list field. --- pymtl3/dsl/Connectable.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/pymtl3/dsl/Connectable.py b/pymtl3/dsl/Connectable.py index c996df266..d730a9697 100644 --- a/pymtl3/dsl/Connectable.py +++ b/pymtl3/dsl/Connectable.py @@ -213,10 +213,31 @@ def __getattr__( s, name ): xd.top_level_signal = sd.top_level_signal xd.elaborate_top = sd.elaborate_top - xd.my_name = name + "".join([ f"[{y}]" for y in indices ]) - xd.full_name = f"{sd.full_name}.{name}" - xd._my_name = name - xd._my_indices = indices + # @bitstruct + # class SomeMsg: + # a: [ Bits8, Bits8 ] + # b: Bits32 + # ... + # class A ( Component ): + # def construct( s ): + # s.struct_port = InPort( SomeMsg ) + # + # Then, the newly created ports representing field a should be + # suffixed with the index, i.e., the name should be + # s.struct_port.a[0], s.struct_port.a[1]. Without the if + # statement below, both ports would have the same name + # s.struct_port.a, which can cause errors in simulation. + if is_bitstruct_class(s._dsl.Type): + xd.my_name = name + "".join([ f"[{y}]" for y in indices ]) + xd.full_name = f"{sd.full_name}.{name}"+"".join([ f"[{y}]" for y in indices ]) + xd._my_name = name + xd._my_indices = indices + + else: + xd.my_name = name + "".join([ f"[{y}]" for y in indices ]) + xd.full_name = f"{sd.full_name}.{name}" + xd._my_name = name + xd._my_indices = indices if parent_is_list: parent.append( x ) From 895f5dfbb3ed4d9db024805596ddb7ea1c7dcac8 Mon Sep 17 00:00:00 2001 From: "yo96@cornell.edu" Date: Sun, 18 Jun 2023 22:29:39 -0700 Subject: [PATCH 3/7] Make sure the test is working --- .../passes/sim/test/DynamicSchedulePass_test.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pymtl3/passes/sim/test/DynamicSchedulePass_test.py b/pymtl3/passes/sim/test/DynamicSchedulePass_test.py index 4eb64cd85..900a5a1bd 100644 --- a/pymtl3/passes/sim/test/DynamicSchedulePass_test.py +++ b/pymtl3/passes/sim/test/DynamicSchedulePass_test.py @@ -283,13 +283,15 @@ def up_out(): def up_abcd(): s.a @= s.struct.b[1] + 1 - x = Top() - x.elaborate() - x.apply( GenDAGPass() ) - x.apply( DynamicSchedulePass() ) - x.apply( PrepareSimPass(print_line_trace=False) ) - x.sim_reset() - x.sim_tick() + dut = Top() + dut.elaborate() + dut.apply( GenDAGPass() ) + dut.apply( DynamicSchedulePass() ) + dut.apply( PrepareSimPass(print_line_trace=False) ) + dut.sim_reset() + dut.sim_tick() + assert dut.a == 4 + assert dut.b == 5 def test_equal_top_level(): class A(Component): From 1f755e1728a9e0354914fc012297da3b6a49d068 Mon Sep 17 00:00:00 2001 From: "yo96@cornell.edu" Date: Wed, 12 Jul 2023 21:42:58 -0700 Subject: [PATCH 4/7] Added more tests to test bistruct with list field type --- .../sim/test/DynamicSchedulePass_test.py | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/pymtl3/passes/sim/test/DynamicSchedulePass_test.py b/pymtl3/passes/sim/test/DynamicSchedulePass_test.py index 900a5a1bd..3e8641290 100644 --- a/pymtl3/passes/sim/test/DynamicSchedulePass_test.py +++ b/pymtl3/passes/sim/test/DynamicSchedulePass_test.py @@ -293,6 +293,110 @@ def up_abcd(): assert dut.a == 4 assert dut.b == 5 +def test_struct_with_nested_list_field(): + @bitstruct + class SomeMsgA: + a: [ Bits8, Bits8 ] + b: [ Bits32, Bits32 ] + + @bitstruct + class SomeMsgB: + msg_a: [ SomeMsgA, SomeMsgA ] + b: [ Bits32, Bits32 ] + + class Top( Component ): + def construct( s ): + s.struct = Wire(SomeMsgB) + s.a = Wire(32) + s.b = Wire(32) + + @update + def up_out(): + s.struct.msg_a[0].a[0] @= 1 + s.struct.msg_a[0].a[1] @= 2 + s.struct.msg_a[0].b[0] @= 3 + s.struct.msg_a[0].b[1] @= 4 + + s.struct.msg_a[1].a[0] @= 5 + s.struct.msg_a[1].a[1] @= 6 + s.struct.msg_a[1].b[0] @= 7 + s.struct.msg_a[1].b[1] @= 8 + + s.struct.b[0] @= 9 + s.struct.b[1] @= 10 + s.b @= s.a + 1 + + @update + def up_abcd(): + s.a @= s.struct.msg_a[1].b[1] + 1 + + dut = Top() + dut.elaborate() + dut.apply( GenDAGPass() ) + dut.apply( DynamicSchedulePass() ) + dut.apply( PrepareSimPass(print_line_trace=False) ) + dut.sim_reset() + dut.sim_tick() + assert dut.a == 9 + assert dut.b == 10 + +def test_list_struct_port_with_nested_list_field(): + @bitstruct + class SomeMsgA: + a: [ Bits8, Bits8 ] + b: [ Bits32, Bits32 ] + + @bitstruct + class SomeMsgB: + msg_a: [ SomeMsgA, SomeMsgA ] + b: [ Bits32, Bits32 ] + + class Top( Component ): + def construct( s ): + s.struct = [ Wire(SomeMsgB) for _ in range(2) ] + s.a = Wire(32) + s.b = Wire(32) + + @update + def up_out(): + s.struct[0].msg_a[0].a[0] @= 1 + s.struct[0].msg_a[0].a[1] @= 2 + s.struct[0].msg_a[0].b[0] @= 3 + s.struct[0].msg_a[0].b[1] @= 4 + s.struct[0].msg_a[1].a[0] @= 5 + s.struct[0].msg_a[1].a[1] @= 6 + s.struct[0].msg_a[1].b[0] @= 7 + s.struct[0].msg_a[1].b[1] @= 8 + s.struct[0].b[0] @= 9 + s.struct[0].b[1] @= 10 + + s.struct[1].msg_a[0].a[0] @= 11 + s.struct[1].msg_a[0].a[1] @= 12 + s.struct[1].msg_a[0].b[0] @= 13 + s.struct[1].msg_a[0].b[1] @= 14 + s.struct[1].msg_a[1].a[0] @= 15 + s.struct[1].msg_a[1].a[1] @= 16 + s.struct[1].msg_a[1].b[0] @= 17 + s.struct[1].msg_a[1].b[1] @= 18 + s.struct[1].b[0] @= 19 + s.struct[1].b[1] @= 20 + + s.b @= s.a + 1 + + @update + def up_abcd(): + s.a @= s.struct[0].msg_a[1].b[1] + s.struct[1].msg_a[0].b[0] + + dut = Top() + dut.elaborate() + dut.apply( GenDAGPass() ) + dut.apply( DynamicSchedulePass() ) + dut.apply( PrepareSimPass(print_line_trace=False) ) + dut.sim_reset() + dut.sim_tick() + assert dut.a == 21 + assert dut.b == 22 + def test_equal_top_level(): class A(Component): def construct( s ): From 2a32d0346fde68b2c0d99b3e0af66b182a44e0c2 Mon Sep 17 00:00:00 2001 From: pp482 Date: Thu, 2 Nov 2023 15:09:57 -0400 Subject: [PATCH 5/7] [version] Bump minor version number --- pymtl3/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pymtl3/version.py b/pymtl3/version.py index 72f67f385..1ac6974f9 100644 --- a/pymtl3/version.py +++ b/pymtl3/version.py @@ -1 +1 @@ -__version__ = "3.1.14" +__version__ = "3.1.15" From b00515f9f30159e9580dda894460827f94635451 Mon Sep 17 00:00:00 2001 From: pp482 Date: Thu, 2 Nov 2023 15:16:05 -0400 Subject: [PATCH 6/7] [github-actions] Specify last python 3.6 and 3.7 version --- .github/workflows/python-package-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/python-package-ci.yml b/.github/workflows/python-package-ci.yml index ad45b3327..f6c06b89f 100644 --- a/.github/workflows/python-package-ci.yml +++ b/.github/workflows/python-package-ci.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [ 3.6, 3.7, 3.8, 3.9 ] # FIXME github recognizes 3.10 as 3.1 lol + python-version: [ 3.6.15, 3.7.17, 3.8, 3.9 ] # FIXME github recognizes 3.10 as 3.1 lol steps: - uses: actions/checkout@v2 From 4e7bd7b5a8f3b4b91f4bfffe9112019f6adba92a Mon Sep 17 00:00:00 2001 From: pp482 Date: Thu, 2 Nov 2023 15:25:03 -0400 Subject: [PATCH 7/7] [github-actions] Use ubuntu-20.04 for Python 3.6 and 3.7 --- .github/workflows/python-package-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package-ci.yml b/.github/workflows/python-package-ci.yml index f6c06b89f..f15786f36 100644 --- a/.github/workflows/python-package-ci.yml +++ b/.github/workflows/python-package-ci.yml @@ -11,11 +11,19 @@ on: jobs: build: - runs-on: ubuntu-latest + # The latest ubuntu release may exclude Python versions that have reached + # the end of life. An example of this is the upgrade from ubuntu-20.04 to + # ubuntu-22.04: support for Python 3.6.* and 3.7.* has been dropped and + # this broke our Github actions. We should periodically revisit this to + # make sure PyMTL works on the latest ubuntu LTS release. As of now I'm + # targeting ubuntu-20.04 because lots of PyMTL users still work with + # Python 3.6 and 3.7. + # runs-on: ubuntu-latest + runs-on: ubuntu-20.04 strategy: fail-fast: false matrix: - python-version: [ 3.6.15, 3.7.17, 3.8, 3.9 ] # FIXME github recognizes 3.10 as 3.1 lol + python-version: [ 3.6, 3.7, 3.8, 3.9 ] # FIXME github recognizes 3.10 as 3.1 lol steps: - uses: actions/checkout@v2