-
Notifications
You must be signed in to change notification settings - Fork 31
Incorrect BlackBoxes input values changes #116
Comments
Taking a look at this. I can't really tell what's going on with our situation. |
Hi @chick, thank you for your interest in this issue. -------- @PosEdge -------
Queue: b5
change on [din] : b5
change on [wr_en] : 1
change on [din] : 1d7
change on [wr_en] : 1
change on [din] : 1d7
change on [wr_en] : 1
-------- @PosEdge -------
Queue: 1d7
ff_inst Dequeue: 2ca
change on [din] : 1d7
change on [wr_en] : 1
change on [din] : 196
change on [wr_en] : 0
change on [din] : 196
change on [wr_en] : 0
-------- @PosEdge -------
change on [din] : 196
change on [wr_en] : 0
change on [din] : 182
change on [wr_en] : 0
change on [din] : 182
change on [wr_en] : 0
-------- @PosEdge -------
ff_inst Dequeue: 117
change on [din] : 182
change on [wr_en] : 0
change on [din] : 29d
change on [wr_en] : 0
change on [din] : 29d
change on [wr_en] : 0
-------- @PosEdge -------
change on [din] : 29d
change on [wr_en] : 0
change on [din] : 77
change on [wr_en] : 1
change on [din] : 77
change on [wr_en] : 1
-------- @PosEdge -------
Queue: 77
change on [din] : 77
change on [wr_en] : 1
change on [din] : 2b6
change on [wr_en] : 0
change on [din] : 2b6
change on [wr_en] : 0 I suspect that the issue comes from treadle struggling with the interpretation of my big host module. |
I just added you as a collaborator on a private repo of mine where I tried
to get a version of what you provide to run.
It currently runs and passes for me, but I really don't know if this is
meaningful.
Please take a look and let me know what you think
I added some notes in the README.md
Hopefully it is at least a step in the right direction.
Chick Markley
Staff Programmer -- Adept Lab
University of California, Berkeley
583-2 Soda Hall, Berkeley, CA 94720-1776
[email protected]
…On Fri, Aug 2, 2019 at 1:23 AM johnsbrew ***@***.***> wrote:
Hi @chick <https://github.com/chick>, thank you for your interest in this
issue.
Here is the scala blackbox file :
https://gist.github.com/johnsbrew/c4b0ce91b30a7b3097589331eccd258d
I have also attached the test file for the module. Unfortunately this test
does not trigger the bug described above (as far as I have seen).
I get results as shown below that are precisely what I would have expected
-------- @Posedge -------
Queue: b5
change on [din] : b5
change on [wr_en] : 1
change on [din] : 1d7
change on [wr_en] : 1
change on [din] : 1d7
change on [wr_en] : 1
-------- @Posedge -------
Queue: 1d7
ff_inst Dequeue: 2ca
change on [din] : 1d7
change on [wr_en] : 1
change on [din] : 196
change on [wr_en] : 0
change on [din] : 196
change on [wr_en] : 0
-------- @Posedge -------
change on [din] : 196
change on [wr_en] : 0
change on [din] : 182
change on [wr_en] : 0
change on [din] : 182
change on [wr_en] : 0
-------- @Posedge -------
ff_inst Dequeue: 117
change on [din] : 182
change on [wr_en] : 0
change on [din] : 29d
change on [wr_en] : 0
change on [din] : 29d
change on [wr_en] : 0
-------- @Posedge -------
change on [din] : 29d
change on [wr_en] : 0
change on [din] : 77
change on [wr_en] : 1
change on [din] : 77
change on [wr_en] : 1
-------- @Posedge -------
Queue: 77
change on [din] : 77
change on [wr_en] : 1
change on [din] : 2b6
change on [wr_en] : 0
change on [din] : 2b6
change on [wr_en] : 0
I suspect that the issue comes from treadle struggling with the
interpretation of my big host module.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#116>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAHBMV3XJP4PF4EDVE3RWSTQCPVIRANCNFSM4IIQ4PTQ>
.
|
Hi @chick, sorry for the delay and thank you very much for taking some time to dig into this issue. inst.sip_ff.clock <=1 h1
inst.sip_ff.io_din <=103204489060824933097 h598400000002862e9
change on [din] : 598400000002862e9
inst.sip_ff.ff_inst.clk <=1 h1
-------- @PosEdge -------
inst.sip_ff.ff_inst : clock inst.sip_ff.ff_inst.clk state (PositiveEdge) This ring a bell (clock propagation through ff_inst) about the way I wrapped my blackbox (in a Module and not ExtModule as you. Please find my version below, do you see anything obviously wrong ? import chisel3._
import chisel3.util._
import chisel3.experimental._
import collection.mutable.{Queue}
class FallthroughFifoBlackBox[T <: Record](params: Map[String, Param], ios: T) extends BlackBox(params) with HasBlackBoxResource {
val io = IO(ios)
// required to match actual verilog module name
override def desiredName = "fallthrough_fifo"
// main verilog file
addResource("/fallthrough_fifo.sv")
// dependencies
addResource("/small_fifo.sv")
}
class FallthroughFifo(
val WIDTH : Int,
val MAX_DEPTH : Int,
val LOW_LATENCY : Boolean = false,
val NEARLY_FULL_THRESH : Option[Int] = None,
val FORCE_ULTRARAM : Boolean = false
) extends Module {
// Constructor: process parameters
var params : Map[String, Param] = Map(
"WIDTH" -> WIDTH,
"LOW_LATENCY" -> LOW_LATENCY,
"MAX_DEPTH" -> MAX_DEPTH,
"USE_AVAILABLE_SLOT" -> true,
"FORCE_ULTRARAM" -> FORCE_ULTRARAM
)
NEARLY_FULL_THRESH match {
case Some(i) => params += ("NEARLY_FULL_THRESH" -> i)
case None => // default : hardware behaviour
}
/* FallthroughFifoIO
* Defines IOs to be shared between wrapper & black-box
* Intra class definition to avoid to pass params
*/
class FallthroughFifoIO extends Bundle {
val wr_en = Input(Bool())
val din = Input(UInt(WIDTH.W))
val rd_en = Input(Bool())
val dout = Output(UInt(WIDTH.W))
val full = Output(Bool())
val nearly_full = Output(Bool())
val empty = Output(Bool())
val available_slots = Output(UInt(log2Up(MAX_DEPTH).W+1.W))
}
val io = IO(new FallthroughFifoIO())
// > Additional Black-box IOs (clock & reset)
class FallthroughFifoBlackBoxIO extends FallthroughFifoIO {
val clk = Input(Clock())
}
// Instanciate blackbox
val ff_inst = Module(new FallthroughFifoBlackBox(params, new FallthroughFifoBlackBoxIO()))
// Connections:
// > special case for clock (NB: and reset if any)
ff_inst.io.clk <> clock
// > automated for all forwarded IOs
for((i_name, i) <- io.elements){
ff_inst.io.elements(i_name) <> i
}
} |
I don't see anything obviously wrong. Treadle's order is done off of a topological sort of the symbol dependencies. There could be some problems there. The scala black boxes have not been used a whole lot (let alone on complicated/interesting designs). There could be some problems in there. I am planning on adding a capability of adding VCD events from internal events within the scala black box. That might provide better clues to possible implementation errors. If you think that might help I can up the priority there. Cheers |
Hi @chick, As far as I understood, the root cause is somehow linked with the fact that clock signals are treated as standard signals with combinational assigns to one another.
Considering the current case with:
This leads in-the-end to the current issue:
Issue: why clock assign is interleaved with register update events? It looks like it should take priority over register changes. Concerning the VCD events for internal black-box events, it might be useful somehow but it would not be a strong request from my side. As illustrated here, VCD waves do not prove 100% reliable when debugging clock-related issues versus combinational events ordering (everything looks fine on the waves for the current issue). I cannot invest much more time on this for now by I will stay tuned on treadle updates. Let me know if you try something :) |
Thanks for putting out the effort there.
|
As far as clock assignments: The order of clock assignments as ordinary connects could be the problem but I am not sure about that. In Firrtl it is possible to make any single bit wire become a |
I will continue poking around, and I certainly understand you are busy. When you get chance can you consider these questions.
|
Hi,
I am running into an issue with a simple fallthrough fifo black-boxing.
I have a complex module with many fifos which pass successfully its test with verilator.
Test crashes with treadle backend and demonstrates an unexpected behavior: in the blackbox scala implementation, the data input
din
changes just before clock posedge...Here is the partial scala context for reference
Here is what I get on the waves (just as expected)
Here is what I get when I add some debug print in the black box implementation (not what I expect, and thus inconsistent with the waves)
Personal thoughts:
wr_en
&din
are changing multiple times within a single step ?wr_en
&din
do not behave in the same way ?Could it be due to the cast of my custom Bundle
Req
as UInt ?@chick , any idea ?
The text was updated successfully, but these errors were encountered: