0

I have a truth table like this:

a b sel O

F F F F

F F T F

F T F F

F T T T

T F F T

T F T F

T T F T

T T T T

so O is the output column, sel is basically a selector. So when sel = F, the O will be the value of a, and if sel= T, the O will be the value of b.

So I was able to come up with an expression (without regarding b input) that correctly matches the output of sel and a, when sel = F: a $$\lor$$ sel (for example you could check that this expression $$a v sel$$ would produce correctly all the combination of values of a, sel and O, without regarding the value of b)

And similarly for matching output of sel and b, when sel = T: $$b ^ sel$$ (for example you could check that this expression $$b ^ sel$$ would produce correctly all the combination of values of b, sel and O, without regarding the value of a)

But now I am not sure how to come up with an expression that would correctly put together $$a v sel$$ and $$b ^ sel$$ to have a final expression that matches the truth table above.

john_w
  • 693
  • 1
  • 6
  • 25

1 Answers1

0
(!s && a) || (s && b)

If s is false, the left side takes the value of a, and the right side is false (and thus ignored).

If s is true, the right side takes the value of b, and the left side is false (and thus ignored).

Amadan
  • 191,408
  • 23
  • 240
  • 301
  • HI, sorry for my stupidity, may I know what is &&? and || here? could you use the "or" "and" "xor" notation in your answer instead? sorry because I think you are using regular expression here. – john_w Jan 20 '21 at 03:15
  • Ah, sorry, I'm using the usual computer programming operators, `&&` is "and", `||` is "or", `!` is "not". It is easier to type than the corresponding mathematical symbols. (Also, notably, Stack Overflow does not parse LaTeX, so `$$\lor$$` is really hard to read.) I have not used "xor" (nor regular expressions). – Amadan Jan 20 '21 at 03:22