Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch over to using bit vectors #21

Merged
merged 1 commit into from
Aug 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions fault/test_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,23 @@ def generate_function_test_vectors(circuit, func, input_ranges=None,
for i, (name, port) in enumerate(circuit.interface.ports.items()):
if port.isoutput():
if isinstance(port, BitType):
args.append([0, 1])
args.append([BitVector(0), BitVector(1)])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to make a Bit type as opposed to BitVector since this is not a multibit value. We could use Python bools for Bits, but they have some funky behavior

>>> ~True
-2

which would motivate defining our own wrapper class with the operator semantics we expect

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of a Bit type with the exact same semantics. python

elif isinstance(port, ArrayType):
num_bits = type(port).N
if isinstance(port, SIntType):
if input_ranges is None:
input_range = range(-2**(num_bits-1), 2**(num_bits-1))
else:
input_range = input_ranges[i]
args.append([SIntVector(x, num_bits=num_bits)
for x in input_range])
else:
if input_ranges is None:
input_range = range(1 << num_bits)
else:
input_range = input_ranges[i]
args.append(input_range)
args.append([BitVector(x, num_bits=num_bits)
for x in input_range])
else:
assert True, "can't test Tuples"

Expand Down