1

A user has a register in a bank implementing a read method through the io_memory interface. The memory operation is served by a memory link returning Sim_PE_Stall_Cpu on the first attempt. At first glance, he doesn’t see a way to propagate the stall exception upwards.

The main question:

How could he forward the stall exception to the caller of the register operation so it can retry?

More details:

Here is a piece of the read method he wants to implement:

method read() {
    ex=$io_memory.operation(&mop,info);
    if(ex==SIM_PE_Stall_Cpu )
        **# What to do here to inform the reader about the stall?**
}

I have also attached the following file with pseudo-code to understand better what he wants to get in his DML: stall-sample.dml

Looking at the attached DML script, the customer has two devices. Here are more details about what the customer wants:

Device 1:

  • To implement a read method from which it is possible to check if Sim_PE_Stall_Cpu occurs on Device 2.

Device 2:

  • To implement a before_read method, including a mechanism to enable Device 1 to see the stall when Sim_PE_Stall_Cpu is gotten on Device 2.
  • To implement a read method where it’s possible to get Sim_PE_Stall_Cpu from a memory link.
  • To forward the stall exception to the caller of the register operation so it can retry.

I checked the content of the pci-device source files, but there is nothing to be considered useful for the use case described by the user.

I’d appreciate any suggestions on this topic.

Thanks,

-JC

Erik Carstensen
  • 634
  • 4
  • 14
Juan Cruz
  • 21
  • 2
  • This sounds remarkably like homework or an exam question. See [How do I ask and answer homework questions?](https://meta.stackoverflow.com/q/334822/128421). Also, your question doesn't do a good job of meeting the requirements for SO. Please see "[ask]", "[Stack Overflow question checklist](https://meta.stackoverflow.com/questions/260648)" and "[mre]" and all their linked pages. – the Tin Man May 11 '23 at 22:14
  • This is a valid reasonable basic DML question and it gets into some of the deeper aspects of how DML integrates with Simics. – jakobengblom2 Jul 07 '23 at 09:42

1 Answers1

2

I'm unsure how the Sim_PE_Stall_Cpu mechanism works exactly; the recommended way is to use the new transaction interface instead of io_memory, and use the SIM_transaction_wait function to handle stalled transactions. This requires Simics 6 and DML 1.4.

That said, I'll try to answer the question of how a DML 1.2 device can signal Sim_PE_Stall_Cpu to the initiator: DML 1.2 is hardcoded to return either Sim_PE_No_Exception or SIM_PE_IO_Not_Taken from io_memory.operation (see dml-builtins.dml:bank.io_memory.operation); however, it is possible to attach a different exception to the memop itself by SIM_set_mem_op_exception. If you override read_access instead of read in the register, then you can retrieve the memop through a method arg and set the exception. I don't know if this solves your problem, though; perhaps the CPU looks only at the io_memory.operation return value, disregarding SIM_get_mem_op_exception. In this case, you may need to insert a proxy object between memory-space and bank that converts any set exception to a return value.

But, please keep in mind that whatever code you write for this will have to be rewritten in terms of transaction_t within a few years, so migrating to transaction_t now would likely save you time in the longer term.

Erik Carstensen
  • 634
  • 4
  • 14
  • Hi Erick. That's very helpful information. Thank you very much for your support on this topic. I think we can consider it as solved. – Juan Cruz May 16 '23 at 18:15