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 10

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

Line No. Rev Author Line
1 10 wfjm
// $Id: RlinkCommandList.cpp 375 2011-04-02 07:56:47Z mueller $
2
//
3
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4
//
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
// 2011-03-05   366   1.0    Initial version
17
// 2011-01-15   355   0.1    First draft
18
// ---------------------------------------------------------------------------
19
 
20
/*!
21
  \file
22
  \version $Id: RlinkCommandList.cpp 375 2011-04-02 07:56:47Z mueller $
23
  \brief   Implemenation of class RlinkCommandList.
24
 */
25
 
26
#include <string>
27
#include <stdexcept>
28
 
29
#include "RlinkCommandList.hpp"
30
 
31
#include "librtools/RosPrintf.hpp"
32
#include "librtools/RosFill.hpp"
33
 
34
using namespace std;
35
using namespace Retro;
36
 
37
/*!
38
  \class Retro::RlinkCommandList
39
  \brief FIXME_docs
40
*/
41
 
42
//------------------------------------------+-----------------------------------
43
//! Default constructor
44
 
45
RlinkCommandList::RlinkCommandList()
46
  : fList()
47
{
48
  fList.reserve(16);                        // should prevent most re-alloc's
49
}
50
 
51
//------------------------------------------+-----------------------------------
52
//! Copy constructor
53
 
54
RlinkCommandList::RlinkCommandList(const RlinkCommandList& rhs)
55
  : fList()
56
{
57
  operator=(rhs);
58
}
59
 
60
//------------------------------------------+-----------------------------------
61
//! Destructor
62
 
63
RlinkCommandList::~RlinkCommandList()
64
{
65
  for (size_t i=0; i<fList.size(); i++) delete fList[i];
66
}
67
 
68
//------------------------------------------+-----------------------------------
69
//! FIXME_docs
70
 
71
size_t RlinkCommandList::AddCommand(RlinkCommand* cmd)
72
{
73
  size_t ind = fList.size();
74
  fList.push_back(cmd);
75
  return ind;
76
}
77
 
78
//------------------------------------------+-----------------------------------
79
//! FIXME_docs
80
 
81
size_t RlinkCommandList::AddCommand(const RlinkCommand& cmd)
82
{
83
  return AddCommand(new RlinkCommand(cmd));
84
}
85
 
86
//------------------------------------------+-----------------------------------
87
//! FIXME_docs
88
 
89
size_t RlinkCommandList::AddCommand(const RlinkCommandList& clist)
90
{
91
  size_t ind = fList.size();
92
  for (size_t i=0; i<clist.Size(); i++) {
93
    AddCommand(new RlinkCommand(clist[i]));
94
  }
95
  return ind;
96
}
97
 
98
//------------------------------------------+-----------------------------------
99
//! FIXME_docs
100
 
101
size_t RlinkCommandList::AddRreg(uint16_t addr)
102
{
103
  RlinkCommand* pcmd = new RlinkCommand();
104
  pcmd->CmdRreg(addr);
105
  return AddCommand(pcmd);
106
}
107
 
108
//------------------------------------------+-----------------------------------
109
//! FIXME_docs
110
 
111
size_t RlinkCommandList::AddRblk(uint16_t addr, size_t size)
112
{
113
  RlinkCommand* pcmd = new RlinkCommand();
114
  pcmd->CmdRblk(addr, size);
115
  return AddCommand(pcmd);
116
}
117
 
118
//------------------------------------------+-----------------------------------
119
//! FIXME_docs
120
 
121
size_t RlinkCommandList::AddRblk(uint16_t addr, uint16_t* block, size_t size)
122
{
123
  RlinkCommand* pcmd = new RlinkCommand();
124
  pcmd->CmdRblk(addr, block, size);
125
  return AddCommand(pcmd);
126
}
127
 
128
//------------------------------------------+-----------------------------------
129
//! FIXME_docs
130
 
131
size_t RlinkCommandList::AddWreg(uint16_t addr, uint16_t data)
132
{
133
  RlinkCommand* pcmd = new RlinkCommand();
134
  pcmd->CmdWreg(addr, data);
135
  return AddCommand(pcmd);
136
}
137
 
138
//------------------------------------------+-----------------------------------
139
//! FIXME_docs
140
 
141
size_t RlinkCommandList::AddWblk(uint16_t addr, std::vector<uint16_t> block)
142
{
143
  RlinkCommand* pcmd = new RlinkCommand();
144
  pcmd->CmdWblk(addr, block);
145
  return AddCommand(pcmd);
146
}
147
 
148
//------------------------------------------+-----------------------------------
149
//! FIXME_docs
150
 
151
size_t RlinkCommandList::AddWblk(uint16_t addr, const uint16_t* block,
152
                                 size_t size)
153
{
154
  RlinkCommand* pcmd = new RlinkCommand();
155
  pcmd->CmdWblk(addr, block, size);
156
  return AddCommand(pcmd);
157
}
158
 
159
//------------------------------------------+-----------------------------------
160
//! FIXME_docs
161
 
162
size_t RlinkCommandList::AddStat()
163
{
164
  RlinkCommand* pcmd = new RlinkCommand();
165
  pcmd->CmdStat();
166
  return AddCommand(pcmd);
167
}
168
 
169
//------------------------------------------+-----------------------------------
170
//! FIXME_docs
171
 
172
size_t RlinkCommandList::AddAttn()
173
{
174
  RlinkCommand* pcmd = new RlinkCommand();
175
  pcmd->CmdAttn();
176
  return AddCommand(pcmd);
177
}
178
 
179
//------------------------------------------+-----------------------------------
180
//! FIXME_docs
181
 
182
size_t RlinkCommandList::AddInit(uint16_t addr, uint16_t data)
183
{
184
  RlinkCommand* pcmd = new RlinkCommand();
185
  pcmd->CmdInit(addr, data);
186
  return AddCommand(pcmd);
187
}
188
 
189
//------------------------------------------+-----------------------------------
190
//! FIXME_docs
191
 
192
void RlinkCommandList::LastVolatile()
193
{
194
  if (fList.size() == 0)
195
    throw out_of_range("RlinkCommandList::LastExpect: list empty");
196
  fList[fList.size()-1]->SetFlagBit(RlinkCommand::kFlagVol);
197
  return;
198
}
199
 
200
//------------------------------------------+-----------------------------------
201
//! FIXME_docs
202
 
203
void RlinkCommandList::LastExpect(RlinkCommandExpect* exp)
204
{
205
  if (fList.size() == 0)
206
    throw out_of_range("RlinkCommandList::LastExpect: list empty");
207
  fList[fList.size()-1]->SetExpect(exp);
208
  return;
209
}
210
 
211
//------------------------------------------+-----------------------------------
212
//! FIXME_docs
213
 
214
void RlinkCommandList::Clear()
215
{
216
 
217
  fList.clear();
218
  return;
219
}
220
 
221
//------------------------------------------+-----------------------------------
222
//! FIXME_docs
223
 
224
void RlinkCommandList::Print(std::ostream& os, const RlinkAddrMap* pamap,
225
                             size_t abase, size_t dbase, size_t sbase) const
226
{
227
  for (size_t i=0; i<fList.size(); i++) {
228
    fList[i]->Print(os, pamap, abase, dbase, sbase);
229
  }
230
  return;
231
}
232
 
233
//------------------------------------------+-----------------------------------
234
//! FIXME_docs
235
 
236
void RlinkCommandList::Dump(std::ostream& os, int ind, const char* text) const
237
{
238
  RosFill bl(ind);
239
  os << bl << (text?text:"--") << "RlinkCommandList @ " << this << endl;
240
 
241
  for (size_t i=0; i<Size(); i++) {
242
    string pref("fList[");
243
    pref << RosPrintf(i) << RosPrintf("]: ");
244
    fList[i]->Dump(os, ind+2, pref.c_str());
245
  }
246
 
247
  return;
248
}
249
 
250
//------------------------------------------+-----------------------------------
251
//! FIXME_docs
252
 
253
RlinkCommandList&
254
  Retro::RlinkCommandList::operator=( const RlinkCommandList& rhs)
255
{
256
  if (&rhs == this) return *this;
257
  for (size_t i=0; i<fList.size(); i++) delete fList[i];
258
  fList.clear();
259
  for (size_t i=0; i<rhs.Size(); i++) AddCommand(rhs[i]);
260
  return *this;
261
}
262
 
263
//------------------------------------------+-----------------------------------
264
//! FIXME_docs
265
 
266
Retro::RlinkCommand& Retro::RlinkCommandList::operator[](size_t ind)
267
{
268
  return *fList.at(ind);
269
}
270
 
271
//------------------------------------------+-----------------------------------
272
//! FIXME_docs
273
 
274
const Retro::RlinkCommand& Retro::RlinkCommandList::operator[](size_t ind) const
275
{
276
  return *fList.at(ind);
277
}
278
 
279
//------------------------------------------+-----------------------------------
280
#if (defined(Retro_NoInline) || defined(Retro_RlinkCommandList_NoInline))
281
#define inline
282
#include "RlinkCommandList.ipp"
283
#undef  inline
284
#endif

powered by: WebSVN 2.1.0

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