// Verilog code for Full Subtractor Dataflow
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 10:18:07 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: full_sub_code
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_sub_code( input_a,
input_b,
input_cin,
diff,
bo);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUT
output diff;
output bo;
//Declaration of Full Subtractor
assign diff = (input_a ^ input_b ^ input_cin);
assign bo = (~(input_a ^ input_b) & input_cin)| (~input_a & input_b);
endmodule
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 10:18:07 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: full_sub_code
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_sub_code( input_a,
input_b,
input_cin,
diff,
bo);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUT
output diff;
output bo;
//Declaration of Full Subtractor
assign diff = (input_a ^ input_b ^ input_cin);
assign bo = (~(input_a ^ input_b) & input_cin)| (~input_a & input_b);
endmodule
----------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for Full subtractor structural,
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 11:00:30 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: full_sub_str
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_sub_str( input_a,
input_b,
input_cin,
diff,
bo);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUT
output diff;
output bo;
wire [4:0] con_lin;
// NOT Gate Instantiation Template
not_gate_code U_NOT_GATE1 (
.input_a(input_a),
.output_y(con_lin[0])
);
// XOR Gate Instantiation Template
xor_gate_code U_XOR_GATE1 (
.input_a(input_a),
.input_b(input_b),
.output_y(con_lin[1])
);
// XOR Gate Instantiation Template
xor_gate_code U_XOR_GATE2 (
.input_a(con_lin[1]),
.input_b(input_cin),
.output_y(diff)
);
// Not Gate Instantiation Template
not_gate_code U_NOT_GATE2 (
.input_a(con_lin[1]),
.output_y(con_lin[2])
);
// AND Gate Instantiation Template
and_gate_beh U_AND_GATE1 (
.input_a(con_lin[2]),
.input_b(input_cin),
.output_y(con_lin[3])
);
// AND Gate Instantiation Template
and_gate_beh U_AND_GATE2 (
.input_a(con_lin[0]),
.input_b(input_b),
.output_y(con_lin[4])
);
// OR Gate Instantiation Template
or_gate_code U_OR_GATE1 (
.input_a(con_lin[3]),
.input_b(con_lin[4]),
.output_y(bo)
);
endmodule
----------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for Full subtractor using if and else if
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 11:42:27 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: full_sub_beh1
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_sub_beh1( input_a,
input_b,
input_cin,
diff,
bo);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUTS
output diff;
output bo;
reg diff;
reg bo;
wire [2:0]con_out;
// Declaration of behavioural style
assign con_out ={input_cin, input_b, input_a};
always @(*) begin
if (con_out == 3'b000) begin
diff <= 1'b0;
bo <= 1'b0;
end else if (con_out == 3'b001) begin
diff <= 1'b1;
bo < = 1'b1;
end else if (con_out == 3'b010) begin
diff <= 1'b1;
bo <= 1'b1;
end else if (con_out == 3'b011) begin
diff <= 1'b0;
bo <= 1'b1;
end else if (con_out == 3'b100) begin
diff <= 1'b1;
bo <= 1'b0;
end else if (con_out == 3'b101) begin
diff <= 1'b0;
bo <=1'b0;
end else if (con_out == 3'b110) begin
diff <= 1'b0;
bo <= 1'b0;
end else begin
diff <= 1'b1;
bo <= 1'b1;
end
end
endmodule
------------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for Full subtractor using case
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 11:42:27 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: full_sub_beh2
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module full_sub_beh2( input_a,
input_b,
input_cin,
diff,
bo);
// INPUTS
input input_a;
input input_b;
input input_cin;
// OUTPUTS
output diff;
output bo;
reg diff;
reg bo;
wire [2:0]con_out;
// Declaration of behavioural style
assign con_out ={input_cin, input_b, input_a};
always @(*) begin
case(con_out)
3'b000:begin
diff = 1'b0;
bo = 1'b0;
end
3'b001:begin
diff = 1'b1;
bo = 1'b1;
end
3'b010:begin
diff = 1'b1;
bo = 1'b1;
end
3'b011:begin
diff = 1'b0;
bo = 1'b1;
end
3'b100:begin
diff = 1'b1;
bo = 1'b0;
end
3'b101:begin
diff = 1'b0;
bo = 1'b0;
end
3'b110:begin
diff = 1'b0;
bo = 1'b0;
end
3'b111:begin
diff = 1'b1;
bo = 1'b1;
end
endcase
end
endmodule
------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment