//Verilog code for FULL ADDER
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED BLUE
// Engineer:
//
// Create Date: 22:34:33 11/04/2016
// Designer Name: Madhu Krishna
// Module Name: full_adder_code
// Project Name
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_adder_code(input_A,
input_B,
input_Cin,
sum,
carry);
//INPUTS
input input_A;
input input_B;
input input_Cin;
//OUPUTS
output sum;
output carry;
reg sum;
reg carry;
//Declaring the sum and carry value
initial begin
assign sum = (input_A)^(input_B)^(input_Cin);
assign carry = ((input_A) & (input_B))|((input_B) & (input_Cin))|((input_Cin)|(input_A));
end
endmodule
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for Full Adder structural
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED BLUE
// Engineer:
//
// Create Date: 12:16:00 11/07/2016
// Design Name: Madhu Krishna
// Module Name: full_adder_str
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_adder_str( input_a,
input_b,
input_cin,
sum,
carry);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUTs
output sum;
output carry;
wire [3:0] con_lin;
// XOR Gate Instantiation Template
xor_gate_3in U_XOR_GATE_3IN (
.input_a(input_a),
.input_b(input_b),
.input_c(input_cin),
.output_y(sum)
);
// AND Gate Instantiation Template
and_gate_beh U_AND_GATE1 (
.input_a(input_a),
.input_b(input_b),
.output_y(con_lin[0])
);
and_gate_beh U_AND_GATE2 (
.input_a(input_a),
.input_b(input_cin),
.output_y(con_lin[1])
);
and_gate_beh U_AND_GATE3 (
.input_a(input_cin),
.input_b(input_a),
.output_y(con_lin[2])
);
// OR Gate Instantiation Template
or_gate_code U_OR_GATE1 (
.input_a(con_lin[0]),
.input_b(con_lin[1]),
.output_y(con_lin[3])
);
or_gate_code U_OR_GATE2 (
.input_a(con_lin[3]),
.input_b(con_lin[2]),
.output_y(carry)
);
endmodule
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED BLUE
// Engineer:
//
// Create Date: 22:34:33 11/04/2016
// Designer Name: Madhu Krishna
// Module Name: full_adder_code
// Project Name
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_adder_code(input_A,
input_B,
input_Cin,
sum,
carry);
//INPUTS
input input_A;
input input_B;
input input_Cin;
//OUPUTS
output sum;
output carry;
reg sum;
reg carry;
//Declaring the sum and carry value
initial begin
assign sum = (input_A)^(input_B)^(input_Cin);
assign carry = ((input_A) & (input_B))|((input_B) & (input_Cin))|((input_Cin)|(input_A));
end
endmodule
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for Full Adder structural
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED BLUE
// Engineer:
//
// Create Date: 12:16:00 11/07/2016
// Design Name: Madhu Krishna
// Module Name: full_adder_str
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_adder_str( input_a,
input_b,
input_cin,
sum,
carry);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUTs
output sum;
output carry;
wire [3:0] con_lin;
// XOR Gate Instantiation Template
xor_gate_3in U_XOR_GATE_3IN (
.input_a(input_a),
.input_b(input_b),
.input_c(input_cin),
.output_y(sum)
);
// AND Gate Instantiation Template
and_gate_beh U_AND_GATE1 (
.input_a(input_a),
.input_b(input_b),
.output_y(con_lin[0])
);
and_gate_beh U_AND_GATE2 (
.input_a(input_a),
.input_b(input_cin),
.output_y(con_lin[1])
);
and_gate_beh U_AND_GATE3 (
.input_a(input_cin),
.input_b(input_a),
.output_y(con_lin[2])
);
// OR Gate Instantiation Template
or_gate_code U_OR_GATE1 (
.input_a(con_lin[0]),
.input_b(con_lin[1]),
.output_y(con_lin[3])
);
or_gate_code U_OR_GATE2 (
.input_a(con_lin[3]),
.input_b(con_lin[2]),
.output_y(carry)
);
endmodule
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for FULL ADDER Behavioural
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 13:09:06 11/07/2016
// Designer Name: Madhu Krishna
// Module Name: full_adder_beh
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_adder_beh( input_a,
input_b,
input_cin,
sum,
carry);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUTS
output sum;
output carry;
reg sum;
reg carry;
wire [2:0]con_out;
assign con_out = {input_cin,input_b,input_a};
always @(*) begin
if(con_out == 3'b000) begin
sum <= 1'b0;
carry <= 1'b0;
end else if (con_out == 3'b001) begin
sum <= 1'b1;
carry <= 1'b0;
end else if (con_out == 3'b010) begin
sum <= 1'b1;
carry <= 1'b0;
end else if (con_out == 3'b011) begin
sum <= 1'b0;
carry <= 1'b1;
end else if (con_out == 3'b100) begin
sum <= 1'b1;
carry <= 1'b0;
end else if (con_out == 3'b101) begin
sum <= 1'b0;
carry <= 1'b1;
end else if (con_out == 3'b110) begin
sum <= 1'b0;
carry <= 1'b1;
end else begin
sum <=1'b1;
carry <=1'b1;
end
end
endmodule
-------------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for Full Adder using case
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-KRISHNA
// Engineer:
//
// Create Date: 14:39:42 11/07/2016
// Designer Name: Madhu-Krishna
// Module Name: full_adder_beh2
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_adder_beh2 (input_a,
input_b,
input_cin,
sum,
carry);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUTS
output sum;
output carry;
reg sum;
reg carry;
wire [2:0] con_out;
assign con_out = {input_cin, input_b, input_a};
always @(*) begin
case (con_out)
3'b000: begin
sum <=1'b0;
carry<=1'b0;
end
3'b001: begin
sum <=1'b1;
carry<=1'b0;
end
3'b010: begin
sum <=1'b1;
carry<=1'b0;
end
3'b011: begin
sum <=1'b0;
carry<=1'b1;
end
3'b100: begin
sum <=1'b1;
carry<=1'b0;
end
3'b101: begin
sum <=1'b0;
carry<=1'b1;
end
3'b110: begin
sum <=1'b0;
carry<=1'b1;
end
3'b111: begin
sum <=1'b1;
carry<=1'b1;
end
endcase
end
endmodule
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment