void PNS_DIFF_PAIR_PLACER::initPlacement()
{
    m_idle = false;
    m_orthoMode = false;
    m_currentEndItem = NULL;
    m_startDiagonal = m_initialDiagonal;

    PNS_NODE* world = Router()->GetWorld();

    world->KillChildren();
    PNS_NODE* rootNode = world->Branch();

    setWorld( rootNode );

    m_lastNode = NULL;
    m_currentNode = rootNode;
    m_currentMode = Settings().Mode();

    if( m_shove )
        delete m_shove;

    m_shove = NULL;

    if( m_currentMode == RM_Shove || m_currentMode == RM_Smart )
    {
        m_shove = new PNS_SHOVE( m_currentNode, Router() );
    }
}
bool PNS_DIFF_PAIR_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
    VECTOR2I p( aP );

    if( !aStartItem )
    {
        Router()->SetFailureReason( _( "Can't start a differential pair "
                                       " in the middle of nowhere." ) );
        return false;
    }

    setWorld( Router()->GetWorld() );
    m_currentNode = m_world;

    if( !findDpPrimitivePair( aP, aStartItem, m_start ) )
    {
        Router()->SetFailureReason( _( "Unable to find complementary differential pair "
                                       "net. Make sure the names of the nets belonging "
                                       "to a differential pair end with either _N/_P or +/-." ) );
        return false;
    }

    m_netP = m_start.PrimP()->Net();
    m_netN = m_start.PrimN()->Net();

    #if 0
	// FIXME: this also needs to be factored out but not so important right now
    // Check if the current track/via gap & track width settings are violated
    BOARD* brd = NULL; // FIXME Router()->GetBoard();
    NETCLASSPTR netclassP = brd->FindNet( m_netP )->GetNetClass();
    NETCLASSPTR netclassN = brd->FindNet( m_netN )->GetNetClass();
    int clearance = std::min( m_sizes.DiffPairGap(), m_sizes.DiffPairViaGap() );

    if( clearance < netclassP->GetClearance() || clearance < netclassN->GetClearance() )
    {
        Router()->SetFailureReason( _( "Current track/via gap setting violates "
                                       "design rules for this net." ) );
        return false;
    }

    if( m_sizes.DiffPairWidth() < brd->GetDesignSettings().m_TrackMinWidth )
    {
        Router()->SetFailureReason( _( "Current track width setting violates design rules." ) );
        return false;
    }
    #endif

    m_currentStart = p;
    m_currentEnd = p;
    m_placingVia = false;
    m_chainedPlacement = false;

    initPlacement();

    return true;
}
bool PNS_MEANDER_SKEW_PLACER::Start( const VECTOR2I& aP, PNS_ITEM* aStartItem )
{
    VECTOR2I p;

    if( !aStartItem || !aStartItem->OfKind( PNS_ITEM::SEGMENT ) )
    {
        Router()->SetFailureReason( _( "Please select a differential pair trace you want to tune." ) );
        return false;
    }

    m_initialSegment = static_cast<PNS_SEGMENT*>( aStartItem );

    p = m_initialSegment->Seg().NearestPoint( aP );

    m_originLine = NULL;
    m_currentNode = NULL;
    m_currentStart = p;

    m_world = Router()->GetWorld( )->Branch();
    m_originLine = m_world->AssembleLine( m_initialSegment );

    PNS_TOPOLOGY topo( m_world );
    m_tunedPath = topo.AssembleTrivialPath( m_initialSegment );

    if( !topo.AssembleDiffPair ( m_initialSegment, m_originPair ) )
    {
        Router()->SetFailureReason( _( "Unable to find complementary differential pair "
                                       "net for skew tuning. Make sure the names of the nets belonging "
                                       "to a differential pair end with either _N/_P or +/-." ) );
        return false;
    }

    if( m_originPair.Gap() < 0 )
        m_originPair.SetGap( Router()->Sizes().DiffPairGap() );

    if( !m_originPair.PLine().SegmentCount() ||
        !m_originPair.NLine().SegmentCount() )
        return false;

    m_tunedPathP = topo.AssembleTrivialPath( m_originPair.PLine().GetLink( 0 ) );
    m_tunedPathN = topo.AssembleTrivialPath( m_originPair.NLine().GetLink( 0 ) );

    m_world->Remove( m_originLine );

    m_currentWidth = m_originLine->Width( );
    m_currentEnd = VECTOR2I( 0, 0 );

    if ( m_originPair.PLine().Net () == m_originLine->Net() )
        m_coupledLength = itemsetLength( m_tunedPathN );
    else
        m_coupledLength = itemsetLength( m_tunedPathP );

    return true;
}
bool PNS_MEANDER_SKEW_PLACER::Move( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
	BOOST_FOREACH( const PNS_ITEM* item, m_tunedPathP.CItems() )
    {
        if( const PNS_LINE* l = dyn_cast<const PNS_LINE*>( item ) )
            Router()->DisplayDebugLine( l->CLine(), 5, 10000 );
    }

    BOOST_FOREACH( const PNS_ITEM* item, m_tunedPathN.CItems() )
    {
        if( const PNS_LINE* l = dyn_cast<const PNS_LINE*>( item ) )
            Router()->DisplayDebugLine( l->CLine(), 4, 10000 );
    }

    return doMove( aP, aEndItem, m_coupledLength + m_settings.m_targetSkew );
}
Beispiel #5
0
void init_sim(int argc, char **argv) {
	topology_file.open(argv[1], std::ifstream::in);
	messages_file.open(argv[2], std::ifstream::in);
	events_file.open(argv[3], std::ifstream::in);

	topology_file >> node_ct;
	messages_file >> msg_ct;
	events_file >> time_ct;
	events_file >> event_ct;

	routers.clear();

	//creem obiectele de tip Router
	for(int i = 0; i < node_ct; ++i) routers.push_back( Router(i, node_ct) );

	int r1, cost, r2;
	while( (topology_file >> r1 >> cost >> r2) ) {
		//anuntam routerele despre vecinii lor directi
		routers[r1].add_nbrh(r2, cost);
		routers[r2].add_nbrh(r1, cost);
	} 

	//std::cout << "  [init_sim] sau initilizat " << routers.size() << " routere . . .\n";

	//incepem flodarea retelei cu mesaje despre vecini
	char nbrh_msg[LEN];

	for(unsigned int i = 0; i < routers.size(); ++i) {
		routers[i].table.set_node_no(node_ct);
		routers[i].topology.set_node_no(node_ct);
		routers[i].known_tags.clear();
	}

	for(unsigned int i = 0; i < routers.size(); ++i) {
		make_null(nbrh_msg, LEN);

		//fiecarui mesaj din prima parte a algoritmului de flodare
		//ii setam tagul egal cu -id-ul routerului care la pornit
		//in acest fel mesajele ce contin toti vecini vor avea tagul un numar negativ sau 0
		sprintf(nbrh_msg, "%d ", -i);  //tag == -i

		sprintf(nbrh_msg + strlen(nbrh_msg), "%d %d ", i, routers[i].nbrh.size());

		for(unsigned int j = 0; j < routers[i].nbrh.size(); ++j) {
			sprintf(nbrh_msg + strlen(nbrh_msg), "%d %d ", routers[i].nbrh[j], routers[i].get_nbrh_cost(routers[i].nbrh[j]));
		} 

		for(unsigned int j = 0; j < routers[i].nbrh.size(); ++j) {
			//cout << "----------------de la " << i << " la " << j << " sa trimis " << nbrh_msg << "\n";
			endpoint[i].send_msg(&endpoint[routers[i].nbrh[j]], nbrh_msg, strlen(nbrh_msg), NULL);
		}

	}  


}
Beispiel #6
0
Nlsrc::Router&
Nlsrc::getRouter(const nlsr::tlv::LsaInfo& info)
{
    const ndn::Name& originRouterName = info.getOriginRouter();

    const auto& pair =
        m_routers.insert(std::make_pair(originRouterName, Router()));

    return pair.first->second;
}
ClientLogger::ClientLogger(
    CoreModules* cm
):
    Plugin(cm)
{
    
    auto comms = cm->getComms();
    auto router = comms->Router();

    router->MapURLRequest(
        "/plugins/ClientLogger/logError",
        [&](
            std::shared_ptr<IHTTPUrlRouter::IConnection> connection
        ){
            ErrorLogger::logError(connection->RequestBody());
        }
    );    
}
int main(int argc, char **argv){
  std::string analysis = PrintRichdemHeader(argc, argv);

  if(argc!=4){
    std::cout<<"Syntax: "<<argv[0]<<" gentest <SIZE> <OUTPUT NAME>\n";
    std::cout<<"\tGenerates a test DEM\n\n";
    std::cout<<"Syntax: "<<argv[0]<<" <ALGORITHM> <INPUT DEM> <OUTPUT NAME>\n";
    std::cout<<"Algorithms:\n";
    std::cout<<"\t1: Barnes et al. (2014) Flat Resolution Algorithm\n";
    std::cout<<"\t2: Garbtecht and Martz (1997) Flat Resolution Algorithm\n";
    return -1;
  }

  if(argv[1]==std::string("gentest")){
    GenerateDEM(std::stoi(argv[2]),argv[3],analysis);
  } else {
    Router(argv[2],argv[1][0],argv[2],argv[3],analysis);    
  }

  return 0;
}
bool PNS_DIFF_PAIR_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
{
    if( !m_fitOk )
        return false;

    if( m_currentTrace.CP().SegmentCount() < 1 ||
            m_currentTrace.CN().SegmentCount() < 1 )
        return false;

    if( m_currentTrace.CP().SegmentCount() > 1 )
        m_initialDiagonal = !DIRECTION_45( m_currentTrace.CP().CSegment( -2 ) ).IsDiagonal();

    PNS_TOPOLOGY topo( m_lastNode );

    if( !m_snapOnTarget && !m_currentTrace.EndsWithVias() )
    {
        SHAPE_LINE_CHAIN newP( m_currentTrace.CP() );
        SHAPE_LINE_CHAIN newN( m_currentTrace.CN() );

        if( newP.SegmentCount() > 1 && newN.SegmentCount() > 1 )
        {
            newP.Remove( -1, -1 );
            newN.Remove( -1, -1 );
        }

        m_currentTrace.SetShape( newP, newN );
    }

    if( m_currentTrace.EndsWithVias() )
    {
        m_lastNode->Add( m_currentTrace.PLine().Via().Clone() );
        m_lastNode->Add( m_currentTrace.NLine().Via().Clone() );
        m_chainedPlacement = false;
    }
    else
    {
        m_chainedPlacement = !m_snapOnTarget;
    }

    PNS_LINE lineP( m_currentTrace.PLine() );
    PNS_LINE lineN( m_currentTrace.NLine() );

    m_lastNode->Add( &lineP );
    m_lastNode->Add( &lineN );

    topo.SimplifyLine( &lineP );
    topo.SimplifyLine( &lineN );

    m_prevPair = m_currentTrace.EndingPrimitives();

    Router()->CommitRouting( m_lastNode );

    m_lastNode = NULL;
    m_placingVia = false;

    if( m_snapOnTarget )
    {
        m_idle = true;
        return true;
    }
    else
    {
        initPlacement();
        return false;
    }
}
bool PNS_DIFF_PAIR_PLACER::attemptWalk( PNS_NODE* aNode, PNS_DIFF_PAIR* aCurrent,
        PNS_DIFF_PAIR& aWalk, bool aPFirst, bool aWindCw, bool aSolidsOnly )
{
    PNS_WALKAROUND walkaround( aNode, Router() );
    PNS_WALKAROUND::WALKAROUND_STATUS wf1;

    Router()->GetRuleResolver()->OverrideClearance( true,
            aCurrent->NetP(), aCurrent->NetN(), aCurrent->Gap() );

    walkaround.SetSolidsOnly( aSolidsOnly );
    walkaround.SetIterationLimit( Settings().WalkaroundIterationLimit() );

    PNS_SHOVE shove( aNode, Router() );
    PNS_LINE walkP, walkN;

    aWalk = *aCurrent;

    int iter = 0;

    PNS_DIFF_PAIR cur( *aCurrent );

    bool currentIsP = aPFirst;

    int mask = aSolidsOnly ? PNS_ITEM::SOLID : PNS_ITEM::ANY;

    do
    {
        PNS_LINE preWalk = ( currentIsP ? cur.PLine() : cur.NLine() );
        PNS_LINE preShove = ( currentIsP ? cur.NLine() : cur.PLine() );
        PNS_LINE postWalk;

        if( !aNode->CheckColliding ( &preWalk, mask ) )
        {
            currentIsP = !currentIsP;

            if( !aNode->CheckColliding( &preShove, mask ) )
                break;
            else
                continue;
        }

        wf1 = walkaround.Route( preWalk, postWalk, false );

        if( wf1 != PNS_WALKAROUND::DONE )
            return false;

        PNS_LINE postShove( preShove );

        shove.ForceClearance( true, cur.Gap() - 2 * PNS_HULL_MARGIN );

        PNS_SHOVE::SHOVE_STATUS sh1;

        sh1 = shove.ProcessSingleLine( postWalk, preShove, postShove );

        if( sh1 != PNS_SHOVE::SH_OK )
            return false;

        postWalk.Line().Simplify();
        postShove.Line().Simplify();

        cur.SetShape( postWalk.CLine(), postShove.CLine(), !currentIsP );

        currentIsP = !currentIsP;

        if( !aNode->CheckColliding( &postShove, mask ) )
            break;

        iter++;
    }
    while( iter < 3 );

    if( iter == 3 )
        return false;

    aWalk.SetShape( cur.CP(), cur.CN() );
    Router()->GetRuleResolver()->OverrideClearance( false );

    return true;
}
Beispiel #11
0
		Router& route(const Rule& rule)
		{
			routers_.push_back(Router(rule));
			return *(routers_.end() - 1);
		}