Using Clocks in Sparta #475
Replies: 2 comments 2 replies
-
Hi @klingaard appreciate your help answering our questions! |
Beta Was this translation helpful? Give feedback.
-
Hi Timothy, appreciate the questions! I agree this part of the simulation infrastructure is not very clear. I'll use this discussion to shed light on it and hopefully find the time to properly document it. First, you are correct in understanding that the Clock's main purpose is to be a "calculator" for event scheduling. This is especially critical for disparate clock domains like a core talking to a memory subsystem via If you're interested in just 1 clock domain, you don't need to do anything with ClockManager or perform any clock creation. Just work under the assumption that 1 ps == 1 cycle and move on. This is how the example CoreModel works as well as the RISC-V perf model Olympia. But that's not your use case 😁. For your use case, I'll assume something simple: that you need to create two clocks, each on its own frequency. In this case you use the Clocks that are associated with a
Because of this rule you cannot set the clock during the finalizing (or construction) phase of simulation. Specifically, you cannot set the clock in the constructor of your Unit or Resource because it's quite possible that the sub-components ( But you'd like to parameterize the clocks... Clocks can be created and associated with a map/sparta/example/CoreModel/src/ExampleSimulation.cpp Lines 748 to 749 in 64e119f For example (using extensions):
Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Greetings,
We are setting up new internal models using Sparta. One thing that is confusing us is the Clock facility in Sparta. Can we get some getting started guidance? They appear to have all the features we need, but I haven't been able to actually instantiate and assign them as the "default" clock to our models.
I'm building clocks based on parameters in the model, in the model class constructor. I can create the clock like so:
(The "10" and "6" would normally be parameters).
However, if I attempt to set them as the clock for the model's resource, as so:
we get an error:
That setClock call seems to be the way that schedule(...) type operations get a hold of the default clock to use to interpret scheduling delays. That's what we are after.
The model constructor is the soonest we have access to the model parameters (as far as we know), and the soonest we can run model-specific code (against, as far as we know). So I don't understand how we can setup model-specific clocks any earlier than this.
What is the expected process or intended usage model here? I've seen the documentation on Clocking that I've been able to find, but details are still sketchy for me.
Regards,
Timothy
Beta Was this translation helpful? Give feedback.
All reactions