Presentation is loading. Please wait.

Presentation is loading. Please wait.

2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4.

Similar presentations


Presentation on theme: "2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4."— Presentation transcript:

1 2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4

2 2-to-1 Multiplexer Multiplexers The Verilog if statement

3 Multiplexers A multiplexer is a digital switch: If s = 0, y = a; if s = 1, y = b

4 Multiplexers A multiplexer is a digital switch: If s = 0, y = a; if s = 1, y = b

5 // Example 4a: 2-to-1 MUX using logic equations module mux21a ( input wire a, input wire b, input wire s, output wire y ); assign y = ~s & a | s & b; endmodule

6 2-to-1 Multiplexer Multiplexers The Verilog if statement

7 Multiplexers A multiplexer is a digital switch: If s = 0, y = a; if s = 1, y = b if(s == 0) y = a; else y = b; Verilog

8 // Example 4b: 2-to-1 MUX using if statement module mux21b ( input wire a, input wire b, input wire s, output reg y ); always @(*) if(s == 0) y = a; else y = b; endmodule

9 // Example 4c: 2-to-1 MUX using ? notation module mux21c ( input wire a, input wire b, input wire s, output reg y ); assign y = s ? b : a; endmodule Note shortcut if statement


Download ppt "2-to-1 Multiplexer: if Statement Discussion D7.1 Example 4."

Similar presentations


Ads by Google