-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from leonardt/nested-arrays
Nested arrays
- Loading branch information
Showing
8 changed files
with
184 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Array: | ||
def __init__(self, value, N): | ||
self.value = value | ||
self.N = N | ||
|
||
def __setitem__(self, index, value): | ||
self.value[index] = value | ||
|
||
def __eq__(self, other): | ||
if not isinstance(other, Array): | ||
return False | ||
return self.N == other.N and self.value == other.value | ||
|
||
def __len__(self): | ||
return self.N | ||
|
||
@property | ||
def flattened_length(self): | ||
if isinstance(self.value, Array): | ||
return self.N * self.value.flattened_length | ||
else: | ||
return self.N | ||
|
||
def flattened(self): | ||
if isinstance(self.value, Array): | ||
return self.value.flattened() | ||
else: | ||
return self.value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[pytest] | ||
[tool:pytest] | ||
pep8ignore = | ||
fault/prototype.py ALL | ||
tests/_test_cgra.py ALL | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import magma as m | ||
|
||
|
||
class TestNestedArraysCircuit(m.Circuit): | ||
IO = ["I", m.In(m.Array(3, m.Bits(4))), "O", m.Out(m.Array(3, m.Bits(4)))] | ||
|
||
@classmethod | ||
def definition(io): | ||
m.wire(io.I, io.O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters