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
0cf25370
Commit
0cf25370
authored
Jul 31, 2016
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consolidate synthesis actions into a single class
parent
5f330e08
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
205 additions
and
271 deletions
+205
-271
__init__.py
hdlmake/action/__init__.py
+1
-3
remote_synthesis.py
hdlmake/action/remote_synthesis.py
+0
-73
synthesis.py
hdlmake/action/synthesis.py
+202
-2
synthesis_project.py
hdlmake/action/synthesis_project.py
+0
-191
module_pool.py
hdlmake/module_pool.py
+2
-2
No files found.
hdlmake/action/__init__.py
View file @
0cf25370
...
...
@@ -28,8 +28,6 @@ from .list_modules import ListModules
from
.merge_cores
import
MergeCores
from
.tree
import
Tree
from
.synthesis_project
import
GenerateSynthesisProject
from
.synthesis
import
GenerateSynthesisMakefile
from
.remote_synthesis
import
GenerateRemoteSynthesisMakefile
from
.synthesis
import
ActionSynthesis
from
.simulation
import
GenerateSimulationMakefile
from
.qsys_hw_tcl_update
import
QsysHwTclUpdate
hdlmake/action/remote_synthesis.py
deleted
100644 → 0
View file @
5f330e08
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013, 2014 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Multi-tool support by Javier D. Garcia-Lasheras (javier@garcialasheras.com)
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# 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 Hdlmake. If not, see <http://www.gnu.org/licenses/>.
import
logging
import
os
import
sys
import
importlib
from
hdlmake.srcfile
import
SourceFileFactory
from
.action
import
Action
class
GenerateRemoteSynthesisMakefile
(
Action
):
def
_check_remote_synthesis
(
self
):
if
not
self
.
top_module
.
action
==
"synthesis"
:
logging
.
error
(
"action must be equal to
\"
synthesis
\"
"
)
sys
.
exit
(
"Exiting"
)
if
not
self
.
top_module
.
manifest_dict
[
"syn_project"
]:
logging
.
error
(
"syn_project must be set in the manifest."
)
sys
.
exit
(
"Exiting"
)
def
remote_synthesis
(
self
):
self
.
_check_all_fetched_or_quit
()
self
.
_check_remote_synthesis
()
self
.
_generate_remote_synthesis_makefile
()
def
_generate_remote_synthesis_makefile
(
self
):
tool_name
=
self
.
get_top_module
()
.
manifest_dict
[
"syn_tool"
]
tool_module
=
importlib
.
import_module
(
"hdlmake.tools.
%
s.
%
s"
%
(
tool_name
,
tool_name
))
tool_object
=
tool_module
.
ToolControls
()
logging
.
info
(
"Generating makefile for remote synthesis."
)
top_mod
=
self
.
get_top_module
()
self
.
env
.
check_remote_tool
(
tool_object
)
self
.
env
.
check_general
()
files
=
self
.
build_file_set
(
self
.
get_top_module
()
.
manifest_dict
[
"syn_top"
])
sff
=
SourceFileFactory
()
files
.
add
(
sff
.
new
(
top_mod
.
manifest_dict
[
"syn_project"
],
module
=
self
.
top_module
))
tool_object
.
generate_remote_synthesis_makefile
(
files
=
files
,
name
=
top_mod
.
manifest_dict
[
"syn_project"
][:
-
5
],
cwd
=
top_mod
.
url
,
user
=
self
.
env
[
"rsynth_user"
],
server
=
self
.
env
[
"rsynth_server"
])
logging
.
info
(
"Remote synthesis makefile generated."
)
hdlmake/action/synthesis.py
View file @
0cf25370
...
...
@@ -23,11 +23,15 @@
from
__future__
import
print_function
import
logging
import
sys
import
os
import
importlib
from
hdlmake.srcfile
import
SourceFileFactory
from
hdlmake.util
import
path
from
.action
import
Action
class
GenerateSynthesisMakefile
(
Action
):
class
ActionSynthesis
(
Action
):
def
_check_synthesis_makefile
(
self
):
# NOTE: top_module is not used in synthesis!!
...
...
@@ -65,9 +69,205 @@ class GenerateSynthesisMakefile(Action):
tool_path
=
env
[
path_key
]
else
:
tool_path
=
""
logging
.
info
(
"Generating synthesis makefile for "
+
name
)
tool_object
.
generate_synthesis_makefile
(
top_mod
=
self
.
get_top_module
(),
tool_path
=
tool_path
)
logging
.
info
(
"Synthesis makefile generated."
)
def
_check_synthesis_project
(
self
):
manifest
=
self
.
get_top_module
()
.
manifest_dict
if
not
manifest
[
"syn_tool"
]:
logging
.
error
(
"syn_tool variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_device"
]:
logging
.
error
(
"syn_device variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_grade"
]:
logging
.
error
(
"syn_grade variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_package"
]:
logging
.
error
(
"syn_package variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_top"
]:
logging
.
error
(
"syn_top variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
def
synthesis_project
(
self
):
self
.
_check_all_fetched_or_quit
()
self
.
_check_synthesis_project
()
self
.
_generate_synthesis_project
()
def
_write_project_vhd
(
self
,
tool
,
version
):
from
string
import
Template
from
datetime
import
date
import
getpass
today
=
date
.
today
()
date_string
=
today
.
strftime
(
"
%
Y
%
m
%
d"
)
template
=
Template
(
"""library ieee;
use work.wishbone_pkg.all;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package sdb_meta_pkg is
------------------------------------------------------------------------------
-- Meta-information sdb records
------------------------------------------------------------------------------
-- Top module repository url
constant c_SDB_REPO_URL : t_sdb_repo_url := (
-- url (string, 63 char)
repo_url => "$repo_url");
-- Synthesis informations
constant c_SDB_SYNTHESIS : t_sdb_synthesis := (
-- Top module name (string, 16 char)
syn_module_name => "$syn_module_name",
-- Commit ID (hex string, 128-bit = 32 char)
-- git log -1 --format="
%
H" | cut -c1-32
syn_commit_id => "$syn_commit_id",
-- Synthesis tool name (string, 8 char)
syn_tool_name => "$syn_tool_name",
-- Synthesis tool version (bcd encoded, 32-bit)
syn_tool_version => "$syn_tool_version", -- $syn_tool_version_str
-- Synthesis date (bcd encoded, 32-bit)
syn_date => "$syn_date", -- $syn_date_str
-- Synthesised by (string, 15 char)
syn_username => "$syn_username");
end sdb_meta_pkg;
package body sdb_meta_pkg is
end sdb_meta_pkg;"""
)
project_vhd
=
open
(
"project.vhd"
,
'w'
)
date_std_logic_vector
=
[]
import
re
for
digit
in
date_string
:
date_std_logic_vector
.
append
(
"{0:04b}"
.
format
(
int
(
digit
)))
syn_tool_version
=
version
syn_tool_version
=
re
.
sub
(
"
\
D"
,
""
,
syn_tool_version
)
syn_tool_std_logic_vector
=
[]
for
digit
in
syn_tool_version
:
syn_tool_std_logic_vector
.
append
(
"{0:04b}"
.
format
(
int
(
digit
)))
filled_template
=
template
.
substitute
(
repo_url
=
self
.
top_module
.
url
,
syn_module_name
=
self
.
top_module
.
manifest_dict
[
"syn_top"
],
syn_commit_id
=
self
.
top_module
.
revision
,
syn_tool_name
=
tool
.
upper
(),
syn_tool_version
=
"0000"
*
(
8
-
len
(
syn_tool_std_logic_vector
))
+
''
.
join
(
syn_tool_std_logic_vector
),
syn_tool_version_str
=
syn_tool_version
,
syn_date
=
''
.
join
(
date_std_logic_vector
),
syn_date_str
=
date_string
,
syn_username
=
getpass
.
getuser
())
project_vhd
.
write
(
filled_template
)
project_vhd
.
close
()
def
_generate_synthesis_project
(
self
):
tool_name
=
self
.
get_top_module
()
.
manifest_dict
[
"syn_tool"
]
tool_module
=
importlib
.
import_module
(
"hdlmake.tools.
%
s.
%
s"
%
(
tool_name
,
tool_name
))
tool_object
=
tool_module
.
ToolControls
()
tool_info
=
tool_object
.
get_keys
()
if
sys
.
platform
==
'cygwin'
:
bin_name
=
tool_info
[
'windows_bin'
]
else
:
bin_name
=
tool_info
[
'linux_bin'
]
path_key
=
tool_info
[
'id'
]
+
'_path'
version_key
=
tool_info
[
'id'
]
+
'_version'
name
=
tool_info
[
'name'
]
id_value
=
tool_info
[
'id'
]
ext_value
=
tool_info
[
'project_ext'
]
env
=
self
.
env
env
.
check_general
()
env
.
check_tool
(
tool_object
)
if
not
self
.
env
.
options
.
force
:
if
self
.
env
[
path_key
]
is
None
:
logging
.
error
(
"Can't generate the "
+
name
+
" project. "
+
name
+
" not found."
)
quit
()
if
version_key
not
in
env
or
not
env
[
version_key
]:
logging
.
error
(
name
+
" version cannot be deduced. Cannot generate "
+
name
+
" "
"project file properly. Please use syn_"
+
id_value
+
"_version in the manifest "
"or set"
)
sys
.
exit
(
"Exiting"
)
logging
.
info
(
"Generating project for "
+
name
+
" v.
%
s"
%
env
[
version_key
])
if
os
.
path
.
exists
(
self
.
top_module
.
manifest_dict
[
"syn_project"
])
or
os
.
path
.
exists
(
self
.
top_module
.
manifest_dict
[
"syn_project"
]
+
"."
+
ext_value
):
logging
.
info
(
"Existing project detected: updating..."
)
update
=
True
else
:
logging
.
info
(
"No previous project: creating a new one..."
)
update
=
False
top_mod
=
self
.
get_top_module
()
fileset
=
self
.
build_file_set
(
top_mod
.
manifest_dict
[
"syn_top"
])
privative_files
=
tool_object
.
supported_files
(
self
.
build_complete_file_set
())
if
privative_files
:
logging
.
info
(
"Privative / non-parseable files detected:
%
s"
%
len
(
privative_files
))
fileset
.
add
(
privative_files
)
sff
=
SourceFileFactory
()
if
self
.
env
.
options
.
generate_project_vhd
:
self
.
_write_project_vhd
(
id_value
,
env
[
version_key
])
fileset
.
add
([
sff
.
new
(
path
=
path
.
rel2abs
(
"project.vhd"
),
module
=
self
.
get_module_by_path
(
"."
))])
tool_object
.
generate_synthesis_project
(
update
=
update
,
tool_version
=
self
.
env
[
version_key
],
top_mod
=
self
.
get_top_module
(),
fileset
=
fileset
)
logging
.
info
(
name
+
" project file generated."
)
def
_check_remote_synthesis
(
self
):
if
not
self
.
top_module
.
action
==
"synthesis"
:
logging
.
error
(
"action must be equal to
\"
synthesis
\"
"
)
sys
.
exit
(
"Exiting"
)
if
not
self
.
top_module
.
manifest_dict
[
"syn_project"
]:
logging
.
error
(
"syn_project must be set in the manifest."
)
sys
.
exit
(
"Exiting"
)
def
remote_synthesis
(
self
):
self
.
_check_all_fetched_or_quit
()
self
.
_check_remote_synthesis
()
self
.
_generate_remote_synthesis_makefile
()
def
_generate_remote_synthesis_makefile
(
self
):
tool_name
=
self
.
get_top_module
()
.
manifest_dict
[
"syn_tool"
]
tool_module
=
importlib
.
import_module
(
"hdlmake.tools.
%
s.
%
s"
%
(
tool_name
,
tool_name
))
tool_object
=
tool_module
.
ToolControls
()
logging
.
info
(
"Generating makefile for remote synthesis."
)
top_mod
=
self
.
get_top_module
()
self
.
env
.
check_remote_tool
(
tool_object
)
self
.
env
.
check_general
()
files
=
self
.
build_file_set
(
self
.
get_top_module
()
.
manifest_dict
[
"syn_top"
])
sff
=
SourceFileFactory
()
files
.
add
(
sff
.
new
(
top_mod
.
manifest_dict
[
"syn_project"
],
module
=
self
.
top_module
))
tool_object
.
generate_remote_synthesis_makefile
(
files
=
files
,
name
=
top_mod
.
manifest_dict
[
"syn_project"
][:
-
5
],
cwd
=
top_mod
.
url
,
user
=
self
.
env
[
"rsynth_user"
],
server
=
self
.
env
[
"rsynth_server"
])
logging
.
info
(
"Remote synthesis makefile generated."
)
hdlmake/action/synthesis_project.py
deleted
100644 → 0
View file @
5f330e08
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013, 2014 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
# Multi-tool support by Javier D. Garcia-Lasheras (javier@garcialasheras.com)
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# 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 Hdlmake. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
print_function
import
logging
import
sys
import
os
import
importlib
from
hdlmake.srcfile
import
SourceFileFactory
from
hdlmake.util
import
path
from
.action
import
Action
class
GenerateSynthesisProject
(
Action
):
def
_check_synthesis_project
(
self
):
manifest
=
self
.
get_top_module
()
.
manifest_dict
if
not
manifest
[
"syn_tool"
]:
logging
.
error
(
"syn_tool variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_device"
]:
logging
.
error
(
"syn_device variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_grade"
]:
logging
.
error
(
"syn_grade variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_package"
]:
logging
.
error
(
"syn_package variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
if
not
manifest
[
"syn_top"
]:
logging
.
error
(
"syn_top variable must be set in the top manifest."
)
sys
.
exit
(
"Exiting"
)
def
synthesis_project
(
self
):
self
.
_check_all_fetched_or_quit
()
self
.
_check_synthesis_project
()
self
.
_generate_synthesis_project
()
def
_write_project_vhd
(
self
,
tool
,
version
):
from
string
import
Template
from
datetime
import
date
import
getpass
today
=
date
.
today
()
date_string
=
today
.
strftime
(
"
%
Y
%
m
%
d"
)
template
=
Template
(
"""library ieee;
use work.wishbone_pkg.all;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
package sdb_meta_pkg is
------------------------------------------------------------------------------
-- Meta-information sdb records
------------------------------------------------------------------------------
-- Top module repository url
constant c_SDB_REPO_URL : t_sdb_repo_url := (
-- url (string, 63 char)
repo_url => "$repo_url");
-- Synthesis informations
constant c_SDB_SYNTHESIS : t_sdb_synthesis := (
-- Top module name (string, 16 char)
syn_module_name => "$syn_module_name",
-- Commit ID (hex string, 128-bit = 32 char)
-- git log -1 --format="
%
H" | cut -c1-32
syn_commit_id => "$syn_commit_id",
-- Synthesis tool name (string, 8 char)
syn_tool_name => "$syn_tool_name",
-- Synthesis tool version (bcd encoded, 32-bit)
syn_tool_version => "$syn_tool_version", -- $syn_tool_version_str
-- Synthesis date (bcd encoded, 32-bit)
syn_date => "$syn_date", -- $syn_date_str
-- Synthesised by (string, 15 char)
syn_username => "$syn_username");
end sdb_meta_pkg;
package body sdb_meta_pkg is
end sdb_meta_pkg;"""
)
project_vhd
=
open
(
"project.vhd"
,
'w'
)
date_std_logic_vector
=
[]
import
re
for
digit
in
date_string
:
date_std_logic_vector
.
append
(
"{0:04b}"
.
format
(
int
(
digit
)))
syn_tool_version
=
version
syn_tool_version
=
re
.
sub
(
"
\
D"
,
""
,
syn_tool_version
)
syn_tool_std_logic_vector
=
[]
for
digit
in
syn_tool_version
:
syn_tool_std_logic_vector
.
append
(
"{0:04b}"
.
format
(
int
(
digit
)))
filled_template
=
template
.
substitute
(
repo_url
=
self
.
top_module
.
url
,
syn_module_name
=
self
.
top_module
.
manifest_dict
[
"syn_top"
],
syn_commit_id
=
self
.
top_module
.
revision
,
syn_tool_name
=
tool
.
upper
(),
syn_tool_version
=
"0000"
*
(
8
-
len
(
syn_tool_std_logic_vector
))
+
''
.
join
(
syn_tool_std_logic_vector
),
syn_tool_version_str
=
syn_tool_version
,
syn_date
=
''
.
join
(
date_std_logic_vector
),
syn_date_str
=
date_string
,
syn_username
=
getpass
.
getuser
())
project_vhd
.
write
(
filled_template
)
project_vhd
.
close
()
def
_generate_synthesis_project
(
self
):
tool_name
=
self
.
get_top_module
()
.
manifest_dict
[
"syn_tool"
]
tool_module
=
importlib
.
import_module
(
"hdlmake.tools.
%
s.
%
s"
%
(
tool_name
,
tool_name
))
tool_object
=
tool_module
.
ToolControls
()
tool_info
=
tool_object
.
get_keys
()
if
sys
.
platform
==
'cygwin'
:
bin_name
=
tool_info
[
'windows_bin'
]
else
:
bin_name
=
tool_info
[
'linux_bin'
]
path_key
=
tool_info
[
'id'
]
+
'_path'
version_key
=
tool_info
[
'id'
]
+
'_version'
name
=
tool_info
[
'name'
]
id_value
=
tool_info
[
'id'
]
ext_value
=
tool_info
[
'project_ext'
]
env
=
self
.
env
env
.
check_general
()
env
.
check_tool
(
tool_object
)
if
not
self
.
env
.
options
.
force
:
if
self
.
env
[
path_key
]
is
None
:
logging
.
error
(
"Can't generate the "
+
name
+
" project. "
+
name
+
" not found."
)
quit
()
if
version_key
not
in
env
or
not
env
[
version_key
]:
logging
.
error
(
name
+
" version cannot be deduced. Cannot generate "
+
name
+
" "
"project file properly. Please use syn_"
+
id_value
+
"_version in the manifest "
"or set"
)
sys
.
exit
(
"Exiting"
)
logging
.
info
(
"Generating project for "
+
name
+
" v.
%
s"
%
env
[
version_key
])
if
os
.
path
.
exists
(
self
.
top_module
.
manifest_dict
[
"syn_project"
])
or
os
.
path
.
exists
(
self
.
top_module
.
manifest_dict
[
"syn_project"
]
+
"."
+
ext_value
):
logging
.
info
(
"Existing project detected: updating..."
)
update
=
True
else
:
logging
.
info
(
"No previous project: creating a new one..."
)
update
=
False
top_mod
=
self
.
get_top_module
()
fileset
=
self
.
build_file_set
(
top_mod
.
manifest_dict
[
"syn_top"
])
privative_files
=
tool_object
.
supported_files
(
self
.
build_complete_file_set
())
if
privative_files
:
logging
.
info
(
"Privative / non-parseable files detected:
%
s"
%
len
(
privative_files
))
fileset
.
add
(
privative_files
)
sff
=
SourceFileFactory
()
if
self
.
env
.
options
.
generate_project_vhd
:
self
.
_write_project_vhd
(
id_value
,
env
[
version_key
])
fileset
.
add
([
sff
.
new
(
path
=
path
.
rel2abs
(
"project.vhd"
),
module
=
self
.
get_module_by_path
(
"."
))])
\
tool_object
.
generate_synthesis_project
(
update
=
update
,
tool_version
=
self
.
env
[
version_key
],
top_mod
=
self
.
get_top_module
(),
fileset
=
fileset
)
logging
.
info
(
name
+
" project file generated."
)
hdlmake/module_pool.py
View file @
0cf25370
...
...
@@ -36,13 +36,13 @@ from . import fetch
from
.env
import
Env
from
.action
import
(
CheckManifest
,
CheckCondition
,
FetchModules
,
ListFiles
,
ListModules
,
MergeCores
,
Tree
,
GenerateSimulationMakefile
,
GenerateSynthesisMakefile
,
GenerateRemoteSynthesisMakefile
,
GenerateSynthesisProject
,
ActionSynthesis
,
QsysHwTclUpdate
)
class
ModulePool
(
list
,
CheckManifest
,
CheckCondition
,
FetchModules
,
ListFiles
,
ListModules
,
MergeCores
,
Tree
,
GenerateSimulationMakefile
,
GenerateSynthesisMakefile
,
GenerateRemoteSynthesisMakefile
,
GenerateSynthesisProject
,
ActionSynthesis
,
QsysHwTclUpdate
):
"""
The ModulePool class acts as the container for the HDLMake modules that
...
...
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