Skip to content

Commit f853300

Browse files
author
martin-henz
committed
solution added
1 parent 57b25d7 commit f853300

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

xml/chapter3/section3/subsection4.xml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,8 +720,32 @@ function or_gate(a1, a2, output) {
720720
<JAVASCRIPT><JAVASCRIPTINLINE>inverter_delay</JAVASCRIPTINLINE>?
721721
</JAVASCRIPT>
722722
</SPLITINLINE>
723-
</EXERCISE>
723+
<SOLUTION>
724+
(contributed by github user <LINK address="https://github.com/taimoon">taimoon</LINK>)
725+
<BREAK/>
726+
Idea: ~(~a &amp; ~b) = nand(~a, ~b) = ~~a | ~~b = a | b
727+
<SNIPPET EVAL="no">
728+
<JAVASCRIPT>
729+
function nand_gate(a1, a2, out){
730+
const tmp = make_wire();
731+
and_gate(a1, a2, tmp);
732+
inverter(tmp, out);
733+
}
724734

735+
function or_gate(a1, a2, out){
736+
const not_a1 = make_wire();
737+
const not_a2 = make_wire();
738+
inverter(a1, not_a1);
739+
inverter(a2, not_a2);
740+
nand_gate(not_a1, not_a2, out);
741+
}
742+
</JAVASCRIPT>
743+
</SNIPPET>
744+
The delay time of the nand-gate is
745+
<JAVASCRIPTINLINE>nand_gate_delay = and_gate_delay + inverter_delay</JAVASCRIPTINLINE> and the delay time of the or-gate above is
746+
<JAVASCRIPTINLINE>or_gate_delay = nand_gate_delay + inverter_delay = and_gate_delay + 2 * inverter_delay</JAVASCRIPTINLINE>.
747+
</SOLUTION>
748+
</EXERCISE>
725749
<SHORT_PAGE lines="1"/>
726750
<EXERCISE>
727751
Figure<SPACE/><REF NAME="fig:ripple-carry"/> shows a

0 commit comments

Comments
 (0)