// add4c.e a simple 4 bit adder with fast cout generation // this uses the component, below, fadd a one bit adder define fadd(a, b, cin, s, cout) circuits s <= a ^ b ^ cin after 1ns; cout <= (a&b)|(a&cin)|(b&cin) after 1ns; end circuits; end fadd; // add4c 4 bit full adder component // simple ripple carry adder with fast cout // inputs a, b, cin // outputs sum, cout define add4c(a[4], b[4], cin, sum[4], cout) signal c[4]; circuits a0 use fadd(a[0], b[0], cin , sum[0], c[0]); a1 use fadd(a[1], b[1], c[0], sum[1], c[1]); a2 use fadd(a[2], b[2], c[1], sum[2], c[2]); a3 use fadd(a[3], b[3], c[2], sum[3], c[3]); cout <= (a[3]&b[3])|((a[3]|b[3])&((a[2]&b[2])|((a[2]|b[2])& ((a[1]&b[1])|((a[1]|b[1])&((a[0]&b[0])|((a[0]|b[0])&cin))))))) after 1ns; end circuits; end add4c;