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
16860fb6
Commit
16860fb6
authored
Jun 11, 2013
by
Paweł Szostek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
corrections suggested by linter
parent
68dafd67
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
676 additions
and
662 deletions
+676
-662
__main__.py
src/__main__.py
+11
-10
configparser.py
src/configparser.py
+30
-29
connection.py
src/connection.py
+8
-8
dep_solver.py
src/dep_solver.py
+14
-14
fetch.py
src/fetch.py
+14
-14
flow.py
src/flow.py
+5
-5
flow_altera.py
src/flow_altera.py
+34
-34
global_mod.py
src/global_mod.py
+4
-4
hdlmake_kernel.py
src/hdlmake_kernel.py
+43
-43
makefile_writer.py
src/makefile_writer.py
+57
-57
manifest_parser.py
src/manifest_parser.py
+20
-19
module.py
src/module.py
+65
-54
msg.py
src/msg.py
+6
-6
new_dep_solver.py
src/new_dep_solver.py
+57
-57
path.py
src/path.py
+9
-9
srcfile.py
src/srcfile.py
+13
-13
vlog_parser.py
src/vlog_parser.py
+286
-286
No files found.
src/__main__.py
View file @
16860fb6
...
...
@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
...
...
@@ -68,7 +68,7 @@ def main():
default
=
None
,
help
=
"List all files in a from of a space-separated string"
)
parser
.
add_option
(
"--merge-cores=name"
,
default
=
None
,
dest
=
"merge_cores"
,
help
=
"Merges entire synthesizable content of an project into a pair of VHDL/Verilog files"
)
help
=
"Merges entire synthesizable content of an project into a pair of VHDL/Verilog files"
)
parser
.
add_option
(
"--ise-proj"
,
action
=
"store_true"
,
dest
=
"ise_proj"
,
default
=
None
,
help
=
"create/update an ise project including list of project"
...
...
@@ -110,27 +110,28 @@ def main():
global_mod
.
options
=
options
#HANDLE PROJECT INDEPENDENT OPTIONS
if
options
.
manifest_help
==
True
:
if
options
.
manifest_help
is
True
:
from
manifest_parser
import
ManifestParser
ManifestParser
()
.
help
()
quit
()
if
options
.
print_version
==
True
:
if
options
.
print_version
is
True
:
p
.
print_version
()
quit
()
# Check later if a simulation tool should have been specified
if
options
.
make_isim
==
True
:
if
options
.
make_isim
is
True
:
global_mod
.
sim_tool
=
"isim"
elif
options
.
make_vsim
==
True
:
elif
options
.
make_vsim
is
True
:
global_mod
.
sim_tool
=
"vsim"
p
.
info
(
"Simulation tool: "
+
str
(
global_mod
.
sim_tool
))
p
.
vprint
(
"LoadTopManifest"
)
pool
=
ModulePool
()
pool
.
new_module
(
parent
=
None
,
url
=
os
.
getcwd
(),
source
=
"local"
,
fetchto
=
"."
)
# Setting top_module as top module of design (ModulePool class)
if
pool
.
get_top_module
()
.
manifest
==
None
:
if
pool
.
get_top_module
()
.
manifest
is
None
:
p
.
rawprint
(
"No manifest found. At least an empty one is needed"
)
p
.
rawprint
(
"To see some help, type hdlmake --help"
)
quit
()
...
...
src/configparser.py
View file @
16860fb6
...
...
@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
...
...
@@ -23,6 +23,7 @@ import sys
import
StringIO
import
contextlib
@
contextlib
.
contextmanager
def
stdoutIO
(
stdout
=
None
):
old
=
sys
.
stdout
...
...
@@ -32,12 +33,13 @@ def stdoutIO(stdout=None):
yield
stdout
sys
.
stdout
=
old
class
ConfigParser
(
object
):
"""Class for parsing python configuration files
Case1: Normal usage
>>> f = open("test.py", "w")
>>> f.write('modules = {"local":"/path/to/local", "svn":"path/to/svn"}
;
')
>>> f.write('modules = {"local":"/path/to/local", "svn":"path/to/svn"} ')
>>> f.write('fetchto = ".."' )
>>> f.close()
>>> p = ConfigParser()
...
...
@@ -143,16 +145,15 @@ class ConfigParser(object):
elif
key
==
"default"
:
self
.
default
=
others
[
"default"
]
elif
key
==
"type"
:
self
.
add_type
(
type_obj
=
others
[
"type"
])
self
.
add_type
(
type_obj
=
others
[
"type"
])
else
:
raise
ValueError
(
"Option not recognized: "
+
key
)
def
add_type
(
self
,
type_obj
):
self
.
types
.
append
(
type
(
type_obj
))
def
__init__
(
self
,
description
=
None
):
if
description
!=
None
:
def
__init__
(
self
,
description
=
None
):
if
description
is
None
:
if
not
isinstance
(
description
,
str
):
raise
ValueError
(
"Description should be a string!"
)
self
.
description
=
description
...
...
@@ -168,25 +169,25 @@ class ConfigParser(object):
def
__getitem__
(
self
,
name
):
if
name
in
self
.
__names
():
return
[
x
for
x
in
self
.
options
if
x
!=
None
and
x
.
name
==
name
][
0
]
return
[
x
for
x
in
self
.
options
if
x
is
None
and
x
.
name
==
name
][
0
]
else
:
raise
RuntimeError
(
"No such option as "
+
str
(
name
))
def
help
(
self
):
p
.
rawprint
(
"Variables available in a manifest:"
)
for
opt
in
self
.
options
:
if
opt
==
None
:
if
opt
is
None
:
p
.
rawprint
(
""
)
continue
line
=
' {0:15}
; {1:29};
{2:45}{3}{4:10}'
line
=
' {0:15}
{1:29}
{2:45}{3}{4:10}'
try
:
tmp_def
=
opt
.
default
if
tmp_def
==
""
:
tmp_def
=
'""'
line
=
line
.
format
(
opt
.
name
,
str
(
opt
.
types
),
opt
.
help
,
', default='
,
tmp_def
)
except
AttributeError
:
#
no default value
line
=
line
.
format
(
opt
.
name
,
str
(
opt
.
types
),
opt
.
help
,
""
,
""
)
line
=
line
.
format
(
opt
.
name
,
str
(
opt
.
types
),
opt
.
help
,
', default='
,
tmp_def
)
except
AttributeError
:
#
no default value
line
=
line
.
format
(
opt
.
name
,
str
(
opt
.
types
),
opt
.
help
,
""
,
""
)
p
.
rawprint
(
line
)
def
add_option
(
self
,
name
,
**
others
):
...
...
@@ -217,7 +218,7 @@ class ConfigParser(object):
def
add_config_file
(
self
,
config_file
):
if
self
.
config_file
is
not
None
:
raise
RuntimeError
(
"Config file should be added only once"
)
import
os
if
not
os
.
path
.
exists
(
config_file
):
raise
RuntimeError
(
"Config file doesn't exists: "
+
config_file
)
...
...
@@ -228,16 +229,16 @@ class ConfigParser(object):
self
.
arbitrary_code
+=
code
+
'
\n
'
def
__names
(
self
):
return
[
o
.
name
for
o
in
self
.
options
if
o
!=
None
]
return
[
o
.
name
for
o
in
self
.
options
if
o
is
None
]
def
parse
(
self
):
options
=
{}
ret
=
{}
if
self
.
config_file
is
not
None
:
with
open
(
self
.
config_file
,
"r"
)
as
config_file
:
content
=
open
(
self
.
config_file
,
"r"
)
.
readlines
()
content
=
''
.
join
(
content
)
if
self
.
config_file
is
not
None
:
with
open
(
self
.
config_file
,
"r"
)
as
config_file
:
content
=
config_file
.
readlines
()
content
=
''
.
join
(
content
)
else
:
content
=
''
content
=
self
.
arbitrary_code
+
'
\n
'
+
content
...
...
@@ -274,14 +275,14 @@ class ConfigParser(object):
p
.
rawprint
(
"> "
+
line
)
#print "out:", s.getvalue()
except
SyntaxError
as
e
:
p
.
error
(
"Invalid syntax in the manifest file "
+
self
.
config_file
+
":
\n
"
+
str
(
e
))
p
.
error
(
"Invalid syntax in the manifest file "
+
self
.
config_file
+
":
\n
"
+
str
(
e
))
quit
()
except
:
p
.
error
(
"Encountered unexpected error while parsing "
+
self
.
config_file
)
p
.
rawprint
(
str
(
sys
.
exc_info
()[
0
])
+
':'
+
str
(
sys
.
exc_info
()[
1
]))
p
.
rawprint
(
str
(
sys
.
exc_info
()[
0
])
+
':'
+
str
(
sys
.
exc_info
()[
1
]))
quit
()
for
opt_name
,
val
in
list
(
options
.
items
()):
#
check delivered options
for
opt_name
,
val
in
list
(
options
.
items
()):
#
check delivered options
if
opt_name
.
startswith
(
'__'
):
continue
if
opt_name
not
in
self
.
__names
():
...
...
@@ -300,15 +301,15 @@ class ConfigParser(object):
try
:
for
key
in
val
:
if
key
not
in
self
[
opt_name
]
.
allowed_keys
:
raise
RuntimeError
(
"Encountered unallowed key: "
+
key
+
" for options '"
+
opt_name
+
"'"
)
except
AttributeError
:
#
no allowed_keys member - don't perform any check
raise
RuntimeError
(
"Encountered unallowed key: "
+
key
+
" for options '"
+
opt_name
+
"'"
)
except
AttributeError
:
#
no allowed_keys member - don't perform any check
pass
for
opt
in
self
.
options
:
#
set values for not listed items with defaults
for
opt
in
self
.
options
:
#
set values for not listed items with defaults
try
:
if
opt
.
name
not
in
ret
:
ret
[
opt
.
name
]
=
opt
.
default
except
AttributeError
:
#
no default value in the option
except
AttributeError
:
#
no default value in the option
pass
return
ret
...
...
@@ -318,4 +319,4 @@ def _test():
doctest
.
testmod
()
if
__name__
==
"__main__"
:
_test
()
\ No newline at end of file
_test
()
src/connection.py
View file @
16860fb6
...
...
@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
...
...
@@ -25,11 +25,11 @@ import msg as p
class
Connection
:
def
__init__
(
self
,
ssh_user
,
ssh_server
):
#if ssh_user
==
None:
#if ssh_user
is
None:
# ssh_user = os.getenv("HDLMAKE_USER")
self
.
ssh_user
=
ssh_user
#if ssh_server
==
None:
#if ssh_server
is
None:
# ssh_server = os.getenv("HDLMAKE_SERVER")
self
.
ssh_server
=
ssh_server
...
...
@@ -37,7 +37,7 @@ class Connection:
return
self
.
ssh_user
+
'@'
+
self
.
ssh_server
def
__data_given
(
self
):
return
self
.
ssh_user
!=
None
and
self
.
ssh_server
!=
None
return
self
.
ssh_user
is
None
and
self
.
ssh_server
is
None
def
__check
(
self
):
if
not
self
.
__data_given
():
...
...
@@ -57,7 +57,7 @@ class Connection:
"""
self
.
__check
()
#create a new catalogue on remote machine
if
dest_folder
==
None
:
if
dest_folder
is
None
:
dest_folder
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
x
in
range
(
8
))
mkdir_cmd
=
'mkdir -p '
+
dest_folder
import
msg
as
p
...
...
src/dep_solver.py
View file @
16860fb6
...
...
@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
...
...
@@ -25,16 +25,16 @@ import os.path
class
IDependable
:
def
__init__
(
self
):
self
.
dep_index
=
0
;
self
.
_dep_fixed
=
False
;
self
.
__dep_provides
=
[]
;
self
.
__dep_requires
=
[]
;
self
.
__dep_depends_on
=
[]
;
self
.
dep_index
=
0
self
.
_dep_fixed
=
False
self
.
__dep_provides
=
[]
self
.
__dep_requires
=
[]
self
.
__dep_depends_on
=
[]
pass
#use proxy template here
def
get_dep_provides
(
self
):
if
self
.
_dep_fixed
==
False
:
if
self
.
_dep_fixed
is
False
:
self
.
__create_deps
()
# self._dep_fixed = True
return
self
.
__dep_provides
...
...
@@ -44,7 +44,7 @@ class IDependable:
dep_provides
=
property
(
get_dep_provides
,
set_dep_provides
)
def
get_dep_requires
(
self
):
if
self
.
_dep_fixed
==
False
:
if
self
.
_dep_fixed
is
False
:
self
.
__create_deps
()
# self._dep_fixed = True
return
self
.
__dep_requires
...
...
@@ -66,7 +66,7 @@ class IDependable:
class
DependencySolver
:
def
__init__
(
self
):
self
.
entities
=
{}
;
self
.
entities
=
{}
def
__lookup_post_provider
(
self
,
files
,
start_index
,
file
):
requires
=
file
.
dep_requires
...
...
@@ -235,8 +235,8 @@ class DependencySolver:
newobj
=
sf
.
SourceFileSet
()
;
newobj
.
add
(
f_nondep
)
;
newobj
=
sf
.
SourceFileSet
()
newobj
.
add
(
f_nondep
)
for
f
in
fset
:
try
:
if
not
f
.
_dep_fixed
:
...
...
src/fetch.py
View file @
16860fb6
...
...
@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
...
...
@@ -24,12 +24,13 @@ import msg as p
import
path
import
global_mod
class
ModulePool
(
list
):
class
ModuleFetcher
:
def
__init__
(
self
):
pass
def
fetch_single_module
(
self
,
module
):
import
global_mod
new_modules
=
[]
p
.
vprint
(
"Fetching module: "
+
str
(
module
))
...
...
@@ -37,8 +38,8 @@ class ModulePool(list):
p
.
vprint
(
"ModPath: "
+
module
.
path
)
else
:
p
.
printhr
()
p
.
info
(
"Fetching module: "
+
str
(
module
)
+
\
" [parent: "
+
str
(
module
.
parent
)
+
"]"
)
p
.
info
(
"Fetching module: "
+
str
(
module
)
+
" [parent: "
+
str
(
module
.
parent
)
+
"]"
)
if
module
.
source
==
"svn"
:
p
.
info
(
"[svn] Fetching to "
+
module
.
fetchto
)
self
.
__fetch_from_svn
(
module
)
...
...
@@ -82,14 +83,14 @@ class ModulePool(list):
os
.
mkdir
(
module
.
fetchto
)
cur_dir
=
os
.
getcwd
()
if
module
.
branch
==
None
:
if
module
.
branch
is
None
:
module
.
branch
=
"master"
basename
=
path
.
url_basename
(
module
.
url
)
mod_path
=
os
.
path
.
join
(
module
.
fetchto
,
basename
)
if
basename
.
endswith
(
".git"
):
basename
=
basename
[:
-
4
]
#
remove trailing .git
basename
=
basename
[:
-
4
]
#
remove trailing .git
if
module
.
isfetched
:
update_only
=
True
...
...
@@ -121,7 +122,6 @@ class ModulePool(list):
module
.
path
=
mod_path
return
rval
def
__init__
(
self
,
*
args
):
list
.
__init__
(
self
,
*
args
)
self
.
top_module
=
None
...
...
@@ -145,7 +145,7 @@ class ModulePool(list):
return
[
m
for
m
in
self
if
m
.
url
==
url
][
0
]
else
:
if
self
.
global_fetch
:
# if there is global fetch parameter (HDLMAKE_COREDIR env variable)
fetchto
=
self
.
global_fetch
# screw module's particular fetchto
fetchto
=
self
.
global_fetch
# screw module's particular fetchto
elif
global_mod
.
top_module
:
fetchto
=
global_mod
.
top_module
.
fetchto
...
...
@@ -169,7 +169,7 @@ class ModulePool(list):
self
.
append
(
new_module
)
return
True
def
fetch_all
(
self
,
unfetched_only
=
False
):
def
fetch_all
(
self
,
unfetched_only
=
False
):
fetcher
=
self
.
ModuleFetcher
()
fetch_queue
=
[
m
for
m
in
self
]
...
...
@@ -185,11 +185,11 @@ class ModulePool(list):
new_modules
=
fetcher
.
fetch_single_module
(
cur_mod
)
for
mod
in
new_modules
:
if
not
mod
.
isfetched
:
p
.
vprint
(
"Appended to fetch queue: "
+
str
(
mod
.
url
))
p
.
vprint
(
"Appended to fetch queue: "
+
str
(
mod
.
url
))
self
.
_add
(
mod
)
fetch_queue
.
append
(
mod
)
else
:
p
.
vprint
(
"NOT appended to fetch queue: "
+
str
(
mod
.
url
))
p
.
vprint
(
"NOT appended to fetch queue: "
+
str
(
mod
.
url
))
def
build_global_file_list
(
self
):
from
srcfile
import
SourceFileSet
...
...
src/flow.py
View file @
16860fb6
...
...
@@ -60,7 +60,7 @@ class ISEProject:
class
StringBuffer
(
list
):
def
__init__
(
self
):
self
.
append
(
""
)
self
.
__blank
=
re
.
compile
(
"^[
\t
\n
]+$"
)
self
.
__blank
=
re
.
compile
(
"^[
\n
]+$"
)
def
write
(
self
,
what
):
if
what
==
""
:
...
...
@@ -255,7 +255,7 @@ class ISEProject:
self
.
__output_libs
(
self
.
xml_libs
)
output_file
=
open
(
filename
,
"w"
)
string_buffer
=
self
.
StringBuffer
()
self
.
xml_doc
.
writexml
(
string_buffer
,
newl
=
"
\n
"
,
addindent
=
"
\t
"
)
self
.
xml_doc
.
writexml
(
string_buffer
,
newl
=
"
\n
"
,
addindent
=
"
"
)
output_file
.
write
(
'
\n
'
.
join
(
string_buffer
))
output_file
.
close
()
...
...
@@ -292,7 +292,7 @@ class ISEProject:
class
ModelsiminiReader
(
object
):
def
__init__
(
self
,
path
=
None
):
if
path
==
None
:
if
path
is
None
:
path
=
self
.
modelsim_ini_dir
()
+
"/modelsim.ini"
self
.
path
=
path
...
...
@@ -316,7 +316,7 @@ class ModelsiminiReader(object):
reading_libraries
=
True
continue
if
re
.
search
(
new_section
,
line
):
if
reading_libraries
==
True
:
if
reading_libraries
is
True
:
#reading_libraries = False
break
else
:
...
...
@@ -336,7 +336,7 @@ class ModelsiminiReader(object):
class
XilinxsiminiReader
(
object
):
def
__init__
(
self
,
path
=
None
):
if
path
==
None
:
if
path
is
None
:
path
=
self
.
xilinxsim_ini_dir
()
+
"/xilinxsim.ini"
self
.
path
=
path
...
...
src/flow_altera.py
View file @
16860fb6
...
...
@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
...
...
@@ -28,34 +28,34 @@ class _QuartusProjectProperty:
"set_global_assignment"
:
SET_GLOBAL_ASSIGNMENT
}
def
__init__
(
self
,
command
,
what
=
None
,
name
=
None
,
name_type
=
None
,
from_
=
None
,
to
=
None
,
section_id
=
None
):
self
.
command
=
command
self
.
what
=
what
self
.
name
=
name
self
.
name_type
=
name_type
self
.
from_
=
from_
self
.
to
=
to
self
.
section_id
=
section_id
self
.
command
=
command
self
.
what
=
what
self
.
name
=
name
self
.
name_type
=
name_type
self
.
from_
=
from_
self
.
to
=
to
self
.
section_id
=
section_id
def
emit
(
self
):
words
=
[]
words
.
append
(
dict
([(
b
,
a
)
for
a
,
b
in
self
.
t
.
items
()])[
self
.
command
])
if
self
.
what
!=
None
:
words
.
append
(
self
.
what
)
if
self
.
name
!=
None
:
words
.
append
(
"-name"
)
words
.
append
(
self
.
name_type
)
words
.
append
(
self
.
name
)
if
self
.
from_
!=
None
:
words
.
append
(
"-from"
)
words
.
append
(
self
.
from_
)
if
self
.
to
!=
None
:
words
.
append
(
"-to"
)
words
.
append
(
self
.
to
)
if
self
.
section_id
!=
None
:
words
.
append
(
"-section_id"
)
words
.
append
(
self
.
section_id
)
return
' '
.
join
(
words
)
words
=
[]
words
.
append
(
dict
([(
b
,
a
)
for
a
,
b
in
self
.
t
.
items
()])[
self
.
command
])
if
self
.
what
is
None
:
words
.
append
(
self
.
what
)
if
self
.
name
is
None
:
words
.
append
(
"-name"
)
words
.
append
(
self
.
name_type
)
words
.
append
(
self
.
name
)
if
self
.
from_
is
None
:
words
.
append
(
"-from"
)
words
.
append
(
self
.
from_
)
if
self
.
to
is
None
:
words
.
append
(
"-to"
)
words
.
append
(
self
.
to
)
if
self
.
section_id
is
None
:
words
.
append
(
"-section_id"
)
words
.
append
(
self
.
section_id
)
return
' '
.
join
(
words
)
class
QuartusProject
:
...
...
@@ -73,7 +73,7 @@ class QuartusProject:
f
.
write
(
self
.
__emit_files
())
f
.
write
(
self
.
__emit_scripts
())
f
.
close
()
f
=
open
(
self
.
filename
+
'.qpf'
,
"w"
)
;
f
=
open
(
self
.
filename
+
'.qpf'
,
"w"
)
f
.
write
(
"PROJECT_REVISION =
\"
"
+
self
.
filename
+
"
\"\n
"
)
f
.
close
()
...
...
@@ -110,7 +110,7 @@ class QuartusProject:
def
add_property
(
self
,
val
):
#don't save files (they are unneeded)
if
val
.
name_type
!=
None
and
"_FILE"
in
val
.
name_type
:
if
val
.
name_type
is
None
and
"_FILE"
in
val
.
name_type
:
return
self
.
properties
.
append
(
val
)
...
...
@@ -166,7 +166,7 @@ class QuartusProject:
i
=
i
+
1
continue
prop
=
QPP
(
command
=
command
,
what
=
what
,
name
=
name
,
name_type
=
name_type
,
from_
=
from_
,
to
=
to
,
section_id
=
section_id
)
name_type
=
name_type
,
from_
=
from_
,
to
=
to
,
section_id
=
section_id
)
self
.
add_property
(
prop
)
f
.
close
()
...
...
@@ -180,7 +180,7 @@ class QuartusProject:
for
key
in
family_names
:
if
re
.
match
(
key
,
syn_device
.
upper
()):
family
=
family_names
[
key
]
;
family
=
family_names
[
key
]
devstring
=
(
syn_device
+
syn_package
+
syn_grade
)
.
upper
()
QPP
=
_QuartusProjectProperty
...
...
src/global_mod.py
View file @
16860fb6
...
...
@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
...
...
src/hdlmake_kernel.py
View file @
16860fb6
...
...
@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
# Modified to allow ISim simulation by Lucas Russo (lucas.russo@lnls.br)
...
...
@@ -59,16 +59,16 @@ class HdlmakeKernel(object):
raise
RuntimeError
(
"Unrecognized or not specified simulation tool: "
+
str
(
tm
.
use_compiler
))
quit
()
# Force declaration of sim_tool varible in Manifest
#if tm.sim_tool
==
None:
#
p.error("sim_tool variable must be defined in the manifest")
#
quit()
#if tm.sim_tool
is
None:
#
p.error("sim_tool variable must be defined in the manifest")
#
quit()
## Make distintion between isim and vsim simulators
#if tm.sim_tool == "vsim":
#
self.generate_modelsim_makefile()
#
self.generate_modelsim_makefile()
#elif tm.sim_tool == "isim":
#
self.generate_isim_makefile()
#
self.generate_isim_makefile()
#else:
#
raise RuntimeError("Unrecognized sim tool: "+tm.sim_tool)
#
raise RuntimeError("Unrecognized sim tool: "+tm.sim_tool)
elif
tm
.
action
==
"synthesis"
:
if
tm
.
syn_project
is
None
:
p
.
error
(
"syn_project variable must be defined in the manifest"
)
...
...
@@ -127,8 +127,8 @@ class HdlmakeKernel(object):
p
.
echo
(
str
([
str
(
m
)
for
m
in
self
.
modules_pool
.
modules
if
not
m
.
isfetched
]))
quit
()
top_module
=
pool
.
get_top_module
()
flist
=
pool
.
build_global_file_list
()
;
flist_sorted
=
solver
.
solve
(
flist
)
;
flist
=
pool
.
build_global_file_list
()
flist_sorted
=
solver
.
solve
(
flist
)
#self.make_writer.generate_modelsim_makefile(flist_sorted, top_module)
self
.
make_writer
.
generate_vsim_makefile
(
flist_sorted
,
top_module
)
...
...
@@ -144,8 +144,8 @@ class HdlmakeKernel(object):
p
.
echo
(
str
([
str
(
m
)
for
m
in
self
.
modules_pool
.
modules
if
not
m
.
isfetched
]))
quit
()
top_module
=
pool
.
get_top_module
()
flist
=
pool
.
build_global_file_list
()
;
flist_sorted
=
solver
.
solve
(
flist
)
;
flist
=
pool
.
build_global_file_list
()
flist_sorted
=
solver
.
solve
(
flist
)
self
.
make_writer
.
generate_isim_makefile
(
flist_sorted
,
top_module
)
def
generate_iverilog_makefile
(
self
):
...
...
@@ -173,7 +173,7 @@ class HdlmakeKernel(object):
self
.
make_writer
.
generate_ise_makefile
(
top_mod
=
self
.
modules_pool
.
get_top_module
(),
ise_path
=
ise_path
)
def
generate_remote_synthesis_makefile
(
self
):
if
self
.
connection
.
ssh_user
==
None
or
self
.
connection
.
ssh_server
==
None
:
if
self
.
connection
.
ssh_user
is
None
or
self
.
connection
.
ssh_server
is
None
:
p
.
warning
(
"Connection data is not given. "
"Accessing environmental variables in the makefile"
)
p
.
info
(
"Generating makefile for remote synthesis."
)
...
...
@@ -186,7 +186,7 @@ class HdlmakeKernel(object):
ise_path
=
self
.
__figure_out_ise_path
()
tcl
=
self
.
__search_tcl_file
()
if
tcl
==
None
:
if
tcl
is
None
:
self
.
__generate_tcl
()
tcl
=
"run.tcl"
files
=
self
.
modules_pool
.
build_very_global_file_list
()
...
...
@@ -229,7 +229,7 @@ class HdlmakeKernel(object):
self
.
__create_new_quartus_project
()
def
__figure_out_ise_path
(
self
):
if
self
.
options
.
force_ise
!=
None
:
if
self
.
options
.
force_ise
is
None
:
if
self
.
options
.
force_ise
==
0
:
ise
=
self
.
__check_ise_version
()
else
:
...
...
@@ -247,7 +247,7 @@ class HdlmakeKernel(object):
return
ise_path
def
__is_xilinx_screwed
(
self
):
if
self
.
__check_ise_version
()
==
None
:
if
self
.
__check_ise_version
()
is
None
:
return
True
else
:
return
False
...
...
@@ -387,7 +387,7 @@ class HdlmakeKernel(object):
files
=
self
.
modules_pool
.
build_very_global_file_list
()
# tcl = self.__search_tcl_file()
# if tcl
==
None:
# if tcl
is
None:
self
.
__generate_tcl
()
tcl
=
"run.tcl"
...
...
@@ -411,7 +411,7 @@ class HdlmakeKernel(object):
os
.
chdir
(
cur_dir
)
def
__search_tcl_file
(
self
,
directory
=
None
):
if
directory
==
None
:
if
directory
is
None
:
directory
=
"."
filenames
=
os
.
listdir
(
directory
)
tcls
=
[]
...
...
@@ -438,7 +438,7 @@ class HdlmakeKernel(object):
remove_list
.
reverse
()
#we will remove modules in backward order
if
len
(
remove_list
):
for
m
in
remove_list
:
p
.
rawprint
(
"
\t
"
+
m
.
url
+
" [from: "
+
m
.
path
+
"]"
)
p
.
rawprint
(
"
"
+
m
.
url
+
" [from: "
+
m
.
path
+
"]"
)
m
.
remove_dir_from_disk
()
else
:
p
.
info
(
"There are no modules to be removed"
)
...
...
@@ -469,23 +469,23 @@ class HdlmakeKernel(object):
p
.
echo
(
str
([
str
(
m
)
for
m
in
self
.
modules_pool
.
modules
if
not
m
.
isfetched
]))
quit
()
flist
=
pool
.
build_global_file_list
()
;
flist_sorted
=
solver
.
solve
(
flist
)
;
flist
=
pool
.
build_global_file_list
()
flist_sorted
=
solver
.
solve
(
flist
)
# if not os.path.exists(self.options.merge_cores):
# os.makedirs(self.options.merge_cores)
base
=
self
.
options
.
merge_cores
f_out
=
open
(
base
+
".vhd"
,
"w"
)
f_out
.
write
(
"
\n\n\n\n
"
)
;
f_out
.
write
(
"------------------------------ WARNING -------------------------------
\n
"
)
;
f_out
.
write
(
"-- This code has been generated by hdlmake --merge-cores option --
\n
"
)
;
f_out
.
write
(
"-- It is provided for your convenience, to spare you from adding --
\n
"
)
;
f_out
.
write
(
"-- lots of individual source files to ISE/Modelsim/Quartus projects --
\n
"
)
;
f_out
.
write
(
"-- mainly for Windows users. Please DO NOT MODIFY this file. If you --
\n
"
)
;
f_out
.
write
(
"-- need to change something inside, edit the original source file --
\n
"
)
;
f_out
.
write
(
"-- and re-genrate the merged version! --
\n
"
)
;
f_out
.
write
(
"----------------------------------------------------------------------
\n
"
)
;
f_out
.
write
(
"
\n\n\n\n
"
)
;
f_out
.
write
(
"
\n\n\n\n
"
)
f_out
.
write
(
"------------------------------ WARNING -------------------------------
\n
"
)
f_out
.
write
(
"-- This code has been generated by hdlmake --merge-cores option --
\n
"
)
f_out
.
write
(
"-- It is provided for your convenience, to spare you from adding --
\n
"
)
f_out
.
write
(
"-- lots of individual source files to ISE/Modelsim/Quartus projects --
\n
"
)
f_out
.
write
(
"-- mainly for Windows users. Please DO NOT MODIFY this file. If you --
\n
"
)
f_out
.
write
(
"-- need to change something inside, edit the original source file --
\n
"
)
f_out
.
write
(
"-- and re-genrate the merged version! --
\n
"
)
f_out
.
write
(
"----------------------------------------------------------------------
\n
"
)
f_out
.
write
(
"
\n\n\n\n
"
)
for
vhdl
in
flist_sorted
.
filter
(
VHDLFile
):
f_out
.
write
(
"
\n\n
--- File:
%
s ----
\n\n
"
%
vhdl
.
rel_path
())
...
...
@@ -495,16 +495,16 @@ class HdlmakeKernel(object):
f_out
=
open
(
base
+
".v"
,
"w"
)
f_out
.
write
(
"
\n\n\n\n
"
)
;
f_out
.
write
(
"////////////////////////////// WARNING ///////////////////////////////
\n
"
)
;
f_out
.
write
(
"// This code has been generated by hdlmake --merge-cores option //
\n
"
)
;
f_out
.
write
(
"// It is provided for your convenience, to spare you from adding //
\n
"
)
;
f_out
.
write
(
"// lots of individual source files to ISE/Modelsim/Quartus projects //
\n
"
)
;
f_out
.
write
(
"// mainly for Windows users. Please DO NOT MODIFY this file. If you //
\n
"
)
;
f_out
.
write
(
"// need to change something inside, edit the original source file //
\n
"
)
;
f_out
.
write
(
"// and re-genrate the merged version! //
\n
"
)
;
f_out
.
write
(
"//////////////////////////////////////////////////////////////////////
\n
"
)
;
f_out
.
write
(
"
\n\n\n\n
"
)
;
f_out
.
write
(
"
\n\n\n\n
"
)
f_out
.
write
(
"////////////////////////////// WARNING ///////////////////////////////
\n
"
)
f_out
.
write
(
"// This code has been generated by hdlmake --merge-cores option //
\n
"
)
f_out
.
write
(
"// It is provided for your convenience, to spare you from adding //
\n
"
)
f_out
.
write
(
"// lots of individual source files to ISE/Modelsim/Quartus projects //
\n
"
)
f_out
.
write
(
"// mainly for Windows users. Please DO NOT MODIFY this file. If you //
\n
"
)
f_out
.
write
(
"// need to change something inside, edit the original source file //
\n
"
)
f_out
.
write
(
"// and re-genrate the merged version! //
\n
"
)
f_out
.
write
(
"//////////////////////////////////////////////////////////////////////
\n
"
)
f_out
.
write
(
"
\n\n\n\n
"
)
for
vlog
in
flist_sorted
.
filter
(
VerilogFile
):
f_out
.
write
(
"
\n\n
// File:
%
s
\n\n
"
%
vlog
.
rel_path
())
...
...
src/makefile_writer.py
View file @
16860fb6
This diff is collapsed.
Click to expand it.
src/manifest_parser.py
View file @
16860fb6
...
...
@@ -2,19 +2,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
...
...
@@ -23,12 +23,12 @@ import os
from
configparser
import
ConfigParser
class
Manifest
:
def
__init__
(
self
,
path
=
None
,
url
=
None
):
def
__init__
(
self
,
path
=
None
,
url
=
None
):
if
not
isinstance
(
path
,
str
):
raise
ValueError
(
"Path must be an instance of str"
)
if
path
==
None
and
url
==
None
:
if
path
is
None
and
url
is
None
:
raise
ValueError
(
"When creating a manifest a path or an URL must be given"
)
if
path
!=
None
and
url
==
None
:
if
path
is
None
and
url
is
None
:
self
.
url
=
path
if
path_mod
.
is_abs_path
(
path
):
self
.
path
=
path
...
...
@@ -37,31 +37,32 @@ class Manifest:
def
__str__
(
self
):
return
self
.
url
def
exists
(
self
):
return
os
.
path
.
exists
(
self
.
path
)
class
ManifestParser
(
ConfigParser
):
def
__init__
(
self
):
ConfigParser
.
__init__
(
self
,
description
=
"Configuration options description"
)
ConfigParser
.
__init__
(
self
,
description
=
"Configuration options description"
)
self
.
add_option
(
'fetchto'
,
default
=
None
,
help
=
"Destination for fetched modules"
,
type
=
''
)
#self.add_option('root_module', default=None, help="Path to root module for currently parsed", type='')
self
.
add_delimiter
()
self
.
add_option
(
'syn_name'
,
default
=
None
,
help
=
"Name of the folder at remote synthesis machine"
,
type
=
''
)
self
.
add_option
(
'syn_device'
,
default
=
None
,
help
=
"Target FPGA device"
,
type
=
''
);
self
.
add_option
(
'syn_grade'
,
default
=
None
,
help
=
"Speed grade of target FPGA"
,
type
=
''
);
self
.
add_option
(
'syn_package'
,
default
=
None
,
help
=
"Package variant of target FPGA"
,
type
=
''
);
self
.
add_option
(
'syn_top'
,
default
=
None
,
help
=
"Top level module for synthesis"
,
type
=
''
);
self
.
add_option
(
'syn_project'
,
default
=
None
,
help
=
"Project file (.xise, .ise, .qpf)"
,
type
=
''
);
self
.
add_option
(
'syn_device'
,
default
=
None
,
help
=
"Target FPGA device"
,
type
=
''
)
self
.
add_option
(
'syn_grade'
,
default
=
None
,
help
=
"Speed grade of target FPGA"
,
type
=
''
)
self
.
add_option
(
'syn_package'
,
default
=
None
,
help
=
"Package variant of target FPGA"
,
type
=
''
)
self
.
add_option
(
'syn_top'
,
default
=
None
,
help
=
"Top level module for synthesis"
,
type
=
''
)
self
.
add_option
(
'syn_project'
,
default
=
None
,
help
=
"Project file (.xise, .ise, .qpf)"
,
type
=
''
)
self
.
add_delimiter
()
self
.
add_option
(
'include_dirs'
,
default
=
None
,
help
=
"Include dirs for Verilog sources"
,
type
=
[])
self
.
add_type
(
'include_dirs'
,
type
=
""
)
self
.
add_option
(
'include_dirs'
,
default
=
None
,
help
=
"Include dirs for Verilog sources"
,
type
=
[])
self
.
add_type
(
'include_dirs'
,
type
=
""
)
self
.
add_delimiter
()
# Modification here!
#
self.add_option('sim_tool', default=None, help = "Simulation tool to be used (isim/vsim)", type = '');
#
self.add_option('sim_tool', default=None, help = "Simulation tool to be used (isim/vsim)", type = '')
self
.
add_option
(
'vsim_opt'
,
default
=
""
,
help
=
"Additional options for vsim"
,
type
=
''
)
self
.
add_option
(
'vcom_opt'
,
default
=
""
,
help
=
"Additional options for vcom"
,
type
=
''
)
self
.
add_option
(
'vlog_opt'
,
default
=
""
,
help
=
"Additional options for vlog"
,
type
=
''
)
...
...
@@ -106,7 +107,7 @@ class ManifestParser(ConfigParser):
return
ConfigParser
.
parse
(
self
)
def
print_help
(
self
):
ConfigParser
.
help
()
ConfigParser
.
help
(
self
)
def
search_for_package
(
self
):
"""
...
...
@@ -120,12 +121,12 @@ class ManifestParser(ConfigParser):
except
UnicodeDecodeError
:
return
[]
package_pattern
=
re
.
compile
(
"^[
\t
]*package[
\t
]+([^
\t
]+)[
\t
]+is[
\t
]*$"
)
package_pattern
=
re
.
compile
(
"^[
]*package[ ]+([^ ]+)[ ]+is[
]*$"
)
ret
=
[]
for
line
in
text
:
m
=
re
.
match
(
package_pattern
,
line
)
if
m
!=
None
:
if
m
is
None
:
ret
.
append
(
m
.
group
(
1
))
f
.
close
()
...
...
src/module.py
View file @
16860fb6
This diff is collapsed.
Click to expand it.
src/msg.py
View file @
16860fb6
...
...
@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
...
...
@@ -49,7 +49,7 @@ def echo(msg):
rawprint
(
msg
)
def
vprint
(
msg
):
if
global_mod
.
options
.
verbose
==
True
:
if
global_mod
.
options
.
verbose
is
True
:
echo
(
msg
)
def
pprint
(
msg
):
...
...
@@ -57,7 +57,7 @@ def pprint(msg):
pp
.
pprint
(
msg
)
def
vpprint
(
msg
):
if
global_mod
.
options
.
verbose
==
True
:
if
global_mod
.
options
.
verbose
is
True
:
pp
=
prettyprinter
.
PrettyPrinter
(
indent
=
2
)
pp
.
pprint
(
msg
)
...
...
src/new_dep_solver.py
View file @
16860fb6
...
...
@@ -2,70 +2,70 @@
class
DepRelation
:
PROVIDE
=
1
USE
=
2
ENTITY
=
1
PACKAGE
=
2
INCLUDE
=
3
PROVIDE
=
1
USE
=
2
ENTITY
=
1
PACKAGE
=
2
INCLUDE
=
3
def
__init__
(
self
,
obj_name
,
direction
,
rel_type
):
self
.
direction
=
direction
self
.
rel_type
=
rel_type
self
.
obj_name
=
obj_name
def
satisfies
(
self
,
rel_b
):
if
(
rel_b
.
direction
==
self
.
USE
):
return
True
elif
(
self
.
direction
==
self
.
PROVIDE
and
rel_b
.
rel_type
==
self
.
rel_type
and
rel_b
.
obj_name
==
self
.
obj_name
):
return
True
return
False
def
__init__
(
self
,
obj_name
,
direction
,
rel_type
):
self
.
direction
=
direction
self
.
rel_type
=
rel_type
self
.
obj_name
=
obj_name
def
satisfies
(
self
,
rel_b
):
if
(
rel_b
.
direction
==
self
.
USE
):
return
True
elif
(
self
.
direction
==
self
.
PROVIDE
and
rel_b
.
rel_type
==
self
.
rel_type
and
rel_b
.
obj_name
==
self
.
obj_name
):
return
True
return
False
def
__str__
(
self
):
dstr
=
{
self
.
USE
:
"Use"
,
self
.
PROVIDE
:
"Provide"
}
ostr
=
{
self
.
ENTITY
:
"entity/module"
,
self
.
PACKAGE
:
"package"
,
self
.
INCLUDE
:
"include/header"
}
return
"
%
s
%
s '
%
s'"
%
(
dstr
[
self
.
direction
],
ostr
[
self
.
rel_type
],
self
.
obj_name
)
def
__str__
(
self
):
dstr
=
{
self
.
USE
:
"Use"
,
self
.
PROVIDE
:
"Provide"
}
ostr
=
{
self
.
ENTITY
:
"entity/module"
,
self
.
PACKAGE
:
"package"
,
self
.
INCLUDE
:
"include/header"
}
return
"
%
s
%
s '
%
s'"
%
(
dstr
[
self
.
direction
],
ostr
[
self
.
rel_type
],
self
.
obj_name
)
class
DepFile
:
def
__init__
(
self
,
filename
,
search_path
=
[]):
self
.
rels
=
[];
self
.
filename
=
filename
parser
=
ParserFactory
()
.
create
(
self
.
filename
,
search_path
)
parser
.
parse
(
self
,
self
.
filename
)
def
__init__
(
self
,
filename
,
search_path
=
[]):
self
.
rels
=
[]
self
.
filename
=
filename
parser
=
ParserFactory
()
.
create
(
self
.
filename
,
search_path
)
parser
.
parse
(
self
,
self
.
filename
)
def
add_relation
(
self
,
rel
):
self
.
rels
.
append
(
rel
);
def
satisfies
(
self
,
rels_b
):
for
r_mine
in
self
.
rels
:
if
not
any
(
map
(
rels_b
,
lambda
x
:
x
.
satisfies
(
r_mine
))):
return
False
def
show_relations
(
self
):
for
r
in
self
.
rels
:
print
(
str
(
r
))
def
add_relation
(
self
,
rel
):
self
.
rels
.
append
(
rel
)
def
satisfies
(
self
,
rels_b
):
for
r_mine
in
self
.
rels
:
if
not
any
(
map
(
rels_b
,
lambda
x
:
x
.
satisfies
(
r_mine
))):
return
False
def
show_relations
(
self
):
for
r
in
self
.
rels
:
print
(
str
(
r
))
class
DepParser
:
def
__init__
(
self
):
pass
def
parse
(
f
,
filename
):
pass
def
__init__
(
self
):
pass
def
parse
(
f
,
filename
):
pass
class
ParserFactory
:
def
create
(
self
,
filename
,
search_path
):
import
re
from
vlog_parser
import
VerilogParser
from
vhdl_parser
import
VHDLParser
def
create
(
self
,
filename
,
search_path
):
import
re
from
vlog_parser
import
VerilogParser
from
vhdl_parser
import
VHDLParser
extension
=
re
.
match
(
re
.
compile
(
".+
\
.(
\
w+)$"
),
filename
)
if
(
not
extension
):
throw
(
"Unecognized file format :
%
s"
%
filename
);
extension
=
extension
.
group
(
1
)
.
lower
()
if
(
extension
in
[
"vhd"
,
"vhdl"
]):
return
VHDLParser
();
elif
(
extension
in
[
"v"
,
"sv"
]):
vp
=
VerilogParser
();
for
d
in
search_path
:
vp
.
add_search_path
(
d
)
return
vp
extension
=
re
.
match
(
re
.
compile
(
".+
\
.(
\
w+)$"
),
filename
)
if
(
not
extension
):
throw
(
"Unecognized file format :
%
s"
%
filename
)
extension
=
extension
.
group
(
1
)
.
lower
()
if
(
extension
in
[
"vhd"
,
"vhdl"
]):
return
VHDLParser
()
elif
(
extension
in
[
"v"
,
"sv"
]):
vp
=
VerilogParser
()
for
d
in
search_path
:
vp
.
add_search_path
(
d
)
return
vp
src/path.py
View file @
16860fb6
...
...
@@ -3,19 +3,19 @@
#
# Copyright (c) 2011 Pawel Szostek (pawel.szostek@cern.ch)
#
# This source code is free software
;
you can redistribute it
# This source code is free software you can redistribute it
# and/or modify it in source code form under the terms of the GNU
# General Public License as published by the Free Software
# Foundation
;
either version 2 of the License, or (at your option)
# Foundation either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY
;
without even the implied warranty of
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program
;
if not, write to the Free Software
# along with this program if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
#
...
...
@@ -42,14 +42,14 @@ def url_parse(url):
"""
Check if link to a repo seems to be correct. Filter revision number and branch
"""
"""url_pat = re.compile("[
\t
]*([^
\t
]+?)[
\t
]*(::)?([^
\t
@]+)?(@[
\t
]*(.+))?[
\t
]*")
"""url_pat = re.compile("[
]*([^ ]+?)[ ]*(::)?([^ @]+)?(@[ ]*(.+))?[
]*")
url_match = re.match(url_pat, url)
if url_match
==
None:
if url_match
is
None:
p.echo("Not a correct repo url: {0}. Skipping".format(url))
url_clean = url_match.group(1)
if url_match.group(3)
!=
None: #there is a branch
if url_match.group(3)
is
None: #there is a branch
branch = url_match.group(3)
if url_match.group(5)
!=
None: #there is a revision given
if url_match.group(5)
is
None: #there is a revision given
rev = url_match.group(5)"""
url_clean
,
branch
,
rev
=
None
,
None
,
None
if
"@@"
in
url
:
...
...
@@ -113,7 +113,7 @@ def is_abs_path(path):
return
False
def
relpath
(
p1
,
p2
=
None
):
if
p2
==
None
:
if
p2
is
None
:
p2
=
os
.
getcwd
()
if
p1
==
p2
:
return
'.'
...
...
src/srcfile.py
View file @
16860fb6
...
...
@@ -44,7 +44,7 @@ class File(object):
def
rel_path
(
self
,
dir
=
None
):
import
path
if
dir
==
None
:
if
dir
is
None
:
dir
=
os
.
getcwd
()
return
path
.
relpath
(
self
.
path
,
dir
)
...
...
@@ -151,7 +151,7 @@ class VHDLFile(SourceFile):
#std_libs = flow.MODELSIM_STANDARD_LIBS
print
"I/O error: ({0})"
.
format
(
e
.
message
)
p
.
error
(
"Picking standard Modelsim simulation libraries. Try to fix the error."
)
std_libs
=
flow
.
MODELSIM_STA
RDAN
D_LIBS
std_libs
=
flow
.
MODELSIM_STA
NDAR
D_LIBS
elif
global_mod
.
top_module
.
action
==
"synthesis"
:
print
(
"setting std libs for synthesis..."
)
if
global_mod
.
top_module
.
target
==
"xilinx"
:
...
...
@@ -166,7 +166,7 @@ class VHDLFile(SourceFile):
except
UnicodeDecodeError
:
return
[]
use_pattern
=
re
.
compile
(
"^[
\t
]*use[
\t
]+([^; ]+)[
\t
]*;
.*$"
)
use_pattern
=
re
.
compile
(
"^[
]*use[ ]+([^ ]+)[ ]*
.*$"
)
lib_pattern
=
re
.
compile
(
"([^.]+)
\
.([^.]+)
\
.all"
)
use_lines
=
[]
...
...
@@ -180,7 +180,7 @@ class VHDLFile(SourceFile):
ret
=
set
()
for
line
in
use_lines
:
m
=
re
.
match
(
lib_pattern
,
line
)
if
m
!=
None
:
if
m
is
None
:
#omit standard libraries
if
(
m
.
group
(
1
))
.
lower
()
in
std_libs
:
continue
...
...
@@ -209,14 +209,14 @@ class VHDLFile(SourceFile):
except
UnicodeDecodeError
:
return
[]
package_pattern
=
re
.
compile
(
"^[
\t
]*package[
\t
]+([^
\t
]+)[
\t
]+is[
\t
]*.*$"
)
package_pattern
=
re
.
compile
(
"^[
]*package[ ]+([^ ]+)[ ]+is[
]*.*$"
)
ret
=
set
()
for
line
in
text
:
#identifiers and keywords are case-insensitive in VHDL
line
=
line
.
lower
()
m
=
re
.
match
(
package_pattern
,
line
)
if
m
!=
None
:
if
m
is
None
:
ret
.
add
((
self
.
library
.
lower
(),
m
.
group
(
1
)
.
lower
()))
f
.
close
()
...
...
@@ -289,12 +289,12 @@ class VerilogFile(SourceFile):
text
=
f
.
readlines
()
except
UnicodeDecodeError
:
return
[]
include_pattern
=
re
.
compile
(
"^[
\t
]*`include[
\t
]+
\"
([^
\"
]+)
\"
.*$"
)
include_pattern
=
re
.
compile
(
"^[
]*`include[
]+
\"
([^
\"
]+)
\"
.*$"
)
ret
=
[]
for
line
in
text
:
#in Verilog and SV identifiers are case-sensitive
m
=
re
.
match
(
include_pattern
,
line
)
if
m
!=
None
:
if
m
is
None
:
ret
.
append
(
m
.
group
(
1
))
f
.
close
()
return
ret
...
...
@@ -365,21 +365,21 @@ class SourceFileSet(list):
for
f
in
files
:
if
f
not
in
self
:
self
.
append
(
f
)
except
:
# single file, not a list
except
TypeError
:
# single file, not a list
if
files
not
in
self
:
self
.
append
(
files
)
def
filter
(
self
,
type
):
def
filter
(
self
,
src_file_
type
):
out
=
SourceFileSet
()
for
f
in
self
:
if
isinstance
(
f
,
type
):
if
isinstance
(
f
,
src_file_
type
):
out
.
add
(
f
)
return
out
def
inversed_filter
(
self
,
type
):
def
inversed_filter
(
self
,
src_file_
type
):
out
=
SourceFileSet
()
for
f
in
self
:
if
not
isinstance
(
f
,
type
):
if
not
isinstance
(
f
,
src_file_
type
):
out
.
add
(
f
)
return
out
...
...
src/vlog_parser.py
View file @
16860fb6
This diff is collapsed.
Click to expand it.
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