Arithmetic
Adder4
__init__
__init__(
carry_in,
a_bus,
b_bus,
carry_out,
sum_bus
)
Construct a new 4-bit adder.
Args:
carry_in
: An object of typeWire
. The carry-in to the adder.a_bus
: An object of typeBus4
. The first addend.a_bus[0]
anda_bus[3]
are the most and least significant bit, respectively.b_bus
: An object of typeBus4
. The second addend.b_bus[0]
andb_bus[3]
are the most and least significant bit, respectively.carry_out
: An object of typeWire
. The carry-out of the adder.sum_bus
: An object of typeBus4
. The sum of the two addends.sum_bus[0]
andsum_bus[3]
are the most and least significant bit, respectively.
Raises:
TypeError
: If eithera_bus
,b_bus
, orsum_bus
is not a bus of width 4.
__str__
Print out the wire values of the 4-bit adder.
carry_in: 0
a_bus: (0, 0, 0, 0)
b_bus: (0, 0, 0, 0)
carry_out: 0
sum_bus: (0, 0, 0, 0)
__call__
__call__(
carry_in=None,
a_bus=None,
b_bus=None,
carry_out=None,
sum_bus=None
)
Force specific values on the wires of the 4-bit adder.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
Adder8
__init__
__init__(
carry_in,
a_bus,
b_bus,
carry_out,
sum_bus
)
Construct a new 8-bit adder.
Args:
carry_in
: An object of typeWire
. The carry-in to the adder.a_bus
: An object of typeBus8
. The first addend.a_bus[0]
anda_bus[7]
are the most and least significant bit, respectively.b_bus
: An object of typeBus8
. The second addend.b_bus[0]
andb_bus[7]
are the most and least significant bit, respectively.carry_out
: An object of typeWire
. The carry-out of the adder.sum_bus
: An object of typeBus8
. The sum of the two addends.sum_bus[0]
andsum_bus[7]
are the most and least significant bit, respectively.
Raises:
TypeError
: If eithera_bus
,b_bus
, orsum_bus
is not a bus of width 8.
__str__
Print out the wire values of the 8-bit adder.
carry_in: 0
a_bus: (0, 0, 0, 0, 0, 0, 0, 0)
b_bus: (0, 0, 0, 0, 0, 0, 0, 0)
carry_out: 0
sum_bus: (0, 0, 0, 0, 0, 0, 0, 0)
__call__
__call__(
carry_in=None,
a_bus=None,
b_bus=None,
carry_out=None,
sum_bus=None
)
Force specific values on the wires of the 8-bit adder.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
Adder16
__init__
__init__(
carry_in,
a_bus,
b_bus,
carry_out,
sum_bus
)
Construct a new 16-bit adder.
Args:
carry_in
: An object of typeWire
. The carry-in to the adder.a_bus
: An object of typeBus16
. The first addend.a_bus[0]
anda_bus[15]
are the most and least significant bit, respectively.b_bus
: An object of typeBus16
. The second addend.b_bus[0]
andb_bus[15]
are the most and least significant bit, respectively.carry_out
: An object of typeWire
. The carry-out of the adder.sum_bus
: An object of typeBus16
. The sum of the two addends.sum_bus[0]
andsum_bus[15]
are the most and least significant bit, respectively.
Raises:
TypeError
: If eithera_bus
,b_bus
, orsum_bus
is not a bus of width 16.
__str__
Print out the wire values of the 16-bit adder.
carry_in: 0
a_bus: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
b_bus: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
carry_out: 0
sum_bus: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
__call__
__call__(
carry_in=None,
a_bus=None,
b_bus=None,
carry_out=None,
sum_bus=None
)
Force specific values on the wires of the 16-bit adder.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
AdderSubtractor4
Class bw.arithmetic.AdderSubtractor4
Defined in bitwise/arithmetic/ADD_SUB.py.
4-bit adder-subtractor.
__init__
__init__(
add_subtract,
a_bus,
b_bus,
overflow,
carry_out,
sum_bus
)
Construct a new 4-bit adder-subtractor.
Args:
add_subtract
: An object of typeWire
. Indicates the operation to carry out - 0 for addition, 1 for subtraction.a_bus
: An object of typeBus4
. The first addend, or the minuend.a_bus[0]
anda_bus[3]
are the most and least significant bit, respectively.a_bus[0]
is the sign bit in subtraction operations.b_bus
: An object of typeBus4
. The second addend, or the subtrahend.b_bus[0]
andb_bus[3]
are the most and least significant bit, respectively.b_bus[0]
is the sign bit in subtraction operations.overflow
: An object of typeWire
. The overflow indicator of the subtractor.carry_out
: An object of typeWire
. The carry-out of the adder.sum_bus
: An object of typeBus4
. The sum of the two addends, or the difference between the minuend and the subtrahend.sum_bus[0]
andsum_bus[3]
are the most and least significant bit, respectively.sum_bus[0]
is the sign bit in subtraction operations.
Raises:
TypeError
: If eithera_bus
,b_bus
, orsum_bus
is not a bus of width 4.
__str__
Print out the wire values of the 4-bit adder-subtractor.
add_subtract: 0
a_bus: (0, 0, 0, 0)
b_bus: (0, 0, 0, 0)
overflow: 0
carry_out: 0
sum_bus: (0, 0, 0, 0)
__call__
__call__(
add_subtract=None,
a_bus=None,
b_bus=None,
overflow=None,
carry_out=None,
sum_bus=None
)
Force specific values on the wires of the 4-bit adder-subtractor.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
AdderSubtractor8
Class bw.arithmetic.AdderSubtractor8
Defined in bitwise/arithmetic/ADD_SUB.py.
8-bit adder-subtractor.
__init__
__init__(
add_subtract,
a_bus,
b_bus,
overflow,
carry_out,
sum_bus
)
Construct a new 8-bit adder-subtractor.
Args:
add_subtract
: An object of typeWire
. Indicates the operation to carry out - 0 for addition, 1 for subtraction.a_bus
: An object of typeBus8
. The first addend, or the minuend.a_bus[0]
anda_bus[7]
are the most and least significant bit, respectively.a_bus[0]
is the sign bit in subtraction operations.b_bus
: An object of typeBus8
. The second addend, or the subtrahend.b_bus[0]
andb_bus[7]
are the most and least significant bit, respectively.b_bus[0]
is the sign bit in subtraction operations.overflow
: An object of typeWire
. The overflow indicator of the subtractor.carry_out
: An object of typeWire
. The carry-out of the adder.sum_bus
: An object of typeBus8
. The sum of the two addends, or the difference between the minuend and the subtrahend.sum_bus[0]
andsum_bus[7]
are the most and least significant bit, respectively.sum_bus[0]
is the sign bit in subtraction operations.
Raises:
TypeError
: If eithera_bus
,b_bus
, orsum_bus
is not a bus of width 8.
__str__
Print out the wire values of the 8-bit adder-subtractor.
add_subtract: 0
a_bus: (0, 0, 0, 0, 0, 0, 0, 0)
b_bus: (0, 0, 0, 0, 0, 0, 0, 0)
overflow: 0
carry_out: 0
sum_bus: (0, 0, 0, 0, 0, 0, 0, 0)
__call__
__call__(
add_subtract=None,
a_bus=None,
b_bus=None,
overflow=None,
carry_out=None,
sum_bus=None
)
Force specific values on the wires of the 8-bit adder-subtractor.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
AdderSubtractor16
Class bw.arithmetic.AdderSubtractor16
Defined in bitwise/arithmetic/ADD_SUB.py.
16-bit adder-subtractor.
__init__
__init__(
add_subtract,
a_bus,
b_bus,
overflow,
carry_out,
sum_bus
)
Construct a new 16-bit adder-subtractor.
Args:
add_subtract
: An object of typeWire
. Indicates the operation to carry out - 0 for addition, 1 for subtraction.a_bus
: An object of typeBus16
. The first addend, or the minuend.a_bus[0]
anda_bus[15]
are the most and least significant bit, respectively.a_bus[0]
is the sign bit in subtraction operations.b_bus
: An object of typeBus16
. The second addend, or the subtrahend.b_bus[0]
andb_bus[15]
are the most and least significant bit, respectively.b_bus[0]
is the sign bit in subtraction operations.overflow
: An object of typeWire
. The overflow indicator of the subtractor.carry_out
: An object of typeWire
. The carry-out of the adder.sum_bus
: An object of typeBus16
. The sum of the two addends, or the difference between the minuend and the subtrahend.sum_bus[0]
andsum_bus[15]
are the most and least significant bit, respectively.sum_bus[0]
is the sign bit in subtraction operations.
Raises:
TypeError
: If eithera_bus
,b_bus
, orsum_bus
is not a bus of width 16.
__str__
Print out the wire values of the 16-bit adder-subtractor.
add_subtract: 0
a_bus: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
b_bus: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
overflow: 0
carry_out: 0
sum_bus: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
__call__
__call__(
add_subtract=None,
a_bus=None,
b_bus=None,
overflow=None,
carry_out=None,
sum_bus=None
)
Force specific values on the wires of the 16-bit adder-subtractor.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
FullAdder
__init__
__init__(
carry_in,
a,
b,
carry_out,
sum
)
Construct a new full adder.
Args:
carry_in
: An object of typeWire
. The carry-in to the adder.a
: An object of typeWire
. The first addend.b
: An object of typeWire
. The second addend.carry_out
: An object of typeWire
. The carry-out of the adder.sum
: An object of typeWire
. The sum of the two addends.
__str__
Print out the wire values of the full adder.
carry_in: 0
a: 0
b: 0
carry_out: 0
sum: 0
__call__
__call__(
carry_in=None,
a=None,
b=None,
carry_out=None,
sum=None
)
Force specific values on the wires of the full adder.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
HalfAdder
__init__
__init__(
a,
b,
carry_out,
sum
)
Construct a new half adder.
Args:
a
: An object of typeWire
. The first addend.b
: An object of typeWire
. The second addend.carry_out
: An object of typeWire
. The carry-out of the adder.sum
: An object of typeWire
. The sum of the two addends.
__str__
Print out the wire values of the half adder.
a: 0
b: 0
carry_out: 0
sum: 0
__call__
__call__(
a=None,
b=None,
carry_out=None,
sum=None
)
Force specific values on the wires of the half adder.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
Multiplier2
Class bw.arithmetic.Multiplier2
Defined in bitwise/arithmetic/MULT.py.
2-bit unsigned array multiplier.
__init__
__init__(
a_1,
a_2,
b_1,
b_2,
product_bus
)
Construct a new 2-bit unsigned multiplier.
Args:
a_1
: An object of typeWire
. The most significant bit of the multiplicand.a_2
: An object of typeWire
. The least significant bit of the multiplicand.b_1
: An object of typeWire
. The most significant bit of the multiplier.b_2
: An object of typeWire
. The least significant bit of the multiplier.product_bus
: An object of typeBus4
. The product.product_bus[0]
andproduct_bus[3]
are the most and least significant bit, respectively.
Raises:
TypeError
: Ifproduct_bus
is not a bus of width 4.
__str__
Print out the wire values of the 2-bit unsigned multiplier.
a_1: 0
a_2: 0
b_1: 0
b_2: 0
product_bus: (0, 0, 0, 0)
__call__
__call__(
a_1=None,
a_2=None,
b_1=None,
b_2=None,
product_bus=None
)
Force specific values on the wires of the 2-bit unsigned multiplier.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
Multiplier4
Class bw.arithmetic.Multiplier4
Defined in bitwise/arithmetic/MULT.py.
4-bit unsigned array multiplier.
__init__
__init__(
a_bus,
b_bus,
product_bus
)
Construct a new 4-bit unsigned multiplier.
Args:
a_bus
: An object of typeBus4
. The multiplicand.a_bus[0]
anda_bus[3]
are the most and least significant bit, respectively.b_bus
: An object of typeBus4
. The multiplier.b_bus[0]
andb_bus[3]
are the most and least significant bit, respectively.product_bus
: An object of typeBus8
. The product.product_bus[0]
andproduct_bus[7]
are the most and least significant bit, respectively.
Raises:
TypeError
: If eithera_bus
orb_bus
is not a bus of width 4, or ifproduct_bus
is not a bus of width 8.
__str__
Print out the wire values of the 4-bit unsigned multiplier.
a_bus: (0, 0, 0, 0)
b_bus: (0, 0, 0, 0)
product_bus: (0, 0, 0, 0, 0, 0, 0, 0)
__call__
__call__(
a_bus=None,
b_bus=None,
product_bus=None
)
Force specific values on the wires of the 4-bit unsigned multiplier.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.
Multiplier8
Class bw.arithmetic.Multiplier8
Defined in bitwise/arithmetic/MULT.py.
8-bit unsigned array multiplier.
__init__
__init__(
a_bus,
b_bus,
product_bus
)
Construct a new 8-bit unsigned multiplier.
Args:
a_bus
: An object of typeBus8
. The multiplicand.a_bus[0]
anda_bus[7]
are the most and least significant bit, respectively.b_bus
: An object of typeBus8
. The multiplier.b_bus[0]
andb_bus[7]
are the most and least significant bit, respectively.product_bus
: An object of typeBus16
. The product.product_bus[0]
andproduct_bus[15]
are the most and least significant bit, respectively.
Raises:
TypeError
: If eithera_bus
orb_bus
is not a bus of width 8, or ifproduct_bus
is not a bus of width 16.
__str__
Print out the wire values of the 16-bit unsigned multiplier.
a_bus: (0, 0, 0, 0, 0, 0, 0, 0)
b_bus: (0, 0, 0, 0, 0, 0, 0, 0)
product_bus: (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
__call__
__call__(
a_bus=None,
b_bus=None,
product_bus=None
)
Force specific values on the wires of the 16-bit unsigned multiplier.
Note that this method takes zero positional arguments; all values must be given as keyword arguments.