Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC DEL 1ns 2cha
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC DEL 1ns 2cha
Commits
da4ee7c9
Commit
da4ee7c9
authored
May 02, 2017
by
Jan Pospisil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added non-zero word highlight in memory printing function hexDump
parent
058fb484
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
CommonFunctions.py
sw/CommonFunctions.py
+13
-3
No files found.
sw/CommonFunctions.py
View file @
da4ee7c9
...
...
@@ -62,36 +62,46 @@ def hexDump( dataArray, bitsPerWord = 32, binary = False, columns = 8 ):
if
i
!=
0
:
sys
.
stdout
.
write
(
"
\n
"
)
sys
.
stdout
.
write
(
"
%4
x: "
%
(
i
*
(
bitsPerWord
/
8
))
)
if
word
!=
0
:
sys
.
stdout
.
write
(
ConColors
.
BOLD
)
if
binary
:
sys
.
stdout
.
write
(
toBin
(
word
,
bitsPerWord
)
+
" "
)
# binary format
else
:
sys
.
stdout
.
write
(
(
"
%%0%
dx "
%
(
bitsPerWord
/
4
))
%
word
)
# hex format
sys
.
stdout
.
write
(
ConColors
.
NONE
)
i
+=
1
sys
.
stdout
.
write
(
"
\n
"
)
def
PrintBit
(
value
,
bit
,
label
,
ifSet
,
ifNotSet
):
def
PrintBit
(
value
,
bit
,
label
,
ifSet
=
""
,
ifNotSet
=
""
):
print
(
" "
+
"["
+
str
(
bit
)
+
"] "
+
label
+
":"
)
if
value
&
(
1
<<
bit
):
print
(
ConColors
.
GREEN
+
" 1: "
+
ifSet
+
ConColors
.
NONE
)
else
:
print
(
ConColors
.
RED
+
" 0: "
+
ifNotSet
+
ConColors
.
NONE
)
def
PrintBits
(
value
,
bitFrom
,
bitTo
,
label
,
descriptions
):
def
PrintBits
(
value
,
bitFrom
,
bitTo
,
label
,
descriptions
=
()
):
print
(
" "
+
"["
+
str
(
bitTo
)
+
":"
+
str
(
bitFrom
)
+
"] "
+
label
+
":"
)
value
&=
(
1
<<
bitTo
+
1
)
-
1
value
>>=
bitFrom
color
=
ConColors
.
YELLOW
description
=
descriptions
[
value
]
if
value
>
len
(
descriptions
)
-
1
:
color
=
ConColors
.
RED
description
=
"<unknown>"
else
:
description
=
descriptions
[
value
]
print
(
color
+
" "
+
str
(
value
)
+
": "
+
description
+
ConColors
.
NONE
)
def
ErrorMsg
(
Text
):
print
(
ConColors
.
RED
+
ConColors
.
BOLD
+
"!!! Error: "
+
ConColors
.
NONE
+
ConColors
.
RED
+
Text
+
ConColors
.
NONE
)
def
WarningMsg
(
Text
):
print
(
ConColors
.
YELLOW
+
ConColors
.
BOLD
+
"Warning: "
+
ConColors
.
NONE
+
ConColors
.
YELLOW
+
Text
+
ConColors
.
NONE
)
def
InfoMsg
(
Text
):
print
(
ConColors
.
CYAN
+
ConColors
.
BOLD
+
"Info: "
+
ConColors
.
NONE
+
Text
)
def
OkMsg
(
Text
):
print
(
ConColors
.
GREEN
+
ConColors
.
BOLD
+
"OK: "
+
ConColors
.
NONE
+
Text
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment