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
ddfe0a4a
Commit
ddfe0a4a
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Some more doc fixes
parent
13f5b30d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!210
Some more doc fixes
Pipeline
#90030
passed
2 years ago
Stage: test
Stage: deploy
This commit is part of merge request
!210
. Comments created here will be created in the context of that merge request.
Changes
4
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
b_asic/process.py
+10
-13
10 additions, 13 deletions
b_asic/process.py
b_asic/sfg_generators.py
+8
-6
8 additions, 6 deletions
b_asic/sfg_generators.py
b_asic/signal.py
+18
-12
18 additions, 12 deletions
b_asic/signal.py
b_asic/simulation.py
+17
-17
17 additions, 17 deletions
b_asic/simulation.py
with
53 additions
and
48 deletions
b_asic/process.py
+
10
−
13
Edit
View file @
ddfe0a4a
"""
"""
B-ASIC classes representing resource usage.
"""
B-ASIC classes representing resource usage.
"""
from
typing
import
Dict
,
Optional
,
Tuple
from
typing
import
Dict
,
Optional
,
Tuple
...
@@ -10,9 +8,10 @@ from b_asic.port import InputPort, OutputPort
...
@@ -10,9 +8,10 @@ from b_asic.port import InputPort, OutputPort
class
Process
:
class
Process
:
"""
"""
Object for use in resource allocation. Has a start time and an execution
Object for use in resource allocation.
time. Subclasses will in many cases contain additional information for
resource assignment.
Has a start time and an execution time. Subclasses will in many cases
contain additional information for resource assignment.
Parameters
Parameters
==========
==========
...
@@ -59,9 +58,7 @@ class Process:
...
@@ -59,9 +58,7 @@ class Process:
return
self
.
_name
return
self
.
_name
def
__repr__
(
self
)
->
str
:
def
__repr__
(
self
)
->
str
:
return
(
return
f
"
Process(
{
self
.
start_time
}
,
{
self
.
execution_time
}
,
{
self
.
name
}
)
"
f
"
Process(
{
self
.
start_time
}
,
{
self
.
execution_time
}
,
{
self
.
name
}
)
"
)
# Static counter for default names
# Static counter for default names
_name_cnt
=
0
_name_cnt
=
0
...
@@ -90,8 +87,7 @@ class OperatorProcess(Process):
...
@@ -90,8 +87,7 @@ class OperatorProcess(Process):
execution_time
=
operation
.
execution_time
execution_time
=
operation
.
execution_time
if
execution_time
is
None
:
if
execution_time
is
None
:
raise
ValueError
(
raise
ValueError
(
"
Operation {operation!r} does not have an execution time
"
"
Operation {operation!r} does not have an execution time specified!
"
"
specified!
"
)
)
super
().
__init__
(
super
().
__init__
(
start_time
,
start_time
,
...
@@ -157,8 +153,9 @@ class MemoryVariable(Process):
...
@@ -157,8 +153,9 @@ class MemoryVariable(Process):
class
PlainMemoryVariable
(
Process
):
class
PlainMemoryVariable
(
Process
):
"""
"""
Object that corresponds to a memory variable which only use numbers for
Object that corresponds to a memory variable which only use numbers for ports.
ports. This can be useful when only a plain memory variable is wanted with
This can be useful when only a plain memory variable is wanted with
no connection to a schedule.
no connection to a schedule.
Parameters
Parameters
...
...
This diff is collapsed.
Click to expand it.
b_asic/sfg_generators.py
+
8
−
6
Edit
View file @
ddfe0a4a
...
@@ -29,8 +29,8 @@ def wdf_allpass(
...
@@ -29,8 +29,8 @@ def wdf_allpass(
execution_time
:
Optional
[
int
]
=
None
,
execution_time
:
Optional
[
int
]
=
None
,
)
->
SFG
:
)
->
SFG
:
"""
"""
Generate a signal flow graph of a WDF allpass section based on symmetric two-port
Generate a signal flow graph of a WDF allpass section based on symmetric two-port
\
adaptors.
adaptors.
Parameters
Parameters
----------
----------
...
@@ -126,8 +126,9 @@ def direct_form_fir(
...
@@ -126,8 +126,9 @@ def direct_form_fir(
add_properties
:
Optional
[
Union
[
Dict
[
str
,
int
],
Dict
[
str
,
Dict
[
str
,
int
]]]]
=
None
,
add_properties
:
Optional
[
Union
[
Dict
[
str
,
int
],
Dict
[
str
,
Dict
[
str
,
int
]]]]
=
None
,
):
):
r
"""
r
"""
Generate a signal flow graph of a direct form FIR filter. The *coefficients* parameter is a
Generate a signal flow graph of a direct form FIR filter.
sequence of impulse response values::
The *coefficients* parameter is a sequence of impulse response values::
coefficients = [h0, h1, h2, ..., hN]
coefficients = [h0, h1, h2, ..., hN]
...
@@ -206,8 +207,9 @@ def transposed_direct_form_fir(
...
@@ -206,8 +207,9 @@ def transposed_direct_form_fir(
add_properties
:
Optional
[
Union
[
Dict
[
str
,
int
],
Dict
[
str
,
Dict
[
str
,
int
]]]]
=
None
,
add_properties
:
Optional
[
Union
[
Dict
[
str
,
int
],
Dict
[
str
,
Dict
[
str
,
int
]]]]
=
None
,
):
):
r
"""
r
"""
Generate a signal flow graph of a transposed direct form FIR filter. The *coefficients* parameter is a
Generate a signal flow graph of a transposed direct form FIR filter.
sequence of impulse response values::
The *coefficients* parameter is a sequence of impulse response values::
coefficients = [h0, h1, h2, ..., hN]
coefficients = [h0, h1, h2, ..., hN]
...
...
This diff is collapsed.
Click to expand it.
b_asic/signal.py
+
18
−
12
Edit
View file @
ddfe0a4a
...
@@ -64,23 +64,26 @@ class Signal(AbstractGraphComponent):
...
@@ -64,23 +64,26 @@ class Signal(AbstractGraphComponent):
@property
@property
def
neighbors
(
self
)
->
Iterable
[
GraphComponent
]:
def
neighbors
(
self
)
->
Iterable
[
GraphComponent
]:
"""
Return a list of the (up to) two operations connected to this signal.
"""
return
[
p
.
operation
for
p
in
[
self
.
source
,
self
.
destination
]
if
p
is
not
None
]
return
[
p
.
operation
for
p
in
[
self
.
source
,
self
.
destination
]
if
p
is
not
None
]
@property
@property
def
source
(
self
)
->
Optional
[
"
OutputPort
"
]:
def
source
(
self
)
->
Optional
[
"
OutputPort
"
]:
"""
T
he source OutputPort of the signal.
"""
"""
Return t
he source OutputPort of the signal.
"""
return
self
.
_source
return
self
.
_source
@property
@property
def
destination
(
self
)
->
Optional
[
"
InputPort
"
]:
def
destination
(
self
)
->
Optional
[
"
InputPort
"
]:
"""
T
he destination InputPort of the signal.
"""
"""
Return t
he destination InputPort of the signal.
"""
return
self
.
_destination
return
self
.
_destination
def
set_source
(
self
,
source
:
Union
[
"
OutputPort
"
,
"
Signal
"
,
"
Operation
"
])
->
None
:
def
set_source
(
self
,
source
:
Union
[
"
OutputPort
"
,
"
Signal
"
,
"
Operation
"
])
->
None
:
"""
"""
Disconnect the previous source OutputPort of the signal and
Connect to the entered source OutputPort.
connect to the entered source OutputPort. Also connect the entered
source port to the signal if it has not already been connected.
Also, disconnect the previous source OutputPort of the signal and
connect the entered source port to the signal if it has not
already been connected.
Parameters
Parameters
==========
==========
...
@@ -111,9 +114,11 @@ class Signal(AbstractGraphComponent):
...
@@ -111,9 +114,11 @@ class Signal(AbstractGraphComponent):
self
,
destination
:
Union
[
"
InputPort
"
,
"
Signal
"
,
"
Operation
"
]
self
,
destination
:
Union
[
"
InputPort
"
,
"
Signal
"
,
"
Operation
"
]
)
->
None
:
)
->
None
:
"""
"""
Disconnect the previous destination InputPort of the signal and
Connect to the entered *destination* InputPort.
connect to the entered destination InputPort. Also connect the entered
destination port to the signal if it has not already been connected.
Also, disconnect the previous destination InputPort of the signal and
connect the entered destination port to the signal if it has not already
been connected.
Parameters
Parameters
==========
==========
...
@@ -143,8 +148,10 @@ class Signal(AbstractGraphComponent):
...
@@ -143,8 +148,10 @@ class Signal(AbstractGraphComponent):
def
remove_source
(
self
)
->
None
:
def
remove_source
(
self
)
->
None
:
"""
"""
Disconnect the source OutputPort of the signal. If the source port
Disconnect the source OutputPort of the signal.
still is connected to this signal then also disconnect the source port.
If the source port still is connected to this signal then also disconnect
the source port.
"""
"""
source
=
self
.
_source
source
=
self
.
_source
if
source
is
not
None
:
if
source
is
not
None
:
...
@@ -162,8 +169,7 @@ class Signal(AbstractGraphComponent):
...
@@ -162,8 +169,7 @@ class Signal(AbstractGraphComponent):
def
dangling
(
self
)
->
bool
:
def
dangling
(
self
)
->
bool
:
"""
"""
Returns True if the signal is missing either a source or a destination,
Return True if the signal is missing either a source or a destination.
else False.
"""
"""
return
self
.
_source
is
None
or
self
.
_destination
is
None
return
self
.
_source
is
None
or
self
.
_destination
is
None
...
...
This diff is collapsed.
Click to expand it.
b_asic/simulation.py
+
17
−
17
Edit
View file @
ddfe0a4a
...
@@ -71,16 +71,16 @@ class Simulation:
...
@@ -71,16 +71,16 @@ class Simulation:
def
set_input
(
self
,
index
:
int
,
input_provider
:
InputProvider
)
->
None
:
def
set_input
(
self
,
index
:
int
,
input_provider
:
InputProvider
)
->
None
:
"""
"""
Set the input used to get values for the specific input at the
Set the input used to get values for the specific input at the
given index of
\
given index to
the internal SFG.
the internal SFG.
Parameters
Parameters
----------
----------
index : int
index : int
The input index.
The input index.
input_provider : list, callable, or number
input_provider : list, callable, or number
Can be an array of values, a callable taking a time index and returning
the value, or a
Can be an array of values, a callable taking a time index and returning
number (constant input).
the value, or a
number (constant input).
"""
"""
if
index
<
0
or
index
>=
len
(
self
.
_input_functions
):
if
index
<
0
or
index
>=
len
(
self
.
_input_functions
):
raise
IndexError
(
raise
IndexError
(
...
@@ -120,8 +120,7 @@ class Simulation:
...
@@ -120,8 +120,7 @@ class Simulation:
bits_override
:
Optional
[
int
]
=
None
,
bits_override
:
Optional
[
int
]
=
None
,
truncate
:
bool
=
True
,
truncate
:
bool
=
True
,
)
->
Sequence
[
Num
]:
)
->
Sequence
[
Num
]:
"""
"""
Run one iteration of the simulation and return the resulting output values.
Run one iteration of the simulation and return the resulting output values.
"""
"""
return
self
.
run_for
(
1
,
save_results
,
bits_override
,
truncate
)
return
self
.
run_for
(
1
,
save_results
,
bits_override
,
truncate
)
...
@@ -133,8 +132,8 @@ class Simulation:
...
@@ -133,8 +132,8 @@ class Simulation:
truncate
:
bool
=
True
,
truncate
:
bool
=
True
,
)
->
Sequence
[
Num
]:
)
->
Sequence
[
Num
]:
"""
"""
Run the simulation until its iteration is greater than or equal to the given
Run the simulation until its iteration is greater than or equal to the given
\
iteration and return the output values of the last iteration.
iteration and return the output values of the last iteration.
"""
"""
result
:
Sequence
[
Num
]
=
[]
result
:
Sequence
[
Num
]
=
[]
while
self
.
_iteration
<
iteration
:
while
self
.
_iteration
<
iteration
:
...
@@ -165,8 +164,8 @@ class Simulation:
...
@@ -165,8 +164,8 @@ class Simulation:
truncate
:
bool
=
True
,
truncate
:
bool
=
True
,
)
->
Sequence
[
Num
]:
)
->
Sequence
[
Num
]:
"""
"""
Run a given number of iterations of the simulation and return the output
Run a given number of iterations of the simulation and return the output
\
values of the last iteration.
values of the last iteration.
"""
"""
return
self
.
run_until
(
return
self
.
run_until
(
self
.
_iteration
+
iterations
,
save_results
,
bits_override
,
truncate
self
.
_iteration
+
iterations
,
save_results
,
bits_override
,
truncate
...
@@ -179,8 +178,8 @@ class Simulation:
...
@@ -179,8 +178,8 @@ class Simulation:
truncate
:
bool
=
True
,
truncate
:
bool
=
True
,
)
->
Sequence
[
Num
]:
)
->
Sequence
[
Num
]:
"""
"""
Run the simulation until the end of its input arrays and return the output
Run the simulation until the end of its input arrays and return the output
\
values of the last iteration.
values of the last iteration.
"""
"""
if
self
.
_input_length
is
None
:
if
self
.
_input_length
is
None
:
raise
IndexError
(
"
Tried to run unlimited simulation
"
)
raise
IndexError
(
"
Tried to run unlimited simulation
"
)
...
@@ -194,11 +193,12 @@ class Simulation:
...
@@ -194,11 +193,12 @@ class Simulation:
@property
@property
def
results
(
self
)
->
ResultArrayMap
:
def
results
(
self
)
->
ResultArrayMap
:
"""
"""
Get a mapping from result keys to numpy arrays containing all results, including
Get a mapping from result keys to numpy arrays containing all results.
intermediate values, calculated for each iteration up until now that was run
with save_results enabled.
This includes intermediate values, calculated for each iteration up until now
The mapping is indexed using the key() method of Operation with the appropriate
that was run with *save_results* enabled.
output index.
The mapping is indexed using the ``key()`` method of Operation with the
appropriate output index.
Example result after 3 iterations::
Example result after 3 iterations::
{
"
c1
"
: [3, 6, 7],
"
c2
"
: [4, 5, 5],
"
bfly1.0
"
: [7, 0, 0],
"
bfly1.1
"
: [-1, 0, 2],
"
0
"
: [7, -2, -1]}
{
"
c1
"
: [3, 6, 7],
"
c2
"
: [4, 5, 5],
"
bfly1.0
"
: [7, 0, 0],
"
bfly1.1
"
: [-1, 0, 2],
"
0
"
: [7, -2, -1]}
...
...
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