home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s199 / 1.img / ADDERGAL.ABL < prev    next >
Encoding:
Text File  |  1986-04-01  |  1.7 KB  |  65 lines

  1. module _AdderGAL
  2. title '5-bit ripple adder using a Lattice GAL
  3. FutureNet - Data I/O  Redmond WA   14 Jan 1985'
  4.  
  5.     AdderGAL    device    'P16V8R';
  6.  
  7. " A GAL must be used for this function because it requires
  8. " 5 registered outputs and 3 combinatoral outputs.
  9.  
  10. " To select the ABEL device file for the GAL follow these rules
  11. " 1. Registers are required.
  12. "    Use the P16V8R.
  13. " 2. No registers, but feedback is required.
  14. "    Use the P16V8C.
  15. " 3. No registers or feedback, but 8 terms per output are required.
  16. "    Use the P16V8S.
  17.  
  18.     X,C,L,H        = .X., .C., 0, 1;
  19.     Clk,Clr,Ena    pin  1, 9,11;
  20.     V4,V3,V2,V1,V0    pin  2, 3, 4, 5, 6;   Data = [V4,V3,V2,V1,V0];
  21.     S4,S3,S2,S1,S0    pin 12,13,14,15,16;   Sum  = [S4,S3,S2,S1,S0];
  22.  
  23. " Equations for a n-Bit ripple adder
  24. "     Sn   = An xor Bn xor Cn
  25. "     Cn+1 = AnBn + (An + Bn)Cn
  26.  
  27. " Compute the first two carries as sub expressions
  28.     C0    = 0;
  29.     C1    = (V0 & S0 # (V0 # S0) & C0);
  30.  
  31. " Compute these carries on outputs to save product terms
  32.      C2,C3,C4    pin  17,18,19;
  33.  
  34. equations
  35.     C2     = V1 & S1 # (V1 # S1) & C1;
  36.     C3     = V2 & S2 # (V2 # S2) & C2;
  37.     C4     = V3 & S3 # (V3 # S3) & C3;
  38.  
  39.     S4    := (S4 $ V4 $ C4) & Clr;
  40.     S3    := (S3 $ V3 $ C3) & Clr;
  41.     S2    := (S2 $ V2 $ C2) & Clr;
  42.     S1    := (S1 $ V1 $ C1) & Clr;
  43.     S0    := (S0 $ V0 $ C0) & Clr;
  44.  
  45. fuses  "User Signature Word
  46.     [2056..2071] = 'V1';
  47.     [2072..2087] = '.3';
  48.     [2088..2103] = 'J-';
  49.     [2104..2119] = '86';
  50.  
  51. test_vectors 
  52.        ([Clk,Clr,Ena,Data] -> Sum )
  53.     [ C , L , L ,  X ] ->  0;    "Clear
  54.     [ C , H , L ,  7 ] ->  7;
  55.     [ C , H , L , 10 ] -> 17;
  56.     [ C , L , L ,  X ] ->  0;    "Clear
  57.     [ C , H , L ,  1 ] ->  1;
  58.     [ C , H , L , 10 ] -> 11;    
  59.     [ C , H , L ,  4 ] -> 15;
  60.     [ C , H , L ,  8 ] -> 23;    
  61.     [ C , H , L , 22 ] -> 13;    "45 overflows to 13 
  62.     [ C , H , L ,  5 ] -> 18;
  63. end _AdderGAL 
  64.  
  65.