{
  "version": 1,
  "author": "Uri Shaked",
  "editor": "wokwi",
  "parts": [
    {
      "type": "wokwi-dip-switch-8",
      "id": "sw1",
      "top": -142.14,
      "left": -150.76,
      "rotate": 90,
      "attrs": {}
    },
    { "type": "wokwi-vcc", "id": "pwr1", "top": -231.09, "left": -172.48, "attrs": {} },
    {
      "type": "board-tt-block-input",
      "id": "chip1",
      "top": -190.98,
      "left": -4.8,
      "attrs": { "verilogRole": "input" }
    },
    {
      "type": "board-tt-block-output",
      "id": "chip2",
      "top": -155.52,
      "left": 603.32,
      "attrs": { "verilogRole": "output" }
    },
    { "type": "wokwi-gate-and-2", "id": "gate1", "top": -599, "left": -140.41, "attrs": {} },
    { "type": "wokwi-gate-or-2", "id": "gate2", "top": -493.4, "left": 89.99, "attrs": {} },
    { "type": "wokwi-gate-xor-2", "id": "gate3", "top": -600.63, "left": -25.21, "attrs": {} },
    { "type": "wokwi-gate-nand-2", "id": "gate4", "top": -541.4, "left": -140.41, "attrs": {} },
    { "type": "wokwi-gate-not", "id": "gate5", "top": -541.4, "left": 89.99, "attrs": {} },
    { "type": "wokwi-gate-buffer", "id": "gate6", "top": -541.4, "left": -25.21, "attrs": {} },
    { "type": "wokwi-mux-2", "id": "mux1", "top": -493.4, "left": -140.41, "attrs": {} },
    { "type": "wokwi-flip-flop-d", "id": "flipflop1", "top": -493.4, "left": -25.21, "attrs": {} },
    { "type": "wokwi-vcc", "id": "pwr4", "top": -598.24, "left": 109.19, "attrs": {} },
    { "type": "wokwi-gnd", "id": "pwr5", "top": -599, "left": 145.7, "attrs": {} },
    { "type": "wokwi-gate-xor-2", "id": "gate11", "top": -194.72, "left": 204.72, "attrs": {} },
    {
      "type": "wokwi-led",
      "id": "led1",
      "top": -197.38,
      "left": 816.07,
      "attrs": { "color": "cyan", "flip": "1" }
    },
    {
      "type": "wokwi-led",
      "id": "led2",
      "top": -34.18,
      "left": 586.47,
      "attrs": { "color": "orange", "flip": "" }
    },
    {
      "type": "wokwi-gnd",
      "id": "pwr6",
      "top": -59.34,
      "left": 918.07,
      "rotate": 270,
      "attrs": {}
    },
    {
      "type": "wokwi-text",
      "id": "text1",
      "top": -340.49,
      "left": 270.63,
      "attrs": { "text": "Extra Credit: 4-bit Full-Adder with Carry" }
    },
    {
      "type": "wokwi-text",
      "id": "text2",
      "top": -151.36,
      "left": -185.7,
      "attrs": { "text": "A0" }
    },
    {
      "type": "wokwi-text",
      "id": "text3",
      "top": -139.9,
      "left": -186.19,
      "attrs": { "text": "A1" }
    },
    {
      "type": "wokwi-text",
      "id": "text4",
      "top": -164.7,
      "left": -187.81,
      "attrs": { "text": "Cin" }
    },
    {
      "type": "wokwi-text",
      "id": "text6",
      "top": -314.65,
      "left": 275.81,
      "attrs": { "text": "Computes A1A0 + B1B0 + Cin = S2S1S0 " }
    },
    {
      "type": "wokwi-text",
      "id": "text7",
      "top": 147.19,
      "left": 466.99,
      "attrs": { "text": "Truth Table" }
    },
    {
      "type": "wokwi-text",
      "id": "text8",
      "top": 155.75,
      "left": 460.46,
      "attrs": { "text": "--------------" }
    },
    {
      "type": "wokwi-text",
      "id": "text9",
      "top": 174.24,
      "left": 394.96,
      "attrs": { "text": "Cin A1 A0 B1 B0 | S2 S1 S0" }
    },
    {
      "type": "wokwi-text",
      "id": "text10",
      "top": 186.62,
      "left": 417.68,
      "attrs": { "text": "------------------------------" }
    },
    {
      "type": "wokwi-text",
      "id": "text 11 ",
      "top": 196.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 0 0 0 | 0 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 12 ",
      "top": 216.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 0 0 1 | 0 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 13 ",
      "top": 236.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 0 1 0 | 0 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 14 ",
      "top": 256.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 0 1 1 | 0 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 15 ",
      "top": 276.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 1 0 0 | 0 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 16 ",
      "top": 296.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 1 0 1 | 0 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 17 ",
      "top": 316.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 1 1 0 | 0 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 18 ",
      "top": 336.4,
      "left": 450.35,
      "attrs": { "text": " 0 0 1 1 1 | 1 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 19 ",
      "top": 356.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 0 0 0 | 0 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 20 ",
      "top": 376.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 0 0 1 | 0 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 21 ",
      "top": 396.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 0 1 0 | 1 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 22 ",
      "top": 416.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 0 1 1 | 1 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 23 ",
      "top": 436.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 1 0 0 | 0 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 24 ",
      "top": 456.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 1 0 1 | 1 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 25 ",
      "top": 476.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 1 1 0 | 1 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 26 ",
      "top": 496.4,
      "left": 450.35,
      "attrs": { "text": " 0 1 1 1 1 | 1 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 27 ",
      "top": 516.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 0 0 0 | 0 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 28 ",
      "top": 536.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 0 0 1 | 0 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 29 ",
      "top": 556.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 0 1 0 | 0 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 30 ",
      "top": 576.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 0 1 1 | 1 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 31 ",
      "top": 596.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 1 0 0 | 0 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 32 ",
      "top": 616.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 1 0 1 | 0 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 33 ",
      "top": 636.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 1 1 0 | 1 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 34 ",
      "top": 656.4,
      "left": 450.35,
      "attrs": { "text": " 1 0 1 1 1 | 1 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 35 ",
      "top": 676.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 0 0 0 | 0 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 36 ",
      "top": 696.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 0 0 1 | 1 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 37 ",
      "top": 716.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 0 1 0 | 1 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 38 ",
      "top": 736.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 0 1 1 | 1 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 39 ",
      "top": 756.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 1 0 0 | 1 0 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 40 ",
      "top": 776.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 1 0 1 | 1 0 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text 41 ",
      "top": 796.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 1 1 0 | 1 1 0" }
    },
    {
      "type": "wokwi-text",
      "id": "text 42 ",
      "top": 816.4,
      "left": 450.35,
      "attrs": { "text": " 1 1 1 1 1 | 1 1 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text28",
      "top": -72.05,
      "left": -121.34,
      "attrs": { "text": "0 | 1" }
    },
    {
      "type": "wokwi-text",
      "id": "text29",
      "top": -232.17,
      "left": 830.57,
      "attrs": { "text": "S0" }
    },
    {
      "type": "wokwi-text",
      "id": "text30",
      "top": 19.12,
      "left": 607.14,
      "attrs": { "text": "Cout0" }
    },
    {
      "type": "wokwi-text",
      "id": "text33",
      "top": -329.76,
      "left": 302.53,
      "attrs": { "text": "-------------------------------" }
    },
    {
      "type": "wokwi-text",
      "id": "text27",
      "top": -295.16,
      "left": 203.41,
      "attrs": { "text": "Note: Adding two n-bit numbers can result in n+1 bits." }
    },
    {
      "type": "wokwi-text",
      "id": "text34",
      "top": -275.9,
      "left": 171.39,
      "attrs": { "text": "In other words, the output requires an extra bit to account for a carry." }
    },
    {
      "type": "wokwi-led",
      "id": "led5",
      "top": -313.07,
      "left": -49.6,
      "attrs": { "color": "blue", "flip": "1" }
    },
    {
      "type": "wokwi-led",
      "id": "led6",
      "top": -312.91,
      "left": -77.3,
      "attrs": { "color": "yellow", "flip": "1" }
    },
    {
      "type": "wokwi-led",
      "id": "led7",
      "top": -312.09,
      "left": -22.59,
      "attrs": { "color": "green", "flip": "1" }
    },
    {
      "type": "wokwi-gnd",
      "id": "pwr3",
      "top": -269.48,
      "left": 79.53,
      "rotate": 270,
      "attrs": {}
    },
    {
      "type": "wokwi-text",
      "id": "text35",
      "top": -330.26,
      "left": -11.44,
      "attrs": { "text": "A0" }
    },
    {
      "type": "wokwi-text",
      "id": "text36",
      "top": -330.42,
      "left": 58.06,
      "attrs": { "text": "B0" }
    },
    {
      "type": "wokwi-text",
      "id": "text37",
      "top": -328.27,
      "left": -70.41,
      "attrs": { "text": "Cin" }
    },
    { "type": "wokwi-gate-xor-2", "id": "gate7", "top": -185.2, "left": 319.8, "attrs": {} },
    { "type": "wokwi-gate-and-2", "id": "gate8", "top": -137.56, "left": 302.52, "attrs": {} },
    { "type": "wokwi-gate-and-2", "id": "gate9", "top": -99.02, "left": 209.67, "attrs": {} },
    { "type": "wokwi-gate-or-2", "id": "gate10", "top": -128.43, "left": 404.48, "attrs": {} },
    { "type": "wokwi-gate-xor-2", "id": "gate12", "top": -10.77, "left": 204.49, "attrs": {} },
    {
      "type": "wokwi-led",
      "id": "led3",
      "top": -81.13,
      "left": 817.32,
      "attrs": { "color": "cyan", "flip": "1" }
    },
    {
      "type": "wokwi-led",
      "id": "led4",
      "top": 43.67,
      "left": 816.94,
      "attrs": { "color": "cyan", "flip": "1" }
    },
    { "type": "wokwi-gate-xor-2", "id": "gate13", "top": -1.25, "left": 319.57, "attrs": {} },
    { "type": "wokwi-gate-and-2", "id": "gate14", "top": 46.39, "left": 302.29, "attrs": {} },
    { "type": "wokwi-gate-and-2", "id": "gate15", "top": 84.93, "left": 209.44, "attrs": {} },
    { "type": "wokwi-gate-or-2", "id": "gate16", "top": 55.52, "left": 404.25, "attrs": {} },
    {
      "type": "wokwi-text",
      "id": "text19",
      "top": -127.99,
      "left": -186.34,
      "attrs": { "text": "B0" }
    },
    {
      "type": "wokwi-text",
      "id": "text20",
      "top": -115.73,
      "left": -185.93,
      "attrs": { "text": "B1" }
    },
    {
      "type": "wokwi-text",
      "id": "text21",
      "top": -98.68,
      "left": 829.52,
      "attrs": { "text": "S1" }
    },
    {
      "type": "wokwi-text",
      "id": "text22",
      "top": 30.41,
      "left": 805.24,
      "attrs": { "text": "S2 (Cout1)" }
    },
    {
      "type": "wokwi-led",
      "id": "led8",
      "top": -312.09,
      "left": 46.97,
      "attrs": { "color": "magenta", "flip": "1" }
    },
    {
      "type": "wokwi-led",
      "id": "led10",
      "top": -312.81,
      "left": 9.25,
      "attrs": { "color": "red", "flip": "1" }
    },
    {
      "type": "wokwi-text",
      "id": "text5",
      "top": -329.59,
      "left": -40.05,
      "attrs": { "text": "A1" }
    },
    {
      "type": "wokwi-text",
      "id": "text23",
      "top": -330.69,
      "left": 20.9,
      "attrs": { "text": "B1" }
    },
    { "type": "wokwi-gnd", "id": "pwr2", "top": 41.33, "left": 583.06, "attrs": {} }
  ],
  "connections": [
    [ "pwr1:VCC", "sw1:8a", "red", [ "v0" ] ],
    [ "pwr1:VCC", "sw1:7a", "red", [ "v0" ] ],
    [ "pwr1:VCC", "sw1:6a", "red", [ "v0" ] ],
    [ "pwr1:VCC", "sw1:5a", "red", [ "v0" ] ],
    [ "pwr1:VCC", "sw1:4a", "red", [ "v0" ] ],
    [ "pwr1:VCC", "sw1:1a", "red", [ "v0" ] ],
    [ "pwr1:VCC", "sw1:2a", "red", [ "v0" ] ],
    [ "pwr1:VCC", "sw1:3a", "red", [ "v0" ] ],
    [ "chip1:EXTIN1", "sw1:2b", "green", [ "h0" ] ],
    [ "sw1:3b", "chip1:EXTIN2", "blue", [ "h0" ] ],
    [ "sw1:7b", "chip1:EXTIN6", "gray", [ "h0" ] ],
    [ "sw1:8b", "chip1:EXTIN7", "gray", [ "v0" ] ],
    [ "sw1:1b", "chip1:EXTIN0", "yellow", [ "h0" ] ],
    [ "pwr6:GND", "led1:C", "black", [ "v0" ] ],
    [ "pwr3:GND", "led7:C", "black", [ "v0.33", "h-17.28" ] ],
    [ "pwr3:GND", "led5:C", "black", [ "v0.33", "h-49.49" ] ],
    [ "gate11:OUT", "gate7:A", "black", [ "v0" ] ],
    [ "gate8:OUT", "gate10:A", "black", [ "v0" ] ],
    [ "gate11:OUT", "gate8:A", "black", [ "v0" ] ],
    [ "gate9:OUT", "gate10:B", "black", [ "v-1.44", "h72.41", "v-20.85" ] ],
    [ "pwr3:GND", "led6:C", "black", [ "v-0.13", "h-39.14" ] ],
    [ "sw1:4b", "chip1:EXTIN3", "red", [ "h0" ] ],
    [ "sw1:5b", "chip1:EXTIN4", "violet", [ "h0" ] ],
    [ "sw1:6b", "chip1:EXTIN5", "gray", [ "h0" ] ],
    [ "gate12:OUT", "gate13:A", "black", [ "v0" ] ],
    [ "gate14:OUT", "gate16:A", "black", [ "v0" ] ],
    [ "gate12:OUT", "gate14:A", "black", [ "v0" ] ],
    [ "gate15:OUT", "gate16:B", "black", [ "v-1.44", "h72.41", "v-20.85" ] ],
    [ "chip1:IN4", "gate12:B", "violet", [ "h18.29", "v147.39" ] ],
    [ "gate10:OUT", "gate13:B", "orange", [ "v70.73", "h-315.13", "v80.36", "h86.1", "v-14.31" ] ],
    [
      "gate10:OUT",
      "gate14:B",
      "orange",
      [ "h-0.25", "v69.97", "h-315.62", "v114.05", "h117.68" ]
    ],
    [ "chip1:IN4", "gate15:B", "violet", [ "h18.21", "v245.18" ] ],
    [ "sw1:4b", "led8:A", "red", [ "h20.32", "v-95.45", "h123.53" ] ],
    [ "sw1:5b", "led10:A", "violet", [ "h26.67", "v-85.1", "h52.2" ] ],
    [ "pwr6:GND", "led3:C", "black", [ "v0" ] ],
    [ "pwr6:GND", "led4:C", "black", [ "v0" ] ],
    [ "pwr2:GND", "led2:C", "black", [ "v0" ] ],
    [ "chip1:IN0", "gate7:B", "white", [ "h66.4", "v41.62", "h101.97", "v-15.8" ] ],
    [ "chip1:IN0", "gate8:B", "white", [ "h67.84", "v74.65" ] ],
    [ "pwr3:GND", "led8:C", "black", [ "v0.55", "h-40.74" ] ],
    [ "pwr3:GND", "led10:C", "black", [ "v0.55", "h-12.19" ] ],
    [ "chip1:IN1", "gate9:A", "green", [ "h40.48", "v79.19" ] ],
    [ "chip1:IN1", "gate11:A", "green", [ "h86.11", "v-13.63", "h14.82" ] ],
    [ "gate12:A", "chip1:IN2", "blue", [ "h-66.71", "v-160.59" ] ],
    [ "gate15:A", "chip1:IN2", "blue", [ "h-72.51", "v-257.73" ] ],
    [ "chip1:IN3", "gate11:B", "red", [ "h0" ] ],
    [ "chip1:IN3", "gate9:B", "red", [ "h26.34", "v83.71" ] ],
    [ "sw1:3b", "led5:A", "blue", [ "h5.52", "v-116.02", "h41.14" ] ],
    [ "sw1:2b", "led7:A", "green", [ "h14.58", "v-94.1", "h57.86" ] ],
    [ "sw1:1b", "led6:A", "yellow", [ "h-1.41", "v-119.6", "h20.37" ] ],
    [ "gate7:OUT", "chip2:OUT0", "cyan", [ "v0.28", "h130.94", "v35.78" ] ],
    [ "led1:A", "chip2:EXTOUT0", "cyan", [ "v0" ] ],
    [ "gate13:OUT", "chip2:OUT1", "limegreen", [ "v1.04", "h107.56", "v-139.33" ] ],
    [ "chip2:EXTOUT1", "led3:A", "limegreen", [ "h45.77", "v81.82" ] ],
    [ "gate16:OUT", "chip2:OUT2", "cyan", [ "v-1.76", "h64.48", "v-183.7" ] ],
    [ "chip2:EXTOUT2", "led4:A", "cyan", [ "h31.61", "v198.73" ] ],
    [ "gate10:OUT", "chip2:OUT3", "orange", [ "v39.39", "h93.49", "v-31.3" ] ],
    [ "chip2:EXTOUT3", "led2:A", "orange", [ "h19.2", "v251.68" ] ]
  ],
  "dependencies": {}
}
Loading
tt-block-input
Loading
tt-block-output
Extra Credit: 4-bit Full-Adder with Carry
A0
A1
Cin
Computes A1A0 + B1B0 + Cin = S2S1S0
Truth Table
--------------
Cin A1 A0 B1 B0 | S2 S1 S0
------------------------------
0 0 0 0 0 | 0 0 0
0 0 0 0 1 | 0 0 1
0 0 0 1 0 | 0 1 0
0 0 0 1 1 | 0 1 1
0 0 1 0 0 | 0 0 1
0 0 1 0 1 | 0 1 0
0 0 1 1 0 | 0 1 1
0 0 1 1 1 | 1 0 0
0 1 0 0 0 | 0 1 0
0 1 0 0 1 | 0 1 1
0 1 0 1 0 | 1 0 0
0 1 0 1 1 | 1 0 1
0 1 1 0 0 | 0 1 1
0 1 1 0 1 | 1 0 0
0 1 1 1 0 | 1 0 1
0 1 1 1 1 | 1 1 0
1 0 0 0 0 | 0 0 1
1 0 0 0 1 | 0 1 0
1 0 0 1 0 | 0 1 1
1 0 0 1 1 | 1 0 0
1 0 1 0 0 | 0 1 0
1 0 1 0 1 | 0 1 1
1 0 1 1 0 | 1 0 0
1 0 1 1 1 | 1 0 1
1 1 0 0 0 | 0 1 1
1 1 0 0 1 | 1 0 0
1 1 0 1 0 | 1 0 1
1 1 0 1 1 | 1 1 0
1 1 1 0 0 | 1 0 0
1 1 1 0 1 | 1 0 1
1 1 1 1 0 | 1 1 0
1 1 1 1 1 | 1 1 1
0 | 1
S0
Cout0
-------------------------------
Note: Adding two n-bit numbers can result in n+1 bits.
In other words, the output requires an extra bit to account for a carry.
A0
B0
Cin
B0
B1
S1
S2 (Cout1)
A1
B1