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
41115f33
Commit
41115f33
authored
1 year ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add simulation-based test for FIR generators
parent
f4cb6655
No related branches found
No related tags found
1 merge request
!273
Add simulation-based test for FIR generators
Pipeline
#93743
passed
1 year ago
Stage: test
Stage: deploy
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_sfg_generators.py
+30
-2
30 additions, 2 deletions
test/test_sfg_generators.py
with
30 additions
and
2 deletions
test/test_sfg_generators.py
+
30
−
2
View file @
41115f33
import
numpy
as
np
from
b_asic.core_operations
import
(
from
b_asic.core_operations
import
(
Addition
,
Addition
,
ConstantMultiplication
,
ConstantMultiplication
,
...
@@ -8,6 +10,8 @@ from b_asic.sfg_generators import (
...
@@ -8,6 +10,8 @@ from b_asic.sfg_generators import (
transposed_direct_form_fir
,
transposed_direct_form_fir
,
wdf_allpass
,
wdf_allpass
,
)
)
from
b_asic.signal_generator
import
Impulse
from
b_asic.simulation
import
Simulation
from
b_asic.special_operations
import
Delay
from
b_asic.special_operations
import
Delay
...
@@ -38,7 +42,8 @@ def test_wdf_allpass():
...
@@ -38,7 +42,8 @@ def test_wdf_allpass():
def
test_direct_form_fir
():
def
test_direct_form_fir
():
sfg
=
direct_form_fir
([
0.3
,
0.5
,
0.7
])
impulse_response
=
[
0.3
,
0.5
,
0.7
]
sfg
=
direct_form_fir
(
impulse_response
)
assert
(
assert
(
len
(
len
(
[
[
...
@@ -52,6 +57,12 @@ def test_direct_form_fir():
...
@@ -52,6 +57,12 @@ def test_direct_form_fir():
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Addition
)])
==
2
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Addition
)])
==
2
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Delay
)])
==
2
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Delay
)])
==
2
sim
=
Simulation
(
sfg
,
[
Impulse
()])
sim
.
run_for
(
4
)
impulse_response
.
append
(
0.0
)
assert
np
.
allclose
(
sim
.
results
[
'
0
'
],
impulse_response
)
impulse_response
=
[
0.3
,
0.4
,
0.5
,
0.6
,
0.3
]
sfg
=
direct_form_fir
(
sfg
=
direct_form_fir
(
(
0.3
,
0.4
,
0.5
,
0.6
,
0.3
),
(
0.3
,
0.4
,
0.5
,
0.6
,
0.3
),
mult_properties
=
{
'
latency
'
:
2
,
'
execution_time
'
:
1
},
mult_properties
=
{
'
latency
'
:
2
,
'
execution_time
'
:
1
},
...
@@ -59,9 +70,15 @@ def test_direct_form_fir():
...
@@ -59,9 +70,15 @@ def test_direct_form_fir():
)
)
assert
sfg
.
critical_path_time
()
==
6
assert
sfg
.
critical_path_time
()
==
6
sim
=
Simulation
(
sfg
,
[
Impulse
()])
sim
.
run_for
(
6
)
impulse_response
.
append
(
0.0
)
assert
np
.
allclose
(
sim
.
results
[
'
0
'
],
impulse_response
)
def
test_transposed_direct_form_fir
():
def
test_transposed_direct_form_fir
():
sfg
=
transposed_direct_form_fir
([
0.3
,
0.5
,
0.7
])
impulse_response
=
[
0.3
,
0.5
,
0.7
]
sfg
=
transposed_direct_form_fir
(
impulse_response
)
assert
(
assert
(
len
(
len
(
[
[
...
@@ -75,9 +92,20 @@ def test_transposed_direct_form_fir():
...
@@ -75,9 +92,20 @@ def test_transposed_direct_form_fir():
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Addition
)])
==
2
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Addition
)])
==
2
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Delay
)])
==
2
assert
len
([
comp
for
comp
in
sfg
.
components
if
isinstance
(
comp
,
Delay
)])
==
2
sim
=
Simulation
(
sfg
,
[
Impulse
()])
sim
.
run_for
(
4
)
impulse_response
.
append
(
0.0
)
assert
np
.
allclose
(
sim
.
results
[
'
0
'
],
impulse_response
)
impulse_response
=
[
0.3
,
0.4
,
0.5
,
0.6
,
0.3
]
sfg
=
transposed_direct_form_fir
(
sfg
=
transposed_direct_form_fir
(
(
0.3
,
0.4
,
0.5
,
0.6
,
0.3
),
(
0.3
,
0.4
,
0.5
,
0.6
,
0.3
),
mult_properties
=
{
'
latency
'
:
2
,
'
execution_time
'
:
1
},
mult_properties
=
{
'
latency
'
:
2
,
'
execution_time
'
:
1
},
add_properties
=
{
'
latency
'
:
1
,
'
execution_time
'
:
1
},
add_properties
=
{
'
latency
'
:
1
,
'
execution_time
'
:
1
},
)
)
assert
sfg
.
critical_path_time
()
==
3
assert
sfg
.
critical_path_time
()
==
3
sim
=
Simulation
(
sfg
,
[
Impulse
()])
sim
.
run_for
(
6
)
impulse_response
.
append
(
0.0
)
assert
np
.
allclose
(
sim
.
results
[
'
0
'
],
impulse_response
)
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