Specman 宏:如何使用可选标签?
Specman macros: How to use optional tags?
我有一个定义端口的宏:
-- Create simple port
define <p_def'struct_member> "p_def <name'name> <type'type>" as {
<name'name> : inout simple_port of <type'type> is instance;
keep bind(<name'name>,empty);
};
我想扩展宏以支持端口列表。我想为它使用一个定义列表大小的可选标签 [<len'name>]
,如下所示:
-- Create simple port OR list of simple ports
define <p_def'struct_member> "p_def <name'name> [\[<len'name>\] ] <type'type>" as {
if len does not exist { // How to implement it?
<name'name> : inout simple_port of <type'type> is instance;
keep bind(<name'name>,empty);
} else { // len exists
<name'name>[<len'name>] : list of inout simple_port of <type'type> is instance;
keep for each in <name'name> {
bind(it,empty);
};
};
};
** 例如,定义大小为 10 的端口列表将如下所示:
p_def my_list_of_ports[10] bit;
我在 Specman e Language Reference 中找不到我怎么知道 optional tag
([<len'name>]
) 是否定义了..你知道如何实现 "if len does not exist" 语句吗在宏观?
感谢您的帮助
如果有人感兴趣,答案是什么:
define <p_def'struct_member> "p_def <name'name>[\[<len'name>\]] <type'type>" as computed {
if <len'name> == NULL {
result = appendf("%s : inout simple_port of %s is instance; \n keep bind(%s,empty);", <name'name>, <type'type>, <name'name>);
} else { // list
result = appendf("%s[%s] : list of inout simple_port of %s is instance; keep for each in %s { bind(it,empty); };", <name'name>, <len'name>, <type'type>, <name'name>);
};
};
我有一个定义端口的宏:
-- Create simple port
define <p_def'struct_member> "p_def <name'name> <type'type>" as {
<name'name> : inout simple_port of <type'type> is instance;
keep bind(<name'name>,empty);
};
我想扩展宏以支持端口列表。我想为它使用一个定义列表大小的可选标签 [<len'name>]
,如下所示:
-- Create simple port OR list of simple ports
define <p_def'struct_member> "p_def <name'name> [\[<len'name>\] ] <type'type>" as {
if len does not exist { // How to implement it?
<name'name> : inout simple_port of <type'type> is instance;
keep bind(<name'name>,empty);
} else { // len exists
<name'name>[<len'name>] : list of inout simple_port of <type'type> is instance;
keep for each in <name'name> {
bind(it,empty);
};
};
};
** 例如,定义大小为 10 的端口列表将如下所示:
p_def my_list_of_ports[10] bit;
我在 Specman e Language Reference 中找不到我怎么知道 optional tag
([<len'name>]
) 是否定义了..你知道如何实现 "if len does not exist" 语句吗在宏观?
感谢您的帮助
如果有人感兴趣,答案是什么:
define <p_def'struct_member> "p_def <name'name>[\[<len'name>\]] <type'type>" as computed {
if <len'name> == NULL {
result = appendf("%s : inout simple_port of %s is instance; \n keep bind(%s,empty);", <name'name>, <type'type>, <name'name>);
} else { // list
result = appendf("%s[%s] : list of inout simple_port of %s is instance; keep for each in %s { bind(it,empty); };", <name'name>, <len'name>, <type'type>, <name'name>);
};
};