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
c54d5710
Commit
c54d5710
authored
Nov 14, 2019
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools: add support for 'ghdl --synth'.
parent
32946855
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
134 additions
and
1 deletion
+134
-1
ghdl_syn.py
hdlmake/tools/ghdl_syn.py
+131
-0
load_tool.py
hdlmake/tools/load_tool.py
+3
-1
No files found.
hdlmake/tools/ghdl_syn.py
0 → 100644
View file @
c54d5710
"""Module providing the synthesis functionality for writing Makefiles"""
from
__future__
import
absolute_import
import
os
,
sys
import
logging
from
.makefile
import
ToolMakefile
from
..util
import
shell
from
..sourcefiles.srcfile
import
VHDLFile
,
VerilogFile
,
SVFile
def
_check_synthesis_manifest
(
top_manifest
):
"""Check the manifest contains all the keys for a synthesis project"""
for
v
in
[
"syn_top"
]:
if
v
not
in
top_manifest
.
manifest_dict
:
raise
Exception
(
"'{}' variable must be set in the top manifest."
.
format
(
v
))
class
GhdlSyn
(
ToolMakefile
):
"""Class that provides the synthesis Makefile writing methods and status"""
TOOL_INFO
=
{
'name'
:
'Ghdl'
,
'id'
:
'ghdl'
,
'windows_bin'
:
'ghdl'
,
'linux_bin'
:
'ghdl'
,
'project_ext'
:
''
}
CLEAN_TARGETS
=
{
'clean'
:
[],
'mrproper'
:
[]}
HDL_FILES
=
{
VHDLFile
:
'$(sourcefile)'
}
def
__init__
(
self
):
super
(
GhdlSyn
,
self
)
.
__init__
()
self
.
_tcl_controls
=
{}
def
write_makefile
(
self
,
top_manifest
,
fileset
,
filename
=
None
):
"""Generate a Makefile for the specific synthesis tool"""
_check_synthesis_manifest
(
top_manifest
)
self
.
makefile_setup
(
top_manifest
,
fileset
,
filename
=
filename
)
self
.
makefile_check_tool
(
'syn_path'
)
self
.
makefile_includes
()
self
.
_makefile_syn_top
()
self
.
_makefile_syn_local
()
self
.
_makefile_syn_files
()
self
.
_makefile_syn_build
()
self
.
_makefile_syn_clean
()
self
.
_makefile_syn_phony
()
self
.
makefile_close
()
logging
.
info
(
self
.
TOOL_INFO
[
'name'
]
+
" synthesis makefile generated."
)
def
_makefile_syn_top
(
self
):
"""Create the top part of the synthesis Makefile"""
top_parameter
=
"""
\
TOP_MODULE := {top_module}
TOOL_PATH := {tool_path}
TOP_MODULE := {top_module}
GHDL := ghdl
"""
self
.
writeln
(
top_parameter
.
format
(
tool_path
=
self
.
manifest_dict
[
"syn_path"
],
top_module
=
self
.
manifest_dict
[
"syn_top"
]))
def
_makefile_syn_files
(
self
):
"""Write the files TCL section of the Makefile"""
ret
=
[]
fileset_dict
=
{}
sources_list
=
[]
fileset_dict
.
update
(
self
.
HDL_FILES
)
fileset_dict
.
update
(
self
.
SUPPORTED_FILES
)
for
filetype
in
fileset_dict
:
file_list
=
[]
for
file_aux
in
self
.
fileset
:
if
isinstance
(
file_aux
,
filetype
):
if
filetype
==
VerilogFile
and
isinstance
(
file_aux
,
SVFile
):
# Discard SVerilog files for verilog type.
continue
file_list
.
append
(
shell
.
tclpath
(
file_aux
.
rel_path
()))
if
not
file_list
==
[]:
ret
.
append
(
'SOURCES_{0} :=
\\\n
'
'{1}
\n
'
.
format
(
filetype
.
__name__
,
'
\\\n
'
.
join
(
file_list
)))
if
not
fileset_dict
[
filetype
]
is
None
:
sources_list
.
append
(
filetype
)
self
.
writeln
(
'
\n
'
.
join
(
ret
))
self
.
writeln
(
'files.tcl:'
)
if
"files"
in
self
.
_tcl_controls
:
echo_command
=
'
\t\t
@echo {0} >> $@'
tcl_command
=
[]
for
command
in
self
.
_tcl_controls
[
"files"
]
.
split
(
'
\n
'
):
tcl_command
.
append
(
echo_command
.
format
(
command
))
command_string
=
"
\n
"
.
join
(
tcl_command
)
if
shell
.
check_windows_commands
():
command_string
=
command_string
.
replace
(
"'"
,
""
)
self
.
writeln
(
command_string
)
for
filetype
in
sources_list
:
filetype_string
=
(
'
\t\t
@$(foreach sourcefile,'
' $(SOURCES_{0}), echo "{1}" >> $@ &)'
.
format
(
filetype
.
__name__
,
fileset_dict
[
filetype
]))
if
shell
.
check_windows_commands
():
filetype_string
=
filetype_string
.
replace
(
'"'
,
''
)
self
.
writeln
(
filetype_string
)
self
.
writeln
()
def
_makefile_syn_local
(
self
):
"""Generic method to write the synthesis Makefile local target"""
self
.
writeln
(
"#target for performing local synthesis
\n
"
"all: synthesis
\n
"
)
def
_makefile_syn_build
(
self
):
"""Generate the synthesis Makefile targets for handling design build"""
self
.
writeln
(
"""
\
synthesis: files.tcl
\t
$(GHDL) --synth @files.tcl -e $(TOP_MODULE)
"""
)
def
_makefile_syn_clean
(
self
):
"""Print the Makefile clean target for synthesis"""
self
.
makefile_clean
()
self
.
makefile_mrproper
()
def
_makefile_syn_phony
(
self
):
"""Print synthesis PHONY target list to the Makefile"""
self
.
writeln
(
".PHONY: mrproper clean all"
)
hdlmake/tools/load_tool.py
View file @
c54d5710
...
...
@@ -13,13 +13,15 @@ def load_syn_tool(tool_name):
from
.diamond
import
ToolDiamond
from
.libero
import
ToolLibero
from
.icestorm
import
ToolIcestorm
from
.ghdl_syn
import
GhdlSyn
available_tools
=
{
'ise'
:
ToolISE
,
'planahead'
:
ToolPlanAhead
,
'vivado'
:
ToolVivado
,
'quartus'
:
ToolQuartus
,
'diamond'
:
ToolDiamond
,
'libero'
:
ToolLibero
,
'icestorm'
:
ToolIcestorm
}
'icestorm'
:
ToolIcestorm
,
'ghdl'
:
GhdlSyn
}
if
tool_name
in
available_tools
:
logging
.
debug
(
"Synthesis tool to be used found:
%
s"
,
tool_name
)
return
available_tools
[
tool_name
]()
...
...
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