commit
211dd49fb5
18
.github/workflows/generate.yml
vendored
18
.github/workflows/generate.yml
vendored
@ -17,9 +17,9 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python 3.x
|
- name: Set up Python 3.x
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
# Semantic version range syntax or exact version of a Python version
|
# Semantic version range syntax or exact version of a Python version
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
@ -44,11 +44,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: build
|
needs: build
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Install iverilog
|
- name: Install iverilog
|
||||||
run: sudo apt install iverilog
|
run: sudo apt install iverilog
|
||||||
- name: Set up Python 3.x
|
- name: Set up Python 3.x
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
# Semantic version range syntax or exact version of a Python version
|
# Semantic version range syntax or exact version of a Python version
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
@ -90,9 +90,9 @@ jobs:
|
|||||||
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
|
python-version: [ '3.7', '3.8', '3.9', '3.10', '3.11' ]
|
||||||
name: Python ${{ matrix.python-version }} test
|
name: Python ${{ matrix.python-version }} test
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Setup python
|
- name: Setup python
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
architecture: x64
|
architecture: x64
|
||||||
@ -107,9 +107,9 @@ jobs:
|
|||||||
needs: test
|
needs: test
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python 3.x
|
- name: Set up Python 3.x
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
# Semantic version range syntax or exact version of a Python version
|
# Semantic version range syntax or exact version of a Python version
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
@ -123,7 +123,7 @@ jobs:
|
|||||||
- name: Generate documentation
|
- name: Generate documentation
|
||||||
run: pdoc --html ariths_gen
|
run: pdoc --html ariths_gen
|
||||||
- name: Upload results
|
- name: Upload results
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: documentation
|
name: documentation
|
||||||
path: html
|
path: html
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from typing import Union
|
from typing import Union, Optional
|
||||||
|
|
||||||
from ariths_gen.wire_components import (
|
from ariths_gen.wire_components import (
|
||||||
Wire,
|
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.N = a.N
|
||||||
self.a = a
|
self.a = a
|
||||||
|
|
||||||
|
@ -381,6 +381,25 @@ def test_wire_as_bus():
|
|||||||
assert r.sum() == 1
|
assert r.sum() == 1
|
||||||
assert r[-1, -1, -1] == 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__":
|
if __name__ == "__main__":
|
||||||
test_unsigned_approxmul()
|
test_unsigned_approxmul()
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from io import StringIO
|
||||||
from ariths_gen.core.cgp_circuit import UnsignedCGPCircuit
|
from ariths_gen.core.cgp_circuit import UnsignedCGPCircuit
|
||||||
from ariths_gen.wire_components import (
|
from ariths_gen.wire_components import (
|
||||||
Wire,
|
Wire,
|
||||||
@ -11,6 +12,7 @@ from ariths_gen.core.arithmetic_circuits import GeneralCircuit
|
|||||||
from ariths_gen.multi_bit_circuits.others import (
|
from ariths_gen.multi_bit_circuits.others import (
|
||||||
UnsignedPopCount
|
UnsignedPopCount
|
||||||
)
|
)
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def test_popcount():
|
def test_popcount():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user