Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
Hdlmake
Commits
1d1ab3f7
Commit
1d1ab3f7
authored
Aug 01, 2019
by
William Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upgrade Qsys file parsing to decode the actual XML, not just a simple regex.
parent
1dd1da5f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
21 deletions
+41
-21
srcfile.py
hdlmake/srcfile.py
+41
-21
No files found.
hdlmake/srcfile.py
View file @
1d1ab3f7
...
@@ -33,9 +33,10 @@ from .dep_file import DepFile, File, DepRelation
...
@@ -33,9 +33,10 @@ from .dep_file import DepFile, File, DepRelation
from
.new_dep_solver
import
DepParser
from
.new_dep_solver
import
DepParser
import
six
import
six
import
re
import
xml.etree.ElementTree
as
ET
import
io
import
mmap
from
.vhdl_parser
import
VHDLParser
class
SourceFile
(
DepFile
):
class
SourceFile
(
DepFile
):
...
@@ -64,7 +65,6 @@ class VHDLFile(SourceFile):
...
@@ -64,7 +65,6 @@ class VHDLFile(SourceFile):
def
__init__
(
self
,
path
,
module
,
library
=
None
):
def
__init__
(
self
,
path
,
module
,
library
=
None
):
SourceFile
.
__init__
(
self
,
path
=
path
,
module
=
module
,
library
=
library
)
SourceFile
.
__init__
(
self
,
path
=
path
,
module
=
module
,
library
=
library
)
from
hdlmake.vhdl_parser
import
VHDLParser
self
.
parser
=
VHDLParser
(
self
)
self
.
parser
=
VHDLParser
(
self
)
...
@@ -296,31 +296,51 @@ class QSYSFile(SourceFile):
...
@@ -296,31 +296,51 @@ class QSYSFile(SourceFile):
"""Qsys - Altera's System Integration Tool"""
"""Qsys - Altera's System Integration Tool"""
def
__init__
(
self
,
path
,
module
):
def
__init__
(
self
,
path
,
module
):
assert
isinstance
(
path
,
six
.
string_types
)
assert
isinstance
(
path
,
six
.
string_types
)
filename
=
os
.
path
.
basename
(
path
)
tree
=
ET
.
parse
(
path
)
entity
=
filename
.
rsplit
(
"."
,
1
)[
0
]
# making some poor assumptions here.
root
=
tree
.
getroot
()
library
=
entity
# and here.
entity
=
root
.
attrib
[
"name"
]
library
=
entity
SourceFile
.
__init__
(
self
,
SourceFile
.
__init__
(
self
,
path
=
path
,
path
=
path
,
module
=
module
,
module
=
module
,
library
=
library
)
library
=
library
)
obj_name
=
"
%
s.
%
s"
%
(
library
,
entity
)
obj_name
=
"
%
s.
%
s"
%
(
library
,
entity
)
self
.
add_relation
(
DepRelation
(
obj_name
,
DepRelation
.
PROVIDE
,
DepRelation
.
ENTITY
))
provides
=
DepRelation
(
obj_name
,
DepRelation
.
PROVIDE
,
DepRelation
.
ENTITY
)
self
.
add_relation
(
DepRelation
(
obj_name
,
DepRelation
.
PROVIDE
,
DepRelation
.
ARCHITECTURE
))
self
.
add_relation
(
provides
)
filename
=
os
.
path
.
basename
(
path
)
logging
.
debug
(
"
%
s -> provides
%
s"
%
(
filename
,
obj_name
))
logging
.
debug
(
"
%
s -> provides
%
s"
%
(
filename
,
obj_name
))
with
io
.
open
(
path
,
'r'
,
encoding
=
"utf-8"
)
as
qsys_file
:
# Avoid loading entire file into memory - since it is a large file.
for
module
in
root
.
iterfind
(
"module"
):
with
mmap
.
mmap
(
qsys_file
.
fileno
(),
0
,
access
=
mmap
.
ACCESS_READ
)
as
qsys_xml
:
for
param
in
module
.
iterfind
(
"parameter[@name='generationInfoDefinition']"
):
child_re
=
r'<hdlLibraryName>(?P<entity>[\w_\d]+)</hdlLibraryName>'
#print(param.tag, param.attrib)
pattern
=
re
.
compile
(
child_re
.
encode
(
"utf-8"
))
cdata_node
=
ET
.
fromstring
(
param
.
text
)
for
match
in
pattern
.
finditer
(
qsys_xml
):
dep_on_lib
=
cdata_node
.
find
(
"hdlLibraryName"
)
.
text
entity
=
str
(
match
.
group
(
"entity"
)
.
decode
(
'utf-8'
))
dep_on_entity
=
cdata_node
.
find
(
"fileSets/fileSet/fileSetFixedName"
)
.
text
library
=
entity
top_level_kind
=
None
obj_name
=
"
%
s.
%
s"
%
(
library
,
entity
)
for
fileSetFile
in
cdata_node
.
iterfind
(
"fileSets/fileSet[fileSetKind='QUARTUS_SYNTH']/fileSetFiles/fileSetFile"
):
depends
=
DepRelation
(
obj_name
,
DepRelation
.
USE
,
DepRelation
.
ENTITY
)
if
fileSetFile
.
find
(
"[fileKind='VERILOG']/fileAttributes/entry[key='TOP_LEVEL_FILE'][value='true']"
)
is
not
None
:
self
.
add_relation
(
depends
)
top_level_kind
=
'verilog'
logging
.
debug
(
"
%
s -> depends
%
s"
%
(
filename
,
obj_name
))
break
elif
fileSetFile
.
find
(
"[fileKind='VHDL']/fileAttributes/entry[key='TOP_LEVEL_FILE'][value='true']"
)
is
not
None
:
top_level_kind
=
'vhdl'
break
else
:
param
=
module
.
find
(
"parameter[@name='logicalView']"
)
if
'value'
in
param
.
attrib
:
top_level_kind
=
"qsys"
elif
param
.
text
is
not
None
:
top_level_kind
=
"ip"
else
:
logging
.
warning
(
"Cannot determine the kind of module for
%
s.
%
s in
%
s"
%
(
dep_on_lib
,
dep_on_entity
,
filename
))
obj_name
=
"
%
s.
%
s"
%
(
dep_on_lib
,
dep_on_entity
)
depends
=
DepRelation
(
obj_name
,
DepRelation
.
USE
,
DepRelation
.
ENTITY
)
self
.
add_relation
(
depends
)
logging
.
debug
(
"
%
s -> depends
%
s (kind:
%
s)"
%
(
filename
,
obj_name
,
top_level_kind
))
self
.
is_parsed
=
True
self
.
is_parsed
=
True
class
DPFFile
(
File
):
class
DPFFile
(
File
):
"""This is the class providing Altera Quartus Design Protocol File"""
"""This is the class providing Altera Quartus Design Protocol File"""
pass
pass
...
...
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