ELLA (programming Language) - Sample

Sample

Sample originally from ftp://ftp.dra.hmg.gb/pub/ella (a now dead link) - Public release.

Code for matrix multiplication hardware design verification:

MAC ZIP = (TYPE t: vector1 vector2) -> t: (vector1, vector2). MAC TRANSPOSE = (TYPE t: matrix) -> t: matrix. MAC INNER_PRODUCT{FN * = TYPE t -> TYPE s, FN + = s -> s} = (t: vector) -> s: IF n = 1 THEN *vector ELSE *vector + INNER_PRODUCT {*,+} vector FI. MAC MATRIX_MULT {FN * = TYPE t->TYPE s, FN + = s->s} = (t: matrix1, t: matrix2) -> s: BEGIN LET transposed_matrix2 = TRANSPOSE matrix2. OUTPUT INNER_PRODUCT{*,+}ZIP(matrix1,transposed_matrix2) END. TYPE element = NEW elt/(1..20), product = NEW prd/(1..1200). FN PLUS = (product: integer1 integer2) -> product: ARITH integer1 + integer2. FN MULT = (element: integer1 integer2) -> product: ARITH integer1 * integer2. FN MULT_234 = (element:matrix1, element:matrix2) -> product: MATRIX_MULT{MULT,PLUS}(matrix1, matrix2). FN TEST = -> product: ( LET m1 = ((elt/2, elt/1, elt/1), (elt/3, elt/6, elt/9)), m2 = ((elt/6, elt/1, elt/3, elt/4), (elt/9, elt/2, elt/8, elt/3), (elt/6, elt/4, elt/1, elt/2)). OUTPUT MULT_234 (m1, m2) ). COM test: just displaysignal MOC

Read more about this topic:  ELLA (programming Language)

Famous quotes containing the word sample:

    The present war having so long cut off all communication with Great-Britain, we are not able to make a fair estimate of the state of science in that country. The spirit in which she wages war is the only sample before our eyes, and that does not seem the legitimate offspring either of science or of civilization.
    Thomas Jefferson (1743–1826)

    All that a city will ever allow you is an angle on it—an oblique, indirect sample of what it contains, or what passes through it; a point of view.
    Peter Conrad (b. 1948)

    As a rule they will refuse even to sample a foreign dish, they regard such things as garlic and olive oil with disgust, life is unliveable to them unless they have tea and puddings.
    George Orwell (1903–1950)