home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s078 / 1.img / ADDER.PLD < prev    next >
Encoding:
Text File  |  1991-12-08  |  1.7 KB  |  52 lines

  1. Name      Adder;
  2. Partno      CA0016;
  3. Date      10/08/85;
  4. Rev       01;
  5. Designer  Woolhiser;
  6. Company   Assisted Technology;
  7. Assembly  None;
  8. Location  None;
  9. Device    p16l8;
  10.  
  11. /****************************************************************/
  12. /*                                */
  13. /* Four bit adder using the CUPL function statement.        */
  14. /*                                 */
  15. /* 4-bit asynchronous adder implemented as a ripple-carry    */
  16. /* through four adder-slice circuits.  Each adder-slice        */
  17. /* takes a pair of 1-bit numbers (Xi, Yi) and the carry from    */
  18. /* a previous slice (Cin) and produces their 1-bit sum (Zi)    */
  19. /* and carry (Cout).  Each adder-slice circuit is defined    */
  20. /* using the CUPL function adder_slice(), which returns        */
  21. /* the product directly and the carry as Cout.            */
  22. /****************************************************************/
  23. /* Allowable Target Device Types :  PAL16L8                   */
  24. /****************************************************************/
  25.  
  26. /** Inputs **/
  27.  
  28. Pin [1..4] = [X1..4];        /* First 4-bit number    */
  29. Pin [5..8] = [Y1..4];        /* Second 4-bit number    */
  30.  
  31. /** Outputs **/
  32.  
  33. Pin [12..15] = [Z1..4];        /* 4-bit sum            */
  34. Pin [16..18] = [C1..3];        /* Intermediate carry vaules    */
  35. Pin 19 = Carry;            /* Carry for 4-bit sum         */
  36.  
  37. /* Adder-slice circuit - add 2, 1-bit, numbers with carry */
  38.  
  39. function adder_slice(X, Y, Cin, Cout) {
  40.     Cout    = Cin & X        /* Compute carry */
  41.         # Cin & Y
  42.         # X & Y;
  43.     adder_slice = Cin $ (X $ Y);    /* Compute sum */
  44. }
  45.  
  46. /* Perform 4, 1-bit, additions and keep the final carry */
  47.  
  48. Z1 = adder_slice(X1, Y1, 'h'0, C1);    /* Initial carry = 'h'0        */
  49. Z2 = adder_slice(X2, Y2,   C1, C2);
  50. Z3 = adder_slice(X3, Y3,   C2, C3);
  51. Z4 = adder_slice(X4, Y4,   C3, Carry);    /* Get final carry value    */
  52.