1、基本步骤
1.1 方法1:
1.创建一个.sv文件
2.定义一个类,包含变量(范围和权重的约束)、变量转换为所需激励数据的方法、生成供参考模型使用的激励的copy
3.时序化,转换为带时钟的数据
1.2 方法2:
1.创建一个data文件
2.读取文件行,预处理后转换为包数据格式
3.时序化,转换为带时钟的数据
2、具体方法
2.1、读取文件激励,file_to_stream_pkg.sv
//
package file_to_stream_pkg;
import config_pkg::*;
typedef struct {
bit err ;
bit sop ;
bit eop ;
bit vld ;
bit [ 2:0] vldb ;
bit [63:0] data ;
bit bypass ;
bit connecting;
} data_stream_s;
typedef struct {
logic [31:0] len ;
bit [63:0] data[$] ;
logic [31:0] data_size;
} pkt_data_s;
task automatic file_data(input string filename,output pkt_data_s pkt_data_q[$]);
int file ;
int file_s ;
string file_line;
string line;
logic[31:0] char_len;
bit [ 3:0] hex_data;
bit [63:0] dd_word_data[$];
bit [ 3:0] char2hex_data[$];
logic[31:0] dd_word_data_size;
pkt_data_s pkt_data ;
//
$display("self_debug[INFO] : file of %0s is processiong!",filename);
file = $fopen(filename,"r");
if(file == 0)begin
return;
end
//
while(!$feof(file))begin
file_s = $fgets(file_line,file);
replace_space(file_line,line);//remove special character at head and tail
//jump space line or flag line
char_len = line.len();
if(is_all_spaces(line)== 1 || line.len() == 0 || line[0] == "#")begin
continue;
end
else begin
&

最低0.47元/天 解锁文章
2547

被折叠的 条评论
为什么被折叠?



