Example #1
0
 def SetMainComponent(self, instance):
     Dev.Debug(Dev.Info, "Project.SetMainComponent(self,typename)")
     iterations = 0
     self.MainComponentInstance = instance
     TmpComponents = {}
     # New Auto-Configuration Method
     self.MainComponentInstance.AddBindings(self)
     TmpComponents = self.UnconfiguredComponents
     while len(TmpComponents) != 0:
         print "Iteration " + str(iterations) + ": " + str(
             len(TmpComponents)) + " Changed Components"
         self.ChangedComponents.clear()
         # - Add all components to the change list
         for c in TmpComponents:
             c.ConfigureComponent(self)
         if (iterations == 0):
             Dev.DisableWarnings()
         TmpComponents = self.ChangedComponents.values()
         iterations += 1
         if iterations > 50:
             Dev.Debug(
                 Dev.Stop,
                 "Project needs more than 50 iterations to solve please check that there are no bugs."
             )
     Dev.EnableWarnings()
     self.MainComponentInstance.AddBindings(self)
     self.MainComponentInstance.ParameterizationCheck(self)
Example #2
0
 def __delattr__(self, attr):
     Dev.Debug(Dev.Info, "Component.__delattr__(self,attr)")
     if not (self.GetConnector(attr) is None):
         # This has to be cleaned up to allow connectors a chance to cleanup logic!
         self.Connectors.remove(self.GetConnector(attr))
         return
     Dev.Debug(Dev.Stop, "Component.__delattr__: UH OH CANT DELETE!")
Example #3
0
 def __getattr__(self, attr):
     Dev.Debug(Dev.Info, "Connector.__getattr__(self,attr)")
     if self.__dict__.has_key(attr):
         return self.__dict__[attr]
     else:
         Dev.Debug(Dev.Stop, "Unknown attribute: " + attr)
         return None
Example #4
0
 def GetInstance(self):
     Dev.Debug(Dev.Info, "Component.GetInstance(self)")
     if (self.Instance is None):
         Dev.Debug(Dev.Error,
                   "Error: Unconfigured component " + self.InstanceName)
     else:
         return self.Instance
Example #5
0
 def GenerateHDL(self, hdlwriter):
     Dev.Debug(Dev.Info, "Project.GenerateHDL(self,hdlwriter)")
     for k, v in self.UnconfiguredComponents.iteritems():
         tmp = v.GetInstance()
         self.Components[tmp.Name] = tmp
     Dev.Debug(Dev.Info, "Project.GenerateHDL(self)")
     if self.MultipleFiles == 0:
         hdlwriter.Write("// " + self.Name + " Project\n\n")
     # Generate components
     for k, v in self.Components.iteritems():
         if not (v is self.MainComponentInstance):
             if self.MultipleFiles == 1:
                 hdlwriter.Open(k + ".v")  # language dep
                 if self.Name != "":
                     hdlwriter.Write("// Subcomponent Component: " +
                                     self.Name + " Project\n\n")
                 hdlwriter.WriteModule(v)
                 if self.MultipleFiles == 1:
                     hdlwriter.Close()
     # Generate top component
     if self.MultipleFiles == 1:
         hdlwriter.Open(self.MainComponentInstance.Name +
                        ".v")  # language dep
         if self.Name != "":
             hdlwriter.Write("// Main Component: " + self.Name +
                             " Project\n\n")
     hdlwriter.WriteModule(self.MainComponentInstance)
     if self.MultipleFiles == 1:
         hdlwriter.Close()
Example #6
0
 def WriteIOPortBindingName(self, relparent=None):
     Dev.Debug(Dev.Info, "Connector.WriteIOPortBindingName(self,hdlwriter)")
     if (relparent is None) or (relparent is self.Comp):
         return self.Name
     elif (relparent is self.Comp.Parent):
         if (self.Conn is None) or (self.Conn.LocalConnector is None):
             print self.Name
             Dev.Debug(
                 Dev.Stop,
                 "PANIC: Trying to write a binding for an unconnected connector!"
             )
         return self.Conn.LocalConnector.Name
Example #7
0
 def GenerateName(self, prj=None):
     Dev.Debug(Dev.Info, "HDLComponent.GenerateName(self)")
     if (self.Parent is None):
         # We are an unnamed main component just set the name to maincomponent
         self.Name = "maincomponent"
     elif not (prj is None):
         # Get a global name unique from the project
         if self.Name is None:
             self.Name = prj.GenerateComponentTypeName()
     else:
         Dev.Debug(Dev.Stop,
                   "Error GenerateName must be implemented or something.")
     return self.Name
Example #8
0
 def ConfigureConnector(self, prj):
     Dev.Debug(Dev.Info, "Connector.ConfigureConnector(self,prj)")
     if not (self.Conn is None):
         for k, v in self.Conn.Connectors.iteritems():  # Check type?
             self.ConfigureEachOther(prj, v)
     elif (self.IOType != HDLIOType.Wire) and (self.IsUsed == 0):
         Dev.Debug(
             Dev.Warning, "Warning: Connector " + self.Name +
             " is not connected to anything.")
     # Check locally connected components
     if not (self.LocalConn is None):
         for k, v in self.LocalConn.Connectors.iteritems():  # Check type?
             self.ConfigureEachOther(prj, v)
Example #9
0
 def __setattr__(self, attr, val):
     Dev.Debug(Dev.Info, "Component.__setattr__(self,attr,val)")
     # Attempts to set anonymous turn into an auto-generated name!
     if attr == "Anonymous":
         if isinstance(val, Component):
             val.Instance = None
             val.MetaInstance = val
             val.InstanceName = self.GenerateComponentName()
             val.Parent = self.GetMetaInstance()
             self.AddSubcomponent(val)
         elif isinstance(val, Connector.Connector):
             val.Name = self.GenerateNetName()
             val.Comp = self.GetMetaInstance()
             val.SetAnonymous()
             val.LateInit()
             self.AddConnector(val)
         else:
             Dev.Debug(Dev.Stop,
                       "Error self.Anonymous is a reserved variable name!")
         return
     if isinstance(val, Component) and (attr != "Instance") and (
             attr != "MetaInstance") and (attr != "Parent"):
         #val.Init(instancename = attr)
         val.Instance = None
         val.MetaInstance = val
         val.InstanceName = attr
         val.Parent = self.GetMetaInstance()
         self.AddSubcomponent(val)
         return
     if isinstance(val, Connector.Connector):
         # If the connector exists then we run Connect!
         # If you want to overwrite a connector you must delete it first
         # so as to unbind it properly from the current Connector!
         if not (self.GetConnector(attr) is None):
             # Maybe I should check for autogen names but I think were ok!
             # At least throw an error
             # TODO: Make sure this throughs an error when its not possible(currently)
             Connect(self.GetConnector(attr), val)
         else:
             val.Name = attr
             val.Comp = self.GetMetaInstance()
             val.LateInit()
             self.AddConnector(val)
         return
     # Default case for non-special components/connectors
     # Modify all special variables to by tied between shell/instance
     if not (self.MetaInstance is self) and (attr != "Instance") and (
             attr != "MetaInstance"):
         self.MetaInstance.__setattr__(attr, val)
     else:
         self.__dict__[attr] = val
Example #10
0
 def ReconnectTo(self, targetconnector):
     if (self.IsAnonymous() == 0):
         Dev.Debug(Dev.Stop,
                   "Connection: Ack! I'm not an anonymous connection!")
     for k, v in self.Connectors.iteritems():
         v.Conn = targetconnector
         targetconnector.Connectors[k] = v
Example #11
0
 def __init__(self):
     Dev.Debug(Dev.Info, "Connector.__init__(self)")
     self.Name = ""
     self.Conn = None
     self.LocalConn = None
     self.Comp = None
     self.IsUsed = 0
     self.Anonymous = 0
Example #12
0
    def AddBindings(self, project):
        """Adds Bindings to a project
		test
		"""
        Dev.Debug(Dev.Info, "Component.AddBindings(self,project)")
        project.AddComponent(self)
        for k, v in self.Components.iteritems():
            v.AddBindings(project)
Example #13
0
    def __init__(this, ip):
        this.dev = Dev()
        this.ip = this.dev.connect(ip)

        # initial the dictionary  begin
        this.dics["exit"] = exit
        this.dics["pm"] = this.__isPmThread
        this.dics["ota"] = this.__isOTAService
        this.dics["launcher"] = this.__isLauncher
Example #14
0
 def __getattr__(self, attr):
     Dev.Debug(Dev.Info, "Component.__getattr__(self,attr)")
     # Avoid Infinite Recursion on Initialization
     if (attr == "MetaInstance"):
         return None
     # Modify all special variables to by tied between meta/instance
     if not (self.MetaInstance is self) and not (self.MetaInstance is None):
         return self.MetaInstance.__getattr__(attr)
     elif self.MetaInstance is self:
         if self.__dict__.has_key(attr):
             return self.__dict__[attr]
     if not (self.GetSubcomponent(attr) is None):
         return self.GetSubcomponent(attr)
     if not (self.GetConnector(attr) is None):
         return self.GetConnector(attr)
     print "Trying to get " + attr + " in component " + self.InstanceName
     Dev.Debug(Dev.Stop,
               "Component.__getattr__(self,attr) does not exist!!!")
Example #15
0
 def AddChangedConnector(self, conn):
     Dev.Debug(Dev.Info, "Project.AddChangedConnector(self,conn)")
     self.AddChangedComponent(conn.Comp)
     if not (conn.Conn is None):
         for k, v in conn.Conn.Connectors.iteritems():
             self.AddChangedComponent(v.Comp)
     if not (conn.LocalConn is None):
         for k, v in conn.LocalConn.Connectors.iteritems():
             self.AddChangedComponent(v.Comp)
Example #16
0
 def ConfigureComponent(self, prj):
     Dev.Debug(Dev.Info, "Component.ConfigureComponent(self)")
     self.Instance = self
     for e in self.Connectors:
         e.ConfigureConnector(prj)
     for k, v in self.Components.iteritems():
         v.ConfigureComponent(prj)
     if self.Name is None:
         self.GenerateName(prj)
Example #17
0
 def __init__(self, cirname=""):
     Dev.Debug(Dev.Info, "Project.__init__(self)")
     self.Name = cirname
     self.UnconfiguredComponents = {}
     self.Components = {}
     self.MainComponentInstance = None
     self.MainComponentName = ""
     self.MultipleFiles = 0
     self.Parameters = {}
     self.ChangedComponents = {}
     self.CompNameNumber = 0
Example #18
0
 def writenetcommon(self, Name, StartIndex, EndIndex):
     Dev.Debug(
         Dev.Info,
         "VerilogWriter.writenetcommon(self,Name,StartIndex,EndIndex)")
     self.outfile.write("\t")
     if (StartIndex != EndIndex):
         self.outfile.write("[" + str(StartIndex) + ":" + str(EndIndex) +
                            "]")
     else:
         self.outfile.write("\t")
     self.outfile.write("\t" + Name + ";\n")
Example #19
0
 def WriteNet(self, Name, IOType, Type, Start, End):
     Dev.Debug(Dev.Info,
               "VerilogWriter.WriteNet(self,Name,IOType,Type,Start,End)")
     if IOType == HDLIOType.Input:
         self.outfile.write("input")
         self.writenetcommon(Name, Start, End)
     elif IOType == HDLIOType.Output:
         self.outfile.write("output")
         self.writenetcommon(Name, Start, End)
     elif IOType == HDLIOType.InOut:
         self.outfile.write("inout")
         self.writenetcommon(Name, Start, End)
     elif IOType == HDLIOType.Wire:
         Dev.Debug(
             Dev.Info,
             "VerilogWriter.WriteNet(self,Name,IOType,Type,Start,End) - Skipping I/O Definition (Wire)"
         )
     else:
         Dev.Debug(Dev.Stop, "Error: Unknown HDLIOType")
     if Type == HDLNetType.Wire:
         self.outfile.write("wire")
     elif Type == HDLNetType.Reg:
         self.outfile.write("reg\t")
     elif Type == HDLNetType.Tri:
         self.outfile.write("tri")
     elif Type == HDLNetType.Wand:
         self.outfile.write("wand")
     elif Type == HDLNetType.Wor:
         self.outfile.write("wor")
     elif Type == HDLNetType.Triand:
         self.outfile.write("triand")
     elif Type == HDLNetType.Trior:
         self.outfile.write("trior")
     elif Type == HDLNetType.Trireg:
         self.outfile.write("trireg")
     else:
         Dev.Debug(Dev.Stop, "Error: Unknown HDLNetType")
     self.writenetcommon(Name, Start, End)
Example #20
0
 def GenerateVerilogHDLHeader(self, hdlwriter):
     Dev.Debug(Dev.Info,
               "Component.GenerateVerilogHDLHeader(self,hdlwriter)")
     if self.Name is None:
         Dev.Debug(
             Dev.Stop,
             "PANIC: self.Name is not set in instance " + self.InstanceName)
     hdlwriter.Write("module " + self.Name + "(")
     i = 0
     for e in self.Connectors:
         if e.IOType != HDLIOType.Wire:
             i = i + 1
     for e in self.Connectors:
         if e.IOType != HDLIOType.Wire:
             e.WriteIOPortNames(hdlwriter)
             i = i - 1
             if i != 0:
                 hdlwriter.Write(",")
     hdlwriter.Write(");\n")
     for e in self.Connectors:
         e.WriteIOPorts(hdlwriter)
     hdlwriter.Write("\n")
     for e in self.Connectors:
         e.WriteIOPortLogic(hdlwriter)
     for k, v in self.Components.iteritems():
         hdlwriter.Write("\n" + v.Name + " " + v.InstanceName + "(\n")
         i = 0
         for c in v.Connectors:
             if c.IOType != HDLIOType.Wire:
                 i = i + 1
         for c in v.Connectors:
             if c.IOType != HDLIOType.Wire:
                 i = i - 1
                 c.WriteIOPortBindings(hdlwriter)
                 if i != 0:
                     hdlwriter.Write(",\n")
         hdlwriter.Write("\n);\n")
Example #21
0
 def GetSubcomponent(self, compname):
     Dev.Debug(Dev.Info, "Component.AddSubcomponent(self,compname)")
     splitcomponentname = re.split("[\.]", compname, 1)
     if self.Components.has_key(splitcomponentname[0]):
         if len(splitcomponentname) == 1:
             retvalue = self.Components[splitcomponentname[0]]
             if not (retvalue.Instance is None) and (retvalue.Instance !=
                                                     retvalue):
                 return retvalue.Instance
             else:
                 return retvalue
         else:
             return self.Components[splitcomponentname[0]].GetSubcomponent(
                 splitcomponentname[1])
     else:
         return None
Example #22
0
 def ChooseCommonParent(self, b):
     if isinstance(b, int):
         # I dont actually have to create a component
         # Connect does that automatically for me!
         return a.Comp
     if (self.Comp is b.Comp) and not (b.Comp is None):
         return self.Comp
     elif (self.Comp.Parent is b.Comp) and not (b.Comp is None):
         return b.Comp
     elif (b.Comp.Parent is self.Comp) and not (self.Comp is None):
         return self.Comp
     elif (self.Comp.Parent is
           b.Comp.Parent) and not (self.Comp.Parent is None):
         return self.Comp.Parent
     else:
         Dev.Debug(Dev.Stop, "No common parent between wires!")
Example #23
0
 def SetParameter(self, param, value):
     Dev.Debug(Dev.Info, "Project.SetParameter(self,param,value)")
     self.Parameters[param] = value
Example #24
0
 def RemoveComponent(self, comp):
     Dev.Debug(Dev.Info, "Project.RemoveComponent(self,typename,comp)")
Example #25
0
 def AddComponent(self, comp):
     Dev.Debug(Dev.Info, "Project.AddComponent(self,typename,comp)")
     self.UnconfiguredComponents[comp] = comp
Example #26
0
 def SetMultifileGeneration(self, tf):
     Dev.Debug(Dev.Info, "Project.SetMultifileGeneration(self,tf)")
     self.MultipleFiles = tf
Example #27
0
 def GenerateComponentTypeName(self):
     Dev.Debug(Dev.Info, "Project.GenerateComponentTypeName(self)")
     tmpstr = "CompType" + str(self.CompNameNumber)
     self.CompNameNumber += 1
     return tmpstr
Example #28
0
 def AddChangedComponent(self, comp):
     Dev.Debug(Dev.Info, "Project.AddChangedComponent(self,comp)")
     self.ChangedComponents[id(comp)] = comp
Example #29
0
 def __init__(self, str=""):
     Dev.Debug(Dev.Info, "VerilogWriter.__init__(self,str)")
     if str != "":
         self.Open(str)
Example #30
0
 def GetParameter(self, param):
     Dev.Debug(Dev.Info, "Project.GetParameter(self,param)")
     return self.Parameters[param]