You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
400 B

  1. /*
  2. Assume sel is binary.
  3. If sel == 0 then outL = L and outR=R
  4. If sel == 1 then outL = R and outR=L
  5. */
  6. template Switcher() {
  7. signal input sel;
  8. signal input L;
  9. signal input R;
  10. signal output outL;
  11. signal output outR;
  12. signal aux;
  13. aux <== (R-L)*sel; // We create aux in order to have only one multiplication
  14. outL <== aux + L;
  15. outR <== -aux + R;
  16. }