home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p078 / 7.img / TUTOR.PLB / SINEWAVE.PLD < prev    next >
Encoding:
Text File  |  1990-12-11  |  2.0 KB  |  44 lines

  1.                            SINE WAVE CONVERTER
  2.  
  3.     This map generates logic for a binary to sin-wave converter, for
  4. example for a digital power inverter.  A counter external to the logic
  5. generates step numbers that run 0, 1, 2, ..., 254, 255, 0.  Given the step
  6. number n, the logic consider it to represent an angle of (n/256)*360
  7. degrees, and computes the trigonometric sin of the angle (see Chapter 12
  8. of the reference guide for a description of the function isin).  The
  9. result is presented in 8 bits of precision according to the following
  10. twos-complement encoding.
  11.  
  12.      Binary     Decimal    Rational   Decimal
  13.      Value       Value     Fraction   Fraction
  14.  
  15.     01111111b     127      127/127    1.0
  16.     01111110b     126      126/127     .99212598...
  17.         :           :         :        .
  18.     00000001b       1        1/127     .00787401...
  19.     00000000b       0        0         .0
  20.     11111111b      -1       -1/127    -.00787401...
  21.         :           :         :        .
  22.     10000010b    -126     -126/127     .99212598...
  23.     10000001b    -127     -127/127    1.0
  24.  
  25.     Because this logic has eight input bits and eight output bits, it
  26. requires at least a 256 x 8 PROM (the logic is too complex to fit in a
  27. PAL).  The input signals become address lines, with high-order bit first.
  28. The output signals become data lines, also with high-order bit first.
  29.  
  30. |PROM256B8   in:STEP[7..0], out:SIN[7..0]
  31. |
  32. | Map:  STEP[7..0] -> SIN[7..0]  { n -> isin(n, 256, 127) }
  33. |
  34. | Vectors:
  35. | { Display "127 * sin(", (STEP[7..0])d, "/256) = ", (SIN[7..0])d
  36. |   Test STEP[7..0]
  37. |   End }
  38.  
  39.  
  40.     VECTORS can test the logic in a PROM, but there is no provision in the
  41. hexadecimal format for the test vectors themselves.  Therefore, with PROMs,
  42. VECTORS is used only as a logic simulator.
  43.  
  44.