Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WishboneSlaveFactory - doWrite is never called in pipelined mode #1310

Open
janschiefer opened this issue Feb 13, 2024 · 3 comments · May be fixed by #1375
Open

WishboneSlaveFactory - doWrite is never called in pipelined mode #1310

janschiefer opened this issue Feb 13, 2024 · 3 comments · May be fixed by #1375

Comments

@janschiefer
Copy link

It may be totally possible that I am completely and utterly wrong...

but I have been playing with WishboneSlaveFactory and and noticed some odd behaviour:

  • When driving WishboneSlaveFactory from a master in "classic" mode everything works fine.

  • However, when I try a "single write operation" in Wishbone B4 pipelined mode with a cycle according to specification, the data is never written to the register. In fact the internal signal "askWrite" is fired, but the signal "doWrite" is never activated.

image

Wishbone specification B4:
image

If I extend the STB-Pulse one more cycle - which is not according to the specification - "doWrite" is called and the register is successfully written:

image

The problem seems to be, that SpinalHDL Lib's wishbone implementation also expects STB to be high in the cycle when ACK is received. However, the specification requires STB only to be high in the cycle before ACK when in pipelined mode:

image

My WB Slave test code:

package tangBusTest

import spinal.core._
import spinal.lib._
import spinal.lib.bus.wishbone._

// Hardware definition
case class WishboneLed(wb_config: WishboneConfig) extends Component {
  val io = new Bundle {
    val leds_out = out Bits (8 bits)
    val wb_bus = slave(Wishbone(wb_config))
  }

  val slave_factory = WishboneSlaveFactory(io.wb_bus)

  if (wb_config.useERR) io.wb_bus.ERR := False

  val leds_reg = slave_factory.createReadWrite(Bits(8 bits), address = 0x08, bitOffset = 0)

  val test_read_reg = slave_factory.read(U(value = 112, 8 bits), address = 0x16, bitOffset = 0)

  io.leds_out := leds_reg

}

object WishboneLed {}

I hope, I have found a valid issue and not wasted your time.

@janschiefer
Copy link
Author

Versions:
ThisBuild / scalaVersion := "2.12.18"
val spinalVersion = "1.10.1"
Java version: OpenJDK Runtime Environment Temurin-17.0.10+7 (build 17.0.10+7)

@andreasWallner
Copy link
Collaborator

andreasWallner commented Feb 14, 2024

Thanks for the extensive report!

I had a look at the Wishbone spec and I'd also say that this looks wrong - I'll have a bit more of a look tomorrow though because I've not looked at wishbone in a long time.
It looks to me like the WishboneDrivers sendPipelinedBlockAsMaster does the right thing though and the pipelined config is tested as well, we'll have to have a looks what going on there.

@andreasWallner
Copy link
Collaborator

Yes, I can confirm that this is wrong, I was curious why our tests did not pick this up... looks to me like they were not finished back in 2018, they don't verify that the register was really written...
If you want to open a PR you're welcome, otherwise I can have a look end of this week.

@jdavidberger jdavidberger linked a pull request Mar 26, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants