学海荡舟手机网
导航

主页 > 电子设备技术 > 电器电路基础 > > 详细内容

SystemC-sc_gen_unique_name

  在Syst中,每一个模块必须有一个名字,该名字必须与其它模块的名字不同,比如psram=new sram ("sram1")就例化了一个sram模块的实例,模块名为"sram1"。有时候我们需要同时例化多个模块实例,为每一个起一个不同的名字,此时我们可以使用char* sc_gen_unique_name( const char* seed )函数,比如下面的例子:  

  1. SC_MODULE(example)  
  2. {  
  3. ……  
  4. sram* psram [10];  
  5.   SC_CTOR(example)  
  6.   {  
  7.      for(int i=0;i<10,i++)   
  8.      {  
  9.          psram [i]= new sram (sc_gen_unique_name ("sram8x256"));  
  10.          ……  
  11.       }  
  12.  }; 


      每次调用sc_gen_unique_name ("sram"),都返回一个以"sram"为前缀的字符串,并且保证与前次调用时的字符串不同。


相关文章