// Verilog code for 2:1 Multiplexers Dataflow
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 12:52:06 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: mux2_1_code
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module mux2_1_code(input_a,
input_b,
sel_0,
output_y);
// INPUTS
input input_a;
input input_b;
input sel_0;
// OUTPUT
output output_y;
//Declaration of mux2:1
assign output_y = ((~sel_0)& (input_a))| (sel_0 & input_b);
endmodule
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 12:52:06 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: mux2_1_code
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module mux2_1_code(input_a,
input_b,
sel_0,
output_y);
// INPUTS
input input_a;
input input_b;
input sel_0;
// OUTPUT
output output_y;
//Declaration of mux2:1
assign output_y = ((~sel_0)& (input_a))| (sel_0 & input_b);
endmodule
-------------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for 2:1 Multiplexers structural.
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 12:52:06 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: mux2_1_str
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module mux2_1_str(input_a,
input_b,
sel_0,
output_y);
// INPUTS
input input_a;
input input_b;
input sel_0;
// OUTPUT
output output_y;
wire [2:0] con_out;
// NOT GATE Instantiation Template
not_gate_code U_NOT_GATE (
.input_a(sel_0),
.output_y(con_out[0])
);
// AND GATE Instantiation Template
and_gate_code U_AND_GATE1 (
.input_a(input_a),
.input_b(con_out[0]),
.output_y(con_out[1])
);
// AND GATE Instantiation Template
and_gate_code U_AND_GATE2 (
.input_a(sel_0),
.input_b(input_b),
.output_y(con_out[2])
);
// OR GATE Instantiation Template
or_gate_code U_OR_GATE1 (
.input_a(con_out[1]),
.input_b(con_out[2]),
.output_y(output_y)
);
endmodule
------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for 2:1 Multiplexers behavioural
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 12:52:06 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: mux2_1_beh
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module mux2_1_beh(input_a,
input_b,
sel_0,
output_y);
// INPUTS
input input_a;
input input_b;
input sel_0;
// OUTPUT
output output_y;
reg output_y;
//Declaration of mux2:1
always @ (*) begin
if(sel_0 == 1'b0) begin
output_y <= input_a;
end else begin
output_y <= input_b;
end
end
endmodule
------------------------------------------------------------------------------------------------------------------------------------------------
// Verilog code for 2:1 Multiplexers behavioural using case
`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: RED-BLUE
// Engineer:
//
// Create Date: 12:52:06 11/08/2016
// Designer Name: Madhu Krishna
// Module Name: mux2_1_beh1
// Project Name:
// Target Devices:
// Tool versions:
// Description:
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
//////////////////////////////////////////////////////////////////////////////////
module mux2_1_beh1(input_a,
input_b,
sel_0,
output_y);
// INPUTS
input input_a;
input input_b;
input sel_0;
// OUTPUT
output output_y;
reg output_y;
//Declaration of mux2:1
always @(*) begin
case(sel_0)
1'b0: output_y = input_a;
1'b1: output_y = input_b;
endcase
end
endmodule
-------------------------------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment