OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librlink/] [RlinkCommandList.cpp] - Blame information for rev 19

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 wfjm
// $Id: RlinkCommandList.cpp 495 2013-03-06 17:13:48Z mueller $
2 10 wfjm
//
3 19 wfjm
// Copyright 2011-2013 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4 10 wfjm
//
5
// This program is free software; you may redistribute and/or modify it under
6
// the terms of the GNU General Public License as published by the Free
7
// Software Foundation, either version 2, or at your option any later version.
8
//
9
// This program is distributed in the hope that it will be useful, but
10
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
11
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
// for complete details.
13
// 
14
// Revision History: 
15
// Date         Rev Version  Comment
16 19 wfjm
// 2013-05-06   495   1.0.3  add RlinkContext to Print() args
17
// 2013-02-03   481   1.0.2  use Rexception
18 12 wfjm
// 2011-04-25   380   1.0.1  use boost/foreach
19 10 wfjm
// 2011-03-05   366   1.0    Initial version
20
// 2011-01-15   355   0.1    First draft
21
// ---------------------------------------------------------------------------
22
 
23
/*!
24
  \file
25 19 wfjm
  \version $Id: RlinkCommandList.cpp 495 2013-03-06 17:13:48Z mueller $
26 10 wfjm
  \brief   Implemenation of class RlinkCommandList.
27
 */
28
 
29
#include <string>
30
 
31 12 wfjm
#include "boost/foreach.hpp"
32 19 wfjm
#define foreach_ BOOST_FOREACH
33 12 wfjm
 
34 10 wfjm
#include "RlinkCommandList.hpp"
35
 
36
#include "librtools/RosPrintf.hpp"
37
#include "librtools/RosFill.hpp"
38 19 wfjm
#include "librtools/Rexception.hpp"
39 10 wfjm
 
40
using namespace std;
41
 
42
/*!
43
  \class Retro::RlinkCommandList
44
  \brief FIXME_docs
45
*/
46
 
47 19 wfjm
// all method definitions in namespace Retro
48
namespace Retro {
49
 
50 10 wfjm
//------------------------------------------+-----------------------------------
51
//! Default constructor
52
 
53
RlinkCommandList::RlinkCommandList()
54
  : fList()
55
{
56
  fList.reserve(16);                        // should prevent most re-alloc's
57
}
58
 
59
//------------------------------------------+-----------------------------------
60
//! Copy constructor
61
 
62
RlinkCommandList::RlinkCommandList(const RlinkCommandList& rhs)
63
  : fList()
64
{
65
  operator=(rhs);
66
}
67
 
68
//------------------------------------------+-----------------------------------
69
//! Destructor
70
 
71
RlinkCommandList::~RlinkCommandList()
72
{
73 19 wfjm
  foreach_ (RlinkCommand* pcmd, fList) { delete pcmd; }
74 10 wfjm
}
75
 
76
//------------------------------------------+-----------------------------------
77
//! FIXME_docs
78
 
79
size_t RlinkCommandList::AddCommand(RlinkCommand* cmd)
80
{
81
  size_t ind = fList.size();
82
  fList.push_back(cmd);
83
  return ind;
84
}
85
 
86
//------------------------------------------+-----------------------------------
87
//! FIXME_docs
88
 
89
size_t RlinkCommandList::AddCommand(const RlinkCommand& cmd)
90
{
91
  return AddCommand(new RlinkCommand(cmd));
92
}
93
 
94
//------------------------------------------+-----------------------------------
95
//! FIXME_docs
96
 
97
size_t RlinkCommandList::AddCommand(const RlinkCommandList& clist)
98
{
99
  size_t ind = fList.size();
100
  for (size_t i=0; i<clist.Size(); i++) {
101
    AddCommand(new RlinkCommand(clist[i]));
102
  }
103
  return ind;
104
}
105
 
106
//------------------------------------------+-----------------------------------
107
//! FIXME_docs
108
 
109
size_t RlinkCommandList::AddRreg(uint16_t addr)
110
{
111
  RlinkCommand* pcmd = new RlinkCommand();
112
  pcmd->CmdRreg(addr);
113
  return AddCommand(pcmd);
114
}
115
 
116
//------------------------------------------+-----------------------------------
117
//! FIXME_docs
118
 
119
size_t RlinkCommandList::AddRblk(uint16_t addr, size_t size)
120
{
121
  RlinkCommand* pcmd = new RlinkCommand();
122
  pcmd->CmdRblk(addr, size);
123
  return AddCommand(pcmd);
124
}
125
 
126
//------------------------------------------+-----------------------------------
127
//! FIXME_docs
128
 
129
size_t RlinkCommandList::AddRblk(uint16_t addr, uint16_t* block, size_t size)
130
{
131
  RlinkCommand* pcmd = new RlinkCommand();
132
  pcmd->CmdRblk(addr, block, size);
133
  return AddCommand(pcmd);
134
}
135
 
136
//------------------------------------------+-----------------------------------
137
//! FIXME_docs
138
 
139
size_t RlinkCommandList::AddWreg(uint16_t addr, uint16_t data)
140
{
141
  RlinkCommand* pcmd = new RlinkCommand();
142
  pcmd->CmdWreg(addr, data);
143
  return AddCommand(pcmd);
144
}
145
 
146
//------------------------------------------+-----------------------------------
147
//! FIXME_docs
148
 
149
size_t RlinkCommandList::AddWblk(uint16_t addr, std::vector<uint16_t> block)
150
{
151
  RlinkCommand* pcmd = new RlinkCommand();
152
  pcmd->CmdWblk(addr, block);
153
  return AddCommand(pcmd);
154
}
155
 
156
//------------------------------------------+-----------------------------------
157
//! FIXME_docs
158
 
159
size_t RlinkCommandList::AddWblk(uint16_t addr, const uint16_t* block,
160
                                 size_t size)
161
{
162
  RlinkCommand* pcmd = new RlinkCommand();
163
  pcmd->CmdWblk(addr, block, size);
164
  return AddCommand(pcmd);
165
}
166
 
167
//------------------------------------------+-----------------------------------
168
//! FIXME_docs
169
 
170
size_t RlinkCommandList::AddStat()
171
{
172
  RlinkCommand* pcmd = new RlinkCommand();
173
  pcmd->CmdStat();
174
  return AddCommand(pcmd);
175
}
176
 
177
//------------------------------------------+-----------------------------------
178
//! FIXME_docs
179
 
180
size_t RlinkCommandList::AddAttn()
181
{
182
  RlinkCommand* pcmd = new RlinkCommand();
183
  pcmd->CmdAttn();
184
  return AddCommand(pcmd);
185
}
186
 
187
//------------------------------------------+-----------------------------------
188
//! FIXME_docs
189
 
190
size_t RlinkCommandList::AddInit(uint16_t addr, uint16_t data)
191
{
192
  RlinkCommand* pcmd = new RlinkCommand();
193
  pcmd->CmdInit(addr, data);
194
  return AddCommand(pcmd);
195
}
196
 
197
//------------------------------------------+-----------------------------------
198
//! FIXME_docs
199
 
200
void RlinkCommandList::LastVolatile()
201
{
202
  if (fList.size() == 0)
203 19 wfjm
    throw Rexception("RlinkCommandList::LastVolatile()",
204
                     "Bad state: list empty");
205 10 wfjm
  fList[fList.size()-1]->SetFlagBit(RlinkCommand::kFlagVol);
206
  return;
207
}
208
 
209
//------------------------------------------+-----------------------------------
210
//! FIXME_docs
211
 
212
void RlinkCommandList::LastExpect(RlinkCommandExpect* exp)
213
{
214
  if (fList.size() == 0)
215 19 wfjm
    throw Rexception("RlinkCommandList::LastExpect()",
216
                     "Bad state: list empty");
217 10 wfjm
  fList[fList.size()-1]->SetExpect(exp);
218
  return;
219
}
220
 
221
//------------------------------------------+-----------------------------------
222
//! FIXME_docs
223
 
224
void RlinkCommandList::Clear()
225
{
226
 
227
  fList.clear();
228
  return;
229
}
230
 
231
//------------------------------------------+-----------------------------------
232
//! FIXME_docs
233
 
234 19 wfjm
void RlinkCommandList::Print(std::ostream& os, const RlinkContext& cntx,
235
                             const RlinkAddrMap* pamap, size_t abase,
236
                             size_t dbase, size_t sbase) const
237 10 wfjm
{
238 19 wfjm
  foreach_ (RlinkCommand* pcmd, fList) {
239
    pcmd->Print(os, cntx, pamap, abase, dbase, sbase);
240 10 wfjm
  }
241
  return;
242
}
243
 
244
//------------------------------------------+-----------------------------------
245
//! FIXME_docs
246
 
247
void RlinkCommandList::Dump(std::ostream& os, int ind, const char* text) const
248
{
249
  RosFill bl(ind);
250
  os << bl << (text?text:"--") << "RlinkCommandList @ " << this << endl;
251
 
252
  for (size_t i=0; i<Size(); i++) {
253
    string pref("fList[");
254
    pref << RosPrintf(i) << RosPrintf("]: ");
255
    fList[i]->Dump(os, ind+2, pref.c_str());
256
  }
257
 
258
  return;
259
}
260
 
261
//------------------------------------------+-----------------------------------
262
//! FIXME_docs
263
 
264
RlinkCommandList&
265
  Retro::RlinkCommandList::operator=( const RlinkCommandList& rhs)
266
{
267
  if (&rhs == this) return *this;
268 12 wfjm
 
269 19 wfjm
  foreach_ (RlinkCommand* pcmd, fList) { delete pcmd; }
270 10 wfjm
  fList.clear();
271
  for (size_t i=0; i<rhs.Size(); i++) AddCommand(rhs[i]);
272
  return *this;
273
}
274
 
275
//------------------------------------------+-----------------------------------
276
//! FIXME_docs
277
 
278
Retro::RlinkCommand& Retro::RlinkCommandList::operator[](size_t ind)
279
{
280
  return *fList.at(ind);
281
}
282
 
283
//------------------------------------------+-----------------------------------
284
//! FIXME_docs
285
 
286
const Retro::RlinkCommand& Retro::RlinkCommandList::operator[](size_t ind) const
287
{
288
  return *fList.at(ind);
289
}
290
 
291 19 wfjm
} // end namespace Retro

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.