Arithmetic Logic Unit (ALU)

Problem Description
Write a verilog code for 16-bit arithmetic logic unit (ALU).
The circuit has three-bit select bus (SEL), sixteen bit input datapaths (A[15:0] and B[15:0]), an 16-bit output datapath (OUT[15:0]) and perform arithmetic and logical operations listed below. Inputs are given such that none of the operations below overflows.
SEL | OPERATION |
3'b000 | 16'h0000 |
3'b001 | A&B |
3'b010 | A|B |
3'b011 | A^B |
3'b100 | ~A |
3'b101 | A-B |
3'b110 | A+B |
3'b111 | 16'hFFFF |
Selection (SEL) | Name | OPERATION |
| Clear | 16'h0000 |
| AND | A&B |
| OR | A|B |
| XOR | A^B |
| NOT | ~A |
| SUB | A-B |
| ADD | A+B |
| Preset | 16'hFFFF |
Verilog
Code Editor Access
Log in to write, run and submit your solution to this interview question. It's free.
Output
Output goes here...
