Add a smarter interface between Action and Tool

parent f5a6d101
......@@ -29,9 +29,7 @@ import sys
from hdlmake.dep_file import DepFile
# import hdlmake.new_dep_solver as dep_solver
from hdlmake.tools import (
ToolIVerilog, ToolISim, ToolModelsim,
ToolActiveHDL, ToolRiviera, ToolGHDL)
from hdlmake.tools import WriterSim
from .action import Action
......@@ -40,6 +38,7 @@ class ActionSimulation(Action):
"""This class contains the simulation specific methods"""
def __init__(self, *args):
self.sim_writer = WriterSim()
super(ActionSimulation, self).__init__(*args)
def _check_simulation_makefile(self):
......@@ -56,16 +55,16 @@ class ActionSimulation(Action):
self._check_all_fetched_or_quit()
self._check_simulation_makefile()
tool_name = self.get_top_module().manifest_dict["sim_tool"]
tool_dict = {"iverilog": ToolIVerilog,
"isim": ToolISim,
"modelsim": ToolModelsim,
"active-hdl": ToolActiveHDL,
"riviera": ToolRiviera,
"ghdl": ToolGHDL}
tool_dict = {"iverilog": self.sim_writer.iverilog,
"isim": self.sim_writer.isim,
"modelsim": self.sim_writer.modelsim,
"active-hdl": self.sim_writer.active_hdl,
"riviera": self.sim_writer.riviera,
"ghdl": self.sim_writer.ghdl}
if not tool_name in tool_dict:
logging.error("Unknown sim_tool: %s", tool_name)
sys.exit("Exiting")
tool_object = tool_dict[tool_name]()
tool_object = tool_dict[tool_name]
tool_info = tool_object.TOOL_INFO
if sys.platform == 'cygwin':
bin_name = tool_info['windows_bin']
......
......@@ -26,9 +26,7 @@ from __future__ import print_function
import logging
import sys
from hdlmake.tools import (
ToolISE, ToolPlanAhead, ToolVivado,
ToolQuartus, ToolDiamond, ToolLibero)
from hdlmake.tools import WriterSyn
from .action import Action
......@@ -38,21 +36,22 @@ class ActionSynthesis(Action):
"""Class providing the public synthesis methods for the user"""
def __init__(self, *args):
self.syn_writer = WriterSyn()
super(ActionSynthesis, self).__init__(*args)
def _load_synthesis_tool(self):
"""Returns a tool_object that provides the synthesis tool interface"""
tool_name = self.get_top_module().manifest_dict["syn_tool"]
tool_dict = {"ise": ToolISE,
"planahead": ToolPlanAhead,
"vivado": ToolVivado,
"quartus": ToolQuartus,
"diamond": ToolDiamond,
"libero": ToolLibero}
tool_dict = {"ise": self.syn_writer.ise,
"planahead": self.syn_writer.planahead,
"vivado": self.syn_writer.vivado,
"quartus": self.syn_writer.quartus,
"diamond": self.syn_writer.diamond,
"libero": self.syn_writer.libero}
if not tool_name in tool_dict:
logging.error("Synthesis tool not recognized: %s", tool_name)
quit()
return tool_dict[tool_name]()
return tool_dict[tool_name]
def _check_synthesis_project(self):
"""Check the manifest contains all the keys for a synthesis project"""
......
......@@ -19,3 +19,5 @@ from .vivado import ToolVivado
from .quartus import ToolQuartus
from .diamond import ToolDiamond
from .libero import ToolLibero
from .writer import WriterSim, WriterSyn
"""Package containing the classes required to print a Makefile"""
from hdlmake.tools import (
ToolIVerilog, ToolISim, ToolModelsim,
ToolActiveHDL, ToolRiviera, ToolGHDL)
from hdlmake.tools import (
ToolISE, ToolPlanAhead, ToolVivado,
ToolQuartus, ToolDiamond, ToolLibero)
class WriterSim(object):
"""Class that is in charge of writing simulation Makefiles"""
def __init__(self):
self.iverilog = ToolIVerilog()
self.isim = ToolISim()
self.modelsim = ToolModelsim()
self.active_hdl = ToolActiveHDL()
self.riviera = ToolRiviera()
self.ghdl = ToolGHDL()
class WriterSyn(object):
"""Class that is in charge of writing synthesis Makefiles"""
def __init__(self):
self.ise = ToolISE()
self.planahead = ToolPlanAhead()
self.vivado = ToolVivado()
self.quartus = ToolQuartus()
self.diamond = ToolDiamond()
self.libero = ToolLibero()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment