2016-12-14 39 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 
相關問題