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
1baba58a
Commit
1baba58a
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Improve typing and fix typos
parent
f929ba05
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!213
Mixfixes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/signal_generator.py
+13
-13
13 additions, 13 deletions
b_asic/signal_generator.py
with
13 additions
and
13 deletions
b_asic/signal_generator.py
+
13
−
13
View file @
1baba58a
"""
B-ASIC
s
ignal
g
enerator
s
B-ASIC
S
ignal
G
enerator
Module.
These can be used as input to Simulation to algorithmically provide signal values.
Especially, all classes defined here will act as a callable which accepts an integer
...
...
@@ -22,7 +22,7 @@ class SignalGenerator:
"""
Base class for signal generators.
Handles operator overloading and define
d
the ``__call__`` method that should
Handles operator overloading and define
s
the ``__call__`` method that should
be overridden.
"""
...
...
@@ -94,7 +94,7 @@ class Impulse(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
1
if
time
==
self
.
_delay
else
0
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
return
f
"
Impulse(
{
self
.
_delay
}
)
"
if
self
.
_delay
else
"
Impulse()
"
...
...
@@ -114,7 +114,7 @@ class Step(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
1
if
time
>=
self
.
_delay
else
0
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
return
f
"
Step(
{
self
.
_delay
}
)
"
if
self
.
_delay
else
"
Step()
"
...
...
@@ -134,7 +134,7 @@ class Constant(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
self
.
_constant
def
__str__
(
self
):
def
__str__
(
self
)
->
str
:
return
f
"
{
self
.
_constant
}
"
...
...
@@ -157,7 +157,7 @@ class ZeroPad(SignalGenerator):
return
self
.
_data
[
time
]
return
0.0
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
return
f
"
ZeroPad(
{
self
.
_data
}
)
"
...
...
@@ -181,7 +181,7 @@ class Sinusoid(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
sin
(
pi
*
(
self
.
_frequency
*
time
+
self
.
_phase
))
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
return
(
f
"
Sinusoid(
{
self
.
_frequency
}
,
{
self
.
_phase
}
)
"
if
self
.
_phase
...
...
@@ -216,7 +216,7 @@ class Gaussian(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
self
.
_rng
.
normal
(
self
.
_loc
,
self
.
_scale
)
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
ret_list
=
[]
if
self
.
_seed
is
not
None
:
ret_list
.
append
(
f
"
seed=
{
self
.
_seed
}
"
)
...
...
@@ -256,7 +256,7 @@ class Uniform(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
self
.
_rng
.
uniform
(
self
.
_low
,
self
.
_high
)
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
ret_list
=
[]
if
self
.
_seed
is
not
None
:
ret_list
.
append
(
f
"
seed=
{
self
.
_seed
}
"
)
...
...
@@ -280,7 +280,7 @@ class _AddGenerator(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
self
.
_a
(
time
)
+
self
.
_b
(
time
)
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
return
f
"
{
self
.
_a
}
+
{
self
.
_b
}
"
...
...
@@ -296,7 +296,7 @@ class _SubGenerator(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
self
.
_a
(
time
)
-
self
.
_b
(
time
)
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
return
f
"
{
self
.
_a
}
-
{
self
.
_b
}
"
...
...
@@ -312,7 +312,7 @@ class _MulGenerator(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
self
.
_a
(
time
)
*
self
.
_b
(
time
)
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
a
=
(
f
"
(
{
self
.
_a
}
)
"
if
isinstance
(
self
.
_a
,
(
_AddGenerator
,
_SubGenerator
))
...
...
@@ -338,7 +338,7 @@ class _DivGenerator(SignalGenerator):
def
__call__
(
self
,
time
:
int
)
->
complex
:
return
self
.
_a
(
time
)
/
self
.
_b
(
time
)
def
__repr__
(
self
):
def
__repr__
(
self
)
->
str
:
a
=
(
f
"
(
{
self
.
_a
}
)
"
if
isinstance
(
self
.
_a
,
(
_AddGenerator
,
_SubGenerator
))
...
...
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