Esempio n. 1
0
void ByteModel::SetConfig( Config *config, bool createChildren )
{
    Params *params = new Params( );
    params->SetParams( config );
    SetParams( params );

    EnduranceModel::SetConfig( config, createChildren );
}
Esempio n. 2
0
void RowModel::SetConfig( Config *conf, bool createChildren )
{
    Params *params = new Params( );
    params->SetParams( conf );
    SetParams( params );

    SetGranularity( p->COLS * 8 );

    EnduranceModel::SetConfig( conf, createChildren );
}
Esempio n. 3
0
void WordModel::SetConfig( Config *config, bool createChildren )
{
    Params *params = new Params( );
    params->SetParams( config );
    SetParams( params );

    SetGranularity( p->BusWidth * 8 );

    EnduranceModel::SetConfig( config, createChildren );
}
Esempio n. 4
0
void StandardRank::SetConfig( Config *c, bool createChildren )
{
     //std::cout<< "HRANK named " << StatName()<< std::endl;
    /*
    std::stringstream formatter1;
    formatter1.str( "" );
    formatter1 << GetParent( )->StatName( ) << ".babyhrank";
    StatName(formatter1.str( ));

  std::cout<<"StandardRank::SetConfig"<<std::endl;
*/
        //std::vector<NVMObject_hook *>::iterator it;
        //std::vector<NVMObject_hook *>& childNodes = GetParent( )->GetTrampoline( )-> GetChildren( );
         //std::cout<<"parent name is "<< GetParent( )->StatName( )<<std::endl;
         //it = childNodes.begin();
         //std::cout << "Mother's children hook name is " << (*it)->StatName( ) << std::endl;
        
/*
        for( it = childNodes.begin(); it != childNodes.end(); it++ )
        {
            std::cout << "Mother's children hook name is " << (*it)->StatName( ) << std::endl;
        }
*/



    conf = c;

    Params *params = new Params( );
    params->SetParams( c );
    SetParams( params );

    deviceWidth = p->DeviceWidth;
    busWidth = p->BusWidth;

    banksPerRefresh = p->BanksPerRefresh;

    if( conf->GetValue( "RAW" ) == -1 )
    {
        std::cout << "NVMain Warning: RAW (Row Activation Window) is not "
            << "specified. Has set it to 4 (FAW)" << std::endl;
        rawNum = 4;
    }
    else
        rawNum = p->RAW;

    assert( rawNum != 0 );

    /* Calculate the number of devices needed. */
    deviceCount = busWidth / deviceWidth;
    if( busWidth % deviceWidth != 0 )
    {
        std::cout << "NVMain: device width is not a multiple of the bus width!\n";
        deviceCount++;
    }

    bankCount = p->BANKS;

    if( createChildren )
    {
        /* When selecting a child, use the bank field from the decoder. */
        AddressTranslator *rankAT = DecoderFactory::CreateDecoderNoWarn( conf->GetString( "Decoder" ) );
        std::cout << "The parent hook name is "<< GetParent( )->StatName( ) <<std::endl;/*zhuguoliang*/
        rankAT->SetTranslationMethod( GetParent( )->GetTrampoline( )->GetParent( )->GetTrampoline( )->GetDecoder( )->GetTranslationMethod( ) );
        rankAT->SetDefaultField( BANK_FIELD );  
        rankAT->SetConfig( c, createChildren );
        SetDecoder( rankAT );

        std::cout << "Creating " << bankCount << " banks in all " 
            << deviceCount << " devices.\n";

        for( ncounter_t i = 0; i < bankCount; i++ )
        {
            std::stringstream formatter;

            Bank *nextBank = BankFactory::CreateBankNoWarn( conf->GetString( "BankType" ) );

            formatter << i;
            nextBank->SetId( i );
            formatter.str( "" );

            formatter << StatName( ) << ".bank" << i;
            nextBank->StatName( formatter.str( ) );

            //std::cout<< "HRANK named " << StatName()<< std::endl;
            nextBank->SetParent( this );
            AddChild( nextBank );

            /* SetConfig recursively. */
            nextBank->SetConfig( c, createChildren );
            nextBank->RegisterStats( );
        }
    }

    /* 
     * Make sure this doesn't cause unnecessary tRRD delays at start 
     * TODO: have Activate check currentCycle < tRRD/tRAW maybe?
     */
    lastActivate = new ncycle_t[rawNum];
    for( ncounter_t i = 0; i < rawNum; i++ )
        lastActivate[i] = 0;

    /* We'll say you can't do anything until the command has time to issue on the bus. */
    nextRead = p->tCMD;
    nextWrite = p->tCMD;
    nextActivate = p->tCMD;
    nextPrecharge = p->tCMD;

    fawWaits = 0;
    rrdWaits = 0;
    actWaits = 0;

    fawWaitTotal = 0;
    rrdWaitTotal = 0;
    actWaitTotal = 0;
}
void NVMain::SetConfig( Config *conf, std::string memoryName, bool createChildren )
{
    TranslationMethod *method;
    int channels, ranks, banks, rows, cols, subarrays;

    Params *params = new Params( );
    params->SetParams( conf );
    SetParams( params );

    StatName( memoryName );

    config = conf;
    if( config->GetSimInterface( ) != NULL )
        config->GetSimInterface( )->SetConfig( conf, createChildren );
    else
      std::cout << "Warning: Sim Interface should be allocated before configuration!" << std::endl;


    if( createChildren )
    {
        if( conf->KeyExists( "MATHeight" ) )
        {
            rows = static_cast<int>(p->MATHeight);
            subarrays = static_cast<int>( p->ROWS / p->MATHeight );
        }
        else
        {
            rows = static_cast<int>(p->ROWS);
            subarrays = 1;
        }
        cols = static_cast<int>(p->COLS);
        banks = static_cast<int>(p->BANKS);
        ranks = static_cast<int>(p->RANKS);
        channels = static_cast<int>(p->CHANNELS);
		word_size = static_cast<uint64_t>( p->tBURST * p->RATE * p->BusWidth/8);
		std::cout<<"word size is "<<word_size<<std::endl;
		std::cout<<"cols is"<<cols<<std::endl;
		std::cout<<"rows is"<<rows<<std::endl;
		std::cout<<"ranks is"<<ranks<<std::endl;
		std::cout<<"banks is"<<banks<<std::endl;
		std::cout<<"ranks is"<<ranks<<std::endl;
		std::cout<<"channels is"<<channels<<std::endl;
		std::cout<<"subarrays is"<<subarrays<<std::endl;
		if( !config->KeyExists("DRCVariant") )
		{
			memory_size += word_size * cols * rows * banks * ranks * channels *subarrays;
			std::cout<<"mem size is "<<memory_size/(1024*1024)<<"MB"<<std::endl;
		}
        if( config->KeyExists( "Decoder" ) )
            translator = DecoderFactory::CreateNewDecoder( config->GetString( "Decoder" ) );
        else
            translator = new AddressTranslator( );

        method = new TranslationMethod( );

        method->SetBitWidths( NVM::mlog2( rows ), 
                    NVM::mlog2( cols ), 
                    NVM::mlog2( banks ), 
                    NVM::mlog2( ranks ), 
                    NVM::mlog2( channels ), 
                    NVM::mlog2( subarrays )
                    );
        method->SetCount( rows, cols, banks, ranks, channels, subarrays );
        method->SetAddressMappingScheme( p->AddressMappingScheme );
        translator->SetConfig( config, createChildren );
        translator->SetTranslationMethod( method );
        translator->SetDefaultField( CHANNEL_FIELD );

        SetDecoder( translator );

        memoryControllers = new MemoryController* [channels];
        channelConfig = new Config* [channels];
        for( int i = 0; i < channels; i++ )
        {
            std::stringstream confString;
            std::string channelConfigFile;

            channelConfig[i] = new Config( *config );

            channelConfig[i]->SetSimInterface( config->GetSimInterface( ) );

            confString << "CONFIG_CHANNEL" << i;

            if( config->GetString( confString.str( ) ) != "" )
            {
                channelConfigFile  = config->GetString( confString.str( ) );

                if( channelConfigFile[0] != '/' )
                {
                    channelConfigFile  = NVM::GetFilePath( config->GetFileName( ) );
                    channelConfigFile += config->GetString( confString.str( ) );
                }
                
                channelConfig[i]->Read( channelConfigFile );
            }
			//std::cout<<"NVMain: initialize memory controller"<<std::endl;
            /* Initialize memory controller */
            memoryControllers[i] = 
                MemoryControllerFactory::CreateNewController( channelConfig[i]->GetString( "MEM_CTL" ) );

            /* When selecting a MC child, use no field from the decoder (only-child). */

            confString.str( "" );
			//memoryControllers[i]'s statName is memoryName.channeli.FCFS(etc)
            confString << memoryName << ".channel" << i << "." 
                << channelConfig[i]->GetString( "MEM_CTL" ); 
            memoryControllers[i]->StatName( confString.str( ) );
            memoryControllers[i]->SetID( i );

            AddChild( memoryControllers[i] );
            memoryControllers[i]->SetParent( this );
            /* Set Config recursively. */
            memoryControllers[i]->SetConfig( channelConfig[i], createChildren );
            /* Register statistics. */
            memoryControllers[i]->RegisterStats( );
        }
    }

    if( p->MemoryPrefetcher != "none" )
    {
        prefetcher = PrefetcherFactory::CreateNewPrefetcher( p->MemoryPrefetcher );
        std::cout << "Made a " << p->MemoryPrefetcher << " prefetcher." << std::endl;
    }

    numChannels = static_cast<unsigned int>(p->CHANNELS);
    
    std::string pretraceFile;

    if( p->PrintPreTrace || p->EchoPreTrace )
    {
        if( config->GetString( "PreTraceFile" ) == "" )
            pretraceFile = "trace.nvt";
        else
            pretraceFile = config->GetString( "PreTraceFile" );

        if( pretraceFile[0] != '/' )
        {
            pretraceFile  = NVM::GetFilePath( config->GetFileName( ) );
            pretraceFile += config->GetString( "PreTraceFile" );
        }

        std::cout << "Using trace file " << pretraceFile << std::endl;

        if( config->GetString( "PreTraceWriter" ) == "" )
            preTracer = TraceWriterFactory::CreateNewTraceWriter( "NVMainTrace" );
        else
            preTracer = TraceWriterFactory::CreateNewTraceWriter( config->GetString( "PreTraceWriter" ) );

        if( p->PrintPreTrace )
            preTracer->SetTraceFile( pretraceFile );
        if( p->EchoPreTrace )
            preTracer->SetEcho( true );
    }
    RegisterStats( );
}