Set HDL Block Parameters for Multiple Blocks

For models that contain a large number of blocks, using the HDL Block Properties dialog box to select block implementations or set implementation parameters for individual blocks may not be practical. It is more efficient to set HDL-related model or block parameters for multiple blocks programmatically. You can use the find_system function to locate the blocks of interest. Then, use a loop to call hdlset_param to set the desired parameters for each block.

See the Simulink® documentation for detailed information about find_system.

The following example uses the sfir_fixed model to demonstrate how to locate a group of blocks in a subsystem and specify the same output pipeline depth for all the blocks.

  1. Open the sfir_fixed model.

  2. Click on the sfir_fixed/symmetric_fir subsystem to select it.

  3. Locate all Product blocks within the subsystem as follows:

     prodblocks = find_system(gcb, 'BlockType', 'Product')
    
    prodblocks = 
    
        'sfir_fixed/symmetric_fir/Product'
        'sfir_fixed/symmetric_fir/Product1'
        'sfir_fixed/symmetric_fir/Product2'
        'sfir_fixed/symmetric_fir/Product3'

  4. Set the output pipeline depth to 2 for all selected blocks.

    for ii=1:length(prodblocks), hdlset_param(prodblocks{ii}, 'OutputPipeline', 2), end;
    
  5. To verify the settings, display the value of the OutputPipeline parameter for the blocks .

     for ii=1:length(prodblocks), hdlget_param(prodblocks{ii},  'OutputPipeline'), end;
    
    ans =
    
         2
    
    
    ans =
    
         2
    
    
    ans =
    
         2
    
    
    ans =
    
         2
Was this topic helpful?