Arithmetic Logic Unit (ALU)

Intel

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

3'b000

Clear

16'h0000

3'b001

AND

A&B

3'b010

OR

A|B

3'b011

XOR

A^B

3'b100

NOT

~A

3'b101

SUB

A-B

3'b110

ADD

A+B

3'b111

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...