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

JTAG VPI Simulation gets blocked by IO #1349

Closed
rpls opened this issue Mar 12, 2024 · 2 comments · Fixed by #1350
Closed

JTAG VPI Simulation gets blocked by IO #1349

rpls opened this issue Mar 12, 2024 · 2 comments · Fixed by #1350

Comments

@rpls
Copy link
Contributor

rpls commented Mar 12, 2024

I recently switched my VexRiscv simulation to the official RISC-V JTAG and JTAG VPI as a network interface and was wondering why the simulation suddenly is excruciatingly slow. Turns out, that the JTAG VPI implementation has a blocking IO call in its main loop. Line 81, i.e., the readFully call is blocking. Since it's executed in a SimThread the simulation gets blocked. In practice, its not fully blocked, since a connected OpenOCD on the VPI port will send regular packages, so the simulation just becomes really slow.

while (this.synchronized(connection) != null) {
try {
inputStream.readFully(buffer)
val vpiCmd = deserializeVpiCmd(buffer)

A trivial fix would be to do a while loop that waits until enough bytes are present in the input buffer, the more elegant fix would probably to do some proper asynchronous IO (e.g., incremental non-blocking reading of VpiCmd packages).

@Dolu1990
Copy link
Member

Hi ^^

For the PR; let's me know when you think it isn't draft :)

Note, i also recently added https://github.com/SpinalHDL/SpinalHDL/blob/composable-exp/lib/src/main/scala/spinal/lib/com/jtag/sim/JtagRemote.scala#L23
Which is in regular openocd

@rpls
Copy link
Contributor Author

rpls commented Mar 16, 2024

For the PR; let's me know when you think it isn't draft :)

I wanted to run some more tests. Played around with a network-thread (Proper thread, not SimThread), that does all the networking, parsing etc. and just passes the VpiCmds.... turns out to be a lot slower. But I'm no Java/Scala Networking Programmer, so I might just have messed it up. Anyway, let's leave it as-is.

Note, i also recently added https://github.com/SpinalHDL/SpinalHDL/blob/composable-exp/lib/src/main/scala/spinal/lib/com/jtag/sim/JtagRemote.scala#L23
Which is in regular openocd

Also a nice option! I'll test which is faster for my use-case.

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