Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simuDAtor
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
simuDAtor
Commits
538f2728
Commit
538f2728
authored
10 months ago
by
Johannes Kung
Browse files
Options
Downloads
Plain Diff
Merge branch '7-indexoutofrange-on-edit-memory-in-pm' into 'main'
fixed index out of range error Closes
#7
See merge request
!20
parents
b885e6d3
4aff07f0
No related branches found
No related tags found
1 merge request
!20
fixed index out of range error
Pipeline
#132081
failed
10 months ago
Stage: test
Changes
2
Pipelines
4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/simudator/core/modules/memory.py
+9
-10
9 additions, 10 deletions
src/simudator/core/modules/memory.py
src/simudator/processor/mia/gui/mia_memory_graphic.py
+19
-6
19 additions, 6 deletions
src/simudator/processor/mia/gui/mia_memory_graphic.py
with
28 additions
and
16 deletions
src/simudator/core/modules/memory.py
+
9
−
10
View file @
538f2728
...
@@ -23,10 +23,10 @@ class Memory(Module):
...
@@ -23,10 +23,10 @@ class Memory(Module):
# signals
# signals
signals
=
{
signals
=
{
"
in_input
"
:
input_signal
,
"
in_input
"
:
input_signal
,
"
in_control
"
:
control_signal
,
"
in_control
"
:
control_signal
,
"
in_address
"
:
address_signal
,
"
in_address
"
:
address_signal
,
"
out_content
"
:
output_signal
"
out_content
"
:
output_signal
,
}
}
# Init super class
# Init super class
...
@@ -54,11 +54,7 @@ class Memory(Module):
...
@@ -54,11 +54,7 @@ class Memory(Module):
adr_sig
=
self
.
signals
[
"
in_address
"
]
adr_sig
=
self
.
signals
[
"
in_address
"
]
ctrl_sig
=
self
.
signals
[
"
in_control
"
]
ctrl_sig
=
self
.
signals
[
"
in_control
"
]
out_sig
=
self
.
signals
[
"
out_content
"
]
out_sig
=
self
.
signals
[
"
out_content
"
]
if
(
if
adr_sig
.
get_value
()
is
not
None
and
ctrl_sig
.
get_value
()
is
not
None
:
adr_sig
.
get_value
()
is
not
None
and
ctrl_sig
.
get_value
()
is
not
None
):
self
.
is_write
=
ctrl_sig
.
get_value
()
self
.
is_write
=
ctrl_sig
.
get_value
()
self
.
current_address
=
adr_sig
.
get_value
()
self
.
current_address
=
adr_sig
.
get_value
()
out_sig
.
update_value
(
self
.
memory
[
self
.
current_address
])
out_sig
.
update_value
(
self
.
memory
[
self
.
current_address
])
...
@@ -98,12 +94,15 @@ class Memory(Module):
...
@@ -98,12 +94,15 @@ class Memory(Module):
for
i
in
range
(
len
(
self
.
memory
)):
for
i
in
range
(
len
(
self
.
memory
)):
self
.
memory
[
i
]
=
0
self
.
memory
[
i
]
=
0
def
get_longest_line_len
(
self
,
ignore_keys
=
[]
)
->
int
:
def
get_longest_line_len
(
self
,
ignore_keys
=
None
)
->
int
:
"""
"""
Helper function for pretty_print that returns the length of
Helper function for pretty_print that returns the length of
the longest value in the memory to print for a module.
the longest value in the memory to print for a module.
"""
"""
if
ignore_keys
is
None
:
ignore_keys
=
[]
longest_memory_line
=
0
longest_memory_line
=
0
for
value
in
self
.
memory
:
for
value
in
self
.
memory
:
...
...
This diff is collapsed.
Click to expand it.
src/simudator/processor/mia/gui/mia_memory_graphic.py
+
19
−
6
View file @
538f2728
...
@@ -2,6 +2,7 @@ import ast
...
@@ -2,6 +2,7 @@ import ast
from
qtpy.QtCore
import
Slot
from
qtpy.QtCore
import
Slot
from
qtpy.QtWidgets
import
(
from
qtpy.QtWidgets
import
(
QErrorMessage
,
QGraphicsRectItem
,
QGraphicsRectItem
,
QGraphicsSimpleTextItem
,
QGraphicsSimpleTextItem
,
QTextEdit
,
QTextEdit
,
...
@@ -28,6 +29,7 @@ class MiaMemoryGraphicsItem(MemoryGraphicsItem):
...
@@ -28,6 +29,7 @@ class MiaMemoryGraphicsItem(MemoryGraphicsItem):
def
__init__
(
self
,
memory_module
:
Memory
,
**
kwargs
):
def
__init__
(
self
,
memory_module
:
Memory
,
**
kwargs
):
super
().
__init__
(
memory_module
,
**
kwargs
)
super
().
__init__
(
memory_module
,
**
kwargs
)
self
.
memory_window
=
None
self
.
memory_window
=
None
self
.
_errorMessageWidget
=
QErrorMessage
()
def
draw_graphics_item
(
self
)
->
None
:
def
draw_graphics_item
(
self
)
->
None
:
# Same as normal memory but no control signal
# Same as normal memory but no control signal
...
@@ -94,9 +96,9 @@ class MiaMemoryGraphicsItem(MemoryGraphicsItem):
...
@@ -94,9 +96,9 @@ class MiaMemoryGraphicsItem(MemoryGraphicsItem):
module_name
,
str
(
parsed_address
),
str
(
parsed_value
)
module_name
,
str
(
parsed_address
),
str
(
parsed_value
)
)
)
except
SyntaxError
as
e
:
except
SyntaxError
as
e
:
self
.
errorMessageWidget
.
showMessage
(
str
(
e
))
self
.
_
errorMessageWidget
.
showMessage
(
str
(
e
))
except
ValueError
:
except
ValueError
:
self
.
errorMessageWidget
.
showMessage
(
self
.
_
errorMessageWidget
.
showMessage
(
"
You must enter a hexadecimal
"
"
number preceeded by
'
0x
'
(e.g.
"
"
0xc3).
"
"
You must enter a hexadecimal
"
"
number preceeded by
'
0x
'
(e.g.
"
"
0xc3).
"
)
)
...
@@ -106,16 +108,27 @@ class MiaMemoryGraphicsItem(MemoryGraphicsItem):
...
@@ -106,16 +108,27 @@ class MiaMemoryGraphicsItem(MemoryGraphicsItem):
Same as prent function but also prases data so it is hexadecimal.
Same as prent function but also prases data so it is hexadecimal.
"""
"""
try
:
try
:
parsed_ad
d
ress
=
int
(
address
,
16
)
parsed_adress
=
int
(
address
,
16
)
parsed_value
=
ast
.
literal_eval
(
value
)
parsed_value
=
ast
.
literal_eval
(
value
)
except
SyntaxError
as
e
:
except
SyntaxError
as
e
:
self
.
errorMessageWidget
.
showMessage
(
str
(
e
))
self
.
_
errorMessageWidget
.
showMessage
(
str
(
e
))
except
ValueError
:
except
ValueError
:
self
.
errorMessageWidget
.
showMessage
(
self
.
_
errorMessageWidget
.
showMessage
(
"
You must enter a hexadecimal
"
"
number preceeded by
'
0x
'
(e.g.
"
"
0xc3).
"
"
You must enter a hexadecimal
"
"
number preceeded by
'
0x
'
(e.g.
"
"
0xc3).
"
)
)
else
:
else
:
module_state
=
self
.
module
.
get_state
()
module_state
=
self
.
module
.
get_state
()
module_state
[
'
memory
'
][
parsed_address
]
=
parsed_value
try
:
if
parsed_adress
<
0
:
raise
IndexError
module_state
[
'
memory
'
][
parsed_adress
]
=
parsed_value
except
IndexError
:
self
.
_errorMessageWidget
.
showMessage
(
"
Address entered was outside the memory space. Adress must be between 0 and 0xff.
"
)
else
:
self
.
module
.
set_state
(
module_state
)
self
.
update_graphics_signal
.
emit
()
module_state
[
'
memory
'
][
parsed_adress
]
=
parsed_value
self
.
module
.
set_state
(
module_state
)
self
.
module
.
set_state
(
module_state
)
self
.
update_graphics_signal
.
emit
()
self
.
update_graphics_signal
.
emit
()
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