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

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [src/] [librlink/] [RlinkCommandExpect.cpp] - Blame information for rev 40

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

Line No. Rev Author Line
1 19 wfjm
// $Id: RlinkCommandExpect.cpp 488 2013-02-16 18:49:47Z mueller $
2 10 wfjm
//
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 15 wfjm
// 2011-11-28   434   1.0.1  Dump(): use proper cast for lp64 compatibility
17 10 wfjm
// 2011-03-12   368   1.0    Initial version
18
// 2011-01-15   355   0.1    First draft
19
// ---------------------------------------------------------------------------
20
 
21
/*!
22
  \file
23 19 wfjm
  \version $Id: RlinkCommandExpect.cpp 488 2013-02-16 18:49:47Z mueller $
24 10 wfjm
  \brief   Implemenation of class RlinkCommandExpect.
25
 */
26
 
27
// debug
28
#include <iostream>
29
 
30
#include <algorithm>
31
 
32
#include "RlinkCommandExpect.hpp"
33
 
34
#include "librtools/RosFill.hpp"
35
#include "librtools/RosPrintf.hpp"
36
#include "librtools/RosPrintBvi.hpp"
37
 
38
using namespace std;
39
 
40
/*!
41
  \class Retro::RlinkCommandExpect
42
  \brief FIXME_docs
43
*/
44
 
45 19 wfjm
// all method definitions in namespace Retro
46
namespace Retro {
47
 
48 10 wfjm
//------------------------------------------+-----------------------------------
49
//! Default constructor
50
 
51
RlinkCommandExpect::RlinkCommandExpect()
52
  : fStatusVal(0),
53
    fStatusMsk(0xff),
54
    fDataVal(0),
55
    fDataMsk(0xffff),
56
    fBlockVal(),
57
    fBlockMsk()
58
{}
59
 
60
//------------------------------------------+-----------------------------------
61
//! FIXME_docs
62
 
63
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk)
64
  : fStatusVal(stat),
65
    fStatusMsk(statmsk),
66
    fDataVal(0),
67
    fDataMsk(0xffff),
68
    fBlockVal(),
69
    fBlockMsk()
70
{}
71
 
72
//------------------------------------------+-----------------------------------
73
//! FIXME_docs
74
 
75
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
76
                                       uint16_t data, uint16_t datamsk)
77
  : fStatusVal(stat),
78
    fStatusMsk(statmsk),
79
    fDataVal(data),
80
    fDataMsk(datamsk),
81
    fBlockVal(),
82
    fBlockMsk()
83
{}
84
 
85
//------------------------------------------+-----------------------------------
86
//! FIXME_docs
87
 
88
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
89
                                       const std::vector<uint16_t>& block)
90
  : fStatusVal(stat),
91
    fStatusMsk(statmsk),
92
    fDataVal(0),
93
    fDataMsk(0xffff),
94
    fBlockVal(block),
95
    fBlockMsk()
96
{}
97
 
98
//------------------------------------------+-----------------------------------
99
//! FIXME_docs
100
 
101
RlinkCommandExpect::RlinkCommandExpect(uint8_t stat, uint8_t statmsk,
102
                                       const std::vector<uint16_t>& block,
103
                                       const std::vector<uint16_t>& blockmsk)
104
  : fStatusVal(stat),
105
    fStatusMsk(statmsk),
106
    fDataVal(0),
107
    fDataMsk(0xffff),
108
    fBlockVal(block),
109
    fBlockMsk(blockmsk)
110
{}
111
 
112
//------------------------------------------+-----------------------------------
113
//! Destructor
114
 
115
RlinkCommandExpect::~RlinkCommandExpect()
116
{}
117
 
118
//------------------------------------------+-----------------------------------
119
//! FIXME_docs
120
 
121
bool RlinkCommandExpect::BlockCheck(size_t ind, uint16_t val) const
122
{
123
  if (ind >= fBlockVal.size()) return true;
124
  uint16_t eval = fBlockVal[ind];
125
  uint16_t emsk = (ind < fBlockMsk.size()) ? fBlockMsk[ind] : 0x0000;
126
  return (val|emsk) == (eval|emsk);
127
}
128
 
129
//------------------------------------------+-----------------------------------
130
//! FIXME_docs
131
 
132
size_t RlinkCommandExpect::BlockCheck(const uint16_t* pval, size_t size) const
133
{
134
  size_t nerr = 0;
135
  for (size_t i=0; i<size; i++) {
136
    if (i >= fBlockVal.size()) break;
137
    uint16_t eval = fBlockVal[i];
138
    uint16_t emsk = (i < fBlockMsk.size()) ? fBlockMsk[i] : 0x0000;
139
    if ((pval[i]|emsk) != (eval|emsk)) nerr += 1;
140
  }
141
 
142
  return nerr;
143
}
144
 
145
//------------------------------------------+-----------------------------------
146
//! FIXME_docs
147
 
148
bool RlinkCommandExpect::BlockIsChecked(size_t ind) const
149
{
150
  if (ind >= fBlockVal.size()) return false;
151
  if (ind >= fBlockMsk.size()) return true;
152
  return fBlockMsk[ind] != 0xffff;
153
}
154
 
155
//------------------------------------------+-----------------------------------
156
//! FIXME_docs
157
 
158
void RlinkCommandExpect::Dump(std::ostream& os, int ind, const char* text) const
159
{
160
  RosFill bl(ind);
161
  os << bl << (text?text:"--") << "RlinkCommandExpect @ " << this << endl;
162
 
163
  os << bl << "  fStatusVal:     " << RosPrintBvi(fStatusVal,0) << endl;
164
  os << bl << "  fStatusMsk:     " << RosPrintBvi(fStatusMsk,0) << endl;
165
  os << bl << "  fDataVal:       " << RosPrintBvi(fDataVal,0) << endl;
166
  os << bl << "  fDataMsk:       " << RosPrintBvi(fDataMsk,0) << endl;
167
  os << bl << "  fBlockVal.size: " << RosPrintf(fBlockVal.size(),"d",3) << endl;
168
  os << bl << "  fBlockMsk.size: " << RosPrintf(fBlockMsk.size(),"d",3) << endl;
169
  if (fBlockVal.size() > 0) {
170
    os << bl << "  fBlockVal & Msk data: ";
171
    size_t width = (fBlockMsk.size()>0) ? 9 : 4;
172 15 wfjm
    size_t ncol  = max(((size_t) 1), (80-ind-4-5)/(width+1));
173 10 wfjm
    for (size_t i=0; i< fBlockVal.size(); i++) {
174
      if (i%ncol == 0) os << "\n" << bl << "    " << RosPrintf(i,"d",3) << ": ";
175
 
176
      os << RosPrintBvi(fBlockVal[i],16);
177
      if (fBlockMsk.size()>0) {
178
        if (i<fBlockMsk.size() && fBlockMsk[i]!=0x0000) {
179
          os << "," <<  RosPrintBvi(fBlockMsk[i],16);
180
        } else {
181
          os << "     ";
182
        }
183
      }
184
      os << " ";
185
    }
186
    os << endl;
187
  }
188
 
189
  return;
190
}
191
 
192 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.