Example #1
0
def save_graphs(fname, path):
    '''输入一个文件名,生成带PIPO和不带PIPO的图,
       然后将生成的图分别保存到tmp\\下的.dot文件和.gexf文件
    '''
    info = vm_parse(fname)
    netlist = Netlist(info)

    #生成保存图的路径
    if not os.path.exists(path):
        os.makedirs(path)
    #生成带pipo的图
    g1 = CircuitGraph(netlist, include_pipo=True)
    g1.to_gexf_file(path + '\\%s_icpipo.gexf' % g1.name)
    g1.to_dot_file(path + "\\%s_icpipo.dot" % g1.name)

    #生成不带pipo的图
    g2 = CircuitGraph(netlist, include_pipo=False)
    g2.to_gexf_file(path + "\\%s_nopipo.gexf" % g2.name)
    g2.to_dot_file(path + "\\%s_nopipo.dot" % g2.name)
    if len(netlist.m_list) <= 20:
        print "\n".join([str(eachPrim) for eachPrim in netlist.m_list])
        verbose_info = True
    else:
        verbose_info = False
        print "Info: The m_list is too long >20. ignore..."
    g2.info(verbose_info)
    g1.info(verbose_info)
    return None
Example #2
0
def save_graphs(fname, path):
    '''输入一个文件名,生成带PIPO和不带PIPO的图,
       然后将生成的图分别保存到tmp\\下的.dot文件和.gexf文件
    '''
    info = vm_parse(fname)
    netlist = Netlist( info)
    
    #生成保存图的路径
    if not os.path.exists( path):
        os.makedirs( path )
    #生成带pipo的图
    g1 = CircuitGraph(netlist, include_pipo = True)
    g1.to_gexf_file(path + '\\%s_icpipo.gexf' % g1.name)
    g1.to_dot_file( path + "\\%s_icpipo.dot" % g1.name)
    
    #生成不带pipo的图
    g2 = CircuitGraph(netlist, include_pipo = False)
    g2.to_gexf_file( path + "\\%s_nopipo.gexf" % g2.name)
    g2.to_dot_file( path +  "\\%s_nopipo.dot" % g2.name)
    if len(netlist.m_list) <= 20:
        print "\n".join( [str(eachPrim) for eachPrim in netlist.m_list] )
        verbose_info =True
    else:
        verbose_info = False
        print "Info: The m_list is too long >20. ignore..."
    g2.info(verbose_info)
    g1.info(verbose_info)
    return None
Example #3
0
def get_graph(fname=None):
    '''@param: fname, a vm file name
       @return: g1, a nx.DiGraph obj
       @brief: 从文件名获得一个图
    '''
    if not fname: fname = raw_input("plz enter file name:")
    info = vm_parse(fname)
    netlist = Netlist(info)
    #nr.check(netlist, check_reset = False)
    g1 = CircuitGraph(netlist)
    return g1
Example #4
0
def get_graph(fname = None):
    '''@param: fname, a vm file name
       @return: g1, a nx.DiGraph obj
       @brief: 从文件名获得一个图
    '''
    if not fname: fname = raw_input("plz enter file name:")
    info = vm_parse( fname)
    netlist    = Netlist(info)
    #nr.check(netlist, check_reset = False)
    g1 = CircuitGraph(netlist)
    return g1
Example #5
0
 def test_Noclk(self):
     vminfo = vm_parse(self.path + "\\b01noclk.v")
     mark_the_circut(vminfo['m_list'])
     nt = Netlist(vminfo)
     check(nt)
Example #6
0
 def test_2CLk(self):
     vminfo = vm_parse(self.path + "\\b011.v")
     mark_the_circut(vminfo['m_list'])
     nt = Netlist(vminfo)
     self.assertRaises(CircuitGraphError, check(nt))
Example #7
0
    def write(self, path):
        if not os.path.exists( path ):
            os.makedirs( path )
        filename = os.path.join(path, self.top_module.name)+".v"
        try:
            fobj = open(filename,'w')
        except Exception,e:
            print e
            return False
        else:
            console = sys.stdout
            sys.stdout = fobj
            print self.top_module
            for port in self.ports:
                port.__print__(pipo_decl = True)
            for wire in self.wires:
                wire.__print__(is_wire_decl = True)
            for prim in self.primitives:
                print prim
            for assign in self.assigns:
                print assign
            print "endmodule"
            sys.stdout = console
            fobj.close()

if __name__ == "__main__":

    fname = raw_input("plz enter file name>")
    info = vm_parse( fname)
    netlist    = Netlist(info)
    print "Cellref in netlist: ", netlist.cellrefs
Example #8
0
 def test_Noclk(self):
     vminfo = vm_parse(self.path + "\\b01noclk.v")
     mark_the_circut( vminfo['m_list'])
     nt = Netlist(vminfo )
     check(nt)
Example #9
0
 def test_2CLk(self):
     vminfo = vm_parse(self.path + "\\b011.v")
     mark_the_circut( vminfo['m_list'])
     nt = Netlist(vminfo )
     self.assertRaises(CircuitGraphError, check(nt) )
Example #10
0
        if not os.path.exists(path):
            os.makedirs(path)
        filename = os.path.join(path, self.top_module.name) + ".v"
        try:
            fobj = open(filename, 'w')
        except Exception, e:
            print e
            return False
        else:
            console = sys.stdout
            sys.stdout = fobj
            print self.top_module
            for port in self.ports:
                port.__print__(pipo_decl=True)
            for wire in self.wires:
                wire.__print__(is_wire_decl=True)
            for prim in self.primitives:
                print prim
            for assign in self.assigns:
                print assign
            print "endmodule"
            sys.stdout = console
            fobj.close()


if __name__ == "__main__":

    fname = raw_input("plz enter file name>")
    info = vm_parse(fname)
    netlist = Netlist(info)
    print "Cellref in netlist: ", netlist.cellrefs