Wire versus Reg in Continuous Assignment
assign drives a wire; procedural blocks drive a reg. Mixing them up is a compile error. The implementation uses a continuous assignment driven from a ternary expression.
The solution module accepts inputs A, B and Sel and drives output Out. When Sel is 0 the output follows A. When Sel is 1 the output follows B.
The compiler throws a syntax error during elaboration. The log reports an illegal left-hand side in the continuous assignment for Out. The simulation cannot start. Inspect the code and correct the fault.
| Signal | Direction | Width | Description |
|---|---|---|---|
Sel |
input | 1 | Select signal; 0 selects A, 1 selects B |
A |
input | 1 | Data input 0 |
B |
input | 1 | Data input 1 |
Out |
output | 1 | Selected output; purely combinational |
Constraints
- Do not change the boolean logic or the
assignkeyword. - Do not convert the logic into an
alwaysblock. - The output must be strictly combinational; no latches or flip-flops.
Topics
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 5 of 25 in the Verilog Syntax and Language Basics track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks