Fatal errors in system verilog

Hi sir/mam
I have done spi master core compile all file,simulation also done ,but give fatal errors ater run the code ,
bellow transcript window display given error mentioned ,
please suggest me

** Fatal: (vsim-131) scb_spi.sv(21): Null instance encountered when dereferencing ‘/top_env_spi_sv_unit::scoreboard::run/this*.gen_scb’

Time: 0 ps Iteration: 1 Process: /top_env_spi_sv_unit::environment::run_env/#FORK#43_ff03d53 File: scb_spi.sv

Fatal error in Task top_env_spi_sv_unit/scoreboard::run at scb_spi.sv line 21

HDL call sequence:

Stopped at scb_spi.sv 21 Task top_env_spi_sv_unit/scoreboard::run

called from env_spi.sv 43 Task top_env_spi_sv_unit/environment::run_env

Thanks in advance

In reply to Nishant Kumar:

There is no way to help you with this kind of error without showing the line of code scb_spi.sv(21), and probably the code around it to show the context.

In reply to dave_59:

thanks to respond dave

this is scoreboard code

pi
//include"transactor.sv" include"mon_spi.sv"

class scoreboard;

mailbox mon_scb;
mailbox gen_scb;

function new(input mailbox mon_scb,mailbox gen_scb);
//this.intf2=intf2;
this.gen_scb=gen_scb;
this.mon_scb=mon_scb;
endfunction

task run();
begin
transactor_spi tr1;
transactor_spi tr2;

gen_scb.try_get(tr1);
mon_scb.try_get(tr2);

if((tr1.wb_dat_i===tr2.wb_dat_o));
$display (“data matched”);
//mon_scb.get(ss_pad_o_1,mosi_pad_o_1,miso_pad_i_1,wb_dat_o_1,wb_ack_o_1,wb_err_o_1,wb_int_o_1);
end
endtask
endclas

In reply to Nishant Kumar:

Nishant,

You are passing ‘gen_scb’ in new method, but where have you allocated object for it.

I think, you missed to allocate object to gen_scb in env from where you are calling scoreboard new method.

In reply to prashant.kaushik:

ok prashant

bellow code are code of env and program(testcase)

include"intf_spi.sv" include"scb_spi.sv"

class environment;
virtual intf_spi.dut intf1;
virtual intf_spi.test intf2;
gen_spi gen_inst;
//transactor_spi tr;
mon_spi mnt;
dr_spi drv;
scoreboard scb;

mailbox gen_dr;
mailbox gen_scb;
mailbox mon_scb;
//virtual intf_spi.test intf2;

function new(input mailbox gen_dr,virtual intf_spi.dut intf1,virtual intf_spi.test intf2);
this.intf1=intf1;
this.intf2=intf2;
this.gen_dr=gen_dr;
endfunction

task build();
gen_inst=new(gen_dr);
drv=new(gen_dr,intf1);
gen_dr=new();

mnt=new(intf2,mon_scb);
scb=new(mon_scb,gen_scb);
endtask:build

task run_env();
fork
gen_inst.run;
$display (“start of drv runtask”);

$display (“end of drv runtask”);
mnt.run;
scb.run;
join_any
drv.run;
//drv.reset(10);
$display(“end of environment class”);
endtask

// program block/testcase

`include"env_spi.sv"

program testcase_spi(intf_spi.dut intf1,intf_spi.test intf2);

environment env;
mailbox gen_dr;

initial
begin
repeat(6)
begin

gen_dr =new();
env = new(gen_dr,intf1,intf2);

//gen_scb=new();
//mon_scb=new();

env.build();
env.run_env();
end
end
endprogram