Question
Write this code in c++ Parity bit generation: Read an unsigned number and assume the last bit is used as the parity bit (bit 32).
Write this code in c++
Parity bit generation:
Read an unsigned number and assume the last bit is used as the parity bit (bit 32).
Calculate the parity and set the last bit as either 0 or 1 (you may or the pattern with
1<<31) to make the last bit a 1.
Now you want to send the pattern to the sender we do this part in simulation.
You must generate a single error. This can be done using random numbers.
After you generate a single error, perform that tasks that the receiver will do. In other words,
the receiver will calculate the parity for the received data and compare it with the received
parity to decide if there is an error or not.
Explain the parity problem:
If sender decides to send an 8 bit pattern the sender adds an extra bit (called the parity bit).
The parity bit is either decided to be even parity or odd paritylets assume we want to use
even parity.
What even parity means: Count the number of 1s that is in the data value if it is even write 0 in
the parity bit if the count is odd write a 1 in the parity bit. This makes the total number of 1s
in the pattern sent an even number.
Receiver when it gets the pattern knows the last bit is the parity bit Receiver calculates the
even parity for the data part. This calculated parity bit becomes either 1 or zero based on the
number of received 1s in the data part.
Of course if there is no error, the value calculated must be the same as the parity bit received.
1010000000000000101 pattern we want to send
000000000100000000 This is for simulating the error the error happened at bit 9
1010000000100000101 This pattern is what the receiver will get
Receiver must find out if it is received correctly
The receiver says:
1010000000100000101 Finds the even parity for the shaded region and it will get
It is even number of 1s so parity becomes zero.
Calculated parity by receiver side is 0
Received parity at receiver side is 1
They dont match and it means there is an error
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started