示例#1
0
def unsubst_mhs( mhs ):
    """
    Undo previous substitutions (delete nf10_axis_sim_* instances, and
    uncomment original cores)
    """
    del_comments = False
    for index in reversed(xrange(len(mhs))):
        ent = mhs[index]

        # All comments after sim cores (in the reversed list) get deleted until
        # next non-comment
        if del_comments and ent.is_comment():
            del mhs[index]
        else:
            del_comments = False

        # Delete sim cores and cores with substituted nets, and enable disabled cores
        if ent.is_begin():
            if ent.disabled_flag:
                mhstools.set_disabled_flag( ent, False )
                if ent.comment == mhstools.DISABLED_FLAG:
                    ent.comment = None
                    del mhs[index+1]
            if ent.core_name() in ['nf10_axis_sim_stim', 'nf10_axis_sim_record']:
                del mhs[index]
                del_comments = True
示例#2
0
    def do_overrides( index, ent ):
        """
        Perform reset and clock overrides on the specified entity, if required.
        The original instance is retained - but disabled - in the MHS file.  A
        special comment marker flags to UNDO to remove such overriden
        instances.
        """
        core_name = ent.core_name()
        core_inst = mhstools.get_parameter( ent, 'INSTANCE' )
        subst_required = False
        new_inst = ent.copy()
        for inst_ent in new_inst.inst_ents:
            if inst_ent.kw() != 'PORT':
                continue
            for args_index in range(len(inst_ent.args)):
                port, net = inst_ent.args[args_index]
                if net in opts.xlate:
                    inst_ent.args[args_index] = (port, opts.xlate[net])
                    subst_required = True
        if subst_required:
            print 'Performing overrides on pcore %s' % core_name
            print '                    (instance %s)' % core_inst
            mhstools.set_disabled_flag( ent, True )
            ent.comment = mhstools.DISABLED_FLAG
            mhs.insert( index+1, new_inst )
            print

        return True
示例#3
0
def unsubst_mhs( mhs ):
    """
    Undo previous substitutions (delete nf10_axis_sim_* instances, and
    uncomment original cores)
    """
    del_comments = False
    for index in reversed(xrange(len(mhs))):
        ent = mhs[index]

        # All comments after sim cores (in the reversed list) get deleted until
        # next non-comment
        if del_comments and ent.is_comment():
            del mhs[index]
        else:
            del_comments = False

        # Delete sim cores and cores with substituted nets, and enable disabled cores
        if ent.is_begin():
            if ent.disabled_flag:
                mhstools.set_disabled_flag( ent, False )
                if ent.comment == mhstools.DISABLED_FLAG:
                    ent.comment = None
                    del mhs[index+1]
            if ent.core_name() in ['nf10_axis_sim_stim', 'nf10_axis_sim_record']:
                del mhs[index]
                del_comments = True
示例#4
0
    def do_overrides( index, ent ):
        """
        Perform reset and clock overrides on the specified entity, if required.
        The original instance is retained - but disabled - in the MHS file.  A
        special comment marker flags to UNDO to remove such overriden
        instances.
        """
        core_name = ent.core_name()
        core_inst = mhstools.get_parameter( ent, 'INSTANCE' )
        subst_required = False
        new_inst = ent.copy()
        for inst_ent in new_inst.inst_ents:
            if inst_ent.kw() != 'PORT':
                continue
            for args_index in range(len(inst_ent.args)):
                port, net = inst_ent.args[args_index]
                if net in opts.xlate:
                    inst_ent.args[args_index] = (port, opts.xlate[net])
                    subst_required = True
        if subst_required:
            print 'Performing overrides on pcore %s' % core_name
            print '                    (instance %s)' % core_inst
            mhstools.set_disabled_flag( ent, True )
            ent.comment = mhstools.DISABLED_FLAG
            mhs.insert( index+1, new_inst )
            print

        return True
示例#5
0
    def do_subst( index, ent ):
        """
        Perform substitution with nf10_axis_sim_{record,stim}.
        """
	global result
	global result_1
	global result_2        
	core_name = ent.core_name()
        core_inst = mhstools.get_parameter( ent, 'INSTANCE' )
        m_width   = mhstools.get_parameter( ent, 'C_M_AXIS_DATA_WIDTH' )
        s_width   = mhstools.get_parameter( ent, 'C_S_AXIS_DATA_WIDTH' )
        mhstools.set_disabled_flag( ent, True )
        print 'Replacing pcore %s (instance %s):' % (core_name, core_inst)

        # Attempt to infer the correct clock and reset nets
        ports = mhstools.get_ents_by_kw( ent, 'PORT' )

        clock_net = get_override( opts.clocks, core_name, core_inst )
        if clock_net is None:
            clocks = filter( lambda x: clk_re.match(x[0]), ports )
            if len(clocks) == 0:
                print '\terror: failed to infer clock - no candidates found'
                return False
            if len(clocks) > 1:
                print '\terror: failed to infer clock - ambiguous possibilities:'
                print '\t\t%s' % '\n\t\t'.join( ['%s (net %s)' % x for x in clocks] )
                return False
            clock_net = clocks[0][1]
            if clock_net in opts.xlate:
                clock_net = opts.xlate[clock_net]
            print '\tinferred clock net: %s' % clock_net
        else:
            print '\tusing clock net override: %s' % clock_net

        reset_net = get_override( opts.resets, core_name, core_inst )
        if reset_net is None:
            resets = filter( lambda x: rst_re.match(x[0]), ports )
            if len(resets) == 0:
                print '\terror: failed to infer reset - no candidates found'
                return False
            if len(resets) > 1:
                print '\terror: failed to infer reset - ambiguous possibilities:'
                print '\t\t%s' % '\n\t\t'.join( ['%s (net %s)' % x for x in resets] )
                return False
            reset_net = resets[0][1]
            if reset_net in opts.xlate:
                reset_net = opts.xlate[reset_net]
            print '\tinferred reset net: %s' % reset_net
        else:
            print '\tusing reset net override: %s' % reset_net

        # Find any AXI Stream ports, and what they're attached to
        bus_args = mhstools.get_ents_by_kw( ent, 'BUS_INTERFACE' )
        s_axis_nets = [net for cls, net in filter( lambda av: s_axis_re.match( av[0] ), bus_args )]
        s_axis_nets.sort()
        m_axis_nets = [net for cls, net in filter( lambda av: m_axis_re.match( av[0] ), bus_args )]
        m_axis_nets.sort()

        # Insert stimulator and recorder cores for AXI Stream nets attached to this entity
        if not s_axis_nets and not m_axis_nets:
            print '\twarning: no AXI Stream nets found, even though core is a candidate\n'
            return True
        if s_axis_nets:
            print '\tnf10_axis_sim_record instance(s) on AXI Stream master net(s):'
            for netno, net in enumerate(s_axis_nets):
                # Attempt to infer correct width parameter
                try:
                    other = mhstools.get_other_inst( mhs, ent, net )
                except mhstools.TooManyError, e:
                    print 'error: more than one other instance attached to net %s.' % net
                    print '       instance name (core name) found:'
                    print '\t\t%s' % '\n\t\t'.join( ['%s (%s)' % (
                                                    mhstools.get_parameter( x, 'INSTANCE'),
                                                    x.core_name()) for x in e.ents] )
                    return False
                if not other:
                    print '\twarning: nothing else attached to net %s' % net
                    return True
                other_width = mhstools.get_parameter( other, 'C_M_AXIS_DATA_WIDTH' )
                if other_width is not None and s_width is not None and other_width != s_width:
                    print 'error: width of attached instance\'s port disagrees with this instance'
                    print '       net %s' % net
                    print '       this inst = %s, inst %s = %s' % (s_width,
                                                                   mhstools.get_parameter(other, 'INSTANCE'),
                                                                   other_width)
                    return False
                width = (s_width if other_width is None else other_width)

                # Perform substitution
                inst_name_log = 'record_%s' % net
		result = result + ' & ' + 'record_%s_activity_rec' % net
                axi_file  = os.path.join( opts.axi_path, '%s%s_log.axi' % (core_inst,
                                                  '_%d' % netno if len(m_axis_nets) != 1 else '' ) )
                insert_recorder( mhs, index+1,
                                 'Replacing core %s (instance %s)' % (core_name, core_inst),
                                 inst_name_log, RECORDER_VER, axi_file, width, net, clock_net )
                print '\t\t%s (%s)' % (net, axi_file)
示例#6
0
    def do_subst( index, ent ):
        """
        Perform substitution with nf10_axis_sim_{record,stim}.
        """
	global result
	global result_1
	global result_2        
	core_name = ent.core_name()
        core_inst = mhstools.get_parameter( ent, 'INSTANCE' )
        m_width   = mhstools.get_parameter( ent, 'C_M_AXIS_DATA_WIDTH' )
        s_width   = mhstools.get_parameter( ent, 'C_S_AXIS_DATA_WIDTH' )
        mhstools.set_disabled_flag( ent, True )
        print 'Replacing pcore %s (instance %s):' % (core_name, core_inst)

        # Attempt to infer the correct clock and reset nets
        ports = mhstools.get_ents_by_kw( ent, 'PORT' )

        clock_net = get_override( opts.clocks, core_name, core_inst )
        if clock_net is None:
            clocks = filter( lambda x: clk_re.match(x[0]), ports )
            if len(clocks) == 0:
                print '\terror: failed to infer clock - no candidates found'
                return False
            if len(clocks) > 1:
                print '\terror: failed to infer clock - ambiguous possibilities:'
                print '\t\t%s' % '\n\t\t'.join( ['%s (net %s)' % x for x in clocks] )
                return False
            clock_net = clocks[0][1]
            if clock_net in opts.xlate:
                clock_net = opts.xlate[clock_net]
            print '\tinferred clock net: %s' % clock_net
        else:
            print '\tusing clock net override: %s' % clock_net

        reset_net = get_override( opts.resets, core_name, core_inst )
        if reset_net is None:
            resets = filter( lambda x: rst_re.match(x[0]), ports )
            if len(resets) == 0:
                print '\terror: failed to infer reset - no candidates found'
                return False
            if len(resets) > 1:
                print '\terror: failed to infer reset - ambiguous possibilities:'
                print '\t\t%s' % '\n\t\t'.join( ['%s (net %s)' % x for x in resets] )
                return False
            reset_net = resets[0][1]
            if reset_net in opts.xlate:
                reset_net = opts.xlate[reset_net]
            print '\tinferred reset net: %s' % reset_net
        else:
            print '\tusing reset net override: %s' % reset_net

        # Find any AXI Stream ports, and what they're attached to
        bus_args = mhstools.get_ents_by_kw( ent, 'BUS_INTERFACE' )
        s_axis_nets = [net for cls, net in filter( lambda av: s_axis_re.match( av[0] ), bus_args )]
        s_axis_nets.sort()
        m_axis_nets = [net for cls, net in filter( lambda av: m_axis_re.match( av[0] ), bus_args )]
        m_axis_nets.sort()

        # Insert stimulator and recorder cores for AXI Stream nets attached to this entity
        if not s_axis_nets and not m_axis_nets:
            print '\twarning: no AXI Stream nets found, even though core is a candidate\n'
            return True
        if s_axis_nets:
            print '\tnf10_axis_sim_record instance(s) on AXI Stream master net(s):'
            for netno, net in enumerate(s_axis_nets):
                # Attempt to infer correct width parameter
                try:
                    other = mhstools.get_other_inst( mhs, ent, net )
                except mhstools.TooManyError, e:
                    print 'error: more than one other instance attached to net %s.' % net
                    print '       instance name (core name) found:'
                    print '\t\t%s' % '\n\t\t'.join( ['%s (%s)' % (
                                                    mhstools.get_parameter( x, 'INSTANCE'),
                                                    x.core_name()) for x in e.ents] )
                    return False
                if not other:
                    print '\twarning: nothing else attached to net %s' % net
                    return True
                other_width = mhstools.get_parameter( other, 'C_M_AXIS_DATA_WIDTH' )
                if other_width is not None and s_width is not None and other_width != s_width:
                    print 'error: width of attached instance\'s port disagrees with this instance'
                    print '       net %s' % net
                    print '       this inst = %s, inst %s = %s' % (s_width,
                                                                   mhstools.get_parameter(other, 'INSTANCE'),
                                                                   other_width)
                    return False
                width = (s_width if other_width is None else other_width)

                # Perform substitution
                inst_name_log = 'record_%s' % net
		result = result + ' & ' + 'record_%s_activity_rec' % net
                axi_file  = os.path.join( opts.axi_path, '%s%s_log.axi' % (core_inst,
                                                  '_%d' % netno if len(m_axis_nets) != 1 else '' ) )
                insert_recorder( mhs, index+1,
                                 'Replacing core %s (instance %s)' % (core_name, core_inst),
                                 inst_name_log, RECORDER_VER, axi_file, width, net, clock_net )
                print '\t\t%s (%s)' % (net, axi_file)