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.

54 lines
960 B

6 years ago
6 years ago
  1. include "../../circuit/mux4.circom";
  2. include "../../node_modules/circom/circuits/bitify.circom";
  3. template Constants() {
  4. var i;
  5. signal output out[16];
  6. out[0] <== 123;
  7. out[1] <== 456;
  8. out[2] <== 789;
  9. out[3] <== 012;
  10. out[4] <== 111;
  11. out[5] <== 222;
  12. out[6] <== 333;
  13. out[7] <== 4546;
  14. out[8] <== 134523;
  15. out[9] <== 44356;
  16. out[10] <== 15623;
  17. out[11] <== 4566;
  18. out[12] <== 1223;
  19. out[13] <== 4546;
  20. out[14] <== 4256;
  21. out[15] <== 4456;
  22. /*
  23. for (i=0;i<16; i++) {
  24. out[i] <== i*2+100;
  25. }
  26. */
  27. }
  28. template Main() {
  29. var i;
  30. signal private input selector;
  31. signal output out;
  32. component mux = Mux4();
  33. component n2b = Num2Bits(4);
  34. component cst = Constants();
  35. selector ==> n2b.in;
  36. for (i=0; i<4; i++) {
  37. n2b.out[i] ==> mux.s[i];
  38. }
  39. for (i=0; i<16; i++) {
  40. cst.out[i] ==> mux.c[i];
  41. }
  42. mux.out ==> out;
  43. }
  44. component main = Main();