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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [src/] [TapActionIRScan.cpp] - Blame information for rev 420

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

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// TAP IR-Scan action: implementation
4
 
5
// Copyright (C) 2009  Embecosm Limited <info@embecosm.com>
6
 
7
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
// This file is part of the Embecosm cycle accurate SystemC JTAG library.
10
 
11
// This program is free software: you can redistribute it and/or modify it
12
// under the terms of the GNU Lesser General Public License as published by
13
// the Free Software Foundation, either version 3 of the License, or (at your
14
// option) any later version.
15
 
16
// This program is distributed in the hope that it will be useful, but WITHOUT
17
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
19
// License for more details.
20
 
21
// You should have received a copy of the GNU Lesser General Public License
22
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 
24
// The C/C++ parts of this program are commented throughout in a fashion
25
// suitable for processing with Doxygen.
26
 
27
// ----------------------------------------------------------------------------
28
 
29
// $Id$
30
 
31
 
32
#include "TapActionIRScan.h"
33
#include "TapStateMachine.h"
34
 
35
 
36
//! Constructor
37
 
38
//! Sets up the superclass with the SystemC completion event and initializes
39
//! our state as appropriate.
40
 
41
//! @param[in] doneEvent  SystemC event to be signalled when this action is
42
//!                       complete.
43
//! @param[in] _iRegIn    The register to shift in.
44
//! @param[in] _iRegSize  Size in bits of the register to shift in.
45
 
46
TapActionIRScan::TapActionIRScan (sc_core::sc_event *_doneEvent,
47
                                  uint32_t           _iRegIn,
48
                                  int                _iRegSize) :
49
  TapAction (_doneEvent),
50
  iRegIn (_iRegIn),
51
  iRegSize (_iRegSize),
52
  iRegOut (0),
53
  bitsShifted (0),
54
  iRScanState (SHIFT_IR_PREPARING)
55
{
56
 
57
}       // TapActionIRScan ()
58
 
59
 
60
//! Process the Shift-IR action
61
 
62
//! This drives the IR-Scan state. We can only do this if we have the TAP
63
//! state machine in a consistent state, which in turn is only possible if we
64
//! have been through a reset cycle.
65
 
66
//! If the state machine shows it has yet to be through a reset cycle, we
67
//! drive that cycle, after issuing a warning. This functionality is provided
68
//! by the parent class, TapAction::.
69
 
70
//! @param[in]  tapStateMachine  The TAP state machine with which this action
71
//!                              is associated. 
72
//! @param[out] tdi              The value to drive on TDI
73
//! @param[in]  tdo              The value currently on TDO
74
//! @param[out] tms              The value to drive on TMS
75
 
76
//! @return  True if the action is complete
77
 
78
bool
79
TapActionIRScan::process (TapStateMachine *tapStateMachine,
80
                          bool            &tdi,
81
                          bool             tdo,
82
                          bool            &tms)
83
{
84
  // Ensure we are in a consistent state. If not then we'll have moved towards
85
  // it and can return with the given tms
86
  if (!checkResetDone (tapStateMachine, tms, true))
87
    {
88
      return false;
89
    }
90
 
91
  // We are consistent, so work through the IR-Scan process
92
  switch (iRScanState)
93
    {
94
    case SHIFT_IR_PREPARING:
95
 
96
      // Are we in the Shift-IR state yet?
97
      if (!tapStateMachine->targetState (TAP_SHIFT_IR, tms))
98
        {
99
          return  false;                // Not there. Accept the TMS value
100
        }
101
      else
102
        {
103
          iRScanState = SHIFT_IR_SHIFTING;      // Drop through
104
        }
105
 
106
    case SHIFT_IR_SHIFTING:
107
 
108
      // Are we still shifting stuff?
109
      if (bitsShifted < iRegSize)
110
        {
111
          // We are in the Shift-IR state. Another bit about to be done, so
112
          // increment the count
113
          bitsShifted++;
114
 
115
          // Shift out the TDI value from the bottom of the register
116
          tdi       = iRegIn & 1;
117
          iRegIn >>= 1;
118
 
119
          // Record the TDO value. This is always a cycle late, so we ignore
120
          // it the first time. The value shifts in from the top.
121
          if (bitsShifted > 1)
122
            {
123
              iRegOut >>= 1;            // Move all the existing bits right
124
 
125
              if (tdo)                  // OR any new bit in
126
                {
127
                  uint32_t tmpBit = 1 << (iRegSize - 1);
128
                  iRegOut |= tmpBit;
129
                }
130
            }
131
 
132
          // TMS is 0 to keep us here UNLESS this is the last bit, in which
133
          // case it is 1 to move us into Exit1-IR.
134
          tms = (bitsShifted == iRegSize);
135
 
136
          return false;
137
        }
138
      else
139
        {
140
          // Capture the last TDO bit
141
          iRegOut >>= 1;                // Move all the existing bits right
142
 
143
          if (tdo)                      // OR any new bit in
144
            {
145
              uint32_t tmpBit = 1 << (iRegSize - 1);
146
              iRegOut |= tmpBit;
147
            }
148
 
149
          iRScanState = SHIFT_IR_UPDATING;      // Drop through
150
        }
151
 
152
    case SHIFT_IR_UPDATING:
153
 
154
      // Are we still trying to update?
155
      if (!tapStateMachine->targetState (TAP_UPDATE_IR, tms))
156
        {
157
          return  false;                // Not there. Accept the TMS value
158
        }
159
      else
160
        {
161
          return  true;                 // All done
162
        }
163
    }
164
}       // process ()
165
 
166
 
167
//! Get the shifted out register
168
 
169
//! @return  The value of the shifted our register
170
 
171
uint32_t
172
TapActionIRScan::getIRegOut ()
173
{
174
  return  iRegOut;
175
 
176
}       // getIRegOut ()
177
 
178
 

powered by: WebSVN 2.1.0

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