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
1bac021c
Commit
1bac021c
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add more tests for Process
parent
aac6c47a
No related branches found
No related tags found
No related merge requests found
Pipeline
#90043
failed
2 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/process.py
+3
-2
3 additions, 2 deletions
b_asic/process.py
test/test_process.py
+24
-0
24 additions, 0 deletions
test/test_process.py
test/test_simulation.py
+5
-9
5 additions, 9 deletions
test/test_simulation.py
with
32 additions
and
11 deletions
b_asic/process.py
+
3
−
2
View file @
1bac021c
...
@@ -58,7 +58,7 @@ class Process:
...
@@ -58,7 +58,7 @@ class Process:
return
self
.
_name
return
self
.
_name
def
__repr__
(
self
)
->
str
:
def
__repr__
(
self
)
->
str
:
return
f
"
Process(
{
self
.
start_time
}
,
{
self
.
execution_time
}
,
{
self
.
name
}
)
"
return
f
"
Process(
{
self
.
start_time
}
,
{
self
.
execution_time
}
,
{
self
.
name
!r
}
)
"
# Static counter for default names
# Static counter for default names
_name_cnt
=
0
_name_cnt
=
0
...
@@ -166,7 +166,8 @@ class PlainMemoryVariable(Process):
...
@@ -166,7 +166,8 @@ class PlainMemoryVariable(Process):
Identifier for the source of the memory variable.
Identifier for the source of the memory variable.
reads : {int: int, ...}
reads : {int: int, ...}
Dictionary where the key is the destination identifier and the value
Dictionary where the key is the destination identifier and the value
is the time after *write_time* that the memory variable is read.
is the time after *write_time* that the memory variable is read, i.e., the
lifetime of the variable.
name : str, optional
name : str, optional
The name of the process.
The name of the process.
"""
"""
...
...
This diff is collapsed.
Click to expand it.
test/test_process.py
+
24
−
0
View file @
1bac021c
import
re
import
pytest
import
pytest
from
b_asic.process
import
PlainMemoryVariable
from
b_asic.process
import
PlainMemoryVariable
...
@@ -10,3 +12,25 @@ def test_PlainMemoryVariable():
...
@@ -10,3 +12,25 @@ def test_PlainMemoryVariable():
assert
mem
.
execution_time
==
2
assert
mem
.
execution_time
==
2
assert
mem
.
life_times
==
(
1
,
2
)
assert
mem
.
life_times
==
(
1
,
2
)
assert
mem
.
read_ports
==
(
4
,
5
)
assert
mem
.
read_ports
==
(
4
,
5
)
assert
repr
(
mem
)
==
"
PlainMemoryVariable(3, 0, {4: 1, 5: 2},
'
Proc. 0
'
)
"
mem2
=
PlainMemoryVariable
(
2
,
0
,
{
4
:
2
,
5
:
3
},
'
foo
'
)
assert
repr
(
mem2
)
==
"
PlainMemoryVariable(2, 0, {4: 2, 5: 3},
'
foo
'
)
"
assert
mem2
<
mem
mem3
=
PlainMemoryVariable
(
2
,
0
,
{
4
:
1
,
5
:
2
})
assert
mem2
<
mem3
def
test_MemoryVariables
(
secondorder_iir_schedule
):
pc
=
secondorder_iir_schedule
.
get_memory_variables
()
mem_vars
=
pc
.
collection
pattern
=
re
.
compile
(
"
MemoryVariable
\\
(3, <b_asic.port.OutputPort object at 0x[a-f0-9]+>,
"
"
{<b_asic.port.InputPort object at 0x[a-f0-9]+>: 4},
'
cmul1.0
'
\\
)
"
)
mem_var
=
[
m
for
m
in
mem_vars
if
m
.
name
==
'
cmul1.0
'
][
0
]
assert
pattern
.
match
(
repr
(
mem_var
))
assert
mem_var
.
execution_time
==
4
assert
mem_var
.
start_time
==
3
This diff is collapsed.
Click to expand it.
test/test_simulation.py
+
5
−
9
View file @
1bac021c
...
@@ -46,6 +46,8 @@ class TestRunFor:
...
@@ -46,6 +46,8 @@ class TestRunFor:
assert
simulation
.
results
[
"
0
"
][
3
]
==
13
assert
simulation
.
results
[
"
0
"
][
3
]
==
13
assert
simulation
.
results
[
"
1
"
][
3
]
==
20
assert
simulation
.
results
[
"
1
"
][
3
]
==
20
assert
simulation
.
iteration
==
101
def
test_with_numpy_arrays_as_input
(
self
,
sfg_two_inputs_two_outputs
):
def
test_with_numpy_arrays_as_input
(
self
,
sfg_two_inputs_two_outputs
):
input0
=
np
.
array
([
5
,
9
,
25
,
-
5
,
7
])
input0
=
np
.
array
([
5
,
9
,
25
,
-
5
,
7
])
input1
=
np
.
array
([
7
,
3
,
3
,
54
,
2
])
input1
=
np
.
array
([
7
,
3
,
3
,
54
,
2
])
...
@@ -131,15 +133,11 @@ class TestRunFor:
...
@@ -131,15 +133,11 @@ class TestRunFor:
)
)
sim
.
run
()
sim
.
run
()
assert
(
assert
(
sim
.
results
[
sim
.
results
[
precedence_sfg_delays
.
find_result_keys_by_name
(
"
ADD2
"
)[
0
]][
4
]
precedence_sfg_delays
.
find_result_keys_by_name
(
"
ADD2
"
)[
0
]
][
4
]
==
31220
==
31220
)
)
assert
(
assert
(
sim
.
results
[
sim
.
results
[
precedence_sfg_delays
.
find_result_keys_by_name
(
"
A1
"
)[
0
]][
2
]
precedence_sfg_delays
.
find_result_keys_by_name
(
"
A1
"
)[
0
]
][
2
]
==
80
==
80
)
)
...
@@ -220,9 +218,7 @@ class TestRun:
...
@@ -220,9 +218,7 @@ class TestRun:
input0
=
np
.
array
([
1
,
2
,
3
,
4
,
5
])
input0
=
np
.
array
([
1
,
2
,
3
,
4
,
5
])
simulation
=
Simulation
(
sfg_simple_filter
,
[
input0
])
simulation
=
Simulation
(
sfg_simple_filter
,
[
input0
])
simulation
.
run_for
(
len
(
input0
),
save_results
=
True
)
simulation
.
run_for
(
len
(
input0
),
save_results
=
True
)
assert
all
(
assert
all
(
simulation
.
results
[
"
0
"
]
==
np
.
array
([
0
,
1.0
,
2.5
,
4.25
,
6.125
]))
simulation
.
results
[
"
0
"
]
==
np
.
array
([
0
,
1.0
,
2.5
,
4.25
,
6.125
])
)
def
test_custom_operation
(
self
,
sfg_custom_operation
):
def
test_custom_operation
(
self
,
sfg_custom_operation
):
simulation
=
Simulation
(
sfg_custom_operation
,
[
lambda
n
:
n
+
1
])
simulation
=
Simulation
(
sfg_custom_operation
,
[
lambda
n
:
n
+
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