Skip to content

Commit

Permalink
Surelog: allow to pass additional options
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Rakoczy <[email protected]>
  • Loading branch information
kamilrakoczy committed Jan 22, 2021
1 parent 192d149 commit 20f1f27
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
35 changes: 20 additions & 15 deletions edalize/surelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,48 @@ def get_doc(cls, api_ver):
{'name' : 'library_files',
'type' : 'String',
'desc' : 'List of the library files for Surelog'},
{'name' : 'surelog_options',
'type' : 'String',
'desc' : 'List of the Surelog parameters'},
]}

def configure_main(self):
(src_files, incdirs) = self._get_fileset_files()
file_list = []
verilog_file_list = []
systemverilog_file_list = []
for f in src_files:
if f.file_type.startswith('verilogSource'):
file_list.append(f.name)
verilog_file_list.append(f.name)
if f.file_type.startswith('systemVerilogSource'):
file_list.append(f.name)
systemverilog_file_list.append("-sv " + f.name)

library_files = self.tool_options.get('library_files', [])
library_command = ""
surelog_options = self.tool_options.get('surelog_options', [])

for library_file in library_files:
library_command = library_command + " -v " + library_file
pattern = len(library_files) * "-v %s"
library_command = pattern % tuple(library_files)

verilog_params_command = ""
for key, value in self.vlogparam.items():
verilog_params_command += ' -P{key}={value}'.format(key=key, value=value)
pattern = len(self.vlogparam.keys()) * " -P%s=%%s"
verilog_params_command = pattern % tuple(self.vlogparam.keys()) % tuple(self.vlogparam.values())

verilog_defines_command = "+define" if self.vlogdefine.items() else ""
for key, value in self.vlogdefine.items():
verilog_defines_command += '+{key}={value}'.format(key=key, value=value)
pattern = len(self.vlogdefine.keys()) * "+%s=%%s"
verilog_defines_command += pattern % tuple(self.vlogdefine.keys()) % tuple(self.vlogdefine.values())

pattern = len(incdirs) * " -I%s"
include_files_command = pattern % tuple(incdirs)

include_files_command = ""
for include_file in incdirs:
include_files_command = include_files_command + " -I" + include_file

template_vars = {
'top' : self.toplevel,
'name' : self.name,
'sources' : ' '.join(file_list),
'sources' : ' '.join(verilog_file_list),
'sv_sources' : ' '.join(systemverilog_file_list),
'library_command' : library_command,
'verilog_params_command' : verilog_params_command,
'verilog_defines_command' : verilog_defines_command,
'include_files_command' : include_files_command,
'surelog_options' : ' '.join(surelog_options),
}


Expand Down
12 changes: 8 additions & 4 deletions edalize/templates/surelog/surelog-makefile.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Auto generated by Edalize
SHELL = bash

VERILOG := {{ sources }}
TOP := {{ top }}
VERILOG := {{ sources }}
SYSTEMVERILOG := {{ sv_sources }}
TOP := {{ top }}

{% if library_command -%}
LIBRARY_COMMAND = {{ library_command }}
Expand All @@ -20,8 +20,12 @@ DEFINES_COMMAND = {{ verilog_defines_command }}
INCLUDE_COMMAND = {{ include_files_command }}
{%- endif %}

{% if surelog_options -%}
SURELOG_OPTIONS = {{ surelog_options }}
{%- endif %}

all: ${TOP}.uhdm

${TOP}.uhdm:
surelog -parse -sverilog ${LIBRARY_COMMAND} ${DEFINES_COMMAND} ${PARAMS_COMMAND} -top ${TOP} ${INCLUDE_COMMAND} ${VERILOG}
surelog ${SURELOG_OPTIONS} -parse ${LIBRARY_COMMAND} ${DEFINES_COMMAND} ${PARAMS_COMMAND} -top ${TOP} ${INCLUDE_COMMAND} ${VERILOG} ${SYSTEMVERILOG}
cp slpp_all/surelog.uhdm ${TOP}.uhdm
4 changes: 4 additions & 0 deletions edalize/vivado.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ def get_doc(cls, api_ver):
{'name' : 'library_files',
'type' : 'String',
'desc' : 'List of the library files for Surelog'},
{'name' : 'surelog_options',
'type' : 'String',
'desc' : 'Additional options for the Surelog'},
]}

""" Get tool version
Expand Down Expand Up @@ -115,6 +118,7 @@ def configure_main(self):
'yosys_as_subtool' : True,
'script_name' : 'yosys.tcl',
'library_files' : self.tool_options.get('library_files', []),
'surelog_options' : self.tool_options.get('surelog_options', []),
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions edalize/yosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def get_doc(cls, api_ver):
{'name' : 'library_files',
'type' : 'String',
'desc' : 'List of the library files for Surelog'},
{'name' : 'surelog_options',
'type' : 'String',
'desc' : 'Additional options for the Surelog'},
]}

def configure_main(self):
Expand All @@ -64,6 +67,7 @@ def configure_main(self):
'parameters' : self.parameters,
'tool_options' : {'surelog' : {
'library_files' : self.tool_options.get('library_files', []),
'surelog_options' : self.tool_options.get('surelog_options', []),
}
}
}
Expand Down

0 comments on commit 20f1f27

Please sign in to comment.