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
30 changes: 30 additions & 0 deletions hw1.t.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
`include "hw1.v"

module demorgan_test ();

// Instantiate device/module under test
reg A, B; //test inputs
wire nA, nB, nAandnB, AnandB, nAornB, AnorB; //test outputs

demorgan dut(A, B, nA, nB, nAandnB, AnandB, nAornB, AnorB);

// Run tests

initial begin
$display("\n");
$display("| A B | ~A ~V || ~A~B | ~(A+B) || ~A+~B | ~(AB) |");
A=0;B=0; #1
$display("| %b %b | %b %b || %b | %b || %b | %b |",
A,B, nA, nB, nAandnB, AnorB, nAornB, AnandB);
A=0;B=1; #1
$display("| %b %b | %b %b || %b | %b || %b | %b |",
A,B, nA, nB, nAandnB, AnorB, nAornB, AnandB);
A=1;B=0; #1
$display("| %b %b | %b %b || %b | %b || %b | %b |",
A,B, nA, nB, nAandnB, AnorB, nAornB, AnandB);
A=1;B=1; #1
$display("| %b %b | %b %b || %b | %b || %b | %b |",
A,B, nA, nB, nAandnB, AnorB, nAornB, AnandB);
$display("\n");
end
endmodule
26 changes: 26 additions & 0 deletions hw1.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// homework 1, exhaustively prove demorgan's law

module demorgan
(
input A,
input B,
output nA,
output nB,
output nAandnB,
output AnandB,
output nAornB,
output AnorB
);

wire nA;
wire nB;
not Ainv(nA, A);
// type: not, name: Ainv, output variable: nA, input variable: A
not Binv(nB, B);
and andgate(nAandnB, nA, nB);
nand nandgate(AnandB, A, B);
or orgate(nAornB, nA, nB);
nor norgate(AnorB, A, B);

endmodule

9 changes: 9 additions & 0 deletions results.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


| A B | ~A ~V || ~A~B | ~(A+B) || ~A+~B | ~(AB) |
| 0 0 | 1 1 || 1 | 1 || 1 | 1 |
| 0 1 | 1 0 || 0 | 0 || 1 | 1 |
| 1 0 | 0 1 || 0 | 0 || 1 | 1 |
| 1 1 | 0 0 || 0 | 0 || 0 | 0 |