最近一直在做一些小模块的验证,之前都是在用现成的环境修修改改。
写一个纯sv的环境;

首先是harness;


module harness

bit clk;
bit rst_n;

w_inf inf(bit clk,bit rst_n);

tc test();

dut dut(
    clk  (inf.clk),
    rst_n(inf.rst_n),
    a    (inf.a),
    b    (inf.b)
);

initial begin
    clk = 0;
    forever #0.5ns clk = ~clk;
end

endmodule

之后是interface;

interface w_inf(bit clk,bit rst_n);

    logic a;
    logic b;
    clocking drv_cb @(posedge clk);
        inout a;
        inout b;
    endclocking

endinterface

之后定义一个transaction;

class transaction

    bit a;
    bit b;

endclass

之后是定义一个sequence;


class w_sequence
    
    bit a[$];

    virtual w_inf bus;

    extern virtual new(w_inf inf);

    extern virtual task tx_process();

    extern virtual task rx_process();

    extern virtual function chk_ans(); 

endclass

task w_sequence::txprocess();
endtask

task w_sequence::rxprocess();
endtask

function w_sequence::new(w_inf inf);
    bus = inf;
endtask

最后定义一下tc;

program tc;

sequence seq;

w_inf inf;

inf = harness.inf;

initial begin

    seq = new(inf);

    fork

    begin
        seq.tx_process();
    end

    begin
        seq.rx_process();
    end

    begin
        harness.rst_n = 0; 
        repeat(4)@(posedge vif.clk);
        harness.rst_n = 1;

        repeat(100)@(posedge vif.clk);

        $finish;

    end

    join
end

endprogram

标签: none

已有 5 条评论

  1. 做了几十年的项目 我总结了最好的一个盘(纯干货)coinsrore.com

  2. 做了几十年的项目 我总结了最好的一个盘(纯干货)coinsrore.com

  3. 做了几十年的项目 我总结了最好的一个盘(纯干货)

  4. 2025年10月新盘 做第一批吃螃蟹的人coinsrore.com

  5. 2025年10月新盘 做第一批吃螃蟹的人coinsrore.com
    新车新盘 嘎嘎稳 嘎嘎靠谱coinsrore.com
    新车首发,新的一年,只带想赚米的人coinsrore.com
    新盘 上车集合 留下 我要发发 立马进裙coinsrore.com
    做了几十年的项目 我总结了最好的一个盘(纯干货)coinsrore.com
    新车上路,只带前10个人coinsrore.com
    新盘首开 新盘首开 征召客户!!!coinsrore.com
    新项目准备上线,寻找志同道合 的合作伙伴coinsrore.com
    新车即将上线 真正的项目,期待你的参与coinsrore.com
    新盘新项目,不再等待,现在就是最佳上车机会!coinsrore.com
    新盘新盘 这个月刚上新盘 新车第一个吃螃蟹!coinsrore.com

添加新评论