2016-12-14 154 views
0

创建我自己的my_macros文件:UVM - 错误 - 近“:”:语法错误,意外“:”,预计标识符或时钟

`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是类的成员。 我收到以下编译错误: at .. \ sv \ my_macros.sv(19):near“:”:语法错误,意外的':',期待IDENTIFIER或时钟。

* 19行是 “默认:......”

+0

你应该让每个人都知道,当你在多个网站上交叉张贴问题:HTTPS:/ /verificationacademy.com/forums/uvm/error-near-begin-syntax-error-unexpected-begin-expecting-function-or-task。 – toolic

回答

0

独立的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 
相关问题