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
4dc54d8d
Commit
4dc54d8d
authored
1 month ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
More typing
parent
0f6db50a
No related branches found
No related tags found
1 merge request
!528
More typing
Pipeline
#161748
passed
1 month ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/codegen/vhdl/__init__.py
+14
-14
14 additions, 14 deletions
b_asic/codegen/vhdl/__init__.py
b_asic/scheduler_gui/main_window.py
+28
-12
28 additions, 12 deletions
b_asic/scheduler_gui/main_window.py
with
42 additions
and
26 deletions
b_asic/codegen/vhdl/__init__.py
+
14
−
14
View file @
4dc54d8d
...
@@ -9,23 +9,23 @@ VHDL_TAB = r" "
...
@@ -9,23 +9,23 @@ VHDL_TAB = r" "
def
write
(
def
write
(
f
ile
:
TextIO
,
f
:
TextIO
,
indent_level
:
int
,
indent_level
:
int
,
text
:
str
,
text
:
str
,
*
,
*
,
end
:
str
=
"
\n
"
,
end
:
str
=
"
\n
"
,
start
:
str
|
None
=
None
,
start
:
str
|
None
=
None
,
):
):
"""
r
"""
Base VHDL code generation utility.
Base VHDL code generation utility.
``f
'
{VHDL_TAB*indent_level}
'
`` is first written to
the TextIO
First,
``f
'
{VHDL_TAB*indent_level}
'
`` is first written to
*f* as indentation.
object *file*.
Immediately after the indentation, *text* is written to *f
ile
*. Finally,
Immediately after the indentation, *text* is written to *f*. Finally,
*text* is also written to *f
ile
*.
*text* is also written to *f*.
Parameters
Parameters
----------
----------
f
ile
: TextIO
f : TextIO
The file object to emit VHDL code to.
The file object to emit VHDL code to.
indent_level : int
indent_level : int
Indentation level to use. Exactly ``f
'
{VHDL_TAB*indent_level}
'
`` is written
Indentation level to use. Exactly ``f
'
{VHDL_TAB*indent_level}
'
`` is written
...
@@ -33,25 +33,25 @@ def write(
...
@@ -33,25 +33,25 @@ def write(
text : str
text : str
The text to write to.
The text to write to.
end : str, default:
'
\n
'
end : str, default:
'
\n
'
Text to write exactly after *text* is written to *f
ile
*.
Text to write exactly after *text* is written to *f*.
start : str, optional
start : str, optional
Text to write before both indentation and *text*.
Text to write before both indentation and *text*.
"""
"""
if
start
is
not
None
:
if
start
is
not
None
:
f
ile
.
write
(
start
)
f
.
write
(
start
)
f
ile
.
write
(
f
"
{
VHDL_TAB
*
indent_level
}{
text
}{
end
}
"
)
f
.
write
(
f
"
{
VHDL_TAB
*
indent_level
}{
text
}{
end
}
"
)
def
write_lines
(
f
ile
:
TextIO
,
lines
:
list
[
tuple
[
int
,
str
]
|
tuple
[
int
,
str
,
str
]]):
def
write_lines
(
f
:
TextIO
,
lines
:
list
[
tuple
[
int
,
str
]
|
tuple
[
int
,
str
,
str
]]):
"""
"""
Multiline VHDL code generation utility.
Multiline VHDL code generation utility.
Each tuple ``(int, str, [int])`` in the list *lines* is written to the
Each tuple ``(int, str, [int])`` in the list *lines* is written to the
TextIO object *f
ile
* using the :func:`vhdl.write` function.
TextIO object *f* using the :func:`vhdl.write` function.
Parameters
Parameters
----------
----------
f
ile
: TextIO
f : TextIO
The file object to emit VHDL code to.
The file object to emit VHDL code to.
lines : list of tuple (int,str) [1], or list of tuple (int,str,str) [2]
lines : list of tuple (int,str) [1], or list of tuple (int,str,str) [2]
[1]: The first ``int`` of the tuple is used as indentation level for the line
[1]: The first ``int`` of the tuple is used as indentation level for the line
...
@@ -61,8 +61,8 @@ def write_lines(file: TextIO, lines: list[tuple[int, str] | tuple[int, str, str]
...
@@ -61,8 +61,8 @@ def write_lines(file: TextIO, lines: list[tuple[int, str] | tuple[int, str, str]
"""
"""
for
tpl
in
lines
:
for
tpl
in
lines
:
if
len
(
tpl
)
==
2
:
if
len
(
tpl
)
==
2
:
write
(
f
ile
,
indent_level
=
tpl
[
0
],
text
=
str
(
tpl
[
1
]))
write
(
f
,
indent_level
=
tpl
[
0
],
text
=
str
(
tpl
[
1
]))
elif
len
(
tpl
)
==
3
:
elif
len
(
tpl
)
==
3
:
write
(
f
ile
,
indent_level
=
tpl
[
0
],
text
=
str
(
tpl
[
1
]),
end
=
str
(
tpl
[
2
]))
write
(
f
,
indent_level
=
tpl
[
0
],
text
=
str
(
tpl
[
1
]),
end
=
str
(
tpl
[
2
]))
else
:
else
:
raise
ValueError
(
"
All tuples in list `lines` must have length 2 or 3
"
)
raise
ValueError
(
"
All tuples in list `lines` must have length 2 or 3
"
)
This diff is collapsed.
Click to expand it.
b_asic/scheduler_gui/main_window.py
+
28
−
12
View file @
4dc54d8d
...
@@ -117,6 +117,9 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -117,6 +117,9 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
_zoom
:
float
_zoom
:
float
_color_per_type
:
ClassVar
[
dict
[
str
,
QColor
]]
=
{}
_color_per_type
:
ClassVar
[
dict
[
str
,
QColor
]]
=
{}
_converted_color_per_type
:
ClassVar
[
dict
[
str
,
str
]]
=
{}
_converted_color_per_type
:
ClassVar
[
dict
[
str
,
str
]]
=
{}
_changed_operation_colors
:
dict
[
str
,
QColor
]
_recent_files_actions
:
list
[
QAction
]
_recent_file_paths
:
deque
[
str
]
def
__init__
(
self
):
def
__init__
(
self
):
"""
Initialize Scheduler-GUI.
"""
"""
Initialize Scheduler-GUI.
"""
...
@@ -137,12 +140,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -137,12 +140,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self
.
_execution_time_plot_dialogs
=
defaultdict
(
lambda
:
None
)
self
.
_execution_time_plot_dialogs
=
defaultdict
(
lambda
:
None
)
self
.
_ports_accesses_for_storage
=
None
self
.
_ports_accesses_for_storage
=
None
self
.
_color_changed_per_type
=
False
self
.
_color_changed_per_type
=
False
self
.
_changed_operation_colors
:
dict
[
str
,
QColor
]
=
{}
self
.
_changed_operation_colors
=
{}
# Recent files
# Recent files
self
.
_max_recent_files
=
4
self
.
_max_recent_files
=
4
self
.
_recent_files_actions
:
list
[
QAction
]
=
[]
self
.
_recent_files_actions
=
[]
self
.
_recent_file_paths
:
deque
[
str
]
=
deque
(
maxlen
=
self
.
_max_recent_files
)
self
.
_recent_file_paths
=
deque
(
maxlen
=
self
.
_max_recent_files
)
self
.
_create_recent_file_actions_and_menus
()
self
.
_create_recent_file_actions_and_menus
()
self
.
_init_graphics
()
self
.
_init_graphics
()
...
@@ -266,8 +269,10 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -266,8 +269,10 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
# Check return value
# Check return value
if
ok
:
if
ok
:
if
factor
>
1
:
if
factor
>
1
:
self
.
schedule
.
increase_time_resolution
(
factor
)
schedule
=
cast
(
Schedule
,
self
.
_schedule
)
self
.
open
(
self
.
schedule
)
schedule
.
increase_time_resolution
(
factor
)
self
.
_schedule
=
schedule
self
.
open
(
self
.
_schedule
)
print
(
f
"
schedule.increase_time_resolution(
{
factor
}
)
"
)
print
(
f
"
schedule.increase_time_resolution(
{
factor
}
)
"
)
self
.
update_statusbar
(
f
"
Time resolution increased by a factor
{
factor
}
"
)
self
.
update_statusbar
(
f
"
Time resolution increased by a factor
{
factor
}
"
)
else
:
# Cancelled
else
:
# Cancelled
...
@@ -276,10 +281,9 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -276,10 +281,9 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
@Slot
()
@Slot
()
def
_decrease_time_resolution
(
self
)
->
None
:
def
_decrease_time_resolution
(
self
)
->
None
:
"""
Callback for decreasing time resolution.
"""
"""
Callback for decreasing time resolution.
"""
schedule
=
cast
(
Schedule
,
self
.
_schedule
)
# Get possible factors
# Get possible factors
vals
=
[
vals
=
[
str
(
v
)
for
v
in
schedule
.
get_possible_time_resolution_decrements
()]
str
(
v
)
for
v
in
self
.
_schedule
.
get_possible_time_resolution_decrements
()
]
# Create dialog
# Create dialog
factor
,
ok
=
QInputDialog
.
getItem
(
factor
,
ok
=
QInputDialog
.
getItem
(
self
,
"
Decrease time resolution
"
,
"
Factor
"
,
vals
,
editable
=
False
self
,
"
Decrease time resolution
"
,
"
Factor
"
,
vals
,
editable
=
False
...
@@ -287,7 +291,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -287,7 +291,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
# Check return value
# Check return value
if
ok
:
if
ok
:
if
int
(
factor
)
>
1
:
if
int
(
factor
)
>
1
:
self
.
_schedule
.
decrease_time_resolution
(
int
(
factor
))
schedule
.
decrease_time_resolution
(
int
(
factor
))
self
.
_schedule
=
schedule
self
.
open
(
self
.
_schedule
)
self
.
open
(
self
.
_schedule
)
print
(
f
"
schedule.decrease_time_resolution(
{
factor
}
)
"
)
print
(
f
"
schedule.decrease_time_resolution(
{
factor
}
)
"
)
self
.
update_statusbar
(
f
"
Time resolution decreased by a factor
{
factor
}
"
)
self
.
update_statusbar
(
f
"
Time resolution decreased by a factor
{
factor
}
"
)
...
@@ -451,6 +456,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -451,6 +456,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
SLOT() for SIGNAL(menu_save.triggered)
SLOT() for SIGNAL(menu_save.triggered)
"""
"""
# TODO: all
# TODO: all
if
self
.
_schedule
is
None
:
return
if
self
.
_file_name
is
None
:
if
self
.
_file_name
is
None
:
self
.
save_as
()
self
.
save_as
()
return
return
...
@@ -468,6 +475,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -468,6 +475,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
SLOT() for SIGNAL(menu_save_as.triggered)
SLOT() for SIGNAL(menu_save_as.triggered)
"""
"""
# TODO: Implement
# TODO: Implement
if
self
.
_schedule
is
None
:
return
filename
,
extension
=
QFileDialog
.
getSaveFileName
(
filename
,
extension
=
QFileDialog
.
getSaveFileName
(
self
,
"
Save File
"
,
"
.
"
,
filter
=
self
.
tr
(
"
B-ASIC schedule (*.bsc)
"
)
self
,
"
Save File
"
,
"
.
"
,
filter
=
self
.
tr
(
"
B-ASIC schedule (*.bsc)
"
)
)
)
...
@@ -580,6 +589,11 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -580,6 +589,11 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
Takes in an operator-id, first clears the
'
Operator
'
part of the info
Takes in an operator-id, first clears the
'
Operator
'
part of the info
table and then fill in the table with new values from the operator
table and then fill in the table with new values from the operator
associated with *graph_id*.
associated with *graph_id*.
Parameters
----------
graph_id : GraphID
GraphID of operation to fill information table with.
"""
"""
self
.
info_table_clear_component
()
self
.
info_table_clear_component
()
self
.
_info_table_fill_component
(
graph_id
)
self
.
_info_table_fill_component
(
graph_id
)
...
@@ -701,7 +715,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -701,7 +715,7 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
self
.
update_statusbar
(
self
.
tr
(
"
Schedule loaded successfully
"
))
self
.
update_statusbar
(
self
.
tr
(
"
Schedule loaded successfully
"
))
def
_redraw_all
(
self
)
->
None
:
def
_redraw_all
(
self
)
->
None
:
self
.
_graph
.
_redraw_all
()
cast
(
SchedulerItem
,
self
.
_graph
)
.
_redraw_all
()
@Slot
()
@Slot
()
def
_reopen_schedule
(
self
)
->
None
:
def
_reopen_schedule
(
self
)
->
None
:
...
@@ -894,12 +908,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -894,12 +908,12 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
@Slot
()
@Slot
()
def
open_preferences_dialog
(
self
):
def
open_preferences_dialog
(
self
):
"""
Open the preferences dialog to customize fonts, colors, and settings
"""
"""
Open the preferences dialog to customize fonts, colors, and settings
.
"""
self
.
_preferences_dialog
=
PreferencesDialog
(
self
)
self
.
_preferences_dialog
=
PreferencesDialog
(
self
)
self
.
_preferences_dialog
.
show
()
self
.
_preferences_dialog
.
show
()
def
load_preferences
(
self
):
def
load_preferences
(
self
):
"
Load the last saved preferences from settings
"
"
Load the last saved preferences from settings
.
"
settings
=
QSettings
()
settings
=
QSettings
()
LATENCY_COLOR_TYPE
.
current_color
=
QColor
(
LATENCY_COLOR_TYPE
.
current_color
=
QColor
(
settings
.
value
(
settings
.
value
(
...
@@ -948,6 +962,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
...
@@ -948,6 +962,8 @@ class ScheduleMainWindow(QMainWindow, Ui_MainWindow):
def
update_color_preferences
(
self
)
->
None
:
def
update_color_preferences
(
self
)
->
None
:
"""
Update preferences of Latency color per type.
"""
"""
Update preferences of Latency color per type.
"""
if
self
.
_schedule
is
None
:
return
used_type_names
=
self
.
_schedule
.
get_used_type_names
()
used_type_names
=
self
.
_schedule
.
get_used_type_names
()
match
(
LATENCY_COLOR_TYPE
.
changed
,
self
.
_color_changed_per_type
):
match
(
LATENCY_COLOR_TYPE
.
changed
,
self
.
_color_changed_per_type
):
case
(
True
,
False
):
case
(
True
,
False
):
...
...
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