2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * Declaration of a IBM memory trace format reader.
35 #include "cpu/trace/reader/ibm_reader.hh"
36 #include "sim/builder.hh"
37 #include "base/misc.hh" // for fatal
41 IBMReader::IBMReader(const string
&name
, const string
&filename
)
42 : MemTraceReader(name
)
44 if (strcmp((filename
.c_str() + filename
.length() -3), ".gz") == 0) {
45 // Compressed file, need to use a pipe to gzip.
47 buf
<< "gzip -d -c " << filename
<< endl
;
48 trace
= popen(buf
.str().c_str(), "r");
50 trace
= fopen(filename
.c_str(), "rb");
53 fatal("Can't open file %s", filename
);
58 IBMReader::getNextReq(MemReqPtr
&req
)
64 tmp_req
= new MemReq();
65 //int cpu_id = (c & 0xf0) >> 4;
67 // We have L1 miss traces, so all accesses are 128 bytes
71 for (int i
= 2; i
>= 0; --i
) {
74 fatal("Unexpected end of file");
76 tmp_req
->paddr
|= ((c
& 0xff) << (8 * i
));
78 tmp_req
->paddr
= tmp_req
->paddr
<< 7;
81 case IBM_COND_EXCLUSIVE_FETCH
:
82 case IBM_READ_ONLY_FETCH
:
85 case IBM_EXCLUSIVE_FETCH
:
86 case IBM_FETCH_NO_DATA
:
93 fatal("Unknown trace entry type.");
101 BEGIN_DECLARE_SIM_OBJECT_PARAMS(IBMReader
)
103 Param
<string
> filename
;
105 END_DECLARE_SIM_OBJECT_PARAMS(IBMReader
)
108 BEGIN_INIT_SIM_OBJECT_PARAMS(IBMReader
)
110 INIT_PARAM(filename
, "trace file")
112 END_INIT_SIM_OBJECT_PARAMS(IBMReader
)
115 CREATE_SIM_OBJECT(IBMReader
)
117 return new IBMReader(getInstanceName(), filename
);
120 REGISTER_SIM_OBJECT("IBMReader", IBMReader
)