initial commit: implement a NAND gate, and test it

This commit is contained in:
2024-06-12 22:01:00 -07:00
commit 9d65605f62
5 changed files with 49 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
*~
*.vcd
*.vvp
nohup.out

11
Makefile Normal file
View File

@@ -0,0 +1,11 @@
clean:
-rm *.vcd *.vvp
nand_tb: nand_tb.vcd
gtkwave nand_tb.vcd &
nand_tb.vcd: nand_tb.vvp
vvp nand_tb.vvp
nand_tb.vvp: nand.v nand_tb.v
iverilog -o nand_tb.vvp nand_tb.v

7
README.md Normal file
View File

@@ -0,0 +1,7 @@
nand2tetris_verilog
===================
My attempt at learning Verilog by using it to implement the
[From Nand to Tetris](https://www.nand2tetris.org/) design. Initial stages
need Icarus Verilog, GTKWave, and make to test.

7
nand.v Normal file
View File

@@ -0,0 +1,7 @@
module Nand (in1, in2, out);
input wire in1;
input wire in2;
output wire out;
assign out=~(in1&&in2);
endmodule

20
nand_tb.v Normal file
View File

@@ -0,0 +1,20 @@
`include "nand.v"
module Nand_test;
reg in1=0;
reg in2=0;
wire out;
initial begin
$dumpfile("nand_tb.vcd");
$dumpvars;
#1 in1=1;
#1 begin
in1=0;
in2=1;
end;
#1 in1=1;
#1 $finish();
end
Nand u1(.in1(in1), .in2(in2), .out(out));
endmodule