2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
|
|
|
|
2016-08-19 18:46:43 +02:00
|
|
|
package rocketchip
|
|
|
|
|
|
|
|
import Chisel._
|
2016-11-16 03:27:52 +01:00
|
|
|
import uncore.devices._
|
2016-08-19 18:46:43 +02:00
|
|
|
import junctions._
|
2016-09-28 06:27:07 +02:00
|
|
|
import util._
|
2016-11-18 23:05:14 +01:00
|
|
|
import config._
|
2016-08-19 23:01:33 +02:00
|
|
|
|
|
|
|
case object IncludeJtagDTM extends Field[Boolean]
|
2016-08-19 18:46:43 +02:00
|
|
|
|
|
|
|
/* JTAG-based Debug Transport Module
|
|
|
|
* and synchronization logic.
|
|
|
|
*
|
|
|
|
* This implements JTAG interface described
|
|
|
|
* in the RISC-V Debug Specification
|
|
|
|
*
|
2016-09-26 20:10:27 +02:00
|
|
|
* This Module is currently a
|
|
|
|
* wrapper around a JTAG implementation
|
|
|
|
* of the Debug Transport Module.
|
|
|
|
* This is black-boxed because
|
2016-08-19 18:46:43 +02:00
|
|
|
* Chisel doesn't currently support:
|
|
|
|
* - Negative Edge Clocking
|
|
|
|
* - Asynchronous Resets
|
|
|
|
* (The tristate requirements of JTAG are exported from the
|
|
|
|
* Chisel domain with the DRV_TDO signal).
|
2016-09-26 20:10:27 +02:00
|
|
|
*
|
|
|
|
* The 'TRST' input is used to asynchronously
|
|
|
|
* reset the Debug Transport Module and the
|
|
|
|
* DTM side of the synchronizer.
|
|
|
|
* This design requires that TRST be
|
|
|
|
* synchronized to TCK (for de-assert) outside
|
|
|
|
* of this module. Your top level code should ensure
|
|
|
|
* that TRST is asserted before the rocket-chip core
|
|
|
|
* comes out of reset.
|
|
|
|
* Note that TRST is an optional
|
|
|
|
* part of the JTAG protocol, but it is not
|
|
|
|
* optional for interfacing with this logic.
|
2016-08-19 18:46:43 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-11-26 03:10:28 +01:00
|
|
|
class JtagDTMWithSync(implicit val p: Parameters) extends Module {
|
2016-09-26 20:10:27 +02:00
|
|
|
// io.DebugBusIO <-> Sync <-> DebugBusIO <-> UInt <-> DTM Black Box
|
2016-08-19 18:46:43 +02:00
|
|
|
|
|
|
|
val io = new Bundle {
|
2016-11-16 03:27:52 +01:00
|
|
|
val jtag = new JTAGIO(true).flip
|
|
|
|
val debug = new AsyncDebugBusIO
|
2016-08-19 18:46:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-16 03:27:52 +01:00
|
|
|
val req_width = io.debug.req.mem(0).getWidth
|
|
|
|
val resp_width = io.debug.resp.mem(0).getWidth
|
2016-08-19 18:46:43 +02:00
|
|
|
|
2016-11-26 03:10:28 +01:00
|
|
|
val jtag_dtm = Module(new DebugTransportModuleJtag(req_width, resp_width))
|
2016-10-05 07:28:56 +02:00
|
|
|
jtag_dtm.io.jtag <> io.jtag
|
2016-08-19 18:46:43 +02:00
|
|
|
|
|
|
|
val io_debug_bus = Wire (new DebugBusIO)
|
2016-11-26 03:10:28 +01:00
|
|
|
io.debug <> ToAsyncDebugBus(io_debug_bus)
|
2016-08-19 18:46:43 +02:00
|
|
|
|
2016-11-26 03:10:28 +01:00
|
|
|
val dtm_req = jtag_dtm.io.dtm_req
|
|
|
|
val dtm_resp = jtag_dtm.io.dtm_resp
|
2016-08-19 18:46:43 +02:00
|
|
|
|
|
|
|
// Translate from straight 'bits' interface of the blackboxes
|
|
|
|
// into the Resp/Req data structures.
|
|
|
|
io_debug_bus.req.valid := dtm_req.valid
|
|
|
|
io_debug_bus.req.bits := new DebugBusReq(p(DMKey).nDebugBusAddrSize).fromBits(dtm_req.bits)
|
|
|
|
dtm_req.ready := io_debug_bus.req.ready
|
|
|
|
|
|
|
|
dtm_resp.valid := io_debug_bus.resp.valid
|
|
|
|
dtm_resp.bits := io_debug_bus.resp.bits.asUInt
|
|
|
|
io_debug_bus.resp.ready := dtm_resp.ready
|
|
|
|
}
|
|
|
|
|
|
|
|
class DebugTransportModuleJtag(reqSize : Int, respSize : Int)(implicit val p: Parameters) extends BlackBox {
|
|
|
|
val io = new Bundle {
|
2016-09-02 03:38:39 +02:00
|
|
|
val jtag = new JTAGIO(true).flip()
|
2016-08-19 18:46:43 +02:00
|
|
|
val dtm_req = new DecoupledIO(UInt(width = reqSize))
|
|
|
|
val dtm_resp = new DecoupledIO(UInt(width = respSize)).flip()
|
|
|
|
}
|
|
|
|
}
|