sysgen 对带parameter的verilog封装blackbox的问题

例如这样一个小模块

module mul#(
parameter MUL_A_WIDTH = 10,
parameter MUL_B_WIDTH = 10,
parameter MUL_C_WIDTH =  MUL_A_WIDTH+MUL_B_WIDTH-1
)

(
input [MUL_A_WIDTH-1:0] a,
input [MUL_B_WIDTH-1:0] b,
output [MUL_C_WIDTH-1:0] c
);

assign c = a*b;

endmodule

 

封装进blackbox后,对其.m进行修改


function mul_config(this_block)

  % Revision History:
  %
  %   29-Jan-2019  (09:34 hours):
  %     Original code was machine generated by Xilinx's System Generator after parsing
  %     E:\BLE\mul.v
  %
  %

  this_block.setTopLevelLanguage('Verilog');

  this_block.setEntityName('mul');

  % System Generator has to assume that your entity  has a combinational feed through; 
  %   if it  doesn't, then comment out the following line:
  this_block.tagAsCombinational;

  this_block.addSimulinkInport('a');
  this_block.addSimulinkInport('b');

  this_block.addSimulinkOutport('c');
  
  this_block.addGeneric('MUL_A_WIDTH',this_block.port('a').width);
  this_block.addGeneric('MUL_B_WIDTH',this_block.port('b').width);

  % -----------------------------
  if (this_block.inputTypesKnown)
      % do input type checking, dynamic output type and generic setup in this code block.
      %% add by wc
      this_block.port('a').useHDLVector(true);
      this_block.port('b').useHDLVector(true);

      c_port = this_block.port('c');
      output_bitwidth = this_block.port('a').width+this_block.port('b').width-1;
      c_port.width = output_bitwidth;
      c_port.makeSigned;
      c_port.binpt = 0;

  
  
  end  % if(inputTypesKnown)
  % -----------------------------

  % System Generator found no apparent clock signals in the HDL, assuming combinational logic.
  % -----------------------------
   if (this_block.inputRatesKnown)
     inputRates = this_block.inputRates; 
     uniqueInputRates = unique(inputRates); 
     outputRate = uniqueInputRates(1);
     for i = 2:length(uniqueInputRates)
       if (uniqueInputRates(i) ~= Inf)
         outputRate = gcd(outputRate,uniqueInputRates(i));
       end
     end  % for(i)
     for i = 1:this_block.numSimulinkOutports 
       this_block.outport(i).setRate(outputRate); 
     end  % for(i)
   end  % if(inputRatesKnown)
  % -----------------------------

    uniqueInputRates = unique(this_block.getInputRates);

  % (!) Custimize the following generic settings as appropriate. If any settings depend
  %      on input types, make the settings in the "inputTypesKnown" code block.
  %      The addGeneric function takes  3 parameters, generic name, type and constant value.
  %      Supported types are boolean, real, integer and string.
  %% add by wc
  %this_block.addGeneric('MUL_A_WIDTH','integer','10');
  %this_block.addGeneric('MUL_B_WIDTH','integer','10');

  %this_block.addGeneric('MUL_C_WIDTH','','');

  % Add addtional source files as needed.
  %  |-------------
  %  | Add files in the order in which they should be compiled.
  %  | If two files "a.vhd" and "b.vhd" contain the entities
  %  | entity_a and entity_b, and entity_a contains a
  %  | component of type entity_b, the correct sequence of
  %  | addFile() calls would be:
  %  |    this_block.addFile('b.vhd');
  %  |    this_block.addFile('a.vhd');
  %  |-------------

  %    this_block.addFile('');
  %    this_block.addFile('');
  this_block.addFile('mul.v');

return;


但仿真都是NaN。不知道是不是不支持

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值