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

Do we really need to wait until ReadWrite to apply writes if writes are inertial? #3544

Open
ktbarrett opened this issue Nov 29, 2023 · 2 comments · May be fixed by #3875
Open

Do we really need to wait until ReadWrite to apply writes if writes are inertial? #3544

ktbarrett opened this issue Nov 29, 2023 · 2 comments · May be fixed by #3875
Labels
category:codebase:handle relating to handles or handle types (BinaryValue) category:codebase:scheduler relating to cocotb's coroutine scheduler, triggers, and coroutine objects

Comments

@ktbarrett
Copy link
Member

Title says it all. I think we could get rid of the ReadWrite stage writing of values and let inertial writes happen as they otherwise would. This would increase performance noticeably (1.5~2x I would think).

@marlonjames
Copy link
Contributor

marlonjames commented Nov 29, 2023

I think this could cause subtle changes in behavior.
Timer is triggered early in the time step, before processes are run, and doing the writes at that time might change behavior, but I haven't looked at the event models in a while.

I wouldn't be against adding a setting that lets users switch to your proposed behavior.

@marlonjames marlonjames added category:codebase:scheduler relating to cocotb's coroutine scheduler, triggers, and coroutine objects category:codebase:handle relating to handles or handle types (BinaryValue) labels Nov 29, 2023
@ktbarrett
Copy link
Member Author

ktbarrett commented Mar 18, 2024

Timer is triggered early in the time step, before processes are run

So this would mean that writes applied by cocotb would be applied after the Timer callback and before the processes run, allowing them to be "seen" by processes? That would be less than ideal. IMO cocotb tasks should be treated as more or less parallel to processes in HDLs.

But applying writes at the beginning of the ReadWrite stage means that cocotb tasks that operate directly after those writes in that ReadWrite stage aren't operating on the outcome of processes or cocotb tasks that applied writes in the previous "pseudo process execution" cycle.

It seems there should be the following behavior.

  1. Run HDL processes
  2. Run cocotb "normal" stage
  3. Apply non-blocking/signal writes from stage 1.
  4. Apply .value signal writes from stage 2.
  5. Run cocotb ReadWrite stage. Repeat from 3.
  6. Run cocotb ReadOnly stage.
  7. Progress simulation time to next time step. Repeat from 1.

The order of 1 and 2 shouldn't matter (it will matter, but we can't guarantee anything. Just don't depend on forced or blocking/variable assigned objects). 3 doesn't matter the order of cocotb or HDL (well, same as before).

Is there any way to accomplish this with the timing model available to all the procedural interfaces?

@ktbarrett ktbarrett linked a pull request May 1, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:codebase:handle relating to handles or handle types (BinaryValue) category:codebase:scheduler relating to cocotb's coroutine scheduler, triggers, and coroutine objects
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants