diff --git a/hw1.t.v b/hw1.t.v new file mode 100644 index 0000000..0869d53 --- /dev/null +++ b/hw1.t.v @@ -0,0 +1,21 @@ +`include "hw1.v" + +module demorgan_test (); + + reg A, B; + wire nA, nB, nAandnB, AandB, nAandB, nAornB, AorB, nAorB; + + demorgan dut(A, B, nA, nB, nAandnB, AandB, nAandB, nAornB, AorB, nAorB); + + initial begin + $display("A B | ~A ~B | ~A~B | ~(AB) | ~A+~B | ~(A+B)"); + A=0;B=0; #1 + $display("%b %b | %b %b | %b | %b | %b | %b ", A,B, nA, nB, nAandnB, nAandB, nAornB, nAorB); + A=0;B=1; #1 + $display("%b %b | %b %b | %b | %b | %b | %b ", A,B, nA, nB, nAandnB, nAandB, nAornB, nAorB); + A=1;B=0; #1 + $display("%b %b | %b %b | %b | %b | %b | %b ", A,B, nA, nB, nAandnB, nAandB, nAornB, nAorB); + A=1;B=1; #1 + $display("%b %b | %b %b | %b | %b | %b | %b ", A,B, nA, nB, nAandnB, nAandB, nAornB, nAorB); + end +endmodule diff --git a/hw1.v b/hw1.v new file mode 100644 index 0000000..8d1f468 --- /dev/null +++ b/hw1.v @@ -0,0 +1,34 @@ +module demorgan +( + input A, + input B, + output nA, + output nB, + output nAandnB, + + output AandB, + output nAandB, + output nAornB, + output AorB, + output nAorB +); + + wire nA; + wire nB; + + wire AandB; + wire AorB; + + not Ainv(nA, A); + not Binv(nB, B); + and andgate(nAandnB, nA, nB); + + and andgate(AandB, A, B); + not AandBinv(nAandB, AandB); + + or orgate(nAornB, nA, nB); + + or orgate(AorB, A, B); + not AorBinv(nAorB, AorB); + +endmodule diff --git a/results.txt b/results.txt new file mode 100644 index 0000000..8a2199c --- /dev/null +++ b/results.txt @@ -0,0 +1,5 @@ +A B | ~A ~B | ~A~B | ~(AB) | ~A+~B | ~(A+B) +0 0 | 1 1 | 1 | 1 | 1 | 1 +0 1 | 1 0 | 0 | 1 | 1 | 0 +1 0 | 0 1 | 0 | 1 | 1 | 0 +1 1 | 0 0 | 0 | 0 | 0 | 0 \ No newline at end of file