opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[prim/rtl] prim_packer creates feedback loop when interfacing to FIFO

Open mwbranstad opened this issue 6 years ago • 15 comments

After some analysis, it appears that the prim_packer module can not conveniently hook up to a feeding FIFO. In other words, a feedback loop is created when trying to gate the valid_i with the output ready_o. I have instructions from @eunchan to expressly not do this, but this is not user friendly. Instead, the output from the internal packer space counter should be provided as an output as a potential fix. When full (count is max, and based on flops), the result of that count can be used directly to gate the packer write signal (valid_i). Please consider this feature. Otherwise, external logic will need to be added to do this same function.

mwbranstad avatar Jul 28 '20 15:07 mwbranstad

Hey Mark, Just so I understand, what is the reason you want to gate valid_i and not use the valid / ready handshake upstream to know that information from a feeding FIFO should not be popped? Am I understanding this correctly?

On Tue, Jul 28, 2020 at 8:53 AM mwbranstad [email protected] wrote:

After some analysis, it appears that the prim_packer module can not conveniently hook up to a feeding FIFO. In other words, a feedback loop is created when trying to gate the valid_i with the output ready_o. I have instructions from @eunchan https://github.com/eunchan to expressly not do this, but this is not user friendly. Instead, the output from the internal packer space counter should be provided as an output as a potential fix. When full (count is max, and based on flops), the result of that count can be used directly to gate the packer write signal (valid_i). Please consider this feature. Otherwise, external logic will need to be added to do this same function.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/3000, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RST2KZK7TR37SC4STITR53X6FANCNFSM4PKVIOZA .

tjaychen avatar Jul 28 '20 16:07 tjaychen

@tjaychen correct! The prim FIFO operates this way, for example.

mwbranstad avatar Jul 28 '20 16:07 mwbranstad

sorry Mark, I think i didn't state this correctly. I'm asking why we would need to gate the valid vs using the condition of valid / ready to pop the upstream fifo?

On Tue, Jul 28, 2020 at 9:32 AM mwbranstad [email protected] wrote:

@tjaychen https://github.com/tjaychen correct! The prim FIFO operates this way, for example.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/3000#issuecomment-665143608, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSWA6YVR7WLKDNLVEU3R534TBANCNFSM4PKVIOZA .

tjaychen avatar Jul 29 '20 02:07 tjaychen

@tjaychen here is my view of this: the prim_packer module is actually quite useful in the function it provides. However, I am used to a fifo flow and related controls. Having feedback signals breaks this model I believe. It could be that the prim_packer was specifically design for a certain flow (maybe high performance) that requires this capability. I was expecting this behavior: 1 - ready_o is asserted (packer is empty) 2 - valid_i is pulsed for N times, where N is full 3 - valid_o asserts on cycle N; if ready_i is asserted, valid_o de-asserts next cycle, else remains asserted and ready_o de-asserts next cycle The above behavior is like the prim_fifo, where there is a 1 clock cycle delay from input to output of the fifo, and no direct control pass-through paths. Again, if this module was designed for a certain usage, I can certainly add external logic to get around the feedback issue. just thought is this were a common problem, all users might benefit from a logic change to remove this potential loop case.

mwbranstad avatar Jul 29 '20 14:07 mwbranstad

Thanks Mark. Actually what you described is exactly how I would expect prim packer to behave. Eunchan can you confirm? What are you seeing the packer do instead..?

On Wed, Jul 29, 2020 at 7:02 AM mwbranstad [email protected] wrote:

@tjaychen https://github.com/tjaychen here is my view of this: the prim_packer module is actually quite useful in the function it provides. However, I am used to a fifo flow and related controls. Having feedback signals breaks this model I believe. It could be that the prim_packer was specifically design for a certain flow (maybe high performance) that requires this capability. I was expecting this behavior: 1 - ready_o is asserted (packer is empty) 2 - valid_i is pulsed for N times, where N is full 3 - valid_o asserts on cycle N; if ready_i is asserted, valid_o de-asserts next cycle, else remains asserted and ready_o de-asserts next cycle The above behavior is like the prim_fifo, where there is a 1 clock cycle delay from input to output of the fifo, and no direct control pass-through paths. Again, if this module was designed for a certain usage, I can certainly add external logic to get around the feedback issue. just thought is this were a common problem, all users might benefit from a logic change to remove this potential loop case.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/3000#issuecomment-665682839, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAH2RSVQ6KDXCCZ4S2WRS7TR6ATVPANCNFSM4PKVIOZA .

tjaychen avatar Jul 29 '20 14:07 tjaychen

Already changed the original setup. Working on re-creating this.

mwbranstad avatar Jul 29 '20 16:07 mwbranstad

@tjaychen I could not get the prim_packer to work as I would have expected it to work. So, after adding an external "depth" counter, I got the timings that I wanted - timing diagram attached. However, I get the following assert to fire and have notidea how to avoid:

image Packer

mwbranstad avatar Jul 29 '20 20:07 mwbranstad

Hi @mwbranstad I just want to double check: are you trying to downsize using prim_packer? is your InW > OutW, if so, I think the current prim_packer might not fully support this case. I filed an issue here https://github.com/lowRISC/opentitan/issues/2446. Just wonder if you encountered the similar issue?

Thanks, Cindy

cindychip avatar Jul 29 '20 20:07 cindychip

Hi @cindychip - yes, going from 128 bits to 32 bits. The waveform shows this working functionally, but the assert may not handle this case. Can this assert be commented out until it has been tested? Otherwise it bombs out the test run currently.

mwbranstad avatar Jul 30 '20 01:07 mwbranstad

Sure if this is only an assertion issue. I will try to fix it soon then. Sorry for the inconveniences.

Cindy

On Wed, Jul 29, 2020, 6:37 PM mwbranstad [email protected] wrote:

Hi @cindychip https://github.com/cindychip - yes, going from 128 bits to 32 bits. The waveform shows this working functionally, but the assert may not handle this case. Can this assert be commented out until it has been tested? Otherwise it bombs out the test run currently.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/3000#issuecomment-666026951, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACXPOOJIRR2Y3KPKUNXYTZDR6DFG3ANCNFSM4PKVIOZA .

cindychip avatar Jul 30 '20 02:07 cindychip

Thanks @cindychip. I believe that it is only an assertion issue.

@tjaychen - back to the functional issues of prim_packer. I see that there are 3 options to proceed: 1 - added a packer_full signal (based on a flop count), which when inverted can be used as "ready" for the upstream FIFO. 2 - create a "prim_packer2" that has prim_fifo_sync controls 3 - Do as I have in the attached waveform, and just add external logic to do this function Please advise on your preference. Thanks.

mwbranstad avatar Jul 30 '20 13:07 mwbranstad

I think I need to review the prim_packer design again. Maybe I forgot the assumption on the behavior of prim_packer.

As far as I know, prim_packer is designed to have max(InW, OutW) storage inside. So basically, it is not FIFO. It is bridge to FIFO. In order to make it in the way @mwbranstad describe, it should have full storage of (InW + OutW) and the valid_o asserts at least one cycle after valid_i.

If we want FIFO behavior, it would be better to have another packer module (maybe prim_packer_fifo?)

eunchan avatar Jul 30 '20 18:07 eunchan

@eunchan that makes sense to me (my option 2 from above). If it would be helpful, I will offer making a simple version, one that does not support masking and uses the minimum storage possible. Let me know. Thanks.

mwbranstad avatar Jul 30 '20 18:07 mwbranstad

Thanks @mwbranstad More than welcome for the contribution :)

On 7/30/20 11:58 AM, mwbranstad wrote:

@eunchan https://github.com/eunchan that makes sense to me (my option 2 from above). If it would be helpful, I will offer making a simple version, one that does not support masking and uses the minimum storage possible. Let me know. Thanks.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lowRISC/opentitan/issues/3000#issuecomment-666602763, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJDG3TYC3FELLJ3XACHZSTR6G7E7ANCNFSM4PKVIOZA.

eunchan avatar Jul 30 '20 19:07 eunchan

A PR has been made to include the new "prim_packer_fifo" and related documentation. It has also been included as a used module in entropy_src rtl.

mwbranstad avatar Aug 04 '20 16:08 mwbranstad