Пример #1
0
void stimulus::entry() {

    reset.write(true);
    wait();
    reset.write(false);

    sc_signed       tmp1(8);
    sc_signed       tmp2(8);
    long            tmp3;
    int             tmp4;
    short           tmp5;
    char            tmp6;
    char            tmp7;
    bool            tmp8;
    sc_unsigned     tmp9(4);
    sc_unsigned     tmp10(4);

    tmp1 = "0b01010101";
    tmp2 = "0b00000010";
    tmp3 = 12345678;
    tmp4 = -123456;
    tmp5 = 20000;
    tmp6 = '$'; 
    tmp7 = 'A';
    tmp8 = "0";
    tmp9 = "0b0001";
    tmp10 = "0b0010";

    while(true){
       out_valid.write(true);
       out_value1.write(tmp1);
       out_value2.write(tmp2);
       out_value3.write(tmp3);
       out_value4.write(tmp4);
       out_value5.write(tmp5);
       out_value6.write(tmp6);
       out_value7.write(tmp7);
       out_value8.write(tmp8);
       out_value9.write(tmp9);
       out_value10.write(tmp10);
       cout << "Stimuli: " << tmp1 << " " << tmp2 << " " << tmp3 << " " << tmp4 << " "
	    << tmp5 << " " << tmp6 << " " << tmp7 << " " << tmp8 << " " << tmp9  << " " << tmp10 <<endl;
       tmp1 = tmp1 + 2;
       tmp2 = tmp2 + 1;
       tmp3 = tmp3 + 5;
       tmp4 = tmp4 + 3;
       tmp5 = tmp5 + 6;
       tmp7 = tmp7 + 1;
       tmp8 = !tmp8;
       tmp9 = tmp9 + 1;
       tmp10 = tmp10 + 1;
       do { wait(); } while (in_ack==false);
       out_valid.write(false);
       wait();
    }
}
Пример #2
0
///
/// @par Detailed description
/// ...
/// @param [in, out] (param1) ...
/// @return ...
/// @note ...
void
sasio::Files::
read_pdb(const std::string &filename)
{
    std::string line, word ;

    std::string element_string ;

    std::ifstream infile(filename) ;

    int count = 0 ;
    int frame = 0 ;

    //string s(line, index, number_characters) ;

    std::vector<float> vector_x;
    std::vector<float> vector_y;
    std::vector<float> vector_z;

    while(getline(infile,line))
    {
        std::istringstream record(line) ;
        record >> word ;

        std::string temp1(word,0,5) ;

        if(temp1 != "ATOM" && temp1 != "HETAT")
        {
            std::cout << "excluding: " << word << std::endl ;
        }
        else
        {
            std::string tmp(line,0,6) ;
            _atom_record().push_back(tmp) ;

            std::string tmp2(line,6,5) ;
            _atom_index().push_back(stoi(tmp2)) ;

            std::string tmp3(line,12,4) ;
            _atom_name().push_back(tmp3) ;

            std::string tmp4(line,16,1) ;
            _atom_altloc().push_back(tmp4) ;

            std::string tmp5(line,17,3) ;
            _atom_resname().push_back(tmp5) ;

            std::string tmp6(line,21,1) ;
            _atom_chain().push_back(tmp6) ;

            std::string tmp7(line,22,4) ;
            _atom_resid().push_back(stoi(tmp7)) ;

            std::string tmp8(line,26,1) ;
            _atom_icode().push_back(tmp8) ;

            std::string tmp9(line,30,8) ;
            vector_x.push_back(stof(tmp9)) ;

            std::string tmp10(line,38,8) ;
            vector_y.push_back(stof(tmp10)) ;

            std::string tmp11(line,46,8) ;
            vector_z.push_back(stof(tmp11)) ;

            try
            {
                std::string tmp12(line,54,6) ;
                if(util::has_only_spaces(tmp12))
                {
                    _atom_occupancy().push_back("0.00") ;
                }
                else
                {
                    _atom_occupancy().push_back(tmp12) ;
                }
            }
            catch(const std::out_of_range& oor)
            {
                _atom_occupancy().push_back("0.00") ;
                std::cerr<<"Occupancy: Out of range error: "<< oor.what() <<std::endl ;
            }

            try
            {
                std::string tmp13(line,60,6) ;
                if(util::has_only_spaces(tmp13))
                {
                    _atom_beta().push_back("0.00") ;
                }
                else
                {
                    _atom_beta().push_back(tmp13) ;
                }
            }
            catch(const std::out_of_range& oor)
            {
                _atom_beta().push_back("0.00") ;
                std::cerr<<"Beta: Out of range error: "<< oor.what() <<std::endl ;
            }

            try
            {
                std::string tmp14(line,72,4) ;
                if(util::has_only_spaces(tmp14))
                {
                    _atom_segname().push_back("SEGN") ;
                }
                else
                {
                    _atom_segname().push_back(tmp14) ;
                }
            }
            catch(const std::out_of_range& oor)
            {
                _atom_segname().push_back("SEGN") ;
                std::cerr<<"Segname: Out of range error: "<< oor.what() <<std::endl ;
            }

            try
            {
                std::string tmp15(line,76,2) ;
                if(util::has_only_spaces(tmp15))
                {
                    std::cout << "Element not found" << std::endl;
                    element_string = element_from_name(tmp3) ;
                    _atom_element().push_back(element_string) ;
                }
                else
                {
                    _atom_element().push_back(tmp15) ;
                }
            }
            catch(const std::out_of_range& oor)
            {
                element_string = element_from_name(tmp3) ;
                _atom_element().push_back(element_string) ;
                std::cerr<<"Element: Out of range error: "<< oor.what() <<std::endl ;
            }

            try
            {
                std::string tmp16(line,78,2) ;
                if(util::has_only_spaces(tmp16))
                {
                    _atom_charge().push_back(" ") ;
                }
                else
                {
                    _atom_charge().push_back(tmp16) ;
                }
            }
            catch(const std::out_of_range& oor)
            {
                _atom_charge().push_back(" ") ;
                std::cerr<<"Charge: Out of range error: "<< oor.what() <<std::endl ;
            }

            count++ ;
        }
    }

    _natoms() = count ;
    infile.close() ;

    int nf = _number_of_frames() ;

    if(_number_of_frames() == 0)
    {
        _x().setZero(_natoms(), 1);
        _y().setZero(_natoms(), 1);
        _z().setZero(_natoms(), 1);
    }
    else
    {
        resize_array() ;
    }

    for(int i = 0 ; i < _natoms() ; ++i)
    {
        _x()(i,_number_of_frames()) = vector_x[i] ;
        _y()(i,_number_of_frames()) = vector_y[i] ;
        _z()(i,_number_of_frames()) = vector_z[i] ;
    }

    std::vector<std::string> s_element ;
    s_element = util::strip_white_space(_atom_element()) ;
    _atom_selement() = s_element ;

    dynamic_cast<sasmol::SasMol*>(this)->calc_mass() ;
    _atom_com() = dynamic_cast<sasmol::SasMol*>(this)->calc_com(frame) ;

    _number_of_frames() += 1 ;

    _set_unique_attributes();

    /*
              1         2         3         4         5         6         7         8
    012345678901234567890123456789012345678901234567890123456789012345678901234567890
             1         2         3         4         5         6         7         8
    12345678901234567890123456789012345678901234567890123456789012345678901234567890
    0    6    1 2   7
    ATOM      1  N   GLY X   1     -21.525 -67.562  86.759  1.00  0.00      GAG  N
    ATOM      2  HT1 GLY X   1     -22.003 -68.460  86.892  1.00  0.00      GAG  H
    ATOM      3  HT2 GLY X   1     -21.905 -66.929  87.525  1.00  0.00      GAG  H

    */
}