Académique Documents
Professionnel Documents
Culture Documents
ANITH M THOMAS
0917102
ANITH M THOMAS
0917102
assign g = e | f; assign j = ~(h & i); assign m = ~(k | l); endmodule TEST BENCH module testbasigat; // Inputs reg a, b, c, e, f, h, i, k, l ; // Outputs wire abar, d ,g ,j ,m; // Instantiate the Unit Under Test (UUT) basegateda uut ( .a(a), .abar(abar), .b(b), .c(c), .d(d), .e(e), .f(f), .g(g), .h(h), .i(i), .j(j), .k(k), .l(l), .m(m) ); initial begin // Initialize Inputs a = 0; b = 0; c = 0; e = 0; f = 0; h = 0; i = 0; k = 0; l = 0; #100; a = 1; // Wait 100 ns for global reset to finish
Page 2
ANITH M THOMAS
0917102
b = 0; c = 1; e = 0; f = 1; h = 0; i = 1; k = 0; l = 1; #100; a = 0; b = 1; c = 0; e = 1; f = 0; h = 1; i = 0; k = 1; l = 0; #100; a = 1; b = 1; c = 1; e = 1; f = 1; h = 1; i = 1; k = 1; l = 1; end endmodule // Wait 100 ns for global reset to finish // Wait 100 ns for global reset to finish
SIMULATION:
Christ University Faculty Of Enigneering Page 3
ANITH M THOMAS
0917102
Page 4
ANITH M THOMAS
0917102
assign s= a ^ b; assign c= a endmodule TEST BENCH: module testhalad; reg a,b; // Inputs & b;
Page 5
ANITH M THOMAS
0917102
wire s,c;
// Outputs
// Instantiate the Unit Under Test (UUT) halvade uut (.a(a), .b(b), .s(s), .c(c) initial begin a = 0; b = 0; // Initialize Inputs );
#100; // Wait 100 ns for global reset to finish a = 0; b = 1; #100; // Wait 100 ns for global reset to finish a = 1; b = 0; #100; // Wait 100 ns for global reset to finish a = 1; b = 1; #100; // Wait 100 ns for global reset to finish end endmodule
SIMUATION:
Page 6
ANITH M THOMAS
0917102
Page 7
ANITH M THOMAS
0917102
Page 8
ANITH M THOMAS
0917102
assign s= (a ^ b ^ c); //Defining the output Sum by a xor b xor c assign ca=((a & b) | (b & c) | (c & a)); /*defining the output Carry by (a and b) or (b and c) or (c and a)*/ endmodule TEST BENCH: module fuadat; // Inputs reg a; reg b; reg c; // Outputs wire s; wire ca; // Instantiate the Unit Under Test (UUT) fuladat uut (.a(a), .b(b), .c(c), .s(s), .ca(ca)); initial begin // Initialize Inputs a = 0; b = 0; c = 0; #100; // Wait 100 ns for global reset to finish a = 0; b = 0; c = 1; #100; // Wait 100 ns for global reset to finish a = 0; b = 1; c = 0; #100; // Wait 100 ns for global reset to finish a = 0; b = 1; c = 1;
Page 9
ANITH M THOMAS
0917102
#100; // Wait 100 ns for global reset to finish a = 1; b = 0; c = 0; #100; // Wait 100 ns for global reset to finish a = 1; b = 0; c = 1; #100; // Wait 100 ns for global reset to finish a = 1; b = 1; c = 0; #100; // Wait 100 ns for global reset to finish a = 1; b = 1; c = 1; end endmodule
SIMULATION:
Page 10
ANITH M THOMAS
0917102
ANITH M THOMAS
0917102
assign bo= w1 & b; endmodule TESTBENCH: module testhalsub; reg a,b; wire di,bo; // Inputs // Outputs
// Instantiate the Unit Under Test (UUT) halsubdat uut (.a(a), .b(b), .di(di), .bo(bo)); initial begin // Initialize Inputs a = 0; b = 0; #100; // Wait 100 ns for global reset to finish a = 0; b = 1; #100; // Wait 100 ns for global reset to finish a = 1; b = 0; #100; // Wait 100 ns for global reset to finish a = 1; b = 1; end endmodule
SIMULATION:
Page 12
ANITH M THOMAS
0917102
Page 13
ANITH M THOMAS
0917102
ANITH M THOMAS
0917102
assign di= ( a ^ b ^ c); assign w1= ~a; assign w2= (w1 & b); assign w3= (w1 & c); assign w4= (b & c); assign bo= (w2 | w3 | w4); endmodule TESTBENCH: module testfulsub; reg a; reg b; reg c; wire di; wire bo; // Outputs // Inputs
// Instantiate the Unit Under Test (UUT) fulsubda uut ( .a(a), .b(b), .c(c), initial begin // Initialize Inputs a = 0; b = 0; c = 0; #100; a = 0; b = 0; c = 1; #100; a = 0; b = 1; c = 0; #100; // Wait 100 ns for global reset to finish
Page 15
.di(di), .bo(bo) );
ANITH M THOMAS
0917102
a = 0; b = 1; c = 1; #100; a = 1; b = 0; c = 0; #100; a = 1; b = 0; c = 1; #100; a = 1; b = 1; c = 0; #100; a = 1; b = 1; c = 1; end endmodule // Wait 100 ns for global reset to finish // Wait 100 ns for global reset to finish // Wait 100 ns for global reset to finish // Wait 100 ns for global reset to finish
SIMULATION:
Page 16
ANITH M THOMAS
0917102
DATA FLOW DESCRIPTION: module mul2to1(a ,b ,s ,y); input a, b, s; output y; wire w1,w2,w3; // Dataflow code for Multiplexer 2 to 1
Christ University Faculty Of Enigneering Page 17
ANITH M THOMAS
0917102
assign w1 = ~s; assign w2 = a & w1 ; assign w3 = b & s ; assign y = w2 | w3 ; endmodule TEST BENCH: module testmux; reg a; reg b; reg s; wire y; // Outputs // Inputs
// Instantiate the Unit Under Test (UUT) mul2to1 uut (.a(a), .b(b), .s(s), .y(y) ); initial begin // Initialize Inputs a = 0; b = 0; s = 0; #100; a = 1; b = 0; s = 0; #100; a = 0; b = 0; s = 1; #100; a = 0; b = 1; s = 1; #100; a = 1; b = 1; s = 0;
Christ University Faculty Of Enigneering Page 18
ANITH M THOMAS
0917102
#100;
a = 1; b = 1; s = 1; end endmodule
SIMULATION:
Page 19
ANITH M THOMAS
0917102
ANITH M THOMAS
0917102
wire w1,w2,w3,w4,w5,w6; //Data Multiplexer for 4 to 1 assign w1 = ~s0; assign w2 = ~s1; assign w3 = (a & w1 & w2); assign w4 = (b & w1 & s1); assign w5 = (c & s0 & w1); assign w6 = (d & s0 & s1); assign y = (w3 | w4 | w5 | w6); endmodule TESTBENCH: module testmuxctoek; // Inputs reg a,b,c,d,s0,s1; // Outputs wire y; // Instantiate the Unit Under Test (UUT) Datamuxchartoek uut (.a(a), .b(b), .c(c), .d(d), .s0(s0), .s1(s1), .y(y) ); initial begin a = 0; b = 0; c = 0; d = 0; s0 = 0; s1 = 0; #100; // Wait 100 ns for global reset to finish
a = 0; b = 0; c = 0; d = 0; s0 = 0; s1 = 1;
Christ University Faculty Of Enigneering Page 21
ANITH M THOMAS
0917102
#100;
Page 22
ANITH M THOMAS
0917102
Page 23
ANITH M THOMAS
0917102
wire e2; wire e3; // Instantiate the Unit Under Test (UUT) bcdtoecxses uut ( .b0(b0), .b1(b1), .b2(b2), .b3(b3), .e0(e0), .e1(e1), .e2(e2), .e3(e3) ); initial begin // Initialize Inputs b0 = 0; b1 = 0; b2 = 0; b3 = 0; #100; // Wait 100 ns for global reset to finish
ANITH M THOMAS
0917102
SIMULATION:
Page 25
ANITH M THOMAS
0917102
Page 26
ANITH M THOMAS
0917102
wire g0; wire g1; wire g2; wire g3; // Instantiate the Unit Under Test (UUT) btogconv uut ( .b0(b0), .b1(b1), .b2(b2), .b3(b3), .g0(g0), .g1(g1), .g2(g2), .g3(g3) ); initial begin // Initialize Inputs b0 = 0; b1 = 0; b2 = 0; b3 = 0; #100; // Wait 100 ns for global reset to finish
ANITH M THOMAS
0917102
#100; b0 = 0; b1 = 0; b2 = 0; b3 = 1; #100; b0 = 1; b1 = 0; b2 = 0; b3 = 1; #100; b0 = 0; b1 = 1; b2 = 0; b3 = 1; #100; b0 = 1; b1 = 1; b2 = 0; b3 = 1; #100; b0 = 0; b1 = 0; b2 = 1; b3 = 1; #100; b0 = 1; b1 = 0; b2 = 1; b3 = 1; #100; b0 = 0; b1 = 1; b2 = 1; b3 = 1; #100; b0 = 1; b1 = 1; b2 = 1; b3 = 1; end endmodule
Page 28
ANITH M THOMAS
0917102
SIMULATION:
Page 29
ANITH M THOMAS
0917102
Page 30
ANITH M THOMAS
0917102
end endmodule TESTBENCH: module testsrfliflo; // Inputs reg r; reg s; reg clk; // Outputs wire q; // Instantiate the Unit Under Test (UUT) srflipflo uut (.r(r), .s(s), .clk(clk), .q(q) ); initial begin clk=1; #100 $finish; end always #10 clk=~clk; initial begin r=0; #20 r=~r; #40 r=~r; end initial begin
Christ University Faculty Of Enigneering Page 31
ANITH M THOMAS
0917102
s=1; #20 s=~s; #40 s=~s; #60 s=~s; end endmodule SIMULATION:
Page 32
ANITH M THOMAS
0917102
Page 33
ANITH M THOMAS
0917102
// Inputs reg d; reg clk; // Outputs wire q; // Instantiate the Unit Under Test (UUT) dflflo uut (.d(d), .clk(clk), .q(q)); initial begin clk=1; #60 $finish; end always #10 clk=~clk; initial begin d=0; #20 d=~d; #10 d=~d; #10 d=~d; end endmodule
Page 34
ANITH M THOMAS
0917102
SIMULATION:
Page 35
ANITH M THOMAS
0917102
Page 36
ANITH M THOMAS
0917102
end endmodule TESTBENCH: module testjkfliflo; // Inputs reg j; reg k; reg clk; // Outputs wire q; // Instantiate the Unit Under Test (UUT) jkfloflli uut (.j(j), .k(k), .clk(clk), .q(q)); initial begin clk=1; #60 $finish; end always #10 clk=~clk; initial begin k=0; #20 k=~k; #40 k=~k; end initial begin
Christ University Faculty Of Enigneering Page 37
ANITH M THOMAS
0917102
j=1; #20 j=~j; #40 j=~j; #60 j=~j; end endmodule SIMULATION:
Page 38
ANITH M THOMAS
0917102
Page 39
ANITH M THOMAS
0917102
reg t; reg clk; // Outputs wire q; // Instantiate the Unit Under Test (UUT) tflofli uut (.t(t), .clk(clk), .q(q)); initial begin clk=1; #60 $finish; end always #10 clk=~clk; initial begin t=0; #20 t=~t; #5 t=~t; #10 t=~t; end endmodule
Page 40
ANITH M THOMAS
0917102
SIMULATION:
Page 41
ANITH M THOMAS
0917102
Page 42
ANITH M THOMAS
0917102
end endmodule TESTBENCH: module testmodte; // Inputs reg clk; reg reset; // Outputs wire [3:0]Q; // Instantiate the Unit Under Test (UUT) modte uut (.clk(clk), .reset(reset), .Q(Q)); initial begin forever begin clk <= 0; #5 clk <= 1; #5 clk <= 0; end end initial begin reset = 1; #12 reset = 0;
Christ University Faculty Of Enigneering Page 43
ANITH M THOMAS
0917102
Page 44
ANITH M THOMAS
0917102
Page 45
ANITH M THOMAS
0917102
end endmodule TESTBENCH: module testmodteen; // Inputs reg clk; reg reset; // Outputs wire [2:0] Q; // Instantiate the Unit Under Test (UUT) modteencoun uut ( .clk(clk), .reset(reset), .Q(Q)); initial begin forever begin clk <= 0; #5 clk <= 1; #5 clk <= 0; end end initial begin reset = 1; #12 reset = 0;
Christ University Faculty Of Enigneering Page 46
ANITH M THOMAS
0917102
Page 47
ANITH M THOMAS
0917102
Page 48
ANITH M THOMAS
0917102
// Instantiate the Unit Under Test (UUT) charbitcomp uut ( .A(A), .B(B), .x(x), .y(y), .z(z)); initial begin // Initialize Inputs A = 0000; #100; A = 0000; #100; A = 0010; #100; A = 1000; end endmodule B = 1001; B = 0001; B = 0000; // Wait 100 ns for global reset to finish B = 0001;
Page 49
ANITH M THOMAS
0917102
SIMULATION:
Page 50