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

task execution capability #58

Open
redxeth opened this issue Jan 31, 2023 · 3 comments
Open

task execution capability #58

redxeth opened this issue Jan 31, 2023 · 3 comments
Assignees

Comments

@redxeth
Copy link
Member

redxeth commented Jan 31, 2023

Add ability to OrignSim to be able to execute a task from the compiled RTL.

e.g.

def call_my_func
  tester.call "test.dut.my_ip.my_block.my_func", 1
end

I dont mind helping to work on it- just wondering if anyone has any advice or particulars they care about.

@ginty
Copy link
Member

ginty commented Feb 1, 2023

There's no way to do that so elegantly I'm afraid.
Origen Sim uses the Verilog VPI interface to communicate with the DUT and there is no way to call a task from that.
There is another interface called the DPI which gets closer - you can't call a task directly from that but it will let you call a C function on the design side which in turn calls the task.
However the work on the OrigenSim side to enable that is likely not trivial and I have no experience of using the DPI.

So even with the DPI you would need to create a C wrapper, but you could also create a Verilog wrapper and use that with existing Origen Sim.
Basically the VPI only allows you to peek and poke at netlist nodes and so I would create a wrapper like this (in pidgin RTL):

reg call_my_task;
reg [15:0] my_task_arg;

always @ posedge call_my_task {
  #my_task(my_task_arg);
}

I haven't written RTL in a while and I forget if you can pass args to tasks like that, hopefully you can.

Then in your Origen code you could do:

def call_my_func(my_arg)
  tester.poke "my_task_arg", my_arg
  tester.poke "call_my_task", 0
  tester.poke "call_my_task", 1
end

call_my_func(0x55)

I would put the Verilog wrappers in their own file and include that into the Origen Sim build, I forget how but I'm sure Origen Sim supports that already.

You can imagine if you had a list of task signatures (like a header file) you could create a script to automatically generate the Verilog and Ruby wrappers for them.

@coreyeng may have other thoughts/experience on this...

@coreyeng
Copy link
Member

coreyeng commented Feb 1, 2023

I have on my to-do list to add this to O2's version. Essentially, it'd work like CATI where there's known functions built in and signals are toggled to kick off the commands.

In the meantime, you can build a task in with an always block to repeatedly monitor a signal and poke that signal (poking arg values beforehand) and launch that way.

The only downside is the tasks must be compiled in during the snapshot build. No adding tasks dynamically. The DPI had the illusion of that but I when I looked further into it, it still needed to be compiled at the outset. It was closer to linking a static library than what it let on (at least back in 2017 when I was looking into it and discussing solely with Cadence - maybe its better now).

As said though, this is on my to-do list for O2.

@redxeth
Copy link
Member Author

redxeth commented Feb 8, 2023

Thanks @ginty and @coreyeng ! I'm still trying to get my head around how OrigenSim even works-- didn't know that there were 2 things, DPI vs VPI. I thought I saw something online about being able to execute tasks. Anyway, I think having the task in the snapshot build is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants