I'm working on making an
8b/10b encoder on an FPGA. At first, I followed the general tables along with a
guide to build each module step by step (this is NOT for an assignment, but being unfamiliar with it, I tried to search how to do it online which led me to the guide), but I ran into an issue with testing.
I was testing my running disparity finite-state machine using all possible 10-bit test values as found in the guide's encoding table PDFs, but I noticed that the 10-bit values were way off than what I thought. For example, given D0.0, I assumed the 10-bit value would be "100111_1011" assuming an RD of -1, but the actual value was "100111_0100". That 3b/4b encoding confused me. I did some research, and all other resources showed the same value. Something was off. So, out of desperation, I looked at the IEEE 802.3 Standards and found out about how to calculate running disparity:
Running disparity for a code-group is calculated on the basis of sub-blocks, where the first six bits (abcdei) form one sub-block (six-bit sub-block) and the second four bits (fghj) form the other sub-block (four-bit subblock).
Running disparity at the beginning of the six-bit sub-block is the running disparity at the end of the last code-group.
Running disparity at the beginning of the four-bit sub-block is the running disparity at the end of the six-bit sub-block.
Running disparity at the end of the code-group is the running disparity at the end of the four-bit sub-block.
That in bold is the key. FGHJ is dependent on what you choose for ABCDEI. That was never mentioned at all on Wikipedia or the guide (unless I totally missed it). In light of this, given the attached picture, I was wondering if my assumption was correct? I drew up a little picture showing what I assumed (incorrectly) and what I think is the correct assumption. Is my assumed assumption correct in the bottom of the picture? Admittedly, it feels kind of odd, how the next RD for the next 8-bit data is dependent on the last 4-bits previous 10-bit word. You don't use the full 10-bit word to calculate the next RD? This will definitely change some things around in my VHDL code.