Ignore:
Timestamp:
Sep 16, 2010, 3:31:33 PM (10 years ago)
Author:
mulligan
Message:

Lots of work done on tidying up code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/Bit.ml

    r64 r83  
    2222  val (-^-): bit -> bit -> bit
    2323  val not: bit -> bit
     24
     25  val zero: bit
     26
     27  (* Half add: two input bits, returns addition of bit plus carry. *)
     28  val half_add: bit -> bit -> (bit * bit)
     29  (* Full add: two input bits, plus input carry bit, returns       *)
     30  (* addition of input bits plus carry.                            *)
     31  val full_add: (bit * bit) -> bit -> (bit * bit)
    2432end;;
    2533
     
    6775      true -> false
    6876    | false -> true
     77
     78  let zero = false
     79
     80  let half_add l r = (l -^- r, l -&- r)
     81  let full_add (l, c) r =
     82    ((l -^- r) -^- c, (l -&- r) -|- (c -&- (l -^- r)))
    6983end;;
Note: See TracChangeset for help on using the changeset viewer.