Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
Hdlmake
Manage
Activity
Members
Labels
Plan
Issues
20
Issue boards
Milestones
Wiki
Code
Merge requests
5
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
Hdlmake
Commits
af468dec
Commit
af468dec
authored
11 years ago
by
Paweł Szostek
Browse files
Options
Downloads
Patches
Plain Diff
comment out leftovers of ancient code
parent
f3cb9d26
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
hdlmake/srcfile.py
+156
-156
156 additions, 156 deletions
hdlmake/srcfile.py
with
156 additions
and
156 deletions
hdlmake/srcfile.py
+
156
−
156
View file @
af468dec
...
...
@@ -46,9 +46,9 @@ class SourceFile(DepFile):
include_paths
=
module
.
include_dirs
[:])
def
gen_index
(
self
):
self
.
__class__
.
cur_index
=
self
.
__class__
.
cur_index
+
1
return
self
.
__class__
.
cur_index
#
def gen_index(self):
#
self.__class__.cur_index = self.__class__.cur_index+1
#
return self.__class__.cur_index
class
VHDLFile
(
SourceFile
):
...
...
@@ -68,88 +68,88 @@ class VHDLFile(SourceFile):
else
:
return
False
def
_create_deps_provides
(
self
):
if
self
.
_check_encryption
():
self
.
dep_index
=
SourceFile
.
gen_index
(
self
)
else
:
self
.
dep_provides
=
list
(
self
.
_search_packages
())
logging
.
debug
(
self
.
path
+
"
provides
"
+
str
(
self
.
dep_provides
))
def
_create_deps_requires
(
self
):
if
self
.
_check_encryption
():
self
.
dep_index
=
SourceFile
.
gen_index
(
self
)
else
:
self
.
dep_requires
=
list
(
self
.
_search_use_clauses
())
logging
.
debug
(
self
.
path
+
"
provides
"
+
str
(
self
.
dep_provides
))
def
_search_use_clauses
(
self
):
"""
Reads a file and looks for
'
use
'
clause. For every
'
use
'
with
non-standard library a tuple (lib, file) is returned in a list.
"""
# Modification here! global_mod.top_module.action does not
# get set for top module in time. FIX this
std_libs
=
[
'
std
'
,
'
ieee
'
]
if
global_mod
.
top_module
.
action
==
"
simulation
"
:
try
:
if
global_mod
.
top_module
.
sim_tool
==
"
isim
"
:
std_libs
=
ise
.
XilinxsiminiReader
().
get_libraries
()
elif
global_mod
.
top_module
.
sim_tool
==
"
vsim
"
or
global_mod
.
top_module
.
sim_tool
==
"
modelsim
"
:
std_libs
=
modelsim
.
ModelsiminiReader
().
get_libraries
()
elif
global_mod
.
top_module
.
sim_tool
==
"
iverilog
"
:
std_libs
=
modelsim
.
MODELSIM_STANDARD_LIBS
else
:
logging
.
warning
(
"
Could not determine simulation tool. Defaulting to Modelsim
"
)
std_libs
=
modelsim
.
MODELSIM_STANDARD_LIBS
except
RuntimeError
as
e
:
logging
.
error
(
"
I/O error: ({0})
"
.
format
(
e
.
message
))
logging
.
error
(
"
Picking standard Modelsim simulation libraries. Try to fix the error.
"
)
std_libs
=
modelsim
.
MODELSIM_STARDAND_LIBS
elif
global_mod
.
top_module
.
action
==
"
synthesis
"
:
if
global_mod
.
top_module
.
target
==
"
xilinx
"
:
std_libs
=
ise
.
ISE_STANDARD_LIBS
elif
global_mod
.
top_module
.
target
==
"
altera
"
:
std_libs
=
quartus
.
QUARTUS_STANDARD_LIBS
import
re
try
:
f
=
open
(
self
.
path
,
"
r
"
)
text
=
f
.
readlines
()
except
UnicodeDecodeError
:
return
[]
use_pattern
=
re
.
compile
(
"
^[
\t
]*use[
\t
]+([^; ]+)[
\t
]*;.*$
"
)
lib_pattern
=
re
.
compile
(
"
([^.]+)\.([^.]+)\.all
"
)
use_lines
=
[]
for
line
in
text
:
#identifiers and keywords are case-insensitive in VHDL
line_lower
=
line
.
lower
()
m
=
re
.
match
(
use_pattern
,
line_lower
)
if
m
is
not
None
:
use_lines
.
append
(
m
.
group
(
1
))
ret
=
set
()
for
line
in
use_lines
:
m
=
re
.
match
(
lib_pattern
,
line
)
if
m
is
not
None
:
#omit standard libraries
if
(
m
.
group
(
1
)).
lower
()
in
std_libs
:
continue
if
self
.
library
!=
"
work
"
:
#if a file is put in a library, `work' points this library
new
=
(
self
.
library
.
lower
(),
m
.
group
(
2
).
lower
())
else
:
new
=
(
m
.
group
(
1
).
lower
(),
m
.
group
(
2
).
lower
())
#dont add if the tuple is already in the list
if
new
in
self
.
dep_provides
:
continue
ret
.
add
(
new
)
f
.
close
()
return
ret
#
def _create_deps_provides(self):
#
if self._check_encryption():
#
self.dep_index = SourceFile.gen_index(self)
#
else:
#
self.dep_provides = list(self._search_packages())
#
logging.debug(self.path + " provides " + str(self.dep_provides))
#
def _create_deps_requires(self):
#
if self._check_encryption():
#
self.dep_index = SourceFile.gen_index(self)
#
else:
#
self.dep_requires = list(self._search_use_clauses())
#
logging.debug(self.path + " provides " + str(self.dep_provides))
#
def _search_use_clauses(self):
#
"""
#
Reads a file and looks for 'use' clause. For every 'use' with
#
non-standard library a tuple (lib, file) is returned in a list.
#
"""
#
# Modification here! global_mod.top_module.action does not
#
# get set for top module in time. FIX this
#
std_libs = ['std', 'ieee']
#
if global_mod.top_module.action == "simulation":
#
try:
#
if global_mod.top_module.sim_tool == "isim":
#
std_libs = ise.XilinxsiminiReader().get_libraries()
#
elif global_mod.top_module.sim_tool == "vsim" or global_mod.top_module.sim_tool == "modelsim":
#
std_libs = modelsim.ModelsiminiReader().get_libraries()
#
elif global_mod.top_module.sim_tool == "iverilog":
#
std_libs = modelsim.MODELSIM_STANDARD_LIBS
#
else:
#
logging.warning("Could not determine simulation tool. Defaulting to Modelsim")
#
std_libs = modelsim.MODELSIM_STANDARD_LIBS
#
except RuntimeError as e:
#
logging.error("I/O error: ({0})".format(e.message))
#
logging.error("Picking standard Modelsim simulation libraries. Try to fix the error.")
#
std_libs = modelsim.MODELSIM_STARDAND_LIBS
#
elif global_mod.top_module.action == "synthesis":
#
if global_mod.top_module.target == "xilinx":
#
std_libs = ise.ISE_STANDARD_LIBS
#
elif global_mod.top_module.target == "altera":
#
std_libs = quartus.QUARTUS_STANDARD_LIBS
#
import re
#
try:
#
f = open(self.path, "r")
#
text = f.readlines()
#
except UnicodeDecodeError:
#
return []
#
use_pattern = re.compile("^[ \t]*use[ \t]+([^; ]+)[ \t]*;.*$")
#
lib_pattern = re.compile("([^.]+)\.([^.]+)\.all")
#
use_lines = []
#
for line in text:
#
#identifiers and keywords are case-insensitive in VHDL
#
line_lower = line.lower()
#
m = re.match(use_pattern, line_lower)
#
if m is not None:
#
use_lines.append(m.group(1))
#
ret = set()
#
for line in use_lines:
#
m = re.match(lib_pattern, line)
#
if m is not None:
#
#omit standard libraries
#
if (m.group(1)).lower() in std_libs:
#
continue
#
if self.library != "work":
#
#if a file is put in a library, `work' points this library
#
new = (self.library.lower(), m.group(2).lower())
#
else:
#
new = (m.group(1).lower(), m.group(2).lower())
#
#dont add if the tuple is already in the list
#
if new in self.dep_provides:
#
continue
#
ret.add(new)
#
f.close()
#
return ret
class
VerilogFile
(
SourceFile
):
...
...
@@ -166,77 +166,77 @@ class VerilogFile(SourceFile):
self
.
include_dirs
.
extend
(
include_dirs
)
self
.
include_dirs
.
append
(
path_mod
.
relpath
(
self
.
dirname
))
def
_create_deps_provides
(
self
):
# self.dep_requires = self.__search_includes()
# self.dep_provides = self.name
self
.
dep_provides
=
self
.
name
def
_create_deps_requires
(
self
):
# self.dep_requires = self.__search_includes()
# self.dep_provides = self.name
if
global_mod
.
top_module
.
sim_tool
==
"
iverilog
"
:
deps
=
self
.
_get_iverilog_dependencies
()
self
.
dep_requires
=
deps
else
:
self
.
dep_requires
=
self
.
_search_includes
()
def
_get_iverilog_dependencies
(
self
):
#
TODO
:
C
heck to see dependencies.list doesn't exist already
if
self
.
path
.
endswith
(
"
.vh
"
)
and
global_mod
.
top_module
.
sim_tool
==
"
iverilog
"
:
return
[]
inc_dirs
=
[]
#inc_dirs = global_mod.top_module.include_dirs
inc_dirs
=
self
.
include_dirs
if
global_mod
.
mod_pool
:
inc_dirs
.
extend
([
os
.
path
.
relpath
(
m
.
path
)
for
m
in
global_mod
.
mod_pool
])
inc_dirs
=
list
(
set
(
inc_dirs
))
vlog_opt
=
global_mod
.
top_module
.
vlog_opt
dep
F
ile
N
ame
=
"
dependencies.list
"
command
=
"
iverilog -
DSIMULATE
-
W
no-timescale -t null -
M
"
+
dep
F
ile
N
ame
command
+=
""
.
join
(
map
(
lambda
x
:
"
-y
"
+
x
,
inc_dirs
))
command
+=
""
.
join
(
map
(
lambda
x
:
"
-
I
"
+
x
,
inc_dirs
))
#
TODO
:
H
ave to find a way to handle this cleanly
if
self
.
rel_path
().
find
(
"
config_romx_llrf4
"
)
>
-
1
:
command
+=
"
"
+
vlog_opt
else
:
command
+=
"
"
+
vlog_opt
+
"
"
+
self
.
rel_path
()
logging
.
debug
(
"
running %s
"
%
command
)
retcode
=
os
.
system
(
command
)
# iverilog_cmd =
P
open(command, shell=
T
rue, stdin=
PIPE
,
# stdout=
PIPE
, close_fds=
T
rue)
# iverilog_cmd.stdout.readlines()
# iverilog_cmd.wait()
# retcode = iverilog_cmd.returncode
print
(
"
retcode
"
,
retcode
)
if
retcode
and
retcode
!=
256
:
logging
.
error
(
"
D
ependencies not met for %s
"
%
str
(
self
.
path
))
logging
.
debug
(
command
,
self
.
include_dirs
,
inc_dirs
,
global_mod
.
mod_pool
)
quit
()
elif
retcode
==
256
:
#dependencies met
pass
dep
F
ile
=
open
(
dep
F
ile
N
ame
,
"
r
"
)
dep
F
iles
=
list
(
set
([
l
.
strip
()
for
l
in
dep
F
ile
.
readlines
()]))
dep
F
ile
.
close
()
return
dep
F
iles
def
_search_includes
(
self
):
import
re
f
=
open
(
self
.
path
,
"
r
"
)
try
:
text
=
f
.
readlines
()
except
U
nicode
D
ecode
E
rror
:
return
[]
include_pattern
=
re
.
compile
(
"
^[
\t
]*`include[
\t
]+
\"
([^
\"
]+)
\"
.*$
"
)
ret
=
[]
for
line
in
text
:
#in
V
erilog and
SV
identifiers are case-sensitive
m
=
re
.
match
(
include_pattern
,
line
)
if
m
is
not
N
one
:
ret
.
append
(
m
.
group
(
1
))
f
.
close
()
return
ret
#
def _create_deps_provides(self):
#
# self.dep_requires = self.__search_includes()
#
# self.dep_provides = self.name
#
self.dep_provides = self.name
#
def _create_deps_requires(self):
#
# self.dep_requires = self.__search_includes()
#
# self.dep_provides = self.name
#
if global_mod.top_module.sim_tool == "iverilog":
#
deps = self._get_iverilog_dependencies()
#
self.dep_requires = deps
#
else:
#
self.dep_requires = self._search_includes()
#
def _get_iverilog_dependencies(self):
#
#
todo
:
c
heck to see dependencies.list doesn't exist already
#
if self.path.endswith(".vh") and global_mod.top_module.sim_tool == "iverilog":
#
return []
#
inc_dirs = []
#
#inc_dirs = global_mod.top_module.include_dirs
#
inc_dirs = self.include_dirs
#
if global_mod.mod_pool:
#
inc_dirs.extend([os.path.relpath(m.path) for m in global_mod.mod_pool])
#
inc_dirs = list(set(inc_dirs))
#
vlog_opt = global_mod.top_module.vlog_opt
#
dep
f
ile
n
ame = "dependencies.list"
#
command = "iverilog -
dsimulate
-
w
no-timescale -t null -
m
" + dep
f
ile
n
ame
#
command += "".join(map(lambda x: " -y"+x, inc_dirs))
#
command += "".join(map(lambda x: " -
i
"+x, inc_dirs))
#
#
todo
:
h
ave to find a way to handle this cleanly
#
if self.rel_path().find("config_romx_llrf4") > -1:
#
command += " " + vlog_opt
#
else:
#
command += " " + vlog_opt + " " + self.rel_path()
#
logging.debug("running %s" % command)
#
retcode = os.system(command)
#
# iverilog_cmd =
p
open(command, shell=
t
rue, stdin=
pipe
,
#
# stdout=
pipe
, close_fds=
t
rue)
#
# iverilog_cmd.stdout.readlines()
#
# iverilog_cmd.wait()
#
# retcode = iverilog_cmd.returncode
#
print("retcode", retcode)
#
if retcode and retcode != 256:
#
logging.error("
d
ependencies not met for %s" % str(self.path))
#
logging.debug(command, self.include_dirs, inc_dirs, global_mod.mod_pool)
#
quit()
#
elif retcode == 256:
#
#dependencies met
#
pass
#
dep
f
ile = open(dep
f
ile
n
ame, "r")
#
dep
f
iles = list(set([l.strip() for l in dep
f
ile.readlines()]))
#
dep
f
ile.close()
#
return dep
f
iles
#
def _search_includes(self):
#
import re
#
f = open(self.path, "r")
#
try:
#
text = f.readlines()
#
except
u
nicode
d
ecode
e
rror:
#
return []
#
include_pattern = re.compile("^[ \t]*`include[ \t]+\"([^ \"]+)\".*$")
#
ret = []
#
for line in text:
#
#in
v
erilog and
sv
identifiers are case-sensitive
#
m = re.match(include_pattern, line)
#
if m is not
n
one:
#
ret.append(m.group(1))
#
f.close()
#
return ret
class
SVFile
(
VerilogFile
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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