|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
部分代码如下。m_device_type = t_device_type'(get_val("CC_DEVIE_TYPE")) ,求助大佬这句的意思是什么?
typedef enum{
EP = 0,
RC = 1,
SW = 2,
DM = 3
} t_device_type;
//----------------------------------------------------------------------
// Task call
//-----------------------------------------------------------------------
initial begin
enum_test;
end
//----------------------------------------------------------------------
//task : enum_test
//description: Operation on enumeration
//----------------------------------------------------------------------
task enum_test;
t_device_type m_device_type;
m_device_type = t_device_type'(get_val("CC_DEVIE_TYPE"));
m_device_type=m_device_type.first; //Traversal enumeration with "do ...while"
do
begin
$display("m_device_type=%s",m_device_type.name);
m_device_type=m_device_type.next;
end
while(m_device_type!=m_device_type.first);
endtask
//--------------------------------------
//------------------------------------------------------------------------
//function : get_val
//description: First part, read constraint file
// second part, put back parameters
//------------------------------------------------------------------------
function bit[7:0] get_val(string name);
//part1:
bit[7:0]params[string];
string name ,line,sub_line,value_str,out_str;
bit [7:0] value;
integer r,file_handle;
string short_prod;
file_handle=$fopen("constraint.v","r");
if(!file_handle)
begin
$display("[%0t] FATAL {%m}: Unable to open file for reading\n", $time);
return 1 ;
end
while (!$feof(file_handle))
begin
r = $fgets(line,file_handle);
if(match_define(line,sub_line))begin
value_str="1" ; //default to 1
r = $sscanf(sub_line,"`define %s %s",name,value_str);
if(str_search(value_str,"h",out_str))
r= $sscanf(out_str,"%x",value);
else if (str_search(value_str,"b",out_str))
r= $sscanf(out_str,"%b",value);
else if (str_search(value_str,"d",out_str))
r= $sscanf(out_str,"%d",value);
else
r= $sscanf(out_str,"%d",value);
params[name]=value;
foreach(params) //check
$display("%s,%s,%d",out_str,name,value);
end
end
$fclose(file_handle);
//part2 :put back parameters
if(params.num()<=0)begin
$display("[%0t] FATAL {%m}:Can't return value for parameter as the params array has zero content\n", $time);
$finish;
end
if(params.exists(name)) begin
return params[name];
end else begin
return 0 ;
end
endfunction:get_val
|
|