导入DPI函数作为UVM参考模型使用
#include <stdio.h>
#include <math.h>
extern "C" int sum(int a, int b){
return a+b;
}
import "DPI-C" context function int sum(int a, int b);
class refmod extends uvm_component;
`uvm_component_utils(refmod)
packet_in tr_in;
packet_out tr_out;
integer a, b;
uvm_get_port #(packet_in) in;
uvm_put_port #(packet_out) out;
function new(string name = "refmod", uvm_component parent);
super.new(name, parent);
in = new("in", this);
out = new("out", this);
endfunction
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
tr_out = packet_out::type_id::create("tr_out", this);
endfunction: build_phase
virtual task run_phase(uvm_phase phase);
super.run_phase(phase);
forever begin
in.get(tr_in);
tr_out.data = sum(tr_in.A, tr_in.B);
out.put(tr_out);
end
endtask: run_phase
endclass: refmod
DPI在混合仿真中的应用
DPI在Matlab中的应用
参考网站:
verificationguide
doulos