Skip to content

Commit

Permalink
Make surelog frontend available to every tool that uses yosys, libara…
Browse files Browse the repository at this point in the history
…y_files "/arch/cells_bb.v" are automaticly included.
  • Loading branch information
mtdudek committed May 12, 2021
1 parent 6898333 commit 27b18a5
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 42 deletions.
15 changes: 13 additions & 2 deletions edalize/icestorm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ def get_doc(cls, api_ver):
{'name' : 'yosys_synth_options',
'type' : 'String',
'desc' : 'Additional options for the synth_ice40 command'},
{'name' : 'yosys_read_options',
'type' : 'String',
'desc' : 'Addtional options for the read_* command (e.g. read_verlog or read_uhdm)'},
{'name' : 'surelog_options',
'type' : 'String',
'desc' : 'Additional options for the Surelog'},
]}

combined_members = icestorm_help['members']
Expand All @@ -47,8 +53,11 @@ def get_doc(cls, api_ver):

def configure_main(self):
# Write yosys script file
(src_files, incdirs) = self._get_fileset_files()
yosys_synth_options = self.tool_options.get('yosys_synth_options', '')
(src_files, incdirs) = self._get_fileset_files()
yosys_synth_options = self.tool_options.get('yosys_synth_options', [])
yosys_read_options = self.tool_options.get('yosys_read_options', [])
yosys_synth_options = ["-nomux"] + yosys_synth_options

yosys_edam = {
'files' : self.files,
'name' : self.name,
Expand All @@ -57,8 +66,10 @@ def configure_main(self):
'tool_options' : {'yosys' : {
'arch' : 'ice40',
'yosys_synth_options' : yosys_synth_options,
'yosys_read_options' : yosys_read_options,
'yosys_as_subtool' : True,
'yosys_template' : self.tool_options.get('yosys_template'),
'surelog_options' : surelog_options,
}
}
}
Expand Down
16 changes: 2 additions & 14 deletions edalize/surelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ class Surelog(Edatool):
def get_doc(cls, api_ver):
if api_ver == 0:
return {'description' : "Surelog",
"members" : [
{'name' : 'library_files',
'type' : 'String',
'desc' : 'List of the library files for Surelog'},
],
'lists' : [
{'name' : 'surelog_options',
'type' : 'String',
Expand All @@ -34,15 +29,8 @@ def configure_main(self):
if f.file_type.startswith('systemVerilogSource'):
systemverilog_file_list.append("-sv " + f.name)

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

if library_files:
print(library_files)
library_files = library_files.split(",")

pattern = len(library_files) * " -v %s"
library_command = pattern % tuple(library_files)
arch = self.tool_options.get('arch', None)

pattern = len(self.vlogparam.keys()) * " -P%s=%%s"
verilog_params_command = pattern % tuple(self.vlogparam.keys()) % tuple(self.vlogparam.values())
Expand All @@ -60,7 +48,7 @@ def configure_main(self):
'name' : self.name,
'sources' : ' '.join(verilog_file_list),
'sv_sources' : ' '.join(systemverilog_file_list),
'library_command' : library_command,
'arch' : arch,
'verilog_params_command' : verilog_params_command,
'verilog_defines_command' : verilog_defines_command,
'include_files_command' : include_files_command,
Expand Down
6 changes: 0 additions & 6 deletions edalize/symbiflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ def get_doc(cls, api_ver):
"type" : "String",
"desc" : 'Select yosys frontend. Currently "uhdm" and "verilog" frontends are supported.'
},
{
"name" : "library_files",
"type" : "String",
"desc" : "list of the library files for surelog"
},
],
'lists' : [
{'name' : 'surelog_options',
Expand Down Expand Up @@ -242,7 +237,6 @@ def configure_vpr(self):
'toplevel' : self.toplevel,
'parameters' : self.parameters,
'tool_options' : {'surelog' : {
'library_files' : self.tool_options.get('library_files', []),
'surelog_options' : self.tool_options.get('surelog_options', []),
}
}
Expand Down
4 changes: 1 addition & 3 deletions edalize/templates/surelog/surelog-makefile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ VERILOG := {{ sources }}
SYSTEMVERILOG := {{ sv_sources }}
TOP := {{ top }}

{% if library_command -%}
LIBRARY_COMMAND = {{ library_command }}
{%- endif %}
LIBRARY_COMMAND := -v $(shell yosys-config --datdir)/{{ arch }}/cells_bb.v

{% if verilog_params_command -%}
PARAMS_COMMAND = {{ verilog_params_command }}
Expand Down
10 changes: 5 additions & 5 deletions edalize/templates/yosys/yosys-makefile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ all: $(TARGET).{{ default_target }}
{{ top }}.uhdm:
$(MAKE) -f surelog.mk

DEPENDENCIES := {{ top }}.uhdm {{ yosys_template }} }}
DEPENDENCIES := {{ top }}.uhdm {{ yosys_template }}
{% else %}
DEPENDENCIES := {{ yosys_template }} }}
DEPENDENCIES := {{ yosys_template }}
{%- endif %}

%.blif: ${DEPENDENCIES}
$(EDALIZE_LAUNCHER) yosys -l yosys.log -p "tcl {{ yosys_template }} }}"
$(EDALIZE_LAUNCHER) yosys -l yosys.log -p "tcl {{ yosys_template }}"
%.json: ${DEPENDENCIES}
$(EDALIZE_LAUNCHER) yosys -l yosys.log -p "tcl {{ yosys_template }} }}"
$(EDALIZE_LAUNCHER) yosys -l yosys.log -p "tcl {{ yosys_template }}"
%.edif: ${DEPENDENCIES}
$(EDALIZE_LAUNCHER) yosys -l yosys.log -p "tcl {{ yosys_template }} }}"
$(EDALIZE_LAUNCHER) yosys -l yosys.log -p "tcl {{ yosys_template }}"

clean:
rm -f $(TARGET).blif $(TARGET).json $(TARGET).edif
16 changes: 13 additions & 3 deletions edalize/trellis.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ def get_doc(cls, api_ver):
{'name' : 'yosys_synth_options',
'type' : 'String',
'desc' : 'Additional options for the synth_ecp5 command'},
{'name' : 'yosys_read_options',
'type' : 'String',
'desc' : 'Addtional options for the read_* command (e.g. read_verlog or read_uhdm)'},
{'name' : 'surelog_options',
'type' : 'String',
'desc' : 'Additional options for the Surelog'},
]}

combined_members = []
Expand All @@ -40,9 +46,11 @@ def get_doc(cls, api_ver):

def configure_main(self):
# Write yosys script file
(src_files, incdirs) = self._get_fileset_files()
yosys_synth_options = self.tool_options.get('yosys_synth_options', [])
yosys_synth_options = ["-nomux"] + yosys_synth_options
(src_files, incdirs) = self._get_fileset_files()
yosys_synth_options = self.tool_options.get('yosys_synth_options', [])
yosys_read_options = self.tool_options.get('yosys_read_options', [])
yosys_synth_options = ["-nomux"] + yosys_synth_options
surelog_options = self.tool_options.get('surelog_options', [])
yosys_edam = {
'files' : self.files,
'name' : self.name,
Expand All @@ -51,7 +59,9 @@ def configure_main(self):
'tool_options' : {'yosys' : {
'arch' : 'ecp5',
'yosys_synth_options' : yosys_synth_options,
'yosys_read_options' : yosys_read_options,
'yosys_as_subtool' : True,
'surelog_options' : surelog_options,
}
}
}
Expand Down
4 changes: 0 additions & 4 deletions edalize/vivado.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ def get_doc(cls, api_ver):
{'name' : 'hw_target',
'type' : 'Description',
'desc' : 'Board identifier (e.g. */xilinx_tcf/Digilent/123456789123A'},
{'name' : 'library_files',
'type' : 'String',
'desc' : 'List of the library files for Surelog'},
],
'lists' : [
{'name' : 'yosys_synth_options',
Expand Down Expand Up @@ -127,7 +124,6 @@ def configure_main(self):
'yosys_read_options' : yosys_read_options,
'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
11 changes: 6 additions & 5 deletions edalize/yosys.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ def configure_main(self):
yosys_read_options = " ".join(self.tool_options.get('yosys_read_options', []))
file_table = []
yosys_synth_options = self.tool_options.get('yosys_synth_options', [])

arch = self.tool_options.get('arch', None)
if not arch:
logger.error("ERROR: arch is not defined.")

use_surelog = False
if "frontend=surelog" in yosys_synth_options:
use_surelog = True
Expand All @@ -69,8 +74,8 @@ def configure_main(self):
'toplevel' : self.toplevel,
'parameters' : self.parameters,
'tool_options' : {'surelog' : {
'library_files' : self.tool_options.get('library_files', []),
'surelog_options' : self.tool_options.get('surelog_options', []),
'arch' : arch,
}
}
}
Expand Down Expand Up @@ -108,10 +113,6 @@ def configure_main(self):
self.toplevel))

output_format = self.tool_options.get('output_format', 'blif')
arch = self.tool_options.get('arch', None)

if not arch:
logger.error("ERROR: arch is not defined.")

makefile_name = self.tool_options.get('makefile_name', self.name + '.mk')
template_vars = {
Expand Down

0 comments on commit 27b18a5

Please sign in to comment.