From 6dc413fd11e4287ececa71272e79f7ded4bf2fca Mon Sep 17 00:00:00 2001 From: Craig Bishop Date: Fri, 18 Jul 2025 12:56:00 -0700 Subject: [PATCH 1/3] Add support for sysBus in EmbeddedRiscvJtag --- .../vexriscv/plugin/EmbeddedRiscvJtag.scala | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala b/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala index 1e625b28..a9ee25da 100644 --- a/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala +++ b/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala @@ -16,7 +16,8 @@ class EmbeddedRiscvJtag(var p : DebugTransportModuleParameter, var debugCd : ClockDomain = null, var jtagCd : ClockDomain = null, var withTap : Boolean = true, - var withTunneling : Boolean = false + var withTunneling : Boolean = false, + var withSysBus : Boolean = false ) extends Plugin[VexRiscv] with VexRiscvRegressionArg{ @@ -25,6 +26,7 @@ class EmbeddedRiscvJtag(var p : DebugTransportModuleParameter, var jtag : Jtag = null var jtagInstruction : JtagTapInstructionCtrl = null var ndmreset : Bool = null + var sysBus : DBusSimpleBus = null def setDebugCd(cd : ClockDomain) : this.type = {debugCd = cd; this} @@ -49,8 +51,23 @@ class EmbeddedRiscvJtag(var p : DebugTransportModuleParameter, flen = pipeline.config.FLEN, withFpuRegAccess = pipeline.config.FLEN == 64 )) - ) + ), + withSysBus = withSysBus ) + if (withSysBus) { + sysBus = master(DBusSimpleBus()) + + sysBus.cmd.valid := dm.io.sysBus.cmd.valid + dm.io.sysBus.cmd.ready := sysBus.cmd.ready + sysBus.cmd.payload.wr := dm.io.sysBus.cmd.wr + sysBus.cmd.payload.address := dm.io.sysBus.cmd.address + sysBus.cmd.payload.data := dm.io.sysBus.cmd.data + sysBus.cmd.payload.size := dm.io.sysBus.cmd.size + + dm.io.sysBus.rsp.ready := sysBus.rsp.ready + dm.io.sysBus.rsp.error := sysBus.rsp.error + dm.io.sysBus.rsp.data := sysBus.rsp.data + } ndmreset := dm.io.ndmreset From 56e8264f92510956b82e2dd6be873427b673058a Mon Sep 17 00:00:00 2001 From: Craig Bishop Date: Fri, 18 Jul 2025 13:30:49 -0700 Subject: [PATCH 2/3] Document EmbeddedRiscvJtag system bus support --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index d944c959..db1e71ef 100644 --- a/README.md +++ b/README.md @@ -1465,6 +1465,41 @@ init halt ``` +##### System Bus +The EmbeddedRiscvJtag plugin can also be configured to support system bus accesses per the RISC-V Debug Specification v1.0. This allows memory access without impacting CPU execution and can be handy when a debug host is regularly polling (e.g. RTT logging). + +```scala +new EmbeddedRiscvJtag( + p = DebugTransportModuleParameter( + addressWidth = 7, + version = 1, + idle = 7 + ), + withTunneling = false, + withTap = true, + withSysBus = true +) +``` + +Then connect `sysBus` to your logic just like a data bus (`sysBus` is a `DBusSimpleBus`). + +```scala +var debugSysBus: Axi4Shared = null + +... + +for (plugin <- cpuConfig.plugins) plugin match { + case plugin: EmbeddedRiscvJtag => { + debugSysBus = plugin.sysBus.toAxi4Shared() + } + case _ => +} + +... + +// Connect debugSysBus to a crossbar, etc. +``` + #### YamlPlugin This plugin offers a service to other plugins to generate a useful Yaml file describing the CPU configuration. It contains, for instance, the sequence of instructions required From d2646897ef4e5d209b80a40b113cd6efbab4b961 Mon Sep 17 00:00:00 2001 From: Craig Bishop Date: Fri, 18 Jul 2025 17:05:34 -0700 Subject: [PATCH 3/3] Fix withSysBus param for DebugModule --- src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala b/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala index a9ee25da..2b4051e8 100644 --- a/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala +++ b/src/main/scala/vexriscv/plugin/EmbeddedRiscvJtag.scala @@ -50,9 +50,9 @@ class EmbeddedRiscvJtag(var p : DebugTransportModuleParameter, xlen = XLEN, flen = pipeline.config.FLEN, withFpuRegAccess = pipeline.config.FLEN == 64 - )) + )), + withSysBus = withSysBus ), - withSysBus = withSysBus ) if (withSysBus) { sysBus = master(DBusSimpleBus())