home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s205 / 1.ddi / BACKUP.001 / DOC_IREF_IFCASE.HLP < prev    next >
Encoding:
Text File  |  1991-03-11  |  8.4 KB  |  245 lines

  1. =====================================================================
  2. Some Notes On Using IF-THEN-ELSE And CASE Statements
  3. =====================================================================
  4. You may not use curly braces, ( i.e. { ...} ) inside of IF-THEN-ELSE clauses
  5. or inside of CASE statements. Instead of the curly-braced shorthand, the
  6. right-hand side of the referred-to logic equation must be copied in full as
  7. the right-hand side of the equivalent logic equation ( as in output pairing ).
  8. Furthermore, although it is legal to do so, it is not recommended that you use
  9. curly-braces outside of an IF-THEN-ELSE or CASE construct to refer to an
  10. equation that is defined inside of such constructs. The result may not be that
  11. which you desire or expect.
  12.  
  13. ---------------------------------------------------------------------
  14. For PALASM 4 version 1.1 the following applies only if you are using the
  15. default = DON'T CARE setting in the Logic Synthesis Options.
  16. ---------------------------------------------------------------------
  17.  
  18. The following rules apply to each pin or node for which outputs are defined 
  19. anywhere in the IF-THEN-ELSE or CASE statement.
  20.  
  21. Specify the desired output for each test condition of the IF-THEN-ELSE or 
  22. CASE statement for which you want a specific output to be generated.   
  23.  
  24. Note:   If you do not request a specific output, the PALASM software assumes 
  25. either you do not care about the output in this condition, or the output in 
  26. this condition is actually defined through some other equations.
  27.  
  28. If you define the behavior of an output in an IF-THEN-ELSE or CASE statement, 
  29. and then define it further using a Boolean equation or a separate IF-THEN-
  30. ELSE or CASE statement, you must obey certain rules.  Specifically, you must 
  31. avoid situations when both of the following occur.
  32.  
  33.  -     More than one of the resulting equations can be simultaneously
  34.        evaluated as true.
  35.  -     The output behavior defined in one equation contradicts behavior
  36.        defined in the other.
  37.  
  38. If you violate these rules, the PALASM software reports the following error 
  39. message: Overlapping on/off covers (check equations for completeness).  
  40. Techniques for avoiding this error are discussed at the end of this release 
  41. note, under the heading Avoiding Overlap Errors.
  42.  
  43.  
  44. You can specify the behavior of each pin or node in four ways.
  45.  
  46. 1.     Define the output as a function of the same inputs for each
  47.        possible test condition.
  48. 2.     Define the output as a function of different inputs for different
  49.        test conditions.
  50. 3.     Define the output for some of the possible test conditions and not
  51.        for others.
  52. 4.     Define the output two different ways for the same test condition.
  53.  
  54. The following examples are given for the IF-THEN-ELSE statement, but they 
  55. apply to the CASE statement also.  The IF-THEN-ELSE statement is a special 
  56. instance of the CASE statement in which IF and ELSE portions replace the 
  57. individual test conditions of the CASE statement.  Sessions 6 and 7 of the 
  58. Boolean Tutorials explain the IF-THEN-ELSE and CASE statements in greater 
  59. detail.
  60.  
  61. Example 1
  62. Defining the output as a function of the same inputs for each possible test 
  63. condition.
  64.  
  65. IF X = 0 THEN
  66.      BEGIN
  67.           Q = A * B
  68.      END
  69. ELSE
  70.      BEGIN
  71.           Q = 0 ;equivalent to Q = GND or /Q = 1 or /Q = VCC
  72.      END
  73.  
  74. The PALASM software interprets this statement as follows.
  75.  
  76.  -     When X = 0, output Q is high when the expression A * B evaluates as
  77.        true and low when the expression A * B evaluates as false. 
  78.  -     When X = 1, output Q is always low. 
  79.  
  80. The statement is reduced to the following Boolean form.
  81.  
  82.           Q = A  *  B  * /X
  83.  
  84. This is then combined with any other equations for Q by the minimizer, as 
  85. described above.
  86.  
  87. Example 2
  88. Defining the output as a function of different inputs for different test 
  89. conditions.
  90.  
  91. IF X = 0 THEN
  92.      BEGIN
  93.           Q = A * B
  94.      END
  95. ELSE
  96.      BEGIN
  97.           Q = C * D
  98.      END
  99.  
  100. The PALASM software interprets this statement as follows.
  101.  
  102.  -     When X = 0, output Q is high when the expression A * B evaluates as
  103.        true and low when the expression A * B evaluates as false. 
  104.  -     When X = 1, output Q is high when the expression C * D evaluates as
  105.        true and low when the expression C * D evaluates as false. 
  106.  
  107. The statement is reduced to the following Boolean form.
  108.  
  109.           Q =  C  *  D  *  X
  110.           +  A  *  B  * /X
  111.  
  112. This is then combined with any other equations for Q by the minimizer, as 
  113. described above.
  114.  
  115. Example 3
  116. Defining the output for some of the possible test conditions and not for 
  117. others.
  118.  
  119. IF X = 0 THEN
  120.      BEGIN
  121.           Q = A * B
  122.      END     ; No ELSE condition or no output
  123.              ; equation
  124.              ; in some of the CASE conditions
  125.  
  126. The PALASM software interprets this statement as follows.
  127.  
  128.  -     When X = 0, output Q is high when the expression A * B evaluates as
  129.        true and low when the expression A * B evaluates as false. 
  130.  -     When X = 1, output Q is undefined.  In the Karnaugh map, don't-care
  131.        values are used for all map locations where X = 1, unless some of
  132.        these locations are defined by other equations for Q.
  133.  
  134. The statement is reduced to the following Boolean form.
  135.  
  136.           Q =  A  *  B  * /X
  137.           +  "don't care" * X
  138.  
  139. This is then combined with any other equations for Q by the minimizer, as 
  140. described above.  In the event that there is no other equation for Q, this 
  141. equation reduces to Q = A * B, in which case output Q is no longer a function 
  142. of input X.  This occurs because of the don't-care values introduced by 
  143. omitting the definition of output Q when X = 1.  If you want output Q to 
  144. remain a function of X, rewrite the IF-THEN-ELSE statement, adding the ELSE 
  145. clause shown in boldface type below.
  146.  
  147. IF X = 0 THEN
  148.      BEGIN
  149.           Q = A * B
  150.      END 
  151. ELSE
  152.      BEGIN
  153.           Q = 0
  154.      END
  155.  
  156. Example 4
  157. Defining the output two different ways for the same test condition.
  158.  
  159. IF X = 0 THEN
  160.      BEGIN
  161.            Q =  A * B
  162.           /Q = /A
  163.      END
  164. ELSE
  165.      BEGIN
  166.           Q = 0 ;equivalent to Q = GND or /Q = 1 or /Q = VCC
  167.      END
  168.  
  169. Here, the designer has defined explicitly when the output should be high or 
  170. low, when X = 0.  The PALASM software interprets this statement as
  171. follows.
  172.  
  173.  -     When X = 0, output Q is high when the expression A * B evaluates as
  174.        true and low when the expression input A is low. 
  175.  -     When X = 1, output Q is always low.
  176.  
  177. The statement is reduced to the following Boolean form.
  178.  
  179.           Q = A * /X
  180.  
  181. This is then combined with any other equations for Q by the minimizer, as 
  182. described above.  Note that output Q is no longer a function of input B.  
  183. This occurs because the PALASM software assumes don't-care values for all 
  184. conditions that are not covered by the equations 
  185.  
  186.           Q =  A * B and /Q = /A, where X = 0.
  187.  
  188. Avoiding Overlap Errors
  189. The following example shows how two separate IF-THEN-ELSE statements can 
  190. interact to produce an Overlapping on/off covers (check equations for 
  191. completeness) error.  Most such errors are caused by unrealizability, as 
  192. illustrated in the following example.
  193. Example
  194.  
  195. IF A = 1 THEN
  196.      BEGIN
  197.           Q = C * D
  198.      END
  199. IF B THEN
  200.      BEGIN
  201.           Q = 1
  202.      END
  203.  
  204. The problem arises in this case when both A and B are high and C or D or both 
  205. C and D are low.  In this situation, the first IF statement tells output Q to 
  206. go low, while the second IF statement tells the same output to go high.  
  207. Since Q cannot be high and low simultaneously, the equation set is 
  208. unrealizable.
  209.  
  210. There are several ways to avoid problems of this nature.  Two of them are 
  211. described below.
  212.  
  213. Method 1
  214. Make it impossible to have more than one 
  215. IF-THEN-ELSE or CASE statement evaluate as 
  216. true simultaneously.
  217.  
  218. Example
  219. IF A = 1 THEN
  220.          BEGIN
  221.                 Q = C * D
  222.          END
  223.  
  224. IF /A * B THEN                  ;Condition /A prevents both IF
  225.      BEGIN                      ;statements from evaluating as
  226.                         Q = 1   ;true simultaneously.
  227.          END
  228.  
  229. Method 2
  230. Make it impossible for the output specifications to conflict by always using 
  231. the same output equation.
  232. Example
  233.  
  234. IF A = 1 THEN
  235.      BEGIN
  236.           Q = 1     ;This output equation...
  237.      END
  238.  
  239. IF B = 1 THEN
  240.      BEGIN
  241.           Q = 1     ;...is identical to this.
  242.      END
  243.  
  244.  
  245.