Build a combinational circuit with four inputs, in[3:0].
There are 3 outputs:
out_and: output of a 4-input AND gate.https://hdlbits.01xz.net/wiki/Gates4
out_or: output of a 4-input OR gate.
out_xor: output of a 4-input XOR gate.
The point of this exercise is to demonstrate the use of the reduction operators, which can be used to prevent having to make logic assignments such as the following:
assign out_and = in & in & in & in;
The following table summarizes the available reduction operators. Note that unlike with the bitwise operators, ~| and ~& can be used for NOR and NAND, respectively.
Using these operators, a simple solution is as follows:
module top_module ( input logic [3:0] in, output logic out_and, output logic out_or, output logic out_xor ); // Reduction gate output assignments assign out_and = ∈ assign out_or = |in; assign out_xor = ^in; endmodule : top_module