chisel icon indicating copy to clipboard operation
chisel copied to clipboard

Micro-optimization opportunity in Queue

Open aswaterman opened this issue 2 years ago • 0 comments

The current logic for updating the maybe_full flag in Queue is when(do_enq =/= do_deq) { maybe_full := do_enq } (which, incidentally, is the same as maybe_full := majority(maybe_full, do_enq, !do_deq), and indeed, DC synthesizes it that way). However, I'm pretty sure it can be simplified to maybe_full := do_enq || (mabye_full && !do_deq). The proof sketch is that the latter expression differs from the previous ones only when do_enq is true, and in such cases it's impossible for the queue to be empty on the following cycle.

The savings is only one AOI gate, but some designs have tons of queues, and if it's free...

aswaterman avatar Aug 13 '22 07:08 aswaterman