LDE_FORMAT(10.6)                                 LDE_FORMAT(10.6)

     NAME
          lde - logic design expression language

     DESCRIPTION
          The lde language contains declaration areas that must appear
          in the following order:

          .x   an optional chip declaration area,
          .m   a master pin definition (LDE only)
          .i   an input declaration area,
          .o   an output declaration area,
          .io  an external input/output declaration area
          .b   a buried input/output declaration area
          .f   an optional field declaration area,
          .e   and an expression area.

          The lde language contains expressions like those in C.
          Identifiers may include +, -, and . and semicolons are not
          used to end statements.  Symbols must be declared before
          used.

          The chip declaration area contains two strings, name and
          type.

          Variables are declared by white-space delimited lists in the
          .i, io, .b, or .o areas or by appearance on the left of an =
          in the .f or .e areas.  The variables are computer words
          with one or more bits representing two-level logic signals.
          In the default case, the least significant bit represents a
          single signal.  An entry identifier[n], where n is an inte-
          ger,  maps the logic signals identifier0, identifier1, ...
          identifiern-1 to the least significant through the n-1th bit
          of identifier. The numeric suffixes are left filled with
          zeros so that they all have the same number of digits.  Sim-
          ilarly, an entry in the field declaration area of the form
          n_id = o_id o_id ... defines a new multibit variable n_id
          the least significant bit of which is the first old identi-
          fier, o_id and the higher bits the following old identifier.

          Lde also accepts white-space delimited declarations of the
          form name:master in the .m area to declare an instance of a
          master definition.  The master corresponds to a library def-
          inition in the target technology to be used. Variables of
          the form name.id for each pin in the corresponding master
          library definition may then be used in the expressions.

          In the .e area, the binary operators *, /, %, +, -, <, <=,
          >, >=, ==, !=, &, ^, |, &&, and || have the same meaning as
          in the C language. So do the unary operators ! and ~ and the
          conditional operator ?:.  Since lde is an expression

     Page 1                       Plan 9             (printed 4/23/24)

     LDE_FORMAT(10.6)                                 LDE_FORMAT(10.6)

          language, no flow control (such as if or switch) is allowed.
          An expression selector is available; expra{[[exprb]:]exprc,
          [[exprd]:]expre, ...} has the value of exprc if expra equals
          exprb. If there is no exprb and there is a colon, then exprc
          is the default case.  If there is no exprb and no colon,
          then the pre-incremented value of the prior value of exprb
          is used, and the prior value of exprb is initialized to -1.

          Combinatorial logic may be specified with the assignment
          operator, =. The assignment operator ~= is a cue to down
          stream programs that the combinational logic of the right
          hand side is to be inverted.

          The assignment operators :=, #=, and ^= specify clocked out-
          puts. The expression on the right hand side is the clock.
          The data input is a simple assignment statement as above.
          := means D flip-flop, #= transparent latch, and ^= toggle
          flip-flop (output toggles when the date input is true).
          Optionally for clocked devices, +=, -=, and %= define sig-
          nals that set, clear, and qualify the clock.

          The operator *= assigns the enable expression for tri-state
          outputs. Sometimes, in the case of tri-state outputs used as
          inputs, it is important to state whether the input is before
          or after the tri-state driver. id<-P means use signal id at
          the pin (after the tri-state driver) while id<-Q means use
          the internal signal before the tri-state driver.

          Identifiers may be modified by a appended single quote ('),
          in which case a value of one has the meaning "don't_care"
          for the unmodified identifier.

          Numeric values may be passed from the command line of the
          program interpreting the lde language.  They appear as $m.
          The (zero based) mth occurrence of -n on the command line
          substitutes the value n for the symbol $m.

     EXAMPLES
          A 4-bit counter.

                .i
                    ck
                    en
                .b
                    x[4]           /* a buried vector */
                .o
                    c[4]
                .f
                    rx = x3 x2 x1 x0    /* note use of vector elements */
                .e
                    x = x ^ (x + 1)     /* expression for counter */
                    x ^= ~0*ck          /* if the elements are toggles */

     Page 2                       Plan 9             (printed 4/23/24)

     LDE_FORMAT(10.6)                                 LDE_FORMAT(10.6)

                    c = rx         /* output bit reversal of counter */
                    c *= ~0*en          /* note ~0* idiom */

          A simple state machine that indicates even, state equals 3,
          or odd, state equals 0, number of input ones.

                .i
                    input clk reset
                .io
                    state[2]
                .e
                    state = state {
                              0:
                                   (input == 1) ? 4 : 0,
                              4:
                                   (input == 1) ? 0 : 4,
                              :
                                   0
                    }

                    state' = state & 1       /* don't cares */

                    state -= reset ~0 : 0         /* clear */

                    state := clk ? ~0 : 0         /* d flip-flop */

     SEE ALSO
          lde(10.1)

     Page 3                       Plan 9             (printed 4/23/24)