kuznia-rdzeni / coreblocks

RISC-V out-of-order core for education and research purposes
https://kuznia-rdzeni.github.io/coreblocks/
BSD 3-Clause "New" or "Revised" License
35 stars 13 forks source link

[RFC] Non blocking if #488

Open lekcyjna123 opened 11 months ago

lekcyjna123 commented 11 months ago

I create this issue, to allow for brainstorm how to implement non blocking if in transactron. Lets take:

with Transaction().body(m):
   with m.If(m, cond):
      method(m)

In current implementation we always block method if transaction is called regardless of cond. We would like to not block method is cond is false.

The easy implementation idea is to calculate runnable signal for each pair of (transaction, method) using:

runnable = enable.implies(ready)

Where enable is signal pointing if transaction want to run method and ready say us if method is ready.

Above idea works as long as:

Lets say:

with Transaction().body(m):
   cond=method1(m, in_data1)
   with m.If(m, cond):
      method2(m)

Now we can consider two cases:


To summarise. We have to decide how to handle if-s which depends from methods whose output depends on input. Some propositions:

All other propositions are welcome.

lekcyjna123 commented 11 months ago

If we had quasi-register, which store high till the end of the cycle, we could implement iterable algorithm in one cycle, but this will make critical path very long...

module circuit(input in1, clk, output out1);
  assign out1 = (in1 | out1) & clk;
endmodule
lekcyjna123 commented 11 months ago

We can split above problem into two:

tilk commented 11 months ago

If we had quasi-register, which store high till the end of the cycle, we could implement iterable algorithm in one cycle, but this will make critical path very long...

Please, no crazy clock manipulation. Pure synchronous logic only.

lekcyjna123 commented 10 months ago

After our Monday talk with @piotro888 I decided to make a short verification in how many places we have method call under m.If which depends on other method output:

This results are based on simple grep for "m.If" on the whole coreblocks directory and checking if we have method calls under this "m.If" (or its "m.Else" branch). Results are promising in my opinion. In 11 places we have possibility to optimise blocking of methods, while only 6 places can not be optimised.

tilk commented 10 months ago

Did you check if there is even any benefit of trying to optimize them in this way? If some method is called in only one place, there is absolutely no harm in blocking it.