Next: , Previous: one_bit_full_adder, Up: Some adders


4.2 five_bit_full_adder

The second block, five_bit_full_adder instantiates the 1-bit version five times, hooking up carry-out of one to carry-in of the next (c_01 through c_34).

     ;;; Five-bit full-adder.
     
     (blk five_bit_full_adder
          (out       5       s)
          (out               c_out)
          (in        5       a)
          (in        5       b)
          (in                c_in))
     
     (wire c_01)                             ; carry chain
     (wire c_12)
     (wire c_23)
     (wire c_34)
     
     (w/ one_bit_full_adder          adder0  ; todo: allow terse syntax
         (c_out                      . c_01)
         (s                          . s[0])
         (a                          . a[0])
         (b                          . b[0])
         (c_in                       . c_in))
     
     (w/ one_bit_full_adder          adder1
         (c_out                      . c_12)
         (s                          . s[1])
         (a                          . a[1])
         (b                          . b[1])
         (c_in                       . c_01))
     
     (w/ one_bit_full_adder          adder2
         (c_out                      . c_23)
         (s                          . s[2])
         (a                          . a[2])
         (b                          . b[2])
         (c_in                       . c_12))
     
     (w/ one_bit_full_adder          adder3
         (c_out                      . c_34)
         (s                          . s[3])
         (a                          . a[3])
         (b                          . b[3])
         (c_in                       . c_23))
     
     (w/ one_bit_full_adder          adder4
         (c_out                      . c_out)
         (s                          . s[4])
         (a                          . a[4])
         (b                          . b[4])
         (c_in                       . c_34))