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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [orpsocv2/] [bench/] [sysc/] [src/] [TapActionIRScan.cpp] - Diff between revs 63 and 462

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 63 Rev 462
Line 26... Line 26...
 
 
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
 
 
// $Id$
// $Id$
 
 
 
 
#include "TapActionIRScan.h"
#include "TapActionIRScan.h"
#include "TapStateMachine.h"
#include "TapStateMachine.h"
 
 
 
 
//! Constructor
//! Constructor
 
 
//! Sets up the superclass with the SystemC completion event and initializes
//! Sets up the superclass with the SystemC completion event and initializes
//! our state as appropriate.
//! our state as appropriate.
 
 
Line 43... Line 41...
//! @param[in] _iRegIn    The register to shift in.
//! @param[in] _iRegIn    The register to shift in.
//! @param[in] _iRegSize  Size in bits of the register to shift in.
//! @param[in] _iRegSize  Size in bits of the register to shift in.
 
 
TapActionIRScan::TapActionIRScan (sc_core::sc_event *_doneEvent,
TapActionIRScan::TapActionIRScan (sc_core::sc_event *_doneEvent,
                                  uint32_t           _iRegIn,
                                  uint32_t           _iRegIn,
                                  int                _iRegSize) :
                                 int _iRegSize):TapAction(_doneEvent),
  TapAction (_doneEvent),
 
  iRegIn (_iRegIn),
  iRegIn (_iRegIn),
  iRegSize (_iRegSize),
iRegSize(_iRegSize), iRegOut(0), bitsShifted(0), iRScanState(SHIFT_IR_PREPARING)
  iRegOut (0),
 
  bitsShifted (0),
 
  iRScanState (SHIFT_IR_PREPARING)
 
{
{
 
 
}       // TapActionIRScan ()
}       // TapActionIRScan ()
 
 
 
 
//! Process the Shift-IR action
//! Process the Shift-IR action
 
 
//! This drives the IR-Scan state. We can only do this if we have the TAP
//! This drives the IR-Scan state. We can only do this if we have the TAP
//! state machine in a consistent state, which in turn is only possible if we
//! state machine in a consistent state, which in turn is only possible if we
//! have been through a reset cycle.
//! have been through a reset cycle.
Line 73... Line 66...
//! @param[in]  tdo              The value currently on TDO
//! @param[in]  tdo              The value currently on TDO
//! @param[out] tms              The value to drive on TMS
//! @param[out] tms              The value to drive on TMS
 
 
//! @return  True if the action is complete
//! @return  True if the action is complete
 
 
bool
bool TapActionIRScan::process(TapStateMachine * tapStateMachine,
TapActionIRScan::process (TapStateMachine *tapStateMachine,
                              bool & tdi, bool tdo, bool & tms)
                          bool            &tdi,
 
                          bool             tdo,
 
                          bool            &tms)
 
{
{
  // Ensure we are in a consistent state. If not then we'll have moved towards
  // Ensure we are in a consistent state. If not then we'll have moved towards
  // it and can return with the given tms
  // it and can return with the given tms
  if (!checkResetDone (tapStateMachine, tms, true))
        if (!checkResetDone(tapStateMachine, tms, true)) {
    {
 
      return false;
      return false;
    }
    }
 
 
  // We are consistent, so work through the IR-Scan process
  // We are consistent, so work through the IR-Scan process
  switch (iRScanState)
        switch (iRScanState) {
    {
 
    case SHIFT_IR_PREPARING:
    case SHIFT_IR_PREPARING:
 
 
      // Are we in the Shift-IR state yet?
      // Are we in the Shift-IR state yet?
      if (!tapStateMachine->targetState (TAP_SHIFT_IR, tms))
                if (!tapStateMachine->targetState(TAP_SHIFT_IR, tms)) {
        {
 
          return  false;                // Not there. Accept the TMS value
          return  false;                // Not there. Accept the TMS value
        }
                } else {
      else
 
        {
 
          iRScanState = SHIFT_IR_SHIFTING;      // Drop through
          iRScanState = SHIFT_IR_SHIFTING;      // Drop through
        }
        }
 
 
    case SHIFT_IR_SHIFTING:
    case SHIFT_IR_SHIFTING:
 
 
      // Are we still shifting stuff?
      // Are we still shifting stuff?
      if (bitsShifted < iRegSize)
                if (bitsShifted < iRegSize) {
        {
 
          // We are in the Shift-IR state. Another bit about to be done, so
          // We are in the Shift-IR state. Another bit about to be done, so
          // increment the count
          // increment the count
          bitsShifted++;
          bitsShifted++;
 
 
          // Shift out the TDI value from the bottom of the register
          // Shift out the TDI value from the bottom of the register
          tdi       = iRegIn & 1;
          tdi       = iRegIn & 1;
          iRegIn >>= 1;
          iRegIn >>= 1;
 
 
          // Record the TDO value. This is always a cycle late, so we ignore
          // Record the TDO value. This is always a cycle late, so we ignore
          // it the first time. The value shifts in from the top.
          // it the first time. The value shifts in from the top.
          if (bitsShifted > 1)
                        if (bitsShifted > 1) {
            {
 
              iRegOut >>= 1;            // Move all the existing bits right
              iRegOut >>= 1;            // Move all the existing bits right
 
 
              if (tdo)                  // OR any new bit in
              if (tdo)                  // OR any new bit in
                {
                {
                  uint32_t tmpBit = 1 << (iRegSize - 1);
                  uint32_t tmpBit = 1 << (iRegSize - 1);
                  iRegOut |= tmpBit;
                  iRegOut |= tmpBit;
                }
                }
            }
            }
 
 
          // TMS is 0 to keep us here UNLESS this is the last bit, in which
          // TMS is 0 to keep us here UNLESS this is the last bit, in which
          // case it is 1 to move us into Exit1-IR.
          // case it is 1 to move us into Exit1-IR.
          tms = (bitsShifted == iRegSize);
          tms = (bitsShifted == iRegSize);
 
 
          return false;
          return false;
        }
                } else {
      else
 
        {
 
          // Capture the last TDO bit
          // Capture the last TDO bit
          iRegOut >>= 1;                // Move all the existing bits right
          iRegOut >>= 1;                // Move all the existing bits right
 
 
          if (tdo)                      // OR any new bit in
          if (tdo)                      // OR any new bit in
            {
            {
Line 150... Line 129...
        }
        }
 
 
    case SHIFT_IR_UPDATING:
    case SHIFT_IR_UPDATING:
 
 
      // Are we still trying to update?
      // Are we still trying to update?
      if (!tapStateMachine->targetState (TAP_UPDATE_IR, tms))
                if (!tapStateMachine->targetState(TAP_UPDATE_IR, tms)) {
        {
 
          return  false;                // Not there. Accept the TMS value
          return  false;                // Not there. Accept the TMS value
        }
                } else {
      else
 
        {
 
          return  true;                 // All done
          return  true;                 // All done
        }
        }
    }
    }
}       // process ()
}       // process ()
 
 
 
 
//! Get the shifted out register
//! Get the shifted out register
 
 
//! @return  The value of the shifted our register
//! @return  The value of the shifted our register
 
 
uint32_t
uint32_t TapActionIRScan::getIRegOut()
TapActionIRScan::getIRegOut ()
 
{
{
  return  iRegOut;
  return  iRegOut;
 
 
}       // getIRegOut ()
}       // getIRegOut ()
 
 
 
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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