Refactor package hierarchy. (#25)
[sifive-blocks.git] / src / main / scala / devices / gpio / JTAG.scala
1 // See LICENSE for license details.
2 package sifive.blocks.devices.gpio
3
4 import Chisel._
5
6 // ------------------------------------------------------------
7 // SPI, UART, etc are with their
8 // respective packages,
9 // This file is for those that don't seem to have a good place
10 // to put them otherwise.
11 // ------------------------------------------------------------
12
13 import freechips.rocketchip.config._
14 import freechips.rocketchip.jtag.{JTAGIO}
15
16 class JTAGPinsIO(hasTRSTn: Boolean = true) extends Bundle {
17
18 val TCK = new GPIOPin()
19 val TMS = new GPIOPin()
20 val TDI = new GPIOPin()
21 val TDO = new GPIOPin()
22 val TRSTn = if (hasTRSTn) Option(new GPIOPin()) else None
23
24 }
25
26 class JTAGGPIOPort(hasTRSTn: Boolean = true)(implicit p: Parameters) extends Module {
27
28 val io = new Bundle {
29 // TODO: make this not hard-coded true.
30 val jtag = new JTAGIO(hasTRSTn)
31 val pins = new JTAGPinsIO(hasTRSTn)
32 }
33
34 io.jtag.TCK := GPIOInputPinCtrl(io.pins.TCK, pue = Bool(true)).asClock
35 io.jtag.TMS := GPIOInputPinCtrl(io.pins.TMS, pue = Bool(true))
36 io.jtag.TDI := GPIOInputPinCtrl(io.pins.TDI, pue = Bool(true))
37 io.jtag.TRSTn.foreach{t => t := GPIOInputPinCtrl(io.pins.TRSTn.get, pue = Bool(true))}
38
39 GPIOOutputPinCtrl(io.pins.TDO, io.jtag.TDO.data)
40 io.pins.TDO.o.oe := io.jtag.TDO.driven
41 }