Hardware interview practice
Direct Programming Interface (DPI) 4-state data mapping
A C model must distinguish 0, 1, X, and Z for every bit of a 32-bit bus. Which SystemVerilog Direct Programming Interface (DPI) boundary choice preserves that information?
Starting point
Question code
// SystemVerilog declaration
import "DPI-C" function void inspect_bus(
input logic [31:0] bus
);
// Matching C declaration from svdpi.h
// void inspect_bus(const svLogicVecVal* bus);Choose one
Answer choices
- A. Use bit [31:0] and an svBitVecVal representation; X and Z are preserved
- B. Use logic [31:0] and an svLogicVecVal representation carrying value and unknown-state information
- C. Use int unsigned; all four states are encoded automatically in its numeric value
- D. Use real and reinterpret its mantissa as four-state bits
