1 |
63 |
julius |
// ----------------------------------------------------------------------------
|
2 |
|
|
|
3 |
|
|
// SystemC JTAG driver header
|
4 |
|
|
|
5 |
|
|
// Copyright (C) 2008 Embecosm Limited <info@embecosm.com>
|
6 |
|
|
|
7 |
|
|
// Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
8 |
|
|
|
9 |
|
|
// This file is part of the cycle accurate model of the OpenRISC 1000 based
|
10 |
|
|
// system-on-chip, ORPSoC, built using Verilator.
|
11 |
|
|
|
12 |
|
|
// This program is free software: you can redistribute it and/or modify it
|
13 |
|
|
// under the terms of the GNU Lesser General Public License as published by
|
14 |
|
|
// the Free Software Foundation, either version 3 of the License, or (at your
|
15 |
|
|
// option) any later version.
|
16 |
|
|
|
17 |
|
|
// This program is distributed in the hope that it will be useful, but WITHOUT
|
18 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
20 |
|
|
// License for more details.
|
21 |
|
|
|
22 |
|
|
// You should have received a copy of the GNU Lesser General Public License
|
23 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
24 |
|
|
|
25 |
|
|
// ----------------------------------------------------------------------------
|
26 |
|
|
|
27 |
|
|
// $Id: JtagDriverSC.h 317 2009-02-22 19:52:12Z jeremy $
|
28 |
|
|
|
29 |
|
|
#ifndef JTAG_DRIVER_SC__H
|
30 |
|
|
#define JTAG_DRIVER_SC__H
|
31 |
|
|
|
32 |
|
|
#include <stdint.h>
|
33 |
|
|
|
34 |
|
|
#include "systemc"
|
35 |
|
|
|
36 |
64 |
julius |
#include "JtagSC_includes.h"
|
37 |
63 |
julius |
|
38 |
|
|
//! Module providing TAP requests to JTAG
|
39 |
|
|
|
40 |
|
|
//! Provides a queue of requests to the JTAG interface. Requests are at the
|
41 |
|
|
//! level of TAP actions for reset, DR-Scan or IR-Scan.
|
42 |
|
|
|
43 |
462 |
julius |
class JtagDriverSC:public sc_core::sc_module {
|
44 |
63 |
julius |
public:
|
45 |
|
|
|
46 |
462 |
julius |
// Constructor
|
47 |
|
|
JtagDriverSC(sc_core::sc_module_name name,
|
48 |
|
|
sc_core::sc_fifo < TapAction * >*_tapActionQueue);
|
49 |
63 |
julius |
|
50 |
|
|
private:
|
51 |
|
|
|
52 |
462 |
julius |
// JTAG instructions
|
53 |
|
|
static const uint32_t CHAIN_SELECT_IR = 0x3; //!< Chain Select instruction
|
54 |
|
|
static const uint32_t DEBUG_IR = 0x8; //!< Debug instruction
|
55 |
63 |
julius |
|
56 |
462 |
julius |
// JTAG register lengths (excluding CRC)
|
57 |
|
|
static const int JTAG_IR_LEN = 4; //!< JTAG instr reg length
|
58 |
|
|
static const int CHAIN_DR_LEN = 4; //!< Length of DR (excl CRC)
|
59 |
|
|
static const int RISC_DEBUG_DR_LEN = 65; //!< Length of DR (excl CRC)
|
60 |
|
|
static const int REGISTER_DR_LEN = 38; //!< Length of DR (excl CRC)
|
61 |
|
|
static const int WISHBONE_DR_LEN = 65; //!< Length of DR (excl CRC)
|
62 |
63 |
julius |
|
63 |
462 |
julius |
// JTAG register address masks
|
64 |
|
|
static const uint32_t RISC_DEBUG_ADDR_MASK = 0xffffffff; //!< Mask for addr
|
65 |
|
|
static const uint32_t REGISTER_ADDR_MASK = 0x0000001f; //!< Mask for addr
|
66 |
|
|
static const uint32_t WISHBONE_ADDR_MASK = 0xffffffff; //!< Mask for addr
|
67 |
63 |
julius |
|
68 |
462 |
julius |
// JTAG register R/W bit
|
69 |
|
|
static const uint64_t RISC_DEBUG_RW = 0x100000000ULL; //!< R/W bit mask
|
70 |
|
|
static const uint64_t REGISTER_RW = 0x000000020ULL; //!< R/W bit mask
|
71 |
|
|
static const uint64_t WISHBONE_RW = 0x100000000ULL; //!< R/W bit mask
|
72 |
63 |
julius |
|
73 |
462 |
julius |
// JTAG register data field offsets
|
74 |
|
|
static const int RISC_DEBUG_DATA_OFF = 33; //!< Offset to data field
|
75 |
|
|
static const int REGISTER_DATA_OFF = 6; //!< Offset to data field
|
76 |
|
|
static const int WISHBONE_DATA_OFF = 33; //!< Offset to data field
|
77 |
63 |
julius |
|
78 |
462 |
julius |
//! JTAG register data field sizes (all the same)
|
79 |
|
|
static const int DR_DATA_LEN = 32;
|
80 |
63 |
julius |
|
81 |
462 |
julius |
//! CRC length
|
82 |
|
|
static const int CRC_LEN = 8;
|
83 |
63 |
julius |
|
84 |
462 |
julius |
// OpenRISC 1000 scan chains
|
85 |
|
|
static const int OR1K_SC_UNDEF = -1; //!< Undefined OR1K scan chain
|
86 |
|
|
static const int OR1K_SC_RISC_DEBUG = 1; //!< for access to SPRs
|
87 |
|
|
static const int OR1K_SC_REGISTER = 4; //!< to stall/reset CPU
|
88 |
|
|
static const int OR1K_SC_WISHBONE = 5; //!< for memory access
|
89 |
63 |
julius |
|
90 |
462 |
julius |
//! Register addresses for the REGISTER scan chain
|
91 |
|
|
static const uint8_t OR1K_RSC_RISCOP = 0x04; //!< Used to reset/stall CPU
|
92 |
63 |
julius |
|
93 |
462 |
julius |
// Bits for the RISCOP register
|
94 |
|
|
static const uint32_t RISCOP_STALL = 0x00000001; //!< Stall the CPU
|
95 |
|
|
static const uint32_t RISCOP_RESET = 0x00000002; //!< Reset the CPU
|
96 |
63 |
julius |
|
97 |
462 |
julius |
//! The JTAG fifo we queue on
|
98 |
|
|
sc_core::sc_fifo < TapAction * >*tapActionQueue;
|
99 |
63 |
julius |
|
100 |
462 |
julius |
//! The currently selected scan chain
|
101 |
|
|
int currentScanChain;
|
102 |
63 |
julius |
|
103 |
462 |
julius |
// SystemC thread to queue actions
|
104 |
|
|
void queueActions();
|
105 |
63 |
julius |
|
106 |
462 |
julius |
// Or1k JTAG actions
|
107 |
|
|
void reset();
|
108 |
|
|
void selectChain(int chain);
|
109 |
|
|
uint32_t readReg(uint32_t addr);
|
110 |
|
|
uint32_t readReg1(uint32_t addr, int bitSizeNoCrc);
|
111 |
|
|
uint32_t readReg1(uint64_t * dRegArray,
|
112 |
|
|
uint32_t addr, int bitSizeNoCrc);
|
113 |
|
|
void writeReg(uint32_t addr, uint32_t data);
|
114 |
|
|
// Utilities to compute CRC-8 the OpenRISC way. Versions for "big" and
|
115 |
|
|
// "small" numbers.
|
116 |
|
|
uint8_t crc8(uint64_t data, int size);
|
117 |
|
|
uint8_t crc8(uint64_t * dataArray, int size);
|
118 |
63 |
julius |
|
119 |
462 |
julius |
// Utilities to insert and extract bit strings from vectors
|
120 |
|
|
void insertBits(uint64_t str,
|
121 |
|
|
int strLen, uint64_t * array, int startBit);
|
122 |
|
|
uint64_t extractBits(uint64_t * array, int startBit, int strLen);
|
123 |
63 |
julius |
|
124 |
462 |
julius |
}; // JtagDriverSC ()
|
125 |
63 |
julius |
|
126 |
462 |
julius |
#endif // JTAG_DRIVER_SC__H
|