// add4pg.e 4 bits of adder that outputs P and G // 4 bit stage with 9 inputs and 6 outputs define add4pg(a[4], b[4], cin, s[4], pout, gout) signal c0, c1, c2; signal nc1; signal p0, p1, p2, p3; signal g0, g1, g2, g3; circuits // basic four stages s00 use fadd(a[0], b[0], cin, s[0], c0); s01 use fadd(a[1], b[1], c0, s[1], c1); s02 use fadd(a[2], b[2], c1, s[2], c2); s03 use fadd(a[3], b[3], c2, s[3], nc1); // Propegate and Generate terms and outputs p0 <= a[0]|b[0] after 1ns; p1 <= a[1]|b[1] after 1ns; p2 <= a[2]|b[2] after 1ns; p3 <= a[3]|b[3] after 1ns; g0 <= a[0]&b[0] after 1ns; g1 <= a[1]&b[1] after 1ns; g2 <= a[2]&b[2] after 1ns; g3 <= a[3]&b[3] after 1ns; pout <= p3&p2&p1&p0 after 1ns; gout <= (g3)| // this would be cout for a ripple adder (p3&g2)| (p3&p2&g1)| (p3&p2&p1&g0)| (p3&p2&p1&p0&cin) after 1ns; end circuits; end add4pg;