Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions hw1.t.v
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions hw1.v
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions results.txt
Original file line number Diff line number Diff line change
@@ -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