From 128b1309a1cedc857049a4d063e82c1ca4ecd10c Mon Sep 17 00:00:00 2001 From: Vojta Mrazek Date: Fri, 5 Apr 2024 09:24:03 +0200 Subject: [PATCH 1/4] popcount fixes --- ariths_gen/multi_bit_circuits/others/popcount.py | 4 ++-- tests/test_popcnt.py | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ariths_gen/multi_bit_circuits/others/popcount.py b/ariths_gen/multi_bit_circuits/others/popcount.py index 04fcda3..4721bce 100644 --- a/ariths_gen/multi_bit_circuits/others/popcount.py +++ b/ariths_gen/multi_bit_circuits/others/popcount.py @@ -1,7 +1,7 @@ """ """ -from typing import Union +from typing import Union, Optional from ariths_gen.wire_components import ( Wire, @@ -45,7 +45,7 @@ class UnsignedPopCount(GeneralCircuit): """ - def __init__(self, a: Bus, adder : Union[ArithmeticCircuit, None] = None, prefix : str = "", name : str = "popcnt", **kwargs): + def __init__(self, a: Bus, adder : Optional[ArithmeticCircuit] = None, prefix : str = "", name : str = "popcnt", **kwargs): self.N = a.N self.a = a diff --git a/tests/test_popcnt.py b/tests/test_popcnt.py index 52de63f..a877254 100644 --- a/tests/test_popcnt.py +++ b/tests/test_popcnt.py @@ -1,3 +1,4 @@ +from io import StringIO from ariths_gen.core.cgp_circuit import UnsignedCGPCircuit from ariths_gen.wire_components import ( Wire, @@ -11,6 +12,7 @@ from ariths_gen.core.arithmetic_circuits import GeneralCircuit from ariths_gen.multi_bit_circuits.others import ( UnsignedPopCount ) +import numpy as np def test_popcount(): From 77724ad115800497e1934ef9c9494dae6b6de0e7 Mon Sep 17 00:00:00 2001 From: Vojta Mrazek Date: Fri, 5 Apr 2024 11:21:42 +0200 Subject: [PATCH 2/4] workflow update --- .github/workflows/generate.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index fd8347c..0b9cde1 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -17,7 +17,7 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.x uses: actions/setup-python@v4 with: @@ -44,11 +44,11 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install iverilog run: sudo apt install iverilog - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Semantic version range syntax or exact version of a Python version python-version: '3.x' @@ -90,9 +90,9 @@ jobs: python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ] name: Python ${{ matrix.python-version }} test steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} architecture: x64 @@ -107,9 +107,9 @@ jobs: needs: test if: github.ref == 'refs/heads/main' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Semantic version range syntax or exact version of a Python version python-version: '3.x' @@ -123,7 +123,7 @@ jobs: - name: Generate documentation run: pdoc --html ariths_gen - name: Upload results - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: documentation path: html From 84a41ad93c5b62e9bf240b52211645ef34e18930 Mon Sep 17 00:00:00 2001 From: Vojta Mrazek Date: Fri, 5 Apr 2024 11:25:37 +0200 Subject: [PATCH 3/4] test unique #21 --- tests/test_all.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_all.py b/tests/test_all.py index bcd9342..5a22005 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -381,6 +381,25 @@ def test_wire_as_bus(): assert r.sum() == 1 assert r[-1, -1, -1] == 1 +def test_unique(): + from ariths_gen.wire_components import Wire, Bus + import pytest + import sys + from ariths_gen.one_bit_circuits.logic_gates import AndGate + from ariths_gen.one_bit_circuits.one_bit_components import TwoOneMultiplexer + from ariths_gen.core.arithmetic_circuits import GeneralCircuit + + class test_circuit(GeneralCircuit): + def __init__(self, a: Bus, prefix="test_circuit", **kwargs): + super().__init__(prefix=prefix, name="test_circuit", inputs=[a], out_N=1, **kwargs) + g = self.add_component(AndGate(a[0], a[1], prefix="g2")) + g2 = self.add_component(AndGate(g.out, a[2], prefix="g2")) + g3 = self.add_component(AndGate(g2.out, g.out, prefix="g2")) + self.out[0] = g3.out + + with pytest.raises(AssertionError): + circ = test_circuit(Bus("a", 3), "c1") + circ.get_v_code_flat(file_object=sys.stdout) if __name__ == "__main__": test_unsigned_approxmul() From 0180735dd5de522843378b5b0cc9aca4dc8f522d Mon Sep 17 00:00:00 2001 From: Vojta Mrazek Date: Fri, 5 Apr 2024 11:27:41 +0200 Subject: [PATCH 4/4] workflow to node.js 20 --- .github/workflows/generate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index 0b9cde1..e1b6530 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Set up Python 3.x - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: # Semantic version range syntax or exact version of a Python version python-version: '3.x'