Codiode

Named Port Connection

EasyVerilog / SystemVerilogBuild2 solved

Connecting ports by position breaks silently when someone reorders a submodule's port list. Connecting them by name, .port(signal), doesn't.

The solution module acts as a wrapper that instantiates a pre-existing module named alu_core. The alu_core module is already defined in the compilation environment. The parent wrapper module must connect its own inputs and outputs to the alu_core instance using explicit named port connections.

This circuit is purely combinational. There are no clocks or resets involved.

Parent Wrapper Ports (solution)

Signal Direction Width Description
a_in input 8 First operand for the ALU
b_in input 8 Second operand for the ALU
op_sel input 3 Operation selector
c_in input 1 Carry input
alu_out output 8 Result from the ALU
c_out output 1 Carry output
z_flag output 1 Zero flag output
ovf_flag output 1 Overflow flag output

Sub-Module Ports (alu_core)

You must instantiate alu_core and map the wrapper ports to these exact sub-module port names:

Sub-Module Port Direction Width Map to Wrapper Signal
operand_a input 8 a_in
operand_b input 8 b_in
opcode input 3 op_sel
carry_in input 1 c_in
result output 8 alu_out
carry_out output 1 c_out
zero_flag output 1 z_flag
overflow_flag output 1 ovf_flag

Constraints

  • You must instantiate the alu_core module inside your solution module.
  • You must use explicit named port connections for every signal.
  • Do not implement the logic for alu_core yourself; assume it is already defined and available to the linker.
  • The circuit is purely combinational; do not use any edge-triggered logic.

Topics

CombinationalSyntaxInstantiation

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