Professional Documents
Culture Documents
Design in Verilog
Design in Verilog
Design in Verilog
LAB 1
Structural Code
endmodule
reg a, b, borin;
wire diff, borout;
initial begin
a = 0; b = 0; borin = 0;
#10;
a = 0; b = 0; borin = 1;
#10;
a = 0; b = 1; borin = 0;
#10;
a = 0; b = 1; borin = 1;
#10;
a = 1; b = 0; borin = 0;
#10;
a = 1; b = 0; borin = 1;
#10;
a = 1; b = 1; borin = 0;
#10;
a = 1; b = 1; borin = 1;
#10;
end
endmodule
Simulation Output
4 bit Full Subtractor
Structural Code
module sub4bit(
input [3:0] a,
input [3:0] b,
output borout,
output [3:0] diff
);
endmodule
module sub4bitTB;
reg [3:0] a, b;
wire borout;
wire [3:0] diff;
end
endmodule
Simulation Output