Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
19e86fcc
Commit
19e86fcc
authored
1 month ago
by
Simon Bjurek
Browse files
Options
Downloads
Patches
Plain Diff
ldlt inverse now verified for matrices up to and including size 3x3
parent
76443401
No related branches found
Branches containing commit
No related tags found
1 merge request
!470
Add slack time scheduling, redid earliest deadline, added max-fan-out and hybrid scheduler, also added example
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
b_asic/core_operations.py
+13
-4
13 additions, 4 deletions
b_asic/core_operations.py
b_asic/sfg_generators.py
+15
-14
15 additions, 14 deletions
b_asic/sfg_generators.py
test/test_sfg_generators.py
+56
-0
56 additions, 0 deletions
test/test_sfg_generators.py
with
85 additions
and
18 deletions
.gitignore
+
1
−
0
View file @
19e86fcc
...
@@ -116,6 +116,7 @@ TODO.txt
...
@@ -116,6 +116,7 @@ TODO.txt
b_asic/_version.py
b_asic/_version.py
docs_sphinx/_build/
docs_sphinx/_build/
docs_sphinx/examples
docs_sphinx/examples
docs_sphinx/sg_execution_times.rst
result_images/
result_images/
.coverage
.coverage
Digraph.gv
Digraph.gv
...
...
This diff is collapsed.
Click to expand it.
b_asic/core_operations.py
+
13
−
4
View file @
19e86fcc
...
@@ -1123,7 +1123,7 @@ class MADS(AbstractOperation):
...
@@ -1123,7 +1123,7 @@ class MADS(AbstractOperation):
def
__init__
(
def
__init__
(
self
,
self
,
is_add
:
Optional
[
bool
]
=
Fals
e
,
is_add
:
Optional
[
bool
]
=
Tru
e
,
src0
:
Optional
[
SignalSourceProvider
]
=
None
,
src0
:
Optional
[
SignalSourceProvider
]
=
None
,
src1
:
Optional
[
SignalSourceProvider
]
=
None
,
src1
:
Optional
[
SignalSourceProvider
]
=
None
,
src2
:
Optional
[
SignalSourceProvider
]
=
None
,
src2
:
Optional
[
SignalSourceProvider
]
=
None
,
...
@@ -1142,15 +1142,24 @@ class MADS(AbstractOperation):
...
@@ -1142,15 +1142,24 @@ class MADS(AbstractOperation):
latency_offsets
=
latency_offsets
,
latency_offsets
=
latency_offsets
,
execution_time
=
execution_time
,
execution_time
=
execution_time
,
)
)
self
.
_is_add
=
is_add
self
.
set_param
(
"
is_add
"
,
is_add
)
# self.set_param("is_add", is_add)
@classmethod
@classmethod
def
type_name
(
cls
)
->
TypeName
:
def
type_name
(
cls
)
->
TypeName
:
return
TypeName
(
"
mads
"
)
return
TypeName
(
"
mads
"
)
def
evaluate
(
self
,
a
,
b
,
c
):
def
evaluate
(
self
,
a
,
b
,
c
):
return
a
+
b
*
c
if
self
.
_is_add
else
a
-
b
*
c
return
a
+
b
*
c
if
self
.
is_add
else
a
-
b
*
c
@property
def
is_add
(
self
)
->
bool
:
"""
Get if operation is an addition.
"""
return
self
.
param
(
"
is_add
"
)
@is_add.setter
def
is_add
(
self
,
is_add
:
bool
)
->
None
:
"""
Set if operation is an addition.
"""
self
.
set_param
(
"
is_add
"
,
is_add
)
@property
@property
def
is_linear
(
self
)
->
bool
:
def
is_linear
(
self
)
->
bool
:
...
...
This diff is collapsed.
Click to expand it.
b_asic/sfg_generators.py
+
15
−
14
View file @
19e86fcc
...
@@ -456,40 +456,41 @@ def ldlt_matrix_inverse(N: int, is_complex: bool) -> SFG:
...
@@ -456,40 +456,41 @@ def ldlt_matrix_inverse(N: int, is_complex: bool) -> SFG:
# R*di*R^T factorization
# R*di*R^T factorization
for
i
in
range
(
N
):
for
i
in
range
(
N
):
for
k
in
range
(
1
,
i
):
for
k
in
range
(
i
):
D
[
i
]
=
MADS
(
False
,
D
[
i
],
M
[
k
][
i
],
R
[
k
][
i
])
D
[
i
]
=
MADS
(
False
,
D
[
i
],
M
[
k
][
i
],
R
[
k
][
i
]
,
name
=
"
M1
"
)
D_inv
[
i
]
=
Reciprocal
(
D
[
i
])
D_inv
[
i
]
=
Reciprocal
(
D
[
i
])
for
j
in
range
(
i
,
N
):
for
j
in
range
(
i
+
1
,
N
):
R
[
i
][
j
]
=
A
[
i
][
j
]
R
[
i
][
j
]
=
A
[
i
][
j
]
for
k
in
range
(
1
,
i
):
for
k
in
range
(
i
):
R
[
i
][
j
]
=
MADS
(
False
,
R
[
i
][
j
],
M
[
k
][
i
],
R
[
k
][
j
])
R
[
i
][
j
]
=
MADS
(
False
,
R
[
i
][
j
],
M
[
k
][
i
],
R
[
k
][
j
]
,
name
=
"
M2
"
)
if
is_complex
:
if
is_complex
:
M
[
i
][
j
]
=
ComplexConjugate
(
R
[
i
][
j
])
M
[
i
][
j
]
=
ComplexConjugate
(
R
[
i
][
j
])
else
:
else
:
M
[
i
][
j
]
=
R
[
i
][
j
]
M
[
i
][
j
]
=
R
[
i
][
j
]
R
[
i
][
j
]
=
MADS
(
True
,
Constant
(
0
,
name
=
"
0
"
),
R
[
i
][
j
],
D_inv
[
i
])
R
[
i
][
j
]
=
MADS
(
True
,
Constant
(
0
,
name
=
"
0
"
),
R
[
i
][
j
],
D_inv
[
i
]
,
name
=
"
M3
"
)
# back substitution
# back substitution
A_inv
=
[[
None
for
_
in
range
(
N
)]
for
_
in
range
(
N
)]
A_inv
=
[[
None
for
_
in
range
(
N
)]
for
_
in
range
(
N
)]
for
i
in
reversed
(
range
(
N
)):
for
i
in
reversed
(
range
(
N
)):
A_inv
[
i
][
i
]
=
D_inv
[
i
]
A_inv
[
i
][
i
]
=
D_inv
[
i
]
for
j
in
reversed
(
range
(
i
)):
for
j
in
reversed
(
range
(
i
+
1
)):
for
k
in
reversed
(
range
(
j
,
N
)):
for
k
in
reversed
(
range
(
j
+
1
,
N
)):
if
k
==
N
-
1
and
i
!=
j
:
if
k
==
N
-
1
and
i
!=
j
:
# my custom
A_inv
[
j
][
i
]
=
MADS
(
if
A_inv
[
k
][
i
]:
False
,
Constant
(
0
,
name
=
"
0
"
),
R
[
j
][
k
],
A_inv
[
i
][
k
],
name
=
"
M4
"
)
else
:
if
A_inv
[
i
][
k
]:
A_inv
[
j
][
i
]
=
MADS
(
A_inv
[
j
][
i
]
=
MADS
(
False
,
Constant
(
0
,
name
=
"
0
"
)
,
R
[
j
][
k
],
A_inv
[
k
][
i
]
False
,
A_inv
[
j
][
i
]
,
R
[
j
][
k
],
A_inv
[
i
][
k
],
name
=
"
M5
"
)
)
else
:
else
:
A_inv
[
j
][
i
]
=
Constant
(
0
,
name
=
"
0
"
)
A_inv
[
j
][
i
]
=
MADS
(
False
,
A_inv
[
j
][
i
],
R
[
j
][
k
],
A_inv
[
k
][
i
])
else
:
A_inv
[
j
][
i
]
=
MADS
(
False
,
A_inv
[
j
][
i
],
R
[
j
][
k
],
A_inv
[
k
][
i
])
outputs
=
[]
outputs
=
[]
for
i
in
range
(
N
):
for
i
in
range
(
N
):
...
...
This diff is collapsed.
Click to expand it.
test/test_sfg_generators.py
+
56
−
0
View file @
19e86fcc
...
@@ -12,6 +12,7 @@ from b_asic.sfg_generators import (
...
@@ -12,6 +12,7 @@ from b_asic.sfg_generators import (
direct_form_1_iir
,
direct_form_1_iir
,
direct_form_2_iir
,
direct_form_2_iir
,
direct_form_fir
,
direct_form_fir
,
ldlt_matrix_inverse
,
radix_2_dif_fft
,
radix_2_dif_fft
,
transposed_direct_form_fir
,
transposed_direct_form_fir
,
wdf_allpass
,
wdf_allpass
,
...
@@ -637,3 +638,58 @@ class TestRadix2FFT:
...
@@ -637,3 +638,58 @@ class TestRadix2FFT:
POINTS
=
5
POINTS
=
5
with
pytest
.
raises
(
ValueError
,
match
=
"
Points must be a power of two.
"
):
with
pytest
.
raises
(
ValueError
,
match
=
"
Points must be a power of two.
"
):
radix_2_dif_fft
(
points
=
POINTS
)
radix_2_dif_fft
(
points
=
POINTS
)
class
TestLdltMatrixInverse
:
def
test_1x1
(
self
):
sfg
=
ldlt_matrix_inverse
(
N
=
1
,
is_complex
=
False
)
A_input
=
[
Constant
(
5
)]
sim
=
Simulation
(
sfg
,
A_input
)
sim
.
run_for
(
1
)
res
=
sim
.
results
assert
np
.
isclose
(
res
[
"
0
"
],
0.2
)
def
test_2x2_simple_spd
(
self
):
sfg
=
ldlt_matrix_inverse
(
N
=
2
,
is_complex
=
False
)
A
=
np
.
array
([[
1
,
2
],
[
2
,
1
]])
A_input
=
[
Constant
(
1
),
Constant
(
2
),
Constant
(
1
)]
A_inv
=
np
.
linalg
.
inv
(
A
)
sim
=
Simulation
(
sfg
,
A_input
)
sim
.
run_for
(
1
)
res
=
sim
.
results
assert
np
.
isclose
(
res
[
"
0
"
],
A_inv
[
0
,
0
])
assert
np
.
isclose
(
res
[
"
1
"
],
A_inv
[
0
,
1
])
assert
np
.
isclose
(
res
[
"
2
"
],
A_inv
[
1
,
1
])
def
test_3x3_simple_spd
(
self
):
sfg
=
ldlt_matrix_inverse
(
N
=
3
,
is_complex
=
False
)
A
=
np
.
array
([[
2
,
-
1
,
0
],
[
-
1
,
3
,
-
1
],
[
0
,
-
1
,
2
]])
A_input
=
[
Constant
(
2
),
Constant
(
-
1
),
Constant
(
0
),
Constant
(
3
),
Constant
(
-
1
),
Constant
(
2
),
]
A_inv
=
np
.
linalg
.
inv
(
A
)
sim
=
Simulation
(
sfg
,
A_input
)
sim
.
run_for
(
1
)
res
=
sim
.
results
assert
np
.
isclose
(
res
[
"
0
"
],
A_inv
[
0
,
0
])
assert
np
.
isclose
(
res
[
"
1
"
],
A_inv
[
0
,
1
])
assert
np
.
isclose
(
res
[
"
2
"
],
A_inv
[
0
,
2
])
assert
np
.
isclose
(
res
[
"
3
"
],
A_inv
[
1
,
1
])
assert
np
.
isclose
(
res
[
"
4
"
],
A_inv
[
1
,
2
])
assert
np
.
isclose
(
res
[
"
5
"
],
A_inv
[
2
,
2
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment