Generate Black Box Interface for Subsystem
What Is a Black Box Interface?
A black box interface for a subsystem is a generated VHDL® component or Verilog® or SystemVerilog module that includes only the HDL input and output port definitions for the subsystem. By generating such a component, you can use a subsystem in your model to generate an interface to existing manually written HDL code, third-party IP, or other code generated by HDL Coder™.
Requirements
The black box implementation is available only for subsystem blocks below the level of the DUT. Virtual and atomic subsystem blocks of custom libraries that are below the level of the DUT also work with black box implementations.
Generate a Black Box Interface for a Subsystem
To generate the interface, select the BlackBox
implementation
for one or more Subsystem blocks. Consider the following model that contains a subsystem
top
, which is the device under test.
The subsystem top
contains two lower-level subsystems:
Suppose that you want to generate HDL code from top
, with a black box
interface from the Interface
subsystem. To specify a black box
interface:
Right-click the
Interface
subsystem and select HDL Code > HDL Block Properties.The HDL Properties dialog box appears.
Set Architecture to
BlackBox
.The following parameters are available for the black box implementation:
The HDL block parameters available for the black box implementation enable you to customize the generated interface. See Customize Black Box or HDL Cosimulation Interface for information about these parameters.
Change parameters as desired, and click Apply.
To generate VHDL
generic
and ageneric map
to pass to a subsystem with a black box interface, set the GenericList parameter in the HDL Properties dialog box.Click OK to close the HDL Properties dialog box.
Alternatively, set the GenericList parameter for the black box
Interface
subsystem in the model by usinghdlset_param
. In the MATLAB Command Window, enter:hdlset_param('ex_blackbox_subsys/Top/Interface','GenericList',... '{{''Sig1'',''''''1'''''',''STD_LOGIC''},{''Sig2'',''"1101"'',''STD_LOGIC_VECTOR(3 DOWNTO 0)''}}');
Generate Code for a Black Box Subsystem Implementation
When you generate code for the DUT in the ex_blackbox_subsys
model,
the following messages appear:
>> makehdl('ex_blackbox_subsys/top') ### Generating HDL for 'ex_blackbox_subsys/top' ### Starting HDL Check. ### HDL Check Complete with 0 errors, 0 warnings and 0 messages. ### Begin VHDL Code Generation ### Working on ex_blackbox_subsys/top/gencode as hdlsrc\gencode.vhd ### Working on ex_blackbox_subsys/top as hdlsrc\top.vhd ### HDL Code Generation Complete.
In the progress messages, observe that the gencode
subsystem
generates a separate file, gencode.vhd
, for its VHDL entity definition. The Interface
subsystem does not
generate such a file. The interface code for this subsystem is in
top.vhd
, generated from ex_blackbox_subsys/top
. The
following code listing shows the component definition and instantiation generated for the
Interface
subsystem.
COMPONENT Interface GENERIC( Sig1 : STD_LOGIC; Sig2 : STD_LOGIC_VECTOR(3 DOWNTO 0) ); PORT( clk : IN std_logic; clk_enable : IN std_logic; reset : IN std_logic; In1 : IN std_logic_vector(7 DOWNTO 0); -- uint8 In2 : IN std_logic_vector(15 DOWNTO 0); -- uint16 In3 : IN std_logic_vector(31 DOWNTO 0); -- uint32 Out1 : OUT std_logic_vector(31 DOWNTO 0) -- uint32 ); END COMPONENT; ... u_Interface : Interface GENERIC MAP( Sig1 => ''1'', Sig2 => '"1101"' ) PORT MAP( clk => clk, clk_enable => enb_const_rate, reset => reset, In1 => gencode_out1, -- uint8 In2 => gencode_out2, -- uint16 In3 => gencode_out3, -- uint32 Out1 => Interface_out1 -- uint32 ); enb <= clk_enable; ce_out <= enb; Out1 <= Interface_out1;
You can also generate VHDL code that includes a generic
with an
integer
data type. To generate HDL code:
In the HDL Block Properties dialog box, enter
{{'Sig1','234'}}
in the GenericList parameter box.Alternatively, set the GenericList parameter for the black box
Interface
subsystem in the model by usinghdlset_param
. In the MATLAB Command Window, enter:hdlset_param('ex_blackbox_subsys/Top/Interface','GenericList','{{''Sig1'',''234''}}');
To generate HDL code, in the MATLAB command window, enter:
makehdl('ex_blackbox_subsys/Top')
The generated HDL code snippet shows the component definition and instantiation
generated for the Interface
subsystem for the top model.
COMPONENT Interface GENERIC( Sig1 : integer ); PORT( clk : IN std_logic; clk_enable : IN std_logic; reset : IN std_logic; In1 : IN std_logic_vector(7 DOWNTO 0); -- uint8 In2 : IN std_logic_vector(15 DOWNTO 0); -- uint16 In3 : IN std_logic_vector(31 DOWNTO 0); -- uint32 Out1 : OUT std_logic_vector(31 DOWNTO 0) -- uint32 ); END COMPONENT; ... u_Interface : Interface GENERIC MAP( Sig1 => 234 ) PORT MAP( clk => clk, clk_enable => enb_const_rate, reset => reset, In1 => gencode_out1, -- uint8 In2 => gencode_out2, -- uint16 In3 => gencode_out3, -- uint32 Out1 => Interface_out1 -- uint32 );
By default, the black box interface generated for subsystems includes clock, clock enable, and reset ports. Customize Black Box or HDL Cosimulation Interface describes how you can rename or suppress generation of these signals, and customize other aspects of the generated interface.