;;; -*- Mode:LISP; Package:HARDWARE; Base:10; Readtable:CL -*-

;;; Weitek floating point multipleier (WTL 2264) and ALU (WTL 2265)
;;;   x in   --> left source 
;;;   y in   --> right source
;;;   z out  --> out-reg

;;; WTL 2264 and WTL 2265 internal registers
;;;   Am, Al, Bm, Bl, Areg, Breg, F, Freg, Mode, Dm, Dl
;;; nAm, nAl, nBm, nBl are the input busses to the Areg and Breg.
;;; Their block diagrams are similar except that the ALU has some feedback paths

;;; LOAD opperations (common to both chips).
;;; These go into the %%INST-FMULT-FPU-LOAD and %%INST-FLOAT-FPU-LOAD fields of a K instruction
(defconstant %%inst-fp-load-D-feedback 	       	(byte 1 5) "For WTL2265, set this bit to feed D back to Areg input bus")
(defconstant %%inst-fp-load-latch-Areg-and-Breg	(byte 1 0) "when set, load Areg and Breg from their respective input busses")
(defconstant %%inst-fp-load-other-bits		(byte 4 1)
  "the rest of the load field.  This is where the $$FP-INST-LOAD- values go.")
(defconstant $$inst-fp-load-noop		#x0 "no load operation")
(defconstant $$inst-fp-load-mode		#x1 "load mode register based on information provided on function input")
(defconstant $$inst-fp-load-both-to-B		#x4 "Load nBm from left operand and Bl from right operand")
(defconstant $$inst-fp-load-both-to-A		#x5 "Load nAm from left operand and Bm from right operand")
(defconstant $$inst-fp-load-low-right->a-left->b      #x2 "Drive the low halves of A and B from right and left respectively")
(defconstant $$inst-fp-load-low-right->b-left->a      #x6 "Drive the low halves of A and B from left and right respectively")
(defconstant $$inst-fp-load-high-right->a-left->b     #x3 "Drive the high halves of A and B from right and left respectively")
(defconstant $$inst-fp-load-high-right->b-left->a     #x7 "Drive the high halves of A and B from left and right respectively")
(defconstant $$inst-fp-load-right->B-high	      #x8 "Drive nBm from right operand")
(defconstant $$inst-fp-load-right->B-low	      #x9 "Drive nBl from right operand")
(defconstant $$inst-fp-load-right->A-low	      #xa "Drive nAl from right operand")
(defconstant $$inst-fp-load-right->A-high	      #xb "Drive nAm from right operand")
(defconstant $$inst-fp-load-left->B-high	      #xc "Drive nBm from left  operand")
(defconstant $$inst-fp-load-left->B-low		      #xd "Drive nBl from left  operand")
(defconstant $$inst-fp-load-left->A-low		      #xe "Drive nAl from left  operand")
(defconstant $$inst-fp-load-left->A-high	      #xf "Drive nAm from left  operand")

;;; Unload operations (common to both chips).
;;; These go into the %%INST-FLOAT-FPU-UNLOAD and %%INST-FMULT-FPU-UNLOAD fields of a K instruction
;;; Consider the 64 bit output to be composed of 4 16 bit chunks numbered from 0 to 3, with 0 being the least significant.
;;; We can now describe what each output operation produces on the 32 bit output bus by two digits, the first describing
;;; which 16 bits of the floating point result drive the most significant 16 bits of the bus and which the least.
(defconstant $$inst-fp-unload-32		#x0 "Unload most significant 32 bits of result")
(defconstant $$inst-fp-unload-high		#x0 "Unload most significant 32 bits of result")
(defconstand $$inst-fp-unload-23		#x1 "Unload most significant 32 bits of result with 16bit halves swapped")
(defconstand $$inst-fp-unload-high-swapped	#x1 "Unload most significant 32 bits of result with 16bit halves swapped")
(defconstand $$inst-fp-unload-31		#x2 "useless")
(defconstand $$inst-fp-unload-13		#x3 "useless")
(defconstand $$inst-fp-unload-10		#x4 "Unload least significant 32 bits of result")
(defconstand $$inst-fp-unload-low		#x4 "Unload least significant 32 bits of result")
(defconstand $$inst-fp-unload-01		#x5 "Unload least significant 32 bits of result with 16bit halves swapped")
(defconstand $$inst-fp-unload-low-swapped	#x5 "Unload least significant 32 bits of result with 16bit halves swapped")
(defconstand $$inst-fp-unload-20		#x6 "useless")
(defconstand $$inst-fp-unload-02		#x7 "useless")

;;; Floating point multiplier operation.  These are what go into the %%INST-FMULT-MPU-OP field of a K instruction.
(defconstant %%inst-fmpu-op-double		(byte 1 0) "Set this bit for double precision multiply, else zero for 32 bit")
(defconstant %%inst-fmpu-op-A-wrapped		(byte 1 1) "Set if the A input is normalized")
(defconstant %%inst-fmpu-op-B-wrapped		(byte 1 2) "Set if the B input is normalized")
(defconstant %%inst-fmpu-op-divide		(byte 1 6) "zero to multiply, one to divide")
(defconstant %%inst-fmpu-op-single-double	(byte 1 7) "mixed precision if set")
(defconstant %%inst-fmpu-op-A-magnitude		(byte 1 3) "use the magnitude of A rather than A itself")
(defconstant %%inst-fmpu-op-B-magnitude		(byte 1 4) "use the magnitude of A rather than B itself")
(defconstant %%inst-fmpu-op-negate-result	(byte 1 5) "negate the result of this operation")

;;; Floating point ALU operation.  These are what go into the %%INST-FLOAT-FPU-OP field of a K instruction.
(defconstant $$inst-falu-op-single-subtract		#x00 "A minus B, single precision")
(defconstant $$inst-falu-op-double-subtract		#x01 "A minus B, double precision")
(defconstant $$inst-falu-op-single-abs-subtract		#x02 "magnitude of A minus B, single precision")
(defconstant $$inst-falu-op-double-abs-subtract		#x03 "magnitude of A minus B, double precision")
(defconstant $$inst-falu-op-single-negate		#x08 "negate, single precision")
(defconstant $$inst-falu-op-double-negate		#x09 "negate, double precision")
(defconstant $$inst-falu-op-single-add			#x10 "add, single precision")
(defconstant $$inst-falu-op-double-add			#x11 "add, double precision")
(defconstant $$inst-falu-op-single-abs-add		#x12 "magnitude of sum, single precision")
(defconstant $$inst-falu-op-double-abs-add		#x13 "magnitude of sum, double precision")
(defconstant $$inst-falu-op-single-add-abs		#x14 "sum of magnitudes, single precision")
(defconstant $$inst-falu-op-double-add-abs		#x15 "sum of magnitudes, single precision")
(defconstant $$inst-falu-op-single-identity		#x18 "identity, single precision")
(defconstant $$inst-falu-op-double-identity		#x19 "identity, double precision")
(defconstant $$inst-falu-op-single-absolute-value	#x1c "absolute value, single precision")
(defconstant $$inst-falu-op-double-absolute-value	#x1d "absolute value, double precision")
(defconstant $$inst-falu-op-single-compare		#x20 "compare, single precision")
(defconstant $$inst-falu-op-double-compare		#x21 "compare, double precision")
(defconstant $$inst-falu-op-single-compare-magnitudes	#x24 "compare magnitudes single precision")
(defconstant $$inst-falu-op-double-compare-magnitudes	#x25 "compare magnitudes double precision")
(defconstant $$inst-falu-op-single-compare-with-zero	#x28 "compare with zero, single precision")
(defconstant $$inst-falu-op-double-compare-with-zero	#x29 "compare with zero, double precision")
(defconstant $$inst-falu-op-single-unwrap-exact		48.  "single unwrap exact value")
(defconstant $$inst-falu-op-double-unwrap-exact		49.  "double unwrap exact value")
(defconstant $$inst-falu-op-single-wrap			50.  "single wrap denormalized value")
(defconstant $$inst-falu-op-double-wrap			51.  "double wrap denormalized value")
(defconstant $$inst-falu-op-single-unwrap-inexact	52.  "single unwrap inexact value")
(defconstant $$inst-falu-op-double-unwrap-inexact	53.  "double unwrap inexact value")
(defconstant $$inst-falu-op-single-fix			56.  "single fix")
(defconstant $$inst-falu-op-double-fix			57.  "double fix")
(defconstant $$inst-falu-op-single-float		58.  "single float")
(defconstant $$inst-falu-op-double-float		59.  "double float")
(defconstant $$inst-falu-op-single-to-double		60.  "convert single to double")
(defconstant $$inst-falu-op-double-to-single		61.  "convert double to single")
(defconstant $$inst-falu-op-integer-A-minus-B		64.  "integer subtract, A - B")
(defconstant $$inst-falu-op-integer-B-minus-A		65.  "integer subtract, B - A")
(defconstant $$inst-falu-op-integer-A-minus-B-with-borrow  66. "integer subtract with borrow, A - B")
(defconstant $$inst-falu-op-integer-B-minus-A-with-borrow  67. "integer subtract with borrow, B - A")
(defconstant $$inst-falu-op-integer-negate		68.  "integer negate")
(defconstant $$inst-falu-op-integer-negate-plus-carry	69.  "integer negate plus carry")
(defconstant $$inst-falu-op-integer-add			70.  "integer add")
(defconstant $$inst-falu-op-integer-add-with-carry	71.  "integer add with carry")
(defconstant $$inst-falu-op-integer-identity		72.  "integer identity operator")
(defconstant $$inst-falu-op-pass-with-carry		73.  "integer identity pluus carry")
(defconstant $$inst-falu-op-integer-logical-and		74.  "integer logical and")
(defconstant $$inst-falu-op-integer-logical-not		75.  "integer logical invert")
(defconstant $$inst-falu-op-integer-logical-xor		76.  "integer exclusive or")
(defconstant $$inst-falu-op-integer-logical-or		77.  "integer logical or")

;;; the following opcodes are not used by the floating point ALU: 
;;; (4 5 6 7 10 11 12 13 14 15 22 23 26 27 30 31 34 35 38 39 42 43 44 45 46 47 54 55 62 63)


