Question

The objective of this system is to implement an odd-bit detection system. There are three bits...

The objective of this system is to implement an odd-bit detection system. There are three bits of inputs and one bit of output. The output is in positive logic: outputing a 1 will turn on the LED, outputing a 0 will turn off the LED. Inputs are positive logic: meaning if the switch pressed is the input is 1, if the switch is not pressed the input is 0. PE0 is an input PE1 is an input PE2 is an input PB4 is the output The specific operation of this system Initialize Port E to make PE0,PE1,PE2 inputs and PB4 an output Over and over, read the inputs, calculate the result and set the output The input/output specification refers to the input, not the switch. The following table illustrates the expected behavior relative to output PB4 as a function of inputs PE0,PE1,PE2 PE2 PE1 PE0 PB4 0 0 0 0 even number of 1’s 0 0 1 1 odd number of 1’s 0 1 0 1 odd number of 1’s 0 1 1 0 even number of 1’s 1 0 0 1 odd number of 1’s 1 0 1 0 even number of 1’s 1 1 0 0 even number of 1’s 1 1 1 1 odd number of 1’s */ // NOTE: Do not use any conditional branches in your solution. // We want you to think of the solution in terms of logical and shift operations

hOW TO DO THIS IN c

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Q=(A+B).(Ā+B)

Table:
PE2   PE1   PE0   PB4
0   0   0   0
0   0   1   1
0   1   0   1
0   1   1   0
1   0   0   1
1   0   1   0
1   1   0   0
1   1   1   1

This implies that odd number of set bit (input as 1) results into output being 1 which points towards XOR gate.
bar(A) = negation of A. When you write answer, it can be represented as shown in figure (with a line above A).
XOR(A,B) = (A+B).(bar(A) + bar(B))

C program:

#include<stdio.h>
void main() {
   int PE2, PE1, PE0,i=0;
   while(i<8){
       printf("Enter PE2, PE1, PE0 (0 or 1) seperated by space:");
       scanf("%d %d %d", &PE2, &PE1, &PE0);
       if ((PE0 !=0 && PE0 !=1) ||(PE1 !=0 && PE1 !=1) || (PE2 !=0 && PE2 !=1) ) {
           printf("Please input only 0 or 1");
           continue;
       }
       printf("PB4:%d\n",PE2^PE1^PE0);
       ++i;
   }
}

Output:

Enter PE2, PE1, PEO ( or 1) seperated by space: 0 0 PB4:3 Enter PE2, PE1, PEO ( or 1) seperated by space:0 0 1 PB4:1 Enter PE

Add a comment
Know the answer?
Add Answer to:
The objective of this system is to implement an odd-bit detection system. There are three bits...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT