【问题标题】:Error - near ":": syntax error, unexpected ':', expecting IDENTIFIER or clock错误 - ":" 附近:语法错误,意外的 ':',需要 IDENTIFIER 或时钟
【发布时间】:2016-12-14 09:44:29
【问题描述】:

我创建了自己的 my_macros 文件:

`ifndef MY_MACROS_SV
`define MY_MACROS_SV

// MACRO: 'my_fatal_err
// calls uvm_fatal in case the assertion is not correct
`define my_fatal(condition, msg )\
   assert (condition) else\
`uvm_fatal("FATAL ERROR", msg)\
\
`define add_rand(mem_type, mem)\
   case (mem_type)\
     "int": add_rand_int(mem);\
     "bit": add_rand_bit(mem);\    
     default: `uvm_fatal("FATAL ERROR", "type is not supported")\ 
     endcase  



`endif  //MY_MACROS_SV

mem_type 需要一个字符串,而mem 是类的成员。

我收到以下编译错误:

在 ..\sv\my_macros.sv(19): ":" 附近: 语法错误,意外的 ':', 期待 IDENTIFIER 或时钟。

第 19 行是default:

【问题讨论】:

    标签: macros system-verilog uvm


    【解决方案1】:

    分离你的 2 个宏:

    `ifndef MY_MACROS_SV
    `define MY_MACROS_SV
    
    // MACRO: 'my_fatal_err
    // calls uvm_fatal in case the assertion is not correct
    `define my_fatal(condition, msg )\
       assert (condition) else\
    `uvm_fatal("FATAL ERROR", msg)
    
    `define add_rand(mem_type, mem)\
       case (mem_type)\
         "int": add_rand_int(mem);\
         "bit": add_rand_bit(mem);\    
         default: `uvm_fatal("FATAL ERROR", "type is not supported")\ 
         endcase  
    
    
    
    `endif  //MY_MACROS_SV
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 2012-08-31
      • 2012-10-20
      相关资源
      最近更新 更多