sv激励生成方法

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
          &

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值