Codiode

Four Bit Absolute Value Circuit

MediumLogic CircuitBuild

DSP pipelines constantly calculate magnitudes for signal strength analysis and error metrics. The absolute value function strips the sign from a two's complement number to return its positive magnitude.

The circuit takes a 4-bit two's complement input A and produces a 4-bit unsigned output Y. When A is positive or zero, Y equals A. When A is negative, Y equals the two's complement negation of A.

A (Decimal) A (Binary) Y (Binary) Y (Decimal)
0 0000 0000 0
7 0111 0111 7
-1 1111 0001 1
-8 1000 1000 8

Constraints

  • Implement combinational logic only.
  • Do not use clocks or sequential elements.
  • Construct the datapath using XOR gates and a 4-bit adder.
  • Drive the conditional inversion and adder carry-in directly from the sign bit of A.

Topics

arithmetictwos-complementdsp

Solve this problem

Place the gates, wire them up and watch the signals settle. Every submission runs on the same simulation engine that grades it.

This problem is part of Codiode Pro. The statement above is free to read.

The circuit builder and code editor need a desktop screen. On a phone, read the problem here and open it on a laptop to solve.

Part of Interview Circuit

Problem 23 of 29 in the Interview Circuit track.

Related problems

Browse all problems · Number system and binary code problems · Digital logic design practice problems · Learning tracks

Solve this on a laptopSend yourself the link and continue there.