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
076319ec
Commit
076319ec
authored
13 years ago
by
Paweł Szostek
Browse files
Options
Downloads
Patches
Plain Diff
Make makefiles more readable and clean
parent
fa2190d5
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synthesis/makefile_writer.py
+101
-83
101 additions, 83 deletions
synthesis/makefile_writer.py
with
101 additions
and
83 deletions
synthesis/makefile_writer.py
+
101
−
83
View file @
076319ec
...
@@ -7,12 +7,23 @@ import msg as p
...
@@ -7,12 +7,23 @@ import msg as p
class
MakefileWriter
(
object
):
class
MakefileWriter
(
object
):
def
__init__
(
self
,
filename
):
def
__init__
(
self
,
filename
):
self
.
_file
=
open
(
filename
,
"
w
"
)
self
.
_file
=
open
(
filename
,
"
w
"
)
self
.
writeln
(
"
####################################
"
)
self
.
writeln
(
"
# This file was generated by hdlmake
"
)
self
.
writeln
(
"
# http://ohwr.org/projects/hdl-make/
"
)
self
.
writeln
(
"
####################################
"
)
self
.
writeln
()
def
__del__
(
self
):
def
__del__
(
self
):
self
.
_file
.
close
()
self
.
_file
.
close
()
# def add(self, line):
def
write
(
self
,
line
=
None
):
# self._file.write(line)
self
.
_file
.
write
(
line
)
def
writeln
(
self
,
text
=
None
):
if
text
==
None
:
self
.
_file
.
write
(
"
\n
"
)
else
:
self
.
_file
.
write
(
text
+
"
\n
"
)
def
reset_file
(
self
,
filename
):
def
reset_file
(
self
,
filename
):
self
.
_file
.
close
()
self
.
_file
.
close
()
...
@@ -22,9 +33,9 @@ class MakefileWriter(object):
...
@@ -22,9 +33,9 @@ class MakefileWriter(object):
if
files
==
None
:
if
files
==
None
:
import
random
import
random
name
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
x
in
range
(
8
))
name
=
''
.
join
(
random
.
choice
(
string
.
ascii_letters
+
string
.
digits
)
for
x
in
range
(
8
))
user_tmpl
=
"
USER := {0}
\n
"
user_tmpl
=
"
USER := {0}
"
server_tmpl
=
"
SERVER := {0}
\n
"
server_tmpl
=
"
SERVER := {0}
"
remote_name_tmpl
=
"
R_NAME := {0}
\n
"
remote_name_tmpl
=
"
R_NAME := {0}
"
files_tmpl
=
"
FILES := {0}
"
files_tmpl
=
"
FILES := {0}
"
file
=
self
.
_file
file
=
self
.
_file
...
@@ -39,40 +50,43 @@ class MakefileWriter(object):
...
@@ -39,40 +50,43 @@ class MakefileWriter(object):
server_tmpl
=
server_tmpl
.
format
(
server
)
server_tmpl
=
server_tmpl
.
format
(
server
)
remote_name_tmpl
=
remote_name_tmpl
.
format
(
name
)
remote_name_tmpl
=
remote_name_tmpl
.
format
(
name
)
file
.
write
(
user_tmpl
)
self
.
writeln
(
user_tmpl
)
file
.
write
(
server_tmpl
)
self
.
writeln
(
server_tmpl
)
file
.
write
(
remote_name_tmpl
)
self
.
writeln
(
remote_name_tmpl
)
file
.
write
(
"
CWD=$(shell pwd)
\n
"
)
self
.
writeln
(
"
CWD := $(shell pwd)
"
)
file
.
write
(
"
\n\n
"
)
self
.
writeln
(
""
)
file
.
write
(
files_tmpl
.
format
(
'
\\\n
'
.
join
([
s
.
rel_path
()
for
s
in
files
])))
self
.
writeln
(
files_tmpl
.
format
(
'
\\\n
'
.
join
([
s
.
rel_path
()
for
s
in
files
])))
file
.
write
(
"
\n\n
"
)
self
.
writeln
(
""
)
file
.
write
(
"
remote: send do_synthesis send_back
\n
"
)
self
.
writeln
(
"
#target for running simulation in the remote location
"
)
file
.
write
(
"
send_back: do_synthesis
\n
"
)
self
.
writeln
(
"
remote: __send __do_synthesis __send_back
"
)
file
.
write
(
"
do_synthesis: send
\n\n
"
)
self
.
writeln
(
"
__send_back: __do_synthesis
"
)
self
.
writeln
(
"
__do_synthesis: __send
"
)
self
.
writeln
(
""
)
mkdir_cmd
=
"
ssh $(USER)@$(SERVER)
'
mkdir -p $(R_NAME)
'"
mkdir_cmd
=
"
ssh $(USER)@$(SERVER)
'
mkdir -p $(R_NAME)
'"
rsync_cmd
=
"
rsync -Rav $(foreach file, $(FILES), $(shell readlink -f $(file))) $(USER)@$(SERVER):$(R_NAME)
"
rsync_cmd
=
"
rsync -Rav $(foreach file, $(FILES), $(shell readlink -f $(file))) $(USER)@$(SERVER):$(R_NAME)
"
send_cmd
=
"
send:
\n\t\t
{0}
\n\t\t
{1}
"
.
format
(
mkdir_cmd
,
rsync_cmd
)
send_cmd
=
"
__
send:
\n\t\t
{0}
\n\t\t
{1}
"
.
format
(
mkdir_cmd
,
rsync_cmd
)
file
.
write
(
send_cmd
)
self
.
write
ln
(
send_cmd
)
file
.
write
(
"
\n\n
"
)
self
.
write
ln
(
""
)
tcl
=
"
run.tcl
"
tcl
=
"
run.tcl
"
synthesis_cmd
=
"
do_synthesis:
\n\t\t
"
synthesis_cmd
=
"
__
do_synthesis:
\n\t\t
"
synthesis_cmd
+=
"
ssh $(USER)@$(SERVER)
'
cd $(R_NAME)$(CWD) && xtclsh {1}
'"
synthesis_cmd
+=
"
ssh $(USER)@$(SERVER)
'
cd $(R_NAME)$(CWD) && xtclsh {1}
'"
file
.
write
(
synthesis_cmd
.
format
(
os
.
path
.
join
(
name
,
cwd
),
tcl
))
self
.
write
ln
(
synthesis_cmd
.
format
(
os
.
path
.
join
(
name
,
cwd
),
tcl
))
file
.
write
(
"
\n\n
"
)
self
.
write
ln
(
)
send_back_cmd
=
"
send_back:
\n\t\t
cd .. && rsync -av $(USER)@$(SERVER):$(R_NAME)$(CWD) . && cd $(CWD)
"
send_back_cmd
=
"
__
send_back:
\n\t\t
cd .. && rsync -av $(USER)@$(SERVER):$(R_NAME)$(CWD) . && cd $(CWD)
"
file
.
write
(
send_back_cmd
)
self
.
write
(
send_back_cmd
)
file
.
write
(
"
\n\n
"
)
self
.
write
(
"
\n\n
"
)
cln_cmd
=
"
cleanremote:
\n\t\t
ssh $(USER)@$(SERVER)
'
rm -rf $(R_NAME)
'"
cln_cmd
=
"
cleanremote:
\n\t\t
ssh $(USER)@$(SERVER)
'
rm -rf $(R_NAME)
'"
file
.
write
(
cln_cmd
)
self
.
writeln
(
"
#target for removing stuff from the remote location
"
)
file
.
write
(
"
\n
"
)
self
.
writeln
(
cln_cmd
)
self
.
writeln
()
def
generate_ise_makefile
(
self
,
top_mod
):
def
generate_ise_makefile
(
self
,
top_mod
):
mk_text
=
"""
PROJECT
=
"""
+
top_mod
.
syn_project
+
"""
mk_text
=
"""
PROJECT
:=
"""
+
top_mod
.
syn_project
+
"""
ISE_CRAP =
\
ISE_CRAP
:
=
\
*.bgn
\
*.bgn
\
*.html
\
*.html
\
*.tcl
\
*.tcl
\
...
@@ -119,58 +133,62 @@ webtalk.log \
...
@@ -119,58 +133,62 @@ webtalk.log \
webtalk_pn.xml
\
webtalk_pn.xml
\
run.tcl
run.tcl
#target for performing local synthesis
local:
local:
\t\t
echo
"
project open $(PROJECT)
"
> run.tcl
\t\t
echo
"
project open $(PROJECT)
"
> run.tcl
\t\t
echo
"
process run {Generate Programming File} -force rerun_all
"
>> run.tcl
\t\t
echo
"
process run {Generate Programming File} -force rerun_all
"
>> run.tcl
\t\t
xtclsh run.tcl
\t\t
xtclsh run.tcl
#target for cleaing all intermediate stuff
clean:
clean:
\t\t
rm -f $(ISE_CRAP)
\t\t
rm -f $(ISE_CRAP)
\t\t
rm -rf xst xlnx_auto_*_xdb iseconfig _xmsgs _ngo
\t\t
rm -rf xst xlnx_auto_*_xdb iseconfig _xmsgs _ngo
#target for cleaning final files
mrproper:
mrproper:
\t
rm -f *.bit *.bin *.mcs
\t
\t
rm -f *.bit *.bin *.mcs
"""
"""
self
.
_file
.
write
(
mk_text
);
self
.
write
(
mk_text
);
def
generate_fetch_makefile
(
self
,
modules_pool
,
file
=
None
):
def
generate_fetch_makefile
(
self
,
modules_pool
,
file
=
None
):
import
path
import
path
rp
=
os
.
path
.
relpath
rp
=
os
.
path
.
relpath
file
=
self
.
_file
file
=
self
.
_file
file
.
write
(
"
fetch:
"
)
self
.
write
(
"
#target for fetching all modules stored in repositories
\n
"
)
file
.
write
(
'
\\\n
'
.
join
([
m
.
basename
()
+
"
__fetch
"
for
m
in
modules_pool
if
m
.
source
in
[
"
svn
"
,
"
git
"
]]))
self
.
write
(
"
fetch:
"
)
file
.
write
(
"
\n\n
"
)
self
.
write
(
'
\\\n
'
.
join
([
"
__
"
+
m
.
basename
()
+
"
_fetch
"
for
m
in
modules_pool
if
m
.
source
in
[
"
svn
"
,
"
git
"
]]))
self
.
write
(
"
\n\n
"
)
for
module
in
modules_pool
:
for
module
in
modules_pool
:
basename
=
module
.
basename
()
basename
=
module
.
basename
()
dir
=
os
.
path
.
join
(
module
.
fetchto
,
basename
)
dir
=
os
.
path
.
join
(
module
.
fetchto
,
basename
)
if
module
.
source
==
"
svn
"
:
if
module
.
source
==
"
svn
"
:
file
.
write
(
basename
+
"
_
_
fetch:
\n
"
)
self
.
write
(
"
__
"
+
basename
+
"
_fetch:
\n
"
)
file
.
write
(
"
\t\t
"
)
self
.
write
(
"
\t\t
"
)
file
.
write
(
"
PWD=$(shell pwd);
"
)
self
.
write
(
"
PWD=$(shell pwd);
"
)
file
.
write
(
"
cd
"
+
rp
(
module
.
fetchto
)
+
'
;
'
)
self
.
write
(
"
cd
"
+
rp
(
module
.
fetchto
)
+
'
;
'
)
c
=
"
svn checkout {0} {1};
"
c
=
"
svn checkout {0} {1};
"
if
module
.
revision
:
if
module
.
revision
:
c
=
c
.
format
(
module
.
url
,
module
.
revision
)
c
=
c
.
format
(
module
.
url
,
module
.
revision
)
else
:
else
:
c
=
c
.
format
(
module
.
url
,
""
)
c
=
c
.
format
(
module
.
url
,
""
)
file
.
write
(
c
)
self
.
write
(
c
)
file
.
write
(
"
cd $(PWD)
\n\n
"
)
self
.
write
(
"
cd $(PWD)
\n\n
"
)
elif
module
.
source
==
"
git
"
:
elif
module
.
source
==
"
git
"
:
file
.
write
(
basename
+
"
_
_
fetch:
\n
"
)
self
.
write
(
"
__
"
+
basename
+
"
_fetch:
\n
"
)
file
.
write
(
"
\t\t
"
)
self
.
write
(
"
\t\t
"
)
file
.
write
(
"
PWD=$(shell pwd);
"
)
self
.
write
(
"
PWD=$(shell pwd);
"
)
file
.
write
(
"
cd
"
+
rp
(
module
.
fetchto
)
+
'
;
'
)
self
.
write
(
"
cd
"
+
rp
(
module
.
fetchto
)
+
'
;
'
)
file
.
write
(
"
if [ -d
"
+
basename
+
"
]; then cd
"
+
basename
+
'
;
'
)
self
.
write
(
"
if [ -d
"
+
basename
+
"
]; then cd
"
+
basename
+
'
;
'
)
file
.
write
(
"
git pull;
"
)
self
.
write
(
"
git pull;
"
)
if
module
.
revision
:
if
module
.
revision
:
file
.
write
(
"
git checkout
"
+
module
.
revision
+
'
;
'
)
self
.
write
(
"
git checkout
"
+
module
.
revision
+
'
;
'
)
file
.
write
(
"
else git clone
"
+
module
.
url
+
'
; fi;
'
)
self
.
write
(
"
else git clone
"
+
module
.
url
+
'
; fi;
'
)
if
module
.
revision
:
if
module
.
revision
:
file
.
write
(
"
git checkout
"
+
module
.
revision
+
'
;
'
)
self
.
write
(
"
git checkout
"
+
module
.
revision
+
'
;
'
)
file
.
write
(
"
cd $(PWD)
\n\n
"
)
self
.
write
(
"
cd $(PWD)
\n\n
"
)
def
generate_modelsim_makefile
(
self
,
fileset
,
top_module
,
file
=
None
):
def
generate_modelsim_makefile
(
self
,
fileset
,
top_module
,
file
=
None
):
from
time
import
gmtime
,
strftime
from
time
import
gmtime
,
strftime
...
@@ -207,55 +225,55 @@ clean:
...
@@ -207,55 +225,55 @@ clean:
"""
"""
#open the file and write the above preambule (part 1)
#open the file and write the above preambule (part 1)
file
=
self
.
_file
file
=
self
.
_file
file
.
write
(
notices
)
self
.
write
(
notices
)
file
.
write
(
make_preambule_p1
)
self
.
write
(
make_preambule_p1
)
rp
=
os
.
path
.
relpath
rp
=
os
.
path
.
relpath
file
.
write
(
"
VERILOG_SRC :=
"
)
self
.
write
(
"
VERILOG_SRC :=
"
)
for
vl
in
fileset
.
filter
(
VerilogFile
):
for
vl
in
fileset
.
filter
(
VerilogFile
):
file
.
write
(
vl
.
rel_path
()
+
"
\\\n
"
)
self
.
write
(
vl
.
rel_path
()
+
"
\\\n
"
)
file
.
write
(
"
\n
"
)
self
.
write
(
"
\n
"
)
file
.
write
(
"
VERILOG_OBJ :=
"
)
self
.
write
(
"
VERILOG_OBJ :=
"
)
for
vl
in
fileset
.
filter
(
VerilogFile
):
for
vl
in
fileset
.
filter
(
VerilogFile
):
file
.
write
(
os
.
path
.
join
(
vl
.
library
,
vl
.
purename
,
"
.
"
+
vl
.
purename
)
+
"
\\\n
"
)
self
.
write
(
os
.
path
.
join
(
vl
.
library
,
vl
.
purename
,
"
.
"
+
vl
.
purename
)
+
"
\\\n
"
)
file
.
write
(
'
\n
'
)
self
.
write
(
'
\n
'
)
libs
=
set
(
f
.
library
for
f
in
fileset
.
files
)
libs
=
set
(
f
.
library
for
f
in
fileset
.
files
)
#list vhdl objects (_primary.dat files)
#list vhdl objects (_primary.dat files)
file
.
write
(
"
VHDL_OBJ :=
"
)
self
.
write
(
"
VHDL_OBJ :=
"
)
for
vhdl
in
fileset
.
filter
(
VHDLFile
):
for
vhdl
in
fileset
.
filter
(
VHDLFile
):
file
.
write
(
os
.
path
.
join
(
vhdl
.
library
,
vhdl
.
purename
,
"
.
"
+
vhdl
.
purename
)
+
"
\\\n
"
)
self
.
write
(
os
.
path
.
join
(
vhdl
.
library
,
vhdl
.
purename
,
"
.
"
+
vhdl
.
purename
)
+
"
\\\n
"
)
file
.
write
(
'
\n
'
)
self
.
write
(
'
\n
'
)
file
.
write
(
'
LIBS :=
'
)
self
.
write
(
'
LIBS :=
'
)
file
.
write
(
'
'
.
join
(
libs
))
self
.
write
(
'
'
.
join
(
libs
))
file
.
write
(
'
\n
'
)
self
.
write
(
'
\n
'
)
#tell how to make libraries
#tell how to make libraries
file
.
write
(
'
LIB_IND :=
'
)
self
.
write
(
'
LIB_IND :=
'
)
file
.
write
(
'
'
.
join
([
lib
+
"
/.
"
+
lib
for
lib
in
libs
]))
self
.
write
(
'
'
.
join
([
lib
+
"
/.
"
+
lib
for
lib
in
libs
]))
file
.
write
(
'
\n
'
)
self
.
write
(
'
\n
'
)
file
.
write
(
make_preambule_p2
)
self
.
write
(
make_preambule_p2
)
vlo
=
top_module
.
vlog_opt
vlo
=
top_module
.
vlog_opt
vmo
=
top_module
.
vmap_opt
vmo
=
top_module
.
vmap_opt
for
lib
in
libs
:
for
lib
in
libs
:
file
.
write
(
lib
+
"
/.
"
+
lib
+
"
:
\n
"
)
self
.
write
(
lib
+
"
/.
"
+
lib
+
"
:
\n
"
)
file
.
write
(
'
'
.
join
([
"
\t
(vlib
"
,
lib
,
"
&&
"
,
"
vmap
"
,
"
-modelsimini modelsim.ini
"
,
self
.
write
(
'
'
.
join
([
"
\t
(vlib
"
,
lib
,
"
&&
"
,
"
vmap
"
,
"
-modelsimini modelsim.ini
"
,
lib
,
"
&&
"
,
"
touch
"
,
lib
+
"
/.
"
+
lib
,
"
)
"
]))
lib
,
"
&&
"
,
"
touch
"
,
lib
+
"
/.
"
+
lib
,
"
)
"
]))
file
.
write
(
'
'
.
join
([
"
||
"
,
"
rm -rf
"
,
lib
,
"
\n
"
]))
self
.
write
(
'
'
.
join
([
"
||
"
,
"
rm -rf
"
,
lib
,
"
\n
"
]))
file
.
write
(
'
\n
'
)
self
.
write
(
'
\n
'
)
#rules for all _primary.dat files for sv
#rules for all _primary.dat files for sv
for
vl
in
fileset
.
filter
(
VerilogFile
):
for
vl
in
fileset
.
filter
(
VerilogFile
):
file
.
write
(
os
.
path
.
join
(
vl
.
library
,
vl
.
purename
,
'
.
'
+
vl
.
purename
)
+
'
:
'
+
vl
.
rel_path
()
+
"
\n
"
)
self
.
write
(
os
.
path
.
join
(
vl
.
library
,
vl
.
purename
,
'
.
'
+
vl
.
purename
)
+
'
:
'
+
vl
.
rel_path
()
+
"
\n
"
)
file
.
write
(
"
\t\t
vlog -work
"
+
vl
.
library
+
"
$(VLOG_FLAGS) +incdir+
"
+
rp
(
vl
.
dirname
)
+
"
$<
"
)
self
.
write
(
"
\t\t
vlog -work
"
+
vl
.
library
+
"
$(VLOG_FLAGS) +incdir+
"
+
rp
(
vl
.
dirname
)
+
"
$<
"
)
file
.
write
(
"
&& mkdir -p
"
+
os
.
path
.
join
(
vl
.
library
+
'
/
'
+
vl
.
purename
)
)
self
.
write
(
"
&& mkdir -p
"
+
os
.
path
.
join
(
vl
.
library
+
'
/
'
+
vl
.
purename
)
)
file
.
write
(
"
&& touch
"
+
os
.
path
.
join
(
vl
.
library
,
vl
.
purename
,
'
.
'
+
vl
.
purename
)
+
'
\n
'
)
self
.
write
(
"
&& touch
"
+
os
.
path
.
join
(
vl
.
library
,
vl
.
purename
,
'
.
'
+
vl
.
purename
)
+
'
\n
'
)
file
.
write
(
"
\n
"
)
self
.
write
(
"
\n
"
)
#list rules for all _primary.dat files for vhdl
#list rules for all _primary.dat files for vhdl
vco
=
top_module
.
vcom_opt
vco
=
top_module
.
vcom_opt
...
@@ -264,16 +282,16 @@ clean:
...
@@ -264,16 +282,16 @@ clean:
basename
=
vhdl
.
name
basename
=
vhdl
.
name
purename
=
vhdl
.
purename
purename
=
vhdl
.
purename
#each .dat depends on corresponding .vhd file
#each .dat depends on corresponding .vhd file
file
.
write
(
os
.
path
.
join
(
lib
,
purename
,
"
.
"
+
purename
)
+
"
:
"
+
vhdl
.
rel_path
()
+
'
\n
'
)
self
.
write
(
os
.
path
.
join
(
lib
,
purename
,
"
.
"
+
purename
)
+
"
:
"
+
vhdl
.
rel_path
()
+
'
\n
'
)
file
.
write
(
'
'
.
join
([
"
\t\t
vcom $(VCOM_FLAGS)
"
,
vco
,
"
-work
"
,
lib
,
vhdl
.
rel_path
(),
self
.
write
(
'
'
.
join
([
"
\t\t
vcom $(VCOM_FLAGS)
"
,
vco
,
"
-work
"
,
lib
,
vhdl
.
rel_path
(),
"
&&
"
,
"
mkdir -p
"
,
os
.
path
.
join
(
lib
,
purename
),
"
&&
"
,
"
touch
"
,
os
.
path
.
join
(
lib
,
purename
,
'
.
'
+
purename
),
'
\n
'
]))
"
&&
"
,
"
mkdir -p
"
,
os
.
path
.
join
(
lib
,
purename
),
"
&&
"
,
"
touch
"
,
os
.
path
.
join
(
lib
,
purename
,
'
.
'
+
purename
),
'
\n
'
]))
file
.
write
(
'
\n
'
)
self
.
write
(
'
\n
'
)
if
len
(
vhdl
.
dep_depends_on
)
!=
0
:
if
len
(
vhdl
.
dep_depends_on
)
!=
0
:
file
.
write
(
os
.
path
.
join
(
lib
,
purename
,
"
.
"
+
purename
)
+
"
:
"
)
self
.
write
(
os
.
path
.
join
(
lib
,
purename
,
"
.
"
+
purename
)
+
"
:
"
)
for
dep_file
in
vhdl
.
dep_depends_on
:
for
dep_file
in
vhdl
.
dep_depends_on
:
name
=
dep_file
.
purename
name
=
dep_file
.
purename
file
.
write
(
"
\\\n
"
+
os
.
path
.
join
(
dep_file
.
library
,
name
,
"
.
"
+
name
))
self
.
write
(
"
\\\n
"
+
os
.
path
.
join
(
dep_file
.
library
,
name
,
"
.
"
+
name
))
file
.
write
(
'
\n\n
'
)
self
.
write
(
'
\n\n
'
)
def
__emit_string
(
self
,
s
):
def
__emit_string
(
self
,
s
):
if
not
s
:
if
not
s
:
...
...
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