Skip to content

Commit

Permalink
Reformat the whole source tree with black
Browse files Browse the repository at this point in the history
* [Templates/VUnit] Adjust to black changes
  • Loading branch information
umarcor committed Nov 4, 2021
1 parent 3145a23 commit 5f081dd
Show file tree
Hide file tree
Showing 101 changed files with 3,176 additions and 2,480 deletions.
83 changes: 44 additions & 39 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,52 @@
from datetime import datetime
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../tests/'))
sys.path.insert(0, os.path.abspath('../tests/test_vunit/vunit_mock/'))

sys.path.insert(0, os.path.abspath(".."))
sys.path.insert(0, os.path.abspath("../tests/"))
sys.path.insert(0, os.path.abspath("../tests/test_vunit/vunit_mock/"))


# -- Project information -----------------------------------------------------

project = 'Edalize'
copyright = '2019-{}, Olof Kindgren'.format(datetime.now().year)
author = 'Olof Kindgren'
project = "Edalize"
copyright = "2019-{}, Olof Kindgren".format(datetime.now().year)
author = "Olof Kindgren"

# The short X.Y version
version = ''
version = ""
# The full version, including alpha/beta/rc tags
release = '0.1.3'
release = "0.1.3"


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
needs_sphinx = '3.0'
needs_sphinx = "3.0"

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
'sphinx_autodoc_typehints',
'sphinx.ext.intersphinx',
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.napoleon",
"sphinx_autodoc_typehints",
"sphinx.ext.intersphinx",
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand All @@ -71,13 +72,15 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None

intersphinx_mapping = {'python': ('https://docs.python.org/3', None),
'vunit': ('https://vunit.github.io/', None)}
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"vunit": ("https://vunit.github.io/", None),
}

# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
Expand All @@ -93,13 +96,16 @@

try:
import sphinx_rtd_theme
html_theme = 'sphinx_rtd_theme'

html_theme = "sphinx_rtd_theme"
except ImportError:
sys.stderr.write('Warning: The Sphinx \'sphinx_rtd_theme\' HTML theme was '+
'not found. Make sure you have the theme installed to produce pretty '+
'HTML output. Falling back to the default theme.\n')
sys.stderr.write(
"Warning: The Sphinx 'sphinx_rtd_theme' HTML theme was "
+ "not found. Make sure you have the theme installed to produce pretty "
+ "HTML output. Falling back to the default theme.\n"
)

html_theme = 'alabaster'
html_theme = "alabaster"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -126,7 +132,7 @@
# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'Edalizedoc'
htmlhelp_basename = "Edalizedoc"


# -- Options for LaTeX output ------------------------------------------------
Expand All @@ -135,15 +141,12 @@
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
Expand All @@ -153,19 +156,15 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'Edalize.tex', 'Edalize Documentation',
'Olof Kindgren', 'manual'),
(master_doc, "Edalize.tex", "Edalize Documentation", "Olof Kindgren", "manual"),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'edalize', 'Edalize Documentation',
[author], 1)
]
man_pages = [(master_doc, "edalize", "Edalize Documentation", [author], 1)]


# -- Options for Texinfo output ----------------------------------------------
Expand All @@ -174,9 +173,15 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'Edalize', 'Edalize Documentation',
author, 'Edalize', 'Edalize is a Python Library for interacting with EDA tools.',
'Miscellaneous'),
(
master_doc,
"Edalize",
"Edalize Documentation",
author,
"Edalize",
"Edalize is a Python Library for interacting with EDA tools.",
"Miscellaneous",
),
]


Expand All @@ -195,7 +200,7 @@
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
epub_exclude_files = ["search.html"]


# -- Extension configuration -------------------------------------------------
Expand Down
16 changes: 9 additions & 7 deletions edalize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,23 @@
from pkgutil import walk_packages

NON_TOOL_PACKAGES = [
'vunit_hooks',
'reporting',
'ise_reporting',
'vivado_reporting',
'quartus_reporting',
"vunit_hooks",
"reporting",
"ise_reporting",
"vivado_reporting",
"quartus_reporting",
]


def get_edatool(name):
return getattr(import_module('{}.{}'.format(__name__, name)),
name.capitalize())
return getattr(import_module("{}.{}".format(__name__, name)), name.capitalize())


def walk_tool_packages():
for _, pkg_name, _ in walk_packages([dirname(__file__)]):
if not pkg_name in NON_TOOL_PACKAGES:
yield pkg_name


def get_edatools():
return [get_edatool(pkg) for pkg in walk_tool_packages()]
70 changes: 42 additions & 28 deletions edalize/apicula.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,55 @@
from edalize.nextpnr import Nextpnr
from edalize.yosys import Yosys


class Apicula(Edatool):

argtypes = ['vlogdefine', 'vlogparam']
argtypes = ["vlogdefine", "vlogparam"]

@classmethod
def get_doc(cls, api_ver):
if api_ver == 0:
options = {
'lists' : [],
'members' : [
{'name' : 'device',
'type' : 'String',
'desc' : 'Required device option for nextpnr-gowin and gowin_pack command (e.g. GW1N-LV1QN48C6/I5)'},
]}
"lists": [],
"members": [
{
"name": "device",
"type": "String",
"desc": "Required device option for nextpnr-gowin and gowin_pack command (e.g. GW1N-LV1QN48C6/I5)",
},
],
}

Edatool._extend_options(options, Yosys)
Edatool._extend_options(options, Nextpnr)

return {'description' : "Open source toolchain for Gowin FPGAs. Uses yosys for synthesis and nextpnr for Place & Route",
'members' : options['members'],
'lists' : options['lists']}
return {
"description": "Open source toolchain for Gowin FPGAs. Uses yosys for synthesis and nextpnr for Place & Route",
"members": options["members"],
"lists": options["lists"],
}

def configure_main(self):
#Pass apicula tool options to yosys and nextpnr
self.edam['tool_options'] = \
{'yosys' : {
'arch' : 'gowin',
'yosys_synth_options' : [f"-json {self.name}.json"] + self.tool_options.get('yosys_synth_options',[]),
'yosys_as_subtool' : True,
'yosys_template' : self.tool_options.get('yosys_template'),
# Pass apicula tool options to yosys and nextpnr
self.edam["tool_options"] = {
"yosys": {
"arch": "gowin",
"yosys_synth_options": [f"-json {self.name}.json"]
+ self.tool_options.get("yosys_synth_options", []),
"yosys_as_subtool": True,
"yosys_template": self.tool_options.get("yosys_template"),
},
"nextpnr": {
"device": self.tool_options.get("device"),
"nextpnr_options": self.tool_options.get("nextpnr_options", []),
},
'nextpnr' : {
'device' : self.tool_options.get('device'),
'nextpnr_options' : self.tool_options.get('nextpnr_options', [])
},
}
}

yosys = Yosys(self.edam, self.work_root)
yosys.configure()

nextpnr = Nextpnr(yosys.edam, self.work_root)
nextpnr.flow_config = {'arch' : 'gowin'}
nextpnr.flow_config = {"arch": "gowin"}
nextpnr.configure()

# Write Makefile
Expand All @@ -58,11 +65,18 @@ def configure_main(self):

commands.commands += nextpnr.commands

#Image generation
depends = self.name+'.pack'
targets = self.name+'.fs'
command = ['gowin_pack', '-d', self.tool_options.get('device'), '-o', targets, depends]
# Image generation
depends = self.name + ".pack"
targets = self.name + ".fs"
command = [
"gowin_pack",
"-d",
self.tool_options.get("device"),
"-o",
targets,
depends,
]
commands.add(command, [targets], [depends])

commands.set_default_target(targets)
commands.write(os.path.join(self.work_root, 'Makefile'))
commands.write(os.path.join(self.work_root, "Makefile"))
52 changes: 29 additions & 23 deletions edalize/ascentlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,52 @@

logger = logging.getLogger(__name__)


class Ascentlint(Edatool):

argtypes = ['vlogdefine', 'vlogparam']
argtypes = ["vlogdefine", "vlogparam"]

@classmethod
def get_doc(cls, api_ver):
if api_ver == 0:
return {'description' : """ Real Intent Ascent Lint backend
return {
"description": """ Real Intent Ascent Lint backend
Ascent Lint performs static source code analysis on HDL code and checks for
common coding errors or coding style violations.
""",
'lists' : [
{'name' : 'ascentlint_options',
'type' : 'String',
'desc' : 'Additional run options for ascentlint'}
]}
"lists": [
{
"name": "ascentlint_options",
"type": "String",
"desc": "Additional run options for ascentlint",
}
],
}

def configure_main(self):
(src_files, incdirs) = self._get_fileset_files(force_slash=True)

self._write_fileset_to_f_file(os.path.join(self.work_root, 'sources.f'),
include_vlogparams = False)
self._write_fileset_to_f_file(
os.path.join(self.work_root, "sources.f"), include_vlogparams=False
)

tcl_source_files = [f for f in src_files if f.file_type == 'tclSource']
waiver_files = [f for f in src_files if f.file_type == 'waiver']
tcl_source_files = [f for f in src_files if f.file_type == "tclSource"]
waiver_files = [f for f in src_files if f.file_type == "waiver"]

template_vars = {
'name' : self.name,
'ascentlint_options' : ' '.join(self.tool_options.get('ascentlint_options', [])),
'tcl_source_files' : tcl_source_files,
'waiver_files' : waiver_files,
'toplevel' : self.toplevel,
'vlogparam' : self.vlogparam,
"name": self.name,
"ascentlint_options": " ".join(
self.tool_options.get("ascentlint_options", [])
),
"tcl_source_files": tcl_source_files,
"waiver_files": waiver_files,
"toplevel": self.toplevel,
"vlogparam": self.vlogparam,
}

self.render_template('run-ascentlint.tcl.j2',
'run-ascentlint.tcl',
template_vars)
self.render_template(
"run-ascentlint.tcl.j2", "run-ascentlint.tcl", template_vars
)

self.render_template('Makefile.j2',
'Makefile',
template_vars)
self.render_template("Makefile.j2", "Makefile", template_vars)
Loading

0 comments on commit 5f081dd

Please sign in to comment.