[RFC][Sim] Add declarations and reads for externally controlled configuration bits#10552
[RFC][Sim] Add declarations and reads for externally controlled configuration bits#10552nanjo712 wants to merge 1 commit into
Conversation
…d configuration bits
|
These However, we should avoid introducing this technical debt into the Sim dialect. I see two better alternatives:
|
|
I think I understand the assertion-control direction better now, but I want to clarify one point. In the current FIRRTLToHW lowering, So the existing mechanism allows the macro to expand to a runtime testbench signal, e.g. Then the external runtime control would come from the simulator's assertion control state, not from an injected |
|
I think there are three separate concepts here:
For Supplement: I am not sure |
|
Hi @fzi-hielscher, I'd be interested to hear your thoughts on modeling runtime configuration within the context of Sim dialects. I would greatly appreciate seeing your perspective on this matter. |
|
Sorry for the late reply. I might be more comfortable if this was model was global variable (c.f. llhd.global_signal), not as config. Lowering them to some arc runtime function (for arcilator) or some ABI-defined macro (SV) is certainly ok. WDYT? |
|
I like your idea of providing global registers/variables for simulation that are not tied to a specific simulator mechanism. But the first thing we need to determine is when and how we want to be able to change their value. I can think of three variants:
The way I'm interpreting the operations you have described here, you have been targeting variant (1), right? But apparently the SiFive use-case for the In the case of (2), I agree with @uenoku that it would be even more useful if we had something like probes, allowing us to manipulate generic signals and not only simulation specific ones. |
Yes, basically SiFive uses something like
Yeah I generally oppose something like global variable but I also wonder we need something that can be lowered from |
|
Thanks, this discussion makes me realize that my initial model was too narrow. My original mental model was that With that in mind, I agree that a probe-like mechanism seems to be the better lower-level abstraction. It makes the problem somewhat larger, but I think it is probably the right layer to solve this. One possible direction could be something like: hw.hierpath @path_to_reset_phase ...
hw.hierpath @path_to_done_reset ...
sim.global_signal @STOP_COND : i1 {
%reset_phase = hw.probe.read @path_to_reset_phase : i1
%done_reset = hw.probe.read @path_to_done_reset : i1
%true = hw.constant true
%not_reset_phase = comb.xor %reset_phase, %true : i1
%stop_cond = comb.and %not_reset_phase, %done_reset : i1
sim.yield %stop_cond : i1
}
%stop_cond = sim.global_signal.read @STOP_COND : i1
%exit_cond = comb.and %stop_cond, %local_cond : i1
sim.clocked_terminate %clock, %exit_cond {success = ...}Here, I would initially keep this read-only. Extending this to writes / force / release seems to introduce significantly more complicated same-time-step ordering and mutation semantics, and I do not think that is necessary for the For This would structurally model the current macro behavior when the macro expands to an expression over probe-able testbench/harness signals. For compatibility, the SV backend could still lower unresolved or ABI-defined hooks to the existing macro path where needed, but the structured probe/global-expression form seems like the cleaner Core-level abstraction. Look forward to your feedback, thanks! |
|
That makes sense to me. I suppose It is probably not what @uenoku had in mind, though? I've never really looked into how FIRRTL probes work, so I don't know if they can provide a better solution here. |
|
I think sim.global_signal looks good for representing global variables in Sim (as long as @fzi-hielscher agrees). However, I still think FIRRTL's SSA-based representation works better for Arc probes. I'd prefer to stick with sim.global_signal for now and avoid widening the scope to include hierarchical path-based probe operations. |
I think we need a mechanism to replace some of the functionality of the SV macros in FIRRTLToHW. From my observation, STOP_COND and PRINTF_COND behave like configurations that allow external injection, and I want to introduce this abstraction into the Sim dialect.
I've implemented a preliminary approach to naming and designing this Op.