Email: bknpk@hotmail.com Phone: +972-54-7649119


V

 

verilator some problems in driving system verilog signals from cpp bench.

  1. In order to practice cpp (c++) verification benches, with system verilog DPI, using a verilog DUT, I decided to download verilator and do some self study exercises.

  2. When I drive input data with no delay, flip-flops in the DUT were not simulated correctly. Their output was set immediately (no sample i.e. one cycle delay). So I decided to put a one unit time delay, as shown in the waves below. This still did not solve the problem completely. Now I saw some combinatorial logic, inside the DUT, not behaving well. Their outputs were not updated, but only after the next clock rise edge, where it was too late. I solved it by registering the driven signals in the system verilog bench and then applying the registered ones to the DUT:

    1.   initial begin
    2.     Trd=1'b0;
    3.     Twr=1'b0;
    4.   end
    5.   //monitor fifo errors v2c DPI function
    6.   import "DPI-C" function integer f_ferr(integer ferr);
    7.   //drive using c2v DPI function
    8.   export "DPI-C" task t_gen_stim;
    9.   task t_gen_stim;
    10.     input bit trd;
    11.     input bit twr;
    12.    /*
    13.    if(trd || twr)
    14.    $display("task drive %d %d at %d", trd, twr, $time);
    15.    */
    16.    Trd=trd;
    17.    Twr=twr;
    18.   endtask
    19.   reg Trd, Twr;
    20.   reg qrd, qwr;
    21.   always @ (posedge clk) begin
    22.     qwr <= Twr;
    23.     qrd <= Trd;
    24.   end
    25. ...
    26.   pipe_fifo u_dut (
    27.    .clk(clk),
    28.    .rst(rst),
    29.    .clr(clr),
    30.    .rd(qrd), //fifo read
    31.    .wr(qwr), //fifo write
    32. ...




  3. Another way round this issue was suggested by Mr Wilson Snyder:
    reg Trd /*verilator public_flat_rw @(negedge clk)*/;
    reg Twr /*verilator public_flat_rw @(negedge clk)*/;

    When I add that your test doesn't fail. This tells
    verilator when your DPI task may be changing the
    signals; see the man page. Verilator uses this to
    schedule the model; without such hints it assumes you
    only change them when the signals would otherwise
    change. (Or it would have to assume they could
    change anywhere which would be very slow.)


  ...


Home

some memory VHDL models

my first experience with verilator.






Search This Site


Feedback This Site




new pages on this site