コード例 #1
0
    def addInterface(self, name=None, type="export", clockandreset=None):
        """Add new interface to component.
        
            name = interface name
            type = type of interface (WBM, WBC, WBS or export) 
            clockandreset = interface clock domain
        """
        
        # Check parameters
        if not name:
            raise ComponentError("*** Parameter error, no interface name specified.")
        name = name.lower()
        
        if not type:
            raise ComponentError("*** Parameter error, no interface type specified.")

        type = str(type).upper()

        if not WB_INTERFACES.has_key(type):
            raise ComponentError("*** Parameter error, unknown interface type '%s'." % type)

        if (type=="WBS" or type=="WBM"):
            if clockandreset==None:
                raise ComponentError("*** Parameter error, interface type '%s' need clockandreset interface." % type)
            clockandreset = clockandreset.lower()
            
        # Check if there is no interface with same name
        if self.interfaces.hasElement(name):
            raise ComponentError("*** Parameter error, interface name '%s' already defined." % name)
        
        self.interfaces.add(name=name, type=type, clockandreset=clockandreset)
コード例 #2
0
def split_signal(signal):
    """Extract signal informations. The signal name must match following naming
    convention:
            type_name_signal
    
    where:
        type = Wishbone interface type. Default = Global/Export (GLS).
        name = Interface name. Default = default.
        signal = Signal name.
    
    @param signal: signal name to analyze
    @return: tuple containing (wb_type, wb_name, signal)   
    """
    
    name = str(signal).upper().split('_')
    
    # Only one substring, testing if it is a Clock&Reset interface signal
    if len(name) == 1:
        if WB_SIGNALS.has_key(signal):
            wb_signal = WB_SIGNALS[signal]
            if WB_INTERFACES["WBC"][1].has_key(wb_signal):
                return ("WBC", "default", wb_signal)
        
        return ("GLS", "export", "export")
    
    wb_signal = None
    wb_interface = None
    wb_name = None

    # Extracting interface type
    if WB_INTERFACES.has_key(name[0]):
        wb_interface = name[0]

    if wb_interface:
        if len(name) == 2:
            if wb_interface == "GLS":
                return ("GLS", "export", "export")
            elif WB_SIGNALS.has_key(name[1]):
                wb_signal = WB_SIGNALS[name[1]]
                wb_name = wb_interface + "_noname"
        else:
            if WB_SIGNALS.has_key(name[2]):
                wb_signal = WB_SIGNALS[name[2]]
                wb_name = name[1]
            elif WB_SIGNALS.has_key(name[1]):
                wb_signal = WB_SIGNALS[name[1]]
                wb_name = wb_interface + "_noname"
    else:
        if WB_SIGNALS.has_key(name[0]):
            wb_signal = WB_SIGNALS[name[0]]
            if WB_INTERFACES["WBC"][1].has_key(wb_signal):
                return ("WBC", "default", wb_signal)
            
        return ("GLS", "export", "export")
    
    if_signals = WB_INTERFACES[wb_interface][1]
    if not wb_signal is None:
        if if_signals.has_key(wb_signal):
            return (wb_interface, wb_name, wb_signal)

        if WB_INTERFACES["WBC"][1].has_key(wb_signal):
            if wb_name.startswith(wb_interface):
                return ("WBC", "_".join([wb_name, "clockandreset"]), wb_signal)
            return ("WBC", "_".join([wb_interface, wb_name, "clockandreset"]), wb_signal)
        
        wb_name = None

    return (wb_interface, wb_name, None)