Add partial support for SVase and sv2v to the DesignFlow.
This commit is contained in:
parent
2c32dbbf67
commit
c55654eb5f
|
@ -15,6 +15,8 @@
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/druc.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/graal.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/dreal.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/sv2v.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/svase.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/yosys.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/yosysnp.py
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/designflow/blif2vst.py
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
|
||||
import os.path
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from pyosys import libyosys as yosys
|
||||
from doit.exceptions import TaskFailed
|
||||
from .task import FlowTask
|
||||
|
||||
|
||||
def printCommand ( command ):
|
||||
commandBin = command[0]
|
||||
print( commandBin, command[1] )
|
||||
for arg in command[2:]:
|
||||
print( ' '*len(commandBin), arg )
|
||||
|
||||
|
||||
class Sv2v ( FlowTask ):
|
||||
|
||||
FlagLog = 0x00000001
|
||||
|
||||
@staticmethod
|
||||
def mkRule ( rule, targets, depends, top=None, incdirs=[], libdirs=[], defines=[], flags=0 ):
|
||||
return Sv2v( rule, targets, depends, top, incdirs, libdirs, defines, flags )
|
||||
|
||||
def __init__ ( self, rule, targets, depends, top, incdirs, libdirs, defines, flags ):
|
||||
self.flags = flags
|
||||
self.incdirs = incdirs
|
||||
self.libdirs = libdirs
|
||||
self.defines = defines
|
||||
self.log = None
|
||||
self.success = True
|
||||
targets = FlowTask._normFileList( targets )
|
||||
depends = FlowTask._normFileList( depends )
|
||||
if top is not None:
|
||||
self.top = top
|
||||
else:
|
||||
self.top = depends[0].stem
|
||||
if targets == []:
|
||||
targets.append( self.top + '.v' )
|
||||
#if self.flags & Sv2v.FlagLog:
|
||||
# self.log = Path( self.top + '.log' )
|
||||
# targets.append( self.log )
|
||||
super().__init__( rule, targets, depends )
|
||||
self.addClean( targets )
|
||||
|
||||
def __repr__ ( self ):
|
||||
return '<sv2v {} top={}>'.format( self.main, self.top )
|
||||
|
||||
@property
|
||||
def main ( self ):
|
||||
return self.file_depend( 0 )
|
||||
|
||||
def doTask ( self ):
|
||||
from ..helpers.io import ErrorMessage
|
||||
for incdir in self.incdirs:
|
||||
if not Path(incdir).is_dir():
|
||||
e = ErrorMessage( 1, [ 'Sv2v.doTask(): Include directory not found "{}"'
|
||||
, '"{}"'.format( incdir ) ] )
|
||||
return TaskFailed( e )
|
||||
command = [ 'sv2v' ]
|
||||
command += [ '--define={}'.format(d) for d in self.defines ]
|
||||
command += [ '--incdir={}'.format(i) for i in self.incdirs ]
|
||||
command += [ '--libdir={}'.format(l) for l in self.libdirs ]
|
||||
command += [ '--top={}'.format( self.top ) ]
|
||||
command += [ depend.as_posix() for depend in self.depends ]
|
||||
printCommand( command )
|
||||
with open( self.file_target(), 'w' ) as fdOut:
|
||||
status = subprocess.call( command, stdout=fdOut )
|
||||
return status == 0
|
||||
|
||||
def create_doit_tasks ( self ):
|
||||
return { 'basename' : self.basename
|
||||
, 'actions' : [ self.doTask ]
|
||||
, 'doc' : 'Run {}.'.format( self )
|
||||
, 'file_dep' : self.file_dep
|
||||
, 'targets' : self.targets
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
import os.path
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
from pyosys import libyosys as yosys
|
||||
from doit.exceptions import TaskFailed
|
||||
from .task import FlowTask
|
||||
|
||||
|
||||
def printCommand ( command ):
|
||||
commandBin = command[0]
|
||||
print( commandBin, command[1] )
|
||||
for arg in command[2:]:
|
||||
print( ' '*len(commandBin), arg )
|
||||
|
||||
|
||||
class Svase ( FlowTask ):
|
||||
|
||||
FlagLog = 0x00000001
|
||||
|
||||
@staticmethod
|
||||
def mkRule ( rule, targets, depends, top=None, incdirs=[], libdirs=[], defines=[], svargs=[], flags=0 ):
|
||||
return Svase( rule, targets, depends, top, incdirs, libdirs, defines, svargs, flags )
|
||||
|
||||
def __init__ ( self, rule, targets, depends, top, incdirs, libdirs, defines, svargs, flags ):
|
||||
self.flags = flags
|
||||
self.svargs = svargs
|
||||
self.incdirs = incdirs
|
||||
self.libdirs = libdirs
|
||||
self.defines = defines
|
||||
self.log = None
|
||||
self.success = True
|
||||
targets = FlowTask._normFileList( targets )
|
||||
depends = FlowTask._normFileList( depends )
|
||||
if top is not None:
|
||||
self.top = top
|
||||
else:
|
||||
self.top = depends[0].stem
|
||||
if targets == []:
|
||||
targets.append( self.top + '.v' )
|
||||
#if self.flags & Svase.FlagLog:
|
||||
# self.log = Path( self.top + '.log' )
|
||||
# targets.append( self.log )
|
||||
super().__init__( rule, targets, depends )
|
||||
self.addClean( targets )
|
||||
|
||||
def __repr__ ( self ):
|
||||
return '<svase top={} {} {}>'.format( self.top, self.file_target(0), self.main )
|
||||
|
||||
@property
|
||||
def main ( self ):
|
||||
return self.file_depend( 0 )
|
||||
|
||||
def doTask ( self ):
|
||||
from ..helpers.io import ErrorMessage
|
||||
for incdir in self.incdirs:
|
||||
if not Path(incdir).is_dir():
|
||||
e = ErrorMessage( 1, [ 'Svase.doTask(): Include directory not found.'
|
||||
, '"{}"'.format( incdir ) ] )
|
||||
return TaskFailed( e )
|
||||
with open( 'slang-args.txt', 'w' ) as fdSlangArgs:
|
||||
for svarg in self.svargs:
|
||||
fdSlangArgs.write( '{}\n'.format(svarg) )
|
||||
for define in self.defines:
|
||||
fdSlangArgs.write( '-D{}\n'.format(define) )
|
||||
for incdir in self.incdirs:
|
||||
fdSlangArgs.write( '--include-directory {}\n'.format(incdir) )
|
||||
for libdir in self.libdirs:
|
||||
fdSlangArgs.write( '--libdir {}\n'.format(libdir) )
|
||||
|
||||
command = [ 'svase' ]
|
||||
command += [ '--slang-argfile=slang-args.txt' ]
|
||||
command += [ self.top ]
|
||||
command += [ self.file_target(0) ]
|
||||
command += [ depend.as_posix() for depend in self.depends ]
|
||||
printCommand( command )
|
||||
status = subprocess.call( command )
|
||||
return status == 0
|
||||
|
||||
def create_doit_tasks ( self ):
|
||||
return { 'basename' : self.basename
|
||||
, 'actions' : [ self.doTask ]
|
||||
, 'doc' : 'Run {}.'.format( self )
|
||||
, 'file_dep' : self.file_dep
|
||||
, 'targets' : self.targets
|
||||
}
|
|
@ -65,7 +65,8 @@ class Yosys ( FlowTask ):
|
|||
e = ErrorMessage( 1, 'Yosys._loadDesign(): Can\'t find design file "{}".'.format( design ))
|
||||
self.success = TaskFailed( e )
|
||||
return
|
||||
if design.suffix == '.v' : self._run_pass( 'read_verilog {}'.format( design.as_posix() ))
|
||||
design = Path( design )
|
||||
if design.suffix == '.v' : self._run_pass( 'read_verilog -sv {}'.format( design.as_posix() ))
|
||||
elif design.suffix == '.il': self._run_pass( 'read_ilang {}'.format( design.as_posix() ))
|
||||
else:
|
||||
e = ErrorMessage( 1, 'Yosys._loadDesign(): Unsupported input format for "{}".'.format( design ))
|
||||
|
|
Loading…
Reference in New Issue