-2

This is a school question (I know some hate this), but I tried and really couldn't think of an answer. I suspect this circuit will do some simple instruction.

enter image description here

So if you had an input like 1101 (representing x blocks) and 0001 (representing y blocks), the first operation will be XOR either or logic.

1101

0001

1100

then you have negation or for all digits. So...

neg(1 or 1 or 0 or 0)

So inside negation is always true, hence 1. (1 or True or vs anything is true)

so neg(1) = 0.

Circuit logic aka neg((x1 XOR y1) OR (x2 XOR y2) OR (x3 XOR y3) OR (x4 XOR y4))

But I was asked what this bonus question significant? As I said, I suspected maybe this is how some basic operation work in assembly (4 blocks gave that way), but it's not basic operation. It's not bit-masking... so this is where I got confused. Shouldn't be hard since it's first bonus question asked in 2nd year course, but it's not clicking to me somehow :( Time to change majors lol welp.

Any ideas?

John Doe
  • 55
  • 1
  • 2
  • sure just try it...write a program and feed in the 256 possibilities if nothing else... – old_timer May 16 '17 at 18:12
  • 1
    If you take 2 bits and XOR them together the result is zero if the inputs are the same and 1 otherwise (This 1 bit compare).. If you used just a multiple input OR gate on the far right then if any of the inputs are 1 (the original bits of X and Y are different) then the result is 1. If and only if all the multiple OR gates inputs are 0 the output will be 0 (the original X and Y must be the same). They use a NOR to reverse the output so now the output is 1 if X and Y were the same and 0 if X and Y were different. This is a 4-bit comparator X=Y – Michael Petch May 17 '17 at 04:22

2 Answers2

1

This logic circuit returns 1 if x and y are equals. Returns 0 if they're not equal.

SiggiSv
  • 1,219
  • 1
  • 10
  • 20
1
#include <stdio.h>
int main ( void )
{
    unsigned int x,y,z;

    for(x=0;x<=0xF;x++)
    {
        for(y=0;y<=0xF;y++)
        {
            z=x^y;
            if(z) z=0; else z=1;
            if(z) printf("%X %X %u\n",x,y,z);
            //if(!z) printf("%X %X %u\n",x,y,z);
        }
    }
    return(0);
}

0 0 1
1 1 1
2 2 1
3 3 1
4 4 1
5 5 1
6 6 1
7 7 1
8 8 1
9 9 1
A A 1
B B 1
C C 1
D D 1
E E 1
F F 1

the first level is just a bitwise xor of x and y as you would have in an xor instruction in a processor/alu. if the bits are different the result is a 1 if the bits are the same the result is a 0. Then the NOR is an OR and a NOT. If any of the bits coming into the OR are not zero then the or is true and the not makes it false, zero. If all of the bits coming into the OR are zero then the OR is a zero and the not makes it one. For all of the bits coming into the OR to be zero then the X and Y bits all have to match to make each XOR output a zero.

XOR
ab result
--------
00 0
01 1
10 1
11 0

If they match the result is 0 if they are different the result is one. Only works for two input, another way to look at xor is it is a odd parity generator, three bits if 1 or 3 bits are set the result is 1 if 0 or 2 bits are set the result is 0 and it continues from there, doesnt matter here these are two input.

OR
ab result
-----------
00 0
01 1
10 1
11 1

if they are all zeros then the result is 0 otherwise if any one of them is not zero the result is 1. Continues to work like this for any number of inputs. Four input if all four are 0 then the result is zero otherwise the result is one.

I could have orred each of the bits together, but instead just check to see if z was zero or not.

old_timer
  • 69,149
  • 8
  • 89
  • 168