Swapped Named Connections
Named connections make an instantiation independent of port order. They don't protect you from naming the wrong port.
A pre-defined module named logic_core is provided in the environment. It performs bitwise AND and OR operations on two 4-bit inputs. The module defines four ports: a_in, b_in, c_out, and d_out. The top-level module solution receives two 4-bit inputs and must drive two 4-bit outputs. The logic_core module must be instantiated and connected using named port mapping. To prove that named connections are order-independent, the instantiation must list the child module's ports in strictly reverse alphabetical order.
The connections between the top module and the sub-module must be mapped as follows:
logic_coreporta_inconnects to top-levelin_1logic_coreportb_inconnects to top-levelin_2logic_coreportc_outconnects to top-levelout_andlogic_coreportd_outconnects to top-levelout_or
| Signal | Direction | Width | Description |
|---|---|---|---|
in_1 |
input | 4 | First 4-bit operand |
in_2 |
input | 4 | Second 4-bit operand |
out_and |
output | 4 | Bitwise AND result from the sub-module |
out_or |
output | 4 | Bitwise OR result from the sub-module |
Constraints
- The design is strictly combinational; there is no clock or reset
- You must instantiate the provided
logic_coremodule - You must use named connections for the instantiation
- The named connections must be listed in strictly reverse alphabetical order of the child module's ports:
.d_out,.c_out,.b_in,.a_in
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 25 of 25 in the Verilog Syntax and Language Basics track.
Related problems
Browse all problems · Verilog practice problems · Learning tracks