XOR Parity Generator

Thread Starter

ctishman

Joined Oct 12, 2011
9
Hey folks. I've got a question about XOR-based parity generators. Perhaps I'm misunderstanding the concept of a parity generator, but from what I read, the generator evaluates the outgoing data and determines whether or not to prepend/append a 1 or 0 in the parity bit. The example they give in my book (Kleitz – Digital Electronics 9th Edition) shows both even and odd parity generators.



The issue I'm having is with running examples in my head. Let's take a 4-bit parity generator checking a binary 5. 0101 feeds into the generator. Each of the first-level XOR2s gets both a zero and a 1 and as a result spits out a 1. The final XOR2 receives two 1s as a result and thus gives a 0, doesn't it? That doesn't make sense in my head because if it's an even-parity generator, shouldn't the result be a 1 so that the parity generated is even?
 

Thread Starter

ctishman

Joined Oct 12, 2011
9
Okay. I solved my own issue, but I'll lay out what I figured out for future seekers.

What I thought was going on
I thought the parity generator was interpreting the binary data and converting it to base-10, then checking if that number was even or odd.

What is really going on
It's just counting up the number of 1s in a given chunk of data and determining whether there's an even number of 1s or an odd number of 1s. It doesn't actually read the binary data at all.

Examples, using a four-bit, even-parity generator:

For reference, the XOR gate's truth table. Reference this if things don't make sense:
A | B | X
0 | 0 | 0
0 | 1 | 1
1 | 0 | 1
1 | 1 | 0

First Example: 0110
First off, note that we have an even number of 1s, so if everything works out right, the parity bit should be a 0 because you don't have to do anything more to make the result even.

The first layer of gates receive a 01 and a 10 respectively. Since they're XOR gates, they each output a 1.

The third gate receives two 1s. Since it too is an XOR gate, it outputs a 0.

We got a 0 for our parity bit. We win.


Second Example: 0111
Note that we have an odd number of 1s. The result should be a 1, because that's what you need to make the result even.

The first XOR gate receives a 01. Just like last time, it spits out a 1. Its partner receives a 11, which outputs a 0. Okay, so on down to our third and final gate. We've got a 1 and a 0 going in, and as a result, we get a 1 as our parity bit, evening it out.
We win again!

Okay, hope that helps people! If things don't make sense, Bill Kleitz (the author of the textbook) has posted lectures for every single chapter to Youtube. It's incredible. Here's the link to his lecture on Parity
 
Last edited:

WBahn

Joined Mar 31, 2012
30,076
I'm glad you solved your own problem and didn't just wait around for the answer to be handed to you. That's particular good in this case because it might have taken a while for us to tumble to the fact that you were thinking in terms of the "value" being even or odd and not the number of 1s in the pattern.
 

Thread Starter

ctishman

Joined Oct 12, 2011
9
It turns out that others in my class had problems with that paragraph in the book as well. I imagine with so much to write, the occasional unclear statement just slips through. It's inevitable, but it's good that help is available here.
 
Top