sub.html 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <html>
  2. <head>
  3. <title>Substituting libraries</title>
  4. </head>
  5. <body bgcolor="FFFFFF">
  6. <h1>Substituting libraries</h1>
  7. <p>Now suppose we have two Logisim circuits that are supposed to do the same thing.
  8. As an instructor, you might have had students complete an assignment:
  9. You have one file containing your solution, but you have several student files
  10. containing their work. Maybe the assignment was to build a two-bit adder.</p>
  11. <p>I'll imagine that we have two files, named <tt>adder-master.circ</tt>
  12. and <tt>adder-query.circ</tt>. Each file contains a circuit named
  13. <q>2-bit adder</q> (it's important that the circuit to test be named exactly the same),
  14. whose appearance is the following.</p>
  15. <blockquote><table><tbody>
  16. <tr><td><tt>adder-master.circ</tt></td>
  17. <td><tt>adder-query.circ</tt></td></tr>
  18. <tr><td><img src="../../../../en/img-guide/verify-adder-master.png" width="184" height="63"></td>
  19. <td><img src="../../../../en/img-guide/verify-adder-query.png" width="171" height="112"></td></tr>
  20. </tbody></table></blockquote>
  21. <p>As you can see, the master circuit uses Logisim's built-in adder,
  22. while the query circuit uses two subcircuits representing a half adder and
  23. a full adder (which themselves are built up of simple gates).
  24. For the purpose of our example, the query circuit has a stupid error:
  25. The carry from the half adder is not connected into the full adder.</p>
  26. <p>We build our testing circuit into a different file. There, we load
  27. <tt>adder-master.circ</tt> as a Logisim Library
  28. (Project &gt; Load Library &gt; Logisim Library&hellip;), and we insert its
  29. 2-bit adder as a subcircuit. We could execute this circuit directly to get
  30. the desired output for a perfect solution.</p>
  31. <blockquote><tt>java&nbsp;-jar&nbsp;logisim-filename.jar&nbsp;adder-test.circ&nbsp;-tty&nbsp;table</tt></blockquote>
  32. <p>But we want to execute the circuit using <tt>adder-query.circ</tt>
  33. rather than <tt>adder-master.circ</tt> as the loaded library.
  34. The naive approach would be to open Logisim and load that library instead;
  35. or you might simply remove the <tt>adder-master.circ</tt> file and rename
  36. <tt>adder-query.circ</tt> to be named <tt>adder-master.circ</tt> instead.
  37. But Logisim includes a handy <q><tt>-sub</tt></q> option that temporarily replace
  38. one file by another during that session &mdash; without making any changes on disk.</p>
  39. <blockquote><tt>java&nbsp;-jar&nbsp;logisim-filename.jar&nbsp;adder-test.circ&nbsp;-tty&nbsp;table&nbsp;-sub&nbsp;adder-master.circ&nbsp;adder-query.circ</tt></blockquote>
  40. <p>The output you would see from this is shown below; it is of course different
  41. from what we saw in <a href="index.html">the previous section</a> since now it is
  42. executing using the erroneous <tt>adder-query.circ</tt>.</p>
  43. <blockquote><pre>00 00 0E0
  44. 01 00 0E1
  45. 10 00 EE0
  46. 11 00 EE1
  47. 00 01 0E1
  48. 01 01 0E0
  49. 10 01 EE1
  50. 11 01 EE0
  51. 00 10 EE0
  52. 01 10 EE1
  53. 10 10 1E0
  54. 11 10 1E1
  55. 00 11 EE1
  56. 01 11 EE0
  57. 10 11 1E1
  58. 11 11 1E0</pre></blockquote>
  59. <p><strong>Next:</strong>&nbsp;<a href="other.html">Other verification options</a>.</p>
  60. </body>
  61. </html>