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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 63 julius
// ----------------------------------------------------------------------------
2
 
3
// Main module providing the JTAG interface: 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
#include "JtagSC.h"
32
 
33
 
34
SC_HAS_PROCESS( JtagSC );
35
 
36
//! Constructor for the JTAG handler.
37
 
38
//! @param[in] name       Name of this module, passed to the parent
39
//!                       constructor. 
40
//! @param[in] fifo_size  Size of the FIFO on which to queue TAP actions.
41
 
42
JtagSC::JtagSC (sc_core::sc_module_name  name,
43
                int                      fifo_size) :
44
  sc_module (name),
45
  currentTapAction (NULL)
46
{
47
  tapActionQueue = new sc_core::sc_fifo<TapAction *> (fifo_size);
48
  stateMachine   = new TapStateMachine ();
49
 
50
  SC_METHOD (processActions);
51
  sensitive << tck.pos ();
52
 
53
}       // JtagSC ()
54
 
55
 
56
//! Destructor for the JTAG handler.
57
 
58
//! Give up our state machine and FIFO
59
 
60
JtagSC::~JtagSC ()
61
{
62
  delete  stateMachine;
63
  delete  tapActionQueue;
64
 
65
}       // ~JtagSC ()
66
 
67
 
68
//! Method to drive the jtag ports.
69
 
70
//! Initial version just drives the reset.
71
 
72
void
73
JtagSC::processActions()
74
{
75
  // TRST is driven as the inverse of the system reset
76
  trst = !sysReset;
77
 
78
  // Do nothing else if in CPU reset (active high)
79
  if (sysReset)
80
    {
81
      return;
82
    }
83
 
84
  // Functions setting the outputs will need bools (they are not generally
85
  // SystemC modules, so don't handle the likes of sc_in<> correctly).
86
  bool  tdi_o;
87
  bool  tms_o;
88
 
89
  // Try to get an action if we don't have one
90
  if (NULL == currentTapAction)
91
    {
92
      if (false == tapActionQueue->nb_read (currentTapAction))
93
        {
94
          // Nothing there, so head for Run-Test/Idle state.
95
          stateMachine->targetState (TAP_RUN_TEST_IDLE, tms_o);
96
          tms  = tms_o;
97
 
98
          return;
99
        }
100
    }
101
 
102
  // Process the action, notifying the originator when done.
103
 
104
  if (currentTapAction->process (stateMachine, tdi_o, tdo, tms_o))
105
    {
106
      currentTapAction->getDoneEvent()->notify();
107
      currentTapAction = NULL;
108
    }
109
 
110
  // Select the new TAP state
111
  stateMachine->nextState (tms_o);
112
 
113
  // Drive the signal ports
114
  tdi  = tdi_o;
115
  tms  = tms_o;
116
 
117
}       // processActions()

powered by: WebSVN 2.1.0

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