How do I draw a truth table of a circuit that :

  • starts off with a full adder/subtractor
  • outputs the result F based on the two inputs (add if opcode is 0, subtract if opcode is 1)
  • then output three flags:
    • N (0 if F is positive or 0, 1 if F is negative)
    • V (0 if no overflow, 1 if there is overflow)
    • Z (0 if F is non-zero, 1 if F is zero)
  • then i want to input N, V, and Z into a comparator which also has two other inputs:
    • OP1 (0 if not checking for A=B, 1 if checking for A=B)
    • OP2 (0 if not checking for A
    • finally I want to output X (0 if comparison is false, 1 if comparison is true)

i don't know if this is vague but i've been searching for resources online and i can't find or figure out the logic behind determining N, V, Z :( any help even just a small hint would be appreciated


to get from N,Z,V,OP1,OP2 to X, I think i have to

  • ((N xor V) and OP2) or (Z and OP2) = X
  • my main problem is now just how to modify the full adder in order for it to output the three flags
  • \$\begingroup\$ Do you understand how to recognize when the result of addition or subtraction is zero or non-zero, if you do it on paper? Or whether the result is positive or negative? \$\endgroup\$ – Elliot Alderson Oct 5 '18 at 11:58
  • \$\begingroup\$ @ElliotAlderson im thinking since i only need a one-bit output to determine if the F is 0, then i should and every result of each bit? since i want to check if every bit is 0 \$\endgroup\$ – user8638151 Oct 5 '18 at 12:04
  • \$\begingroup\$ Why don't you try that on paper with some 3-bit numbers and see if it works. How will you know if a number is positive or negative? \$\endgroup\$ – Elliot Alderson Oct 5 '18 at 12:25
  • \$\begingroup\$ Hint: check out how 8080 or 6802 flags are implemented. N is just one bit of the result. V(overflow) is really a carry bit. Z is determined from all of the bits being 0. Comparing A<=>?B is done by subtracting A-B, discarding the difference value, but examining the NVZ flags of the difference. \$\endgroup\$ – MarkU Oct 5 '18 at 22:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.