Codiode

Bitwise versus Logical Negation

MediumVerilog / SystemVerilogBuild4 solved

~ and ! look alike and do very different things. ~ inverts every bit; ! asks whether the whole bus is zero and answers with a single bit.

This module receives an 8-bit input bus and computes two distinct outputs concurrently. The first output provides a bit-by-bit inverted version of the input data. The second output acts as a zero-detection flag, asserting high only when the entire 8-bit input bus is exactly zero.

The circuit is purely combinational. There is no clock or reset, and outputs must reflect the input state continuously.

Signal Direction Width Description
in_bus input 8 The 8-bit input data bus
out_bitwise output 8 The bitwise negation of in_bus
out_logical output 1 The logical negation of in_bus; evaluates to 1 when in_bus is zero

Constraints

  • The design must be purely combinational with no latches or registers
  • out_logical must be exactly 1 bit wide
  • out_bitwise must be exactly 8 bits wide

Topics

Combinational LogicVerilog SyntaxOperators

Solve this problem

Write the module in Verilog, SystemVerilog or VHDL. Your submission is compiled and simulated against the problem's testbench. You get the waveform back, not a stored answer.

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 Verilog Syntax and Language Basics

Problem 9 of 25 in the Verilog Syntax and Language Basics track.

Related problems

Browse all problems · Verilog practice problems · Learning tracks

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