您好,欢迎来到榕意旅游网。
搜索
您的当前位置:首页IC验证,一种noc在passive模式下的自动比对方法

IC验证,一种noc在passive模式下的自动比对方法

来源:榕意旅游网

实现目的:

1、所有master端和slave端的读写数据对比。

2、确保master的所有读写意图都正确传递到slave端。

环境结构:

 

代码:monitor采样到的数据存储在一下类中,来完成最终的比对

class store_history#(ADDR_WIDTH=32, DATA_WIDTH=32);
    typedef bit[DATA_WIDTH-1:0] bitq[$];

    protected string m_name;
    protected bitq   m_mem_send   [bit[ADDR_WIDTH-1:0]];
    protected bitq   m_mem_receive[bit[ADDR_WIDTH-1:0]];
    
    function new(string name="store_history");
        m_name = name;
    endfunction
    
    extern function void send(bit[ADDR_WIDTH-1] addr, bit[DATA_WIDTH-1] data);
    extern function void receive(bit[ADDR_WIDTH-1] addr, bit[DATA_WIDTH-1] data);
    extern function bit[1:0] compare(store_history obj_exp);
    extern function bit compare_mem(string str_type, const ref bitq act[bit[ADDR_WIDTH-1:0]], const ref bitq exp[bit[ADDR_WIDTH-1:0]]);
endclass
 
function void store_history::send(bit[ADDR_WIDTH-1] addr, bit[DATA_WIDTH-1] data);
   m_mem_send[addr].push_back(data);
endfunction

function void store_history::receive(bit[ADDR_WIDTH-1] addr, bit[DATA_WIDTH-1] data);
    m_mem_receive[addr].push_back(data);
endfunction

function bit[1:0] store_history::compare(store_history obj_exp);
    bit[1:0] b_pass;
    
    b_pass[0] = compare_mem("send"   , m_mem_send   , obj_exp.m_mem_send   );
    b_pass[1] = compare_mem("receive", m_mem_receive, obj_exp.m_mem_receive);
    
    return b_pass;
endfunction

function bit store_history::compare_mem(string str_type, const ref bitq act[bit[ADDR_WIDTH-1:0]], const ref bitq exp[bit[ADDR_WIDTH-1:0]]);
    bit b_pass=1'b1;
    
    foreach(act[i]) begin
        bit b_err=1'b1;
        
        if(act[i].size() == exp[i].size()) begin
            bit[DATA_WIDTH-1:0] aa[]=act[i];
            bit[DATA_WIDTH-1:0] bb[]=exp[i];
            
            aa.sort();
            bb.sort();
            b_err = (aa != bb);
        end
        
        if(b_err == 1'b1) begin
            string str_act;
            string str_exp;
            
            b_pass = 1'b0;
            
            foreach(act[i][j]) begin
                str_act = {str_act, $sformatf(" %0h", act[i][j])};
            end
            foreach(exp[i][j]) begin
                str_exp = {str_exp, $sformatf(" %0h", exp[i][j])};
            end
            
            $display("%s ERROR: %s addr: %0h\nact data:%s\nexp data:%s",
                     m_name, str_type, i, str_act, str_exp);
        end
    end

    return b_pass;
endfunction



 
 

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- nryq.cn 版权所有 赣ICP备2024042798号-6

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务