home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / self / contrib.lha / contrib / simulator / examples.self < prev    next >
Encoding:
Text File  |  1991-05-23  |  4.0 KB  |  127 lines

  1. "$ Revision: 1.0 $"
  2. "Copyright 1990:
  3.     Jecel Mattos de Assumpcao Jr.
  4.     LSI - EPSUP, Sao Paulo, SP, Brasil"
  5.  
  6.     "Example Components"
  7.  
  8.     "library <examples> cc"
  9.     " a simple combinational circuit "
  10.  
  11.     "library <examples? st"
  12.     " a trivial state machine to test FSMs "
  13.  
  14.     "library <examples> osc"
  15.     " a controlled oscilator to test component vectors "
  16.  
  17. library examples _DefineSlots: ( |
  18.     cc = ( |
  19.            parent* = traits simulation component.
  20.            sim**.
  21.            dad.
  22.            leaf.
  23.            type = 'combinational circuit test'.
  24.            a. b. c. d. g.
  25.            declare = (
  26.                    a: input.
  27.                    b: input.
  28.                    c: input.
  29.                    d: input.
  30.                    g: output.
  31.                   ).
  32.            behave = ( set: g To: ((a || b) && (c || d)) After: 10 ).
  33.            u1. u2. u3.
  34.            netlist = (
  35.                       u1: ( get: library or2 ).
  36.                       u2: ( get: library or2 ).
  37.                       u3: ( get: library and2 ).
  38.                       u1 out to: u3 in1.
  39.                       u2 out to: u3 in2.
  40.                       u1 in1 to: a.
  41.                       u1 in2 to: b.
  42.                       u2 in1 to: c.
  43.                       u2 in2 to: d.
  44.                       u3 out to: g.
  45.                      ).
  46.     | ).
  47.     ff = ( |
  48.            parent* = traits simulation component.
  49.            sim**.
  50.            dad.
  51.            leaf.
  52.            type = 'single phase clock latch test'.
  53.            in. phi. out.
  54.            declare = (
  55.                    in: input.
  56.                    phi: input.
  57.                    out: output.
  58.                   ).
  59.            latch. inv.
  60.            netlist = (
  61.                       latch: ( get: library ocLatch ).
  62.                       inv: ( get: library inverter ).
  63.                       in to: latch in.
  64.                       phi to: latch phi.
  65.                       latch out to: inv in.
  66.                       inv out to: out.
  67.                      ).
  68.     | ).
  69.     st = ( |
  70.            parent* = traits simulation component.
  71.            sim**.
  72.            dad.
  73.            leaf.
  74.            type = 'state machine test'.
  75.            clk. sm. div3.
  76.            declare = (
  77.                    clk: input.
  78.                    sm: ( fsm initial: 'first' ).
  79.                    div3: output.
  80.            ).
  81.            behave = (
  82.                   sm onRising: clk Is: [
  83.                       state: 'first' Do: [ goto: 'second'.
  84.                                            set: div3 To: h After: 2 ].
  85.                       state: 'second' Do: [ goto: 'third'.
  86.                                             set: div3 To: l After: 2 ].
  87.                       state: 'third' Do: [ goto: 'first' ].
  88.                   ].
  89.            ).
  90.     | ).
  91.     osc = ( |
  92.             parent* = traits simulation component.
  93.             sim**.
  94.             dad.
  95.             leaf.
  96.             type = 'controlled oscilator'.
  97.             enable. out.
  98.             declare = (
  99.                        enable: input.
  100.                        out: input.
  101.             ).
  102.             behave = (
  103.                    enable isHigh ifTrue: [
  104.                        out isHigh ifTrue: [ set: out To: l After: 12 ]
  105.                                      False: [ set: out To: h After: 12 ].
  106.                    ].
  107.                    enable isUnknown ifTrue: [ set: out To: x After: 12 ].
  108.                    enable isLow ifTrue: [ set: out To: h After: 12 ].
  109.             ).
  110.             nand. invs.
  111.             netlist = (
  112.                    nand: ( get: library nand2 ).
  113.                    invs: vector copySize: 6.
  114.                    6 do: [ | :i |
  115.                        invs at: i Put: ( get: library inverter ).
  116.                    ].
  117.                    1 to: 5 Do: [ | :i |
  118.                        ( invs at: i ) in to: ( invs at: i - 1 ) out.
  119.                    ].
  120.                    ( invs at: 5 ) out to: out.
  121.                    nand in1 to: out.
  122.                    nand in2 to: enable.
  123.                    nand out to: ( invs at: 0 ) in.
  124.             ).
  125.     | ).
  126. | )
  127.