Skip to content

Commit bdf3723

Browse files
authored
Merge pull request #1956 from ucb-bar/jtag_reset_external
Support externally-driven separate JTAG reset pin
2 parents 1fc865a + 161fbeb commit bdf3723

File tree

6 files changed

+25
-13
lines changed

6 files changed

+25
-13
lines changed

fpga/src/main/scala/arty/HarnessBinders.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class WithArtyJTAGHarnessBinder extends HarnessBinder({
3434
port.io.TCK := jtag_wire.TCK
3535
port.io.TMS := jtag_wire.TMS
3636
port.io.TDI := jtag_wire.TDI
37+
port.io.reset.foreach(_ := th.referenceReset)
3738

3839
val io_jtag = Wire(new JTAGPins(() => new BasePin(), false)).suggestName("jtag")
3940

fpga/src/main/scala/arty100t/HarnessBinders.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,12 @@ class WithArty100TPMODUART extends WithArty100TUART("G2", "F3")
126126
class WithArty100TJTAG extends HarnessBinder({
127127
case (th: HasHarnessInstantiators, port: JTAGPort, chipId: Int) => {
128128
val ath = th.asInstanceOf[LazyRawModuleImp].wrapper.asInstanceOf[Arty100THarness]
129-
val harnessIO = IO(chiselTypeOf(port.io)).suggestName("jtag")
130-
harnessIO <> port.io
129+
val harnessIO = IO(new JTAGChipIO(false)).suggestName("jtag")
130+
harnessIO.TDO := port.io.TDO
131+
port.io.TCK := harnessIO.TCK
132+
port.io.TDI := harnessIO.TDI
133+
port.io.TMS := harnessIO.TMS
134+
port.io.reset.foreach(_ := th.referenceReset)
131135

132136
ath.sdc.addClock("JTCK", IOPin(harnessIO.TCK), 10)
133137
ath.sdc.addGroup(clocks = Seq("JTCK"))
@@ -138,6 +142,7 @@ class WithArty100TJTAG extends HarnessBinder({
138142
("E2", IOPin(harnessIO.TDI)),
139143
("D4", IOPin(harnessIO.TDO))
140144
)
145+
141146
packagePinsWithPackageIOs foreach { case (pin, io) => {
142147
ath.xdc.addPackagePin(io, pin)
143148
ath.xdc.addIOStandard(io, "LVCMOS33")

fpga/src/main/scala/vcu118/HarnessBinders.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class WithJTAG extends HarnessBinder({
4343
port.io.TCK := jtag_io.TCK
4444
port.io.TMS := jtag_io.TMS
4545
port.io.TDI := jtag_io.TDI
46+
port.io.reset.foreach(_ := th.referenceReset)
4647
jtag_io.TDO.data := port.io.TDO
4748
jtag_io.TDO.driven := true.B
4849
// ignore srst_n

generators/chipyard/src/main/scala/example/FlatChipTop.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class FlatChipTop(implicit p: Parameters) extends LazyModule with HasChipyardPor
131131
require(!debug.clockeddmi.isDefined)
132132
require(!debug.apb.isDefined)
133133
val (jtag_pad, jtagIOCells) = debug.systemjtag.map { j =>
134-
val jtag_wire = Wire(new JTAGChipIO)
134+
val jtag_wire = Wire(new JTAGChipIO(false))
135135
j.jtag.TCK := jtag_wire.TCK
136136
j.jtag.TMS := jtag_wire.TMS
137137
j.jtag.TDI := jtag_wire.TDI

generators/chipyard/src/main/scala/harness/HarnessBinders.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class WithSimJTAGDebug extends HarnessBinder({
187187
port.io.TCK := jtag_wire.TCK
188188
port.io.TMS := jtag_wire.TMS
189189
port.io.TDI := jtag_wire.TDI
190+
port.io.reset.foreach(_ := th.harnessBinderReset.asBool)
190191
val jtag = Module(new SimJTAG(tickDelay=3))
191192
jtag.connect(jtag_wire, th.harnessBinderClock, th.harnessBinderReset.asBool, ~(th.harnessBinderReset.asBool), dtm_success)
192193
}
@@ -205,6 +206,7 @@ class WithTiedOffJTAG extends HarnessBinder({
205206
port.io.TCK := true.B.asClock
206207
port.io.TMS := true.B
207208
port.io.TDI := true.B
209+
port.io.reset.foreach(_ := true.B)
208210
}
209211
})
210212

generators/chipyard/src/main/scala/iobinders/IOBinders.scala

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,18 @@ class WithExtInterruptIOCells extends OverrideIOBinder({
288288
})
289289

290290
// Rocketchip's JTAGIO exposes the oe signal, which doesn't go off-chip
291-
class JTAGChipIO extends Bundle {
291+
class JTAGChipIO(hasReset: Boolean) extends Bundle {
292292
val TCK = Input(Clock())
293293
val TMS = Input(Bool())
294294
val TDI = Input(Bool())
295295
val TDO = Output(Bool())
296+
val reset = Option.when(hasReset)(Input(Bool()))
296297
}
297298

298299
// WARNING: Don't disable syncReset unless you are trying to
299300
// get around bugs in RTL simulators
300-
class WithDebugIOCells(syncReset: Boolean = true) extends OverrideLazyIOBinder({
301+
// If externalReset, exposes a reset in through JTAGChipIO, which is sync'd to TCK
302+
class WithDebugIOCells(syncReset: Boolean = true, externalReset: Boolean = true) extends OverrideLazyIOBinder({
301303
(system: HasPeripheryDebug) => {
302304
implicit val p = GetSystemParameters(system)
303305
val tlbus = system.asInstanceOf[BaseSubsystem].locateTLBusWrapper(p(ExportDebug).slaveWhere)
@@ -319,13 +321,6 @@ class WithDebugIOCells(syncReset: Boolean = true) extends OverrideLazyIOBinder({
319321
}
320322
// Tie off disableDebug
321323
d.disableDebug.foreach { d => d := false.B }
322-
// Drive JTAG on-chip IOs
323-
d.systemjtag.map { j =>
324-
j.reset := (if (syncReset) ResetCatchAndSync(j.jtag.TCK, clockBundle.reset.asBool) else clockBundle.reset.asBool)
325-
j.mfr_id := p(JtagDTMKey).idcodeManufId.U(11.W)
326-
j.part_number := p(JtagDTMKey).idcodePartNum.U(16.W)
327-
j.version := p(JtagDTMKey).idcodeVersion.U(4.W)
328-
}
329324
}
330325
Debug.connectDebugClockAndReset(Some(debug), clockBundle.clock)
331326

@@ -336,7 +331,15 @@ class WithDebugIOCells(syncReset: Boolean = true) extends OverrideLazyIOBinder({
336331
}
337332

338333
val jtagTuple = debug.systemjtag.map { j =>
339-
val jtag_wire = Wire(new JTAGChipIO)
334+
val jtag_wire = Wire(new JTAGChipIO(externalReset))
335+
336+
// Drive JTAG on-chip IOs
337+
val jReset = if (externalReset) jtag_wire.reset.get else clockBundle.reset.asBool
338+
j.reset := (if (syncReset) ResetCatchAndSync(j.jtag.TCK, jReset) else jReset)
339+
j.mfr_id := p(JtagDTMKey).idcodeManufId.U(11.W)
340+
j.part_number := p(JtagDTMKey).idcodePartNum.U(16.W)
341+
j.version := p(JtagDTMKey).idcodeVersion.U(4.W)
342+
340343
j.jtag.TCK := jtag_wire.TCK
341344
j.jtag.TMS := jtag_wire.TMS
342345
j.jtag.TDI := jtag_wire.TDI

0 commit comments

Comments
 (0)