From 11601c336526f5b15587d45895048def4d8114a3 Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Wed, 3 Mar 2021 15:44:51 -0700 Subject: [PATCH] continue work on gear box --- gearbox.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gearbox.py b/gearbox.py index fb3b65e..a82bc01 100755 --- a/gearbox.py +++ b/gearbox.py @@ -86,7 +86,23 @@ class ArbitraryGearbox(Elaboratable): # 2) there are in_width invalid bits in front of the write_ptr + # There are multiple cases for read_ptr and write_ptr: + # read_ptr < write_ptr. Here, the valid bits do not wrap, the invalid bits wrap. + # The valid bits are: inclusive [read_ptr, write_ptr) exclusive + # the invalid bits are inclusive [write_ptr, K) exclusive, union with inclusive [0, read_ptr) exclusive + + + # write_ptr < read_ptr. Here, the valid bits wrap, and the invalid bits do not wrap. + # The valid bits are: inclusive [read_ptr, K) exclusive, union with inclusive [0, write_ptr) exclusive + # the invalid bits are inclusive [write_ptr, read_ptr) exclusive + + # Naturally, there is a tricky edge case which requires an extra bit (literally) of disambiguation. + # If write_ptr == read_ptr we don't know if the buffer is entirely full or entirely empty. + + # If the last operation was a read, and we find write_ptr == read_ptr, we know it's empty + # If the last operation was a write, and we find write_ptr == read_ptr, we know it's full + return m -- GitLab