OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 63 Rev 462
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
 
 
// TAP action header: abstract class implementation
// TAP action header: abstract class implementation
 
 
// Copyright (C) 2009  Embecosm Limited <info@embecosm.com>
// Copyright (C) 2009  Embecosm Limited <info@embecosm.com>
 
 
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
 
 
// This file is part of the Embecosm cycle accurate SystemC JTAG library.
// This file is part of the Embecosm cycle accurate SystemC JTAG library.
 
 
// This program is free software: you can redistribute it and/or modify it
// This program is free software: you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
// under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or (at your
// the Free Software Foundation, either version 3 of the License, or (at your
// option) any later version.
// option) any later version.
 
 
// This program is distributed in the hope that it will be useful, but WITHOUT
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
// License for more details.
// License for more details.
 
 
// You should have received a copy of the GNU Lesser General Public License
// You should have received a copy of the GNU Lesser General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
// The C/C++ parts of this program are commented throughout in a fashion
// The C/C++ parts of this program are commented throughout in a fashion
// suitable for processing with Doxygen.
// suitable for processing with Doxygen.
 
 
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
 
 
// $Id$
// $Id$
 
 
#include <iostream>
#include <iostream>
 
 
#include "TapAction.h"
#include "TapAction.h"
 
 
class  sc_event;
class sc_event;
 
 
 
 
//! Constructor
//! Constructor
 
 
//! Records the SystemC event used to notify completion and sets the
//! Records the SystemC event used to notify completion and sets the
//! resetCounter to zero.
//! resetCounter to zero.
 
 
//! @param _actionType  The action type
//! @param _actionType  The action type
 
 
TapAction::TapAction (sc_core::sc_event *_doneEvent) :
TapAction::TapAction (sc_core::sc_event *_doneEvent) :
  doneEvent (_doneEvent),
doneEvent(_doneEvent), resetCounter(0)
  resetCounter (0)
 
{
{
 
 
}       // TapAction ()
}                               // TapAction ()
 
 
 
 
//! Accessor to get the SystemC completion event
//! Accessor to get the SystemC completion event
 
 
//! @return  The SystemC completion event
//! @return  The SystemC completion event
 
 
sc_core::sc_event *
sc_core::sc_event * TapAction::getDoneEvent()
TapAction::getDoneEvent ()
 
{
{
  return  doneEvent;
        return doneEvent;
 
 
}       // getDoneEvent ()
}                               // getDoneEvent ()
 
 
 
 
//! Function to check the TAP is in a consistent state, optionally with a
//! Function to check the TAP is in a consistent state, optionally with a
//! warning.
//! warning.
 
 
//! This is a convenience for subclasses (hence protected), so they can ensure
//! This is a convenience for subclasses (hence protected), so they can ensure
//! the state machine is in a consistent state.
//! the state machine is in a consistent state.
 
 
//! @note The method returns TRUE to indicate that the machine is in the
//! @note The method returns TRUE to indicate that the machine is in the
//!       consistent state. However the TapStateMachine resetDone flag is set
//!       consistent state. However the TapStateMachine resetDone flag is set
//!       when the final TMS is set - the state will only be reached IF that
//!       when the final TMS is set - the state will only be reached IF that
//!       TMS is driven. This mechanism gives users flexibility. They can
//!       TMS is driven. This mechanism gives users flexibility. They can
//!       detect the final TMS being driven.
//!       detect the final TMS being driven.
 
 
//! @param[in]  tapStateMachine  The TAP state machine with which we are
//! @param[in]  tapStateMachine  The TAP state machine with which we are
//!                              associated.
//!                              associated.
//! @param[out] tms              The value to drive on the JTAG TMS
//! @param[out] tms              The value to drive on the JTAG TMS
//! @param[in]  warn             True to indicate a warning message should be
//! @param[in]  warn             True to indicate a warning message should be
//!                              issued when starting a reset cycle.
//!                              issued when starting a reset cycle.
 
 
//! @return  TRUE if the TAP state machine was already in a consistent state.
//! @return  TRUE if the TAP state machine was already in a consistent state.
 
 
bool
bool TapAction::checkResetDone(TapStateMachine * tapStateMachine,
TapAction::checkResetDone (TapStateMachine *tapStateMachine,
                               bool & tms, bool warn)
                           bool            &tms,
 
                           bool             warn)
 
{
{
  // Nothing more to do if we are consistent
  // Nothing more to do if we are consistent
  if (tapStateMachine->getResetDone ())
        if (tapStateMachine->getResetDone()) {
    {
 
      return  true;
      return  true;
    }
    }
 
 
  // Need to reset. If requested and this is the first cycle of reset, give a
  // Need to reset. If requested and this is the first cycle of reset, give a
  // warning.
  // warning.
  if (warn && (0 == resetCounter))
        if (warn && (0 == resetCounter)) {
    {
                std::cerr << "JTAG TAP state inconsistent: resetting" <<
      std::cerr << "JTAG TAP state inconsistent: resetting" << std::endl;
                    std::endl;
    }
    }
 
 
  // Drive towards reset
  // Drive towards reset
  resetCounter++;
        resetCounter++;
  tms = 1;
        tms = 1;
 
 
  // If we have got to the end of the reset sequence we can clear the
        // If we have got to the end of the reset sequence we can clear the
  // tapStateMachine and report we are consistent. However we will not return
        // tapStateMachine and report we are consistent. However we will not return
  // true until the next call.
  // true until the next call.
  if (tapStateMachine->TAP_RESET_CYCLES == resetCounter)
        if (tapStateMachine->TAP_RESET_CYCLES == resetCounter) {
    {
 
      tapStateMachine->setResetDone (true);
      tapStateMachine->setResetDone (true);
      resetCounter = 0;                          // Ready for next time
      resetCounter = 0;                          // Ready for next time
    }
        } else {
  else
 
    {
 
      return false;
      return false;
    }
        }
}       // checkResetDone ()
}                               // checkResetDone ()
 
 

powered by: WebSVN 2.1.0

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