Files
FPGA_Uni/ModelSim/lu.sv
T

20 lines
484 B
Systemverilog

`ifndef LU_H_SV
`define LU_H_SV
module lu #(parameter width = 2) (
input logic [1:0] op, // 2 bit operand
input logic [2**width-1:0] A, // width defined as 2^n
input logic [2**width-1:0] B,
output logic [2**width-1:0] Y);
always_comb begin
case (op) // different operations of A and B based on operand
2'b00: Y = A & B;
2'b01: Y = A | B;
2'b10: Y = A ^ B;
2'b11: Y = ~(A | B);
default:Y = '0;
endcase
end
endmodule
`endif