コード例 #1
0
ファイル: syntax.py プロジェクト: chanwooc/connectal
def generate_bsvcpp(filelist, project_dir, bsvdefines, interfaces, bsvpath):
    for inputfile in filelist:
        syntax_parse(open(inputfile).read(), inputfile, bsvdefines, bsvpath)
    ## code generation pass
    ilist = []
    for i in interfaces:
        ifc = globalv.globalvars.get(i)
        if not ifc:
            print('Connectal: Unable to locate the interface:', i)
            for keys in globalv.globalvars:
                print('    ', keys)
            sys.exit(1)
        ifc = ifc.instantiate(dict(zip(ifc.params, ifc.params)))
        ilist.append(ifc)
        for ditem in ifc.decls:
            for pitem in ditem.params:
                thisType = pitem.type
                p = globalv.globalvars.get(thisType.name)
                if p and thisType.params and p.params:
                    myName = '%sL_%s_P' % (thisType.name, '_'.join(
                        [t.name for t in thisType.params if t]))
                    pitem.oldtype = pitem.type
                    pitem.type = AST.Type(myName, [])
                    if not globalv.globalvars.get(myName):
                        globalv.add_new(
                            AST.TypeDef(
                                p.tdtype.instantiate(
                                    dict(zip(p.params, thisType.params))),
                                myName, []))
    jsondata = AST.serialize_json(ilist, globalimports, bsvdefines)
    if project_dir:
        cppgen.generate_cpp(project_dir, noisyFlag, jsondata)
        bsvgen.generate_bsv(project_dir, noisyFlag, False, jsondata)
コード例 #2
0
ファイル: syntax.py プロジェクト: chamdoo/xbsv
def generate_bsvcpp(filelist, project_dir, dutname, bsvdefines, s2hinterface, h2sinterface, nf):
    global noisyFlag
    noisyFlag=nf
    for inputfile in filelist:
        syntax_parse(open(inputfile).read(),inputfile, bsvdefines)
    ## code generation pass
    swProxies = []
    hwProxies = []
    swWrappers = []
    hwWrappers = []
    for i in set(s2hinterface + h2sinterface):
        ifc = globalv.globalvars[i]
        ifc = ifc.instantiate(dict(zip(ifc.params, ifc.params)))
        ifc.ind = AST.Interface(i, [], [], None, ifc.package)
        ifc.ind.insertPutFailedMethod()
        ifc.ind.req = ifc
        ifc.assignRequestResponseChannels()
        ifc.ind.assignRequestResponseChannels()
        if i in s2hinterface:
            swProxies.append(ifc)
            hwWrappers.append(ifc)
        if i in h2sinterface:
            hwProxies.append(ifc)
            swWrappers.append(ifc)
    cppgen.generate_cpp(globalv.globaldecls, project_dir, noisyFlag, swProxies, swWrappers)
    bsvgen.generate_bsv(globalimports, project_dir, noisyFlag, hwProxies, hwWrappers, dutname)
コード例 #3
0
ファイル: syntax.py プロジェクト: 8l/connectal
def generate_bsvcpp(filelist, project_dir, bsvdefines, interfaces):
    for inputfile in filelist:
        syntax_parse(open(inputfile).read(),inputfile, bsvdefines)
    ## code generation pass
    ilist = []
    for i in interfaces:
        ifc = globalv.globalvars.get(i)
        if not ifc:
            print 'Connectal: Unable to locate the interface:', i
            for keys in globalv.globalvars:
                print '    ', keys
            sys.exit(1)
        ifc = ifc.instantiate(dict(zip(ifc.params, ifc.params)))
        ilist.append(ifc)
        for ditem in ifc.decls:
            for pitem in ditem.params:
                thisType = pitem.type
                p = globalv.globalvars.get(thisType.name)
                if p and thisType.params and p.params:
                    myName = '%sL_%s_P' % (thisType.name, '_'.join([t.name for t in thisType.params if t]))
                    pitem.oldtype = pitem.type
                    pitem.type = AST.Type(myName, [])
                    if not globalv.globalvars.get(myName):
                        globalv.add_new(AST.TypeDef(p.tdtype.instantiate(dict(zip(p.params, thisType.params))), myName, []))
    jsondata = AST.serialize_json(ilist, globalimports, bsvdefines)
    if project_dir:
        cppgen.generate_cpp(project_dir, noisyFlag, jsondata)
        bsvgen.generate_bsv(project_dir, noisyFlag, False, jsondata)
コード例 #4
0
ファイル: syntax.py プロジェクト: m-liu/bluedbm_test
def generate_bsvcpp(filelist, project_dir, dutname, bsvdefines, interfaces, nf):
    global noisyFlag
    noisyFlag=nf
    for inputfile in filelist:
        syntax_parse(open(inputfile).read(),inputfile, bsvdefines)
    ## code generation pass
    ilist = []
    for i in interfaces:
        ifc = globalv.globalvars[i]
        ifc = ifc.instantiate(dict(zip(ifc.params, ifc.params)))
        ifc.ind = AST.Interface(i, [], [], None, ifc.package)
        ifc.ind.req = ifc
        ilist.append(ifc)
    jsondata = AST.serialize_json(ilist, globalimports, dutname)
    cppgen.generate_cpp(project_dir, noisyFlag, jsondata)
    bsvgen.generate_bsv(project_dir, noisyFlag, jsondata)
コード例 #5
0
ファイル: syntax.py プロジェクト: chanwooc/connectal
                           debugfile=parserdir + '/parser.out')
        import parsetab
        sys.exit(0)
    ifitems = []
    t = os.environ.get('INTERFACES')
    if t:
        t = t.split()
        for item in t:
            if item not in ifitems:
                ifitems.append(item)
    deflist = []
    t = os.environ.get('BSVDEFINES_LIST')
    if t:
        deflist = t.split()
    noisyFlag = os.environ.get('D') == '1'
    if os.environ.get('D'):
        parseDebugFlag = True
    if noisyFlag:
        parseTrace = True
    project_dir = os.environ.get('DTOP')
    tmp = os.environ.get('PROTODEBUG')
    if tmp:
        print('JSONNN', tmp)
        j2file = open(tmp).read()
        jsondata = json.loads(j2file)
        cppgen.generate_cpp(project_dir, noisyFlag, jsondata)
        bsvgen.generate_bsv(project_dir, noisyFlag, True, jsondata)
    else:
        bsvpath = os.environ.get('BSVPATH', []).split(':')
        generate_bsvcpp(sys.argv[1:], project_dir, deflist, ifitems, bsvpath)
コード例 #6
0
def simgen():
    cppgen.generate_cpp('generatedcpp', False, generated_table_sim)
コード例 #7
0
ファイル: syntax.py プロジェクト: 8l/connectal
        parser = yacc.yacc(outputdir=parserdir,debugfile=parserdir+'/parser.out')
        import parsetab
        sys.exit(0)
    ifitems = []
    t = os.environ.get('INTERFACES')
    if t:
        t = t.split()
        for item in t:
            if item not in ifitems:
                ifitems.append(item)
    deflist = []
    t = os.environ.get('BSVDEFINES_LIST')
    if t:
        deflist = t.split()
    noisyFlag = os.environ.get('V') == '1'
    if os.environ.get('D'):
        parseDebugFlag=True
    if noisyFlag:
        parseTrace=True
    project_dir =  os.environ.get('DTOP')
    tmp = os.environ.get('PROTODEBUG')
    if tmp:
        print 'JSONNN', tmp
        j2file = open(tmp).read()
        jsondata = json.loads(j2file)
        cppgen.generate_cpp(project_dir, noisyFlag, jsondata)
        bsvgen.generate_bsv(project_dir, noisyFlag, True, jsondata)
    else:
        generate_bsvcpp(sys.argv[1:], project_dir, deflist, ifitems)

コード例 #8
0
## SOFTWARE.
import os, sys, json
sys.path.insert(
    0,
    os.path.dirname(os.path.abspath(__file__)) + '/../../connectal/scripts')
import cppgen

if __name__ == '__main__':
    print 'new', sys.argv
    filename = "generatedDesignInterfaceFile.json"
    if (len(sys.argv) > 1):
        filename = sys.argv[1]
    jsondata = json.loads(open(filename).read())
    # for examples/gray
    jsondata['globaldecls'].append({
        "dtype": "TypeDef",
        "tdtype": {
            "type": "Type",
            "name": "10",
            "params": [{
                "name": "32"
            }]
        },
        "tname": "width"
    })
    cppgen.generateJson = False
    #cppgen.generatePacketOnly = True
    cppgen.synchronousInvoke = True
    cppgen.generate_cpp(".", False, jsondata)
    open('jni/driver_signature_file.h', 'w')
コード例 #9
0
## ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
## CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
import os, sys, json
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)) + '/../../connectal/scripts')
import cppgen

connectalProjectString = '''
#ifndef _ConnectalProjectConfig_h
#define _ConnectalProjectConfig_h

#define MainClockPeriod 20
#define SIMULATION ""
#define BOARD_verilator ""

#endif // _ConnectalProjectConfig_h
'''

if __name__=='__main__':
    print 'new', sys.argv
    filename = "generatedDesignInterfaceFile.json"
    if (len(sys.argv) > 1):
        filename = sys.argv[1];
    jsondata = json.loads(open(filename).read())
    cppgen.generateJson = False
    cppgen.generatePacketOnly = True
    cppgen.suppressGeneratedMakefile = True
    cppgen.generate_cpp(".", False, jsondata)
    #open('jni/ConnectalProjectConfig.h', 'w').write(connectalProjectString)
    open('jni/driver_signature_file.h', 'w')