summaryrefslogtreecommitdiff
path: root/src/mem/ruby/slicc_interface/RubyRequest.cc
blob: 2d8c94ed600d9ce520e2281b7c5ee6a88e2697a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>

#include "mem/ruby/slicc_interface/RubyRequest.hh"

using namespace std;

ostream&
operator<<(ostream& out, const RubyRequest& obj)
{
    out << hex << "0x" << obj.paddr << " data: 0x" << flush;
    for (int i = 0; i < obj.len; i++) {
        out << (int)obj.data[i];
    }
    out << dec << " type: " << RubyRequestType_to_string(obj.type) << endl;
    return out;
}

vector<string>
tokenizeString(string str, string delims)
{
    vector<string> tokens;
    char* pch;
    char* tmp;
    const char* c_delims = delims.c_str();
    tmp = new char[str.length()+1];
    strcpy(tmp, str.c_str());
    pch = strtok(tmp, c_delims);
    while (pch != NULL) {
        string tmp_str(pch);
        if (tmp_str == "null") tmp_str = "";
        tokens.push_back(tmp_str);

        pch = strtok(NULL, c_delims);
    }
    delete [] tmp;
    return tokens;
}