GAL ALU: equations


chip alu gal22v10

; pin 1   2   3   4   5   6   7   8   9   10  11  12
      clk B0  B1  B2  B3  S0  S1  S2  S3  S4  Ci  GND

; pin 13  14  15  16  17  18  19  20  21  22  23  24
      foo SLI C1  C2  Co  A0  A1  A2  A3  C3  SRI VCC

;S4..S0: control Bits
;
;00000 A =  0         (zero)
;00001 A =  A  NOR  B
;00010 A =  A  AND /B
;00011 A = /B
;00100 A = /A  AND  B
;00101 A = /A         (also: first step of decrement A)
;00110 A =  A  XOR  B (also: first step of ADC)
;00111 A =  A NAND  B
;01000 A =  A  AND  B
;01001 A =  A XNOR  B (also: first step of SBC)
;01010 A =  A         (do nothing)
;01011 A =  A   OR /B
;01100 A =  B
;01101 A = /A   OR  B
;01110 A =  A   OR  B
;01111 A =  1         (all Bits set = -1)
;10xx0 A =  SHL A     (shift A left)
;10xx1 A =  SHR A     (shift right)
;11x00 A =  A + Ci    (increment takes only one step with Ci carry input set)
;11x01 second step of SBC (Ci is low_active borrow, like with the 6502)
;11x10 second step of ADC (Ci is high_active carry)
;11x11 second step of decrement A (Ci should be set to 0, because decrement is  ADC based)

@define shl " S4 * /S3 * /S0"
@define shr " S4 * /S3 *  S0"
@define cy  " S4 *  S3"

equations 

A0 := shl * SLI + shr * A1  + cy  * Ci * /A0 + cy * /Ci * A0
    + /S4 * S3 *  A0 *  B0  + /S4 * S2 * /A0 *  B0
    + /S4 * S1 *  A0 * /B0  + /S4 * S0 * /A0 * /B0

A1 := shl * A0  + shr * A2  + cy  * C1 * /A1 + cy * /C1 * A1
    + /S4 * S3 *  A1 *  B1  + /S4 * S2 * /A1 *  B1
    + /S4 * S1 *  A1 * /B1  + /S4 * S0 * /A1 * /B1

A2 := shl * A1  + shr * A3  + cy  * C2 * /A2 + cy * /C2 * A2
    + /S4 * S3 *  A2 *  B2  + /S4 * S2 * /A2 *  B2
    + /S4 * S1 *  A2 * /B2  + /S4 * S0 * /A2 * /B2

A3 := shl * A2  + shr * SRI + cy  * C3 * /A3 + cy * /C3 * A3
    + /S4 * S3 *  A3 *  B3  + /S4 * S2 * /A3 *  B3
    + /S4 * S1 *  A3 * /B3  + /S4 * S0 * /A3 * /B3

C1 = cy * Ci * A0 + cy * S0 * /A0 * /B0 + cy * S1 * /A0 * B0 

C2 = cy * Ci * A0 * A1
   + cy * S0 * /A0 * A1 * /B0 + cy * S1 * /A0 * A1 * B0
   + cy * S0 *      /A1 * /B1 + cy * S1 * /A1 * B1

C3 = cy * C2 * A2 + cy * S0 * /A2 * /B2 + cy * S1 * /A2 * B2 

Co = cy * C2 * A2 * A3
   + cy * S0 * /A2 * A3 * /B2 + cy * S1 * /A2 * A3 * B2
   + cy * S0 *      /A3 * /B3 + cy * S1 * /A3 * B3


Code was compiled with EQN2JED, Version 3,
but be warned that I haven't tested this code,
or tried to burn it into a GAL !

So don't expect it to work exactly as intended...
if you make to squeeze this stuff into a GAL16V8
(without sacrificing too much functionality),
please write an article about it.


[HOME] [UP]/ [BACK] [1] [2] [3] [4] [5] [6] [7] [8] [NEXT]

(c) Dieter Mueller 2012