@@ -75,6 +75,8 @@ class cv32e40p_float_zfinx_base_instr_stream extends cv32e40p_base_instr_stream;
75
75
logic [31 : 0 ] csr_rm = $urandom_range (0 ,4 );
76
76
logic [31 : 0 ] csr_mstatus_fs = 0 ;
77
77
// for clr_crs_fflags usage - end
78
+
79
+ riscv_reg_t xreg_for_set_fpr = ZERO ;
78
80
79
81
rand int unsigned num_of_instr_per_stream;
80
82
rand riscv_reg_t avail_gp_regs[][]; // regs for extension zfinx and f
@@ -389,28 +391,29 @@ class cv32e40p_float_zfinx_base_instr_stream extends cv32e40p_base_instr_stream;
389
391
virtual function void initialize_regs ();
390
392
// set random value on all gpr/fpr registers prior directed stream
391
393
// random fp value with mantissa not zeroes
392
- if (init_gpr) begin : SET_GPR_RAND_VALUE
393
- logic [ 31 : 0 ] i_imm;
394
- for ( int i = 1 ; i < 32 ; i ++ ) begin
395
- riscv_reg_t i_gpr = riscv_reg_t ' (i) ;
396
- // if (i_gpr inside { cfg.reserved_regs}) continue;
397
- if (i == int '(cfg.sp )) continue ; // do not alter stack pointer
398
- if (i == int '( cfg.tp)) continue ; // do not alter thread pointer
399
- if (cfg.gen_debug_section) begin
400
- if (i == int '(cfg_cv32e40p.dp)) continue ; // do not alter debug pointer
401
- end
394
+ logic [ 31 : 0 ] i_imm;
395
+ for ( int i = 1 ; i < 32 ; i ++ ) begin
396
+ riscv_reg_t i_gpr = riscv_reg_t ' (i);
397
+ // if ( i_gpr inside {cfg.reserved_regs}) continue ;
398
+ if (i == int '( cfg.sp)) continue ; // do not alter stack pointer
399
+ if (i == int '(cfg.tp )) continue ; // do not alter thread pointer
400
+ if (cfg.gen_debug_section) begin
401
+ if (i == int '(cfg_cv32e40p.dp)) continue ; // do not alter debug pointer
402
+ end
403
+ if (init_gpr) begin : SET_GPR_RAND_VALUE
402
404
rand_fp_val (i_imm);
403
405
`SET_GPR_VALUE (i_gpr,i_imm);
404
406
end
407
+ if (xreg_for_set_fpr == ZERO ) xreg_for_set_fpr = i_gpr;
405
408
end
406
- if (init_fpr) begin : SET_FPR_RAND_VALUE
407
- logic [31 : 0 ] i_imm;
408
- for (int i= 0 ; i< 32 ; i++ ) begin
409
- riscv_fpr_t i_fpr = riscv_fpr_t ' (i);
409
+ for (int i= 0 ; i< 32 ; i++ ) begin
410
+ riscv_fpr_t i_fpr = riscv_fpr_t ' (i);
411
+ if (init_fpr) begin : SET_FPR_RAND_VALUE
410
412
rand_fp_val (i_imm);
411
- `SET_FPR_VALUE (i_fpr,i_imm);
413
+ `SET_FPR_VALUE (i_fpr,i_imm,xreg_for_set_fpr );
412
414
end
413
415
end
416
+
414
417
set_reserved_sp_addr ();
415
418
set_csr_fm (gp_reg_scratch);
416
419
endfunction : initialize_regs
@@ -426,9 +429,9 @@ class cv32e40p_float_zfinx_base_instr_stream extends cv32e40p_base_instr_stream;
426
429
bit select_fp_instr, include_fpc, rand_status;
427
430
428
431
rand_status = std:: randomize (select_fp_instr) with { select_fp_instr dist { 0 : = 1 , 1 : = 1 } ;} ;
429
- assert (rand_status);
432
+ assert (rand_status) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
430
433
rand_status = std:: randomize (include_fpc) with { include_fpc dist { 0 : = 3 , 1 : = 1 } ;} ; // less weight on fpc
431
- assert (rand_status);
434
+ assert (rand_status) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
432
435
433
436
if (! use_same_instr_per_stream) include_instr.delete ();
434
437
include_group.delete ();
@@ -492,7 +495,7 @@ class cv32e40p_float_zfinx_base_instr_stream extends cv32e40p_base_instr_stream;
492
495
exclude_instr = new [exclude_instr.size ()+ 1 ] ({ exclude_instr, prev_instr.instr_name} );
493
496
end
494
497
if (use_same_instr_per_stream && prev_instr != null ) begin
495
- assert (use_fp_only_for_directed_instr && use_same_instr_per_stream);
498
+ assert (use_fp_only_for_directed_instr && use_same_instr_per_stream) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
496
499
include_instr = new [1 ] ({ prev_instr.instr_name} );
497
500
end
498
501
endfunction : update_next_instr_arg_list
@@ -1025,7 +1028,7 @@ class cv32e40p_float_zfinx_base_instr_stream extends cv32e40p_base_instr_stream;
1025
1028
logic [11 : 0 ] csr= 12'h000 , int idx= 0
1026
1029
);
1027
1030
riscv_instr instr;
1028
- assert (instr_name != INVALID_INSTR );
1031
+ assert (instr_name != INVALID_INSTR ) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
1029
1032
instr = new riscv_instr :: get_rand_instr (
1030
1033
.include_instr ({ instr_name} )
1031
1034
);
@@ -1298,8 +1301,8 @@ class cv32e40p_constraint_mc_fp_instr_stream extends cv32e40p_float_zfinx_base_i
1298
1301
int rand_mc_latency = $urandom_range (0 ,mc_instr_latency);
1299
1302
int loop_cnt = 0 ;
1300
1303
1301
- assert (! (instr == null && instr_zfinx == null && instr_f == null ));
1302
- assert (rand_mc_latency >= 0 );
1304
+ assert (! (instr == null && instr_zfinx == null && instr_f == null )) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
1305
+ assert (rand_mc_latency >= 0 ) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
1303
1306
1304
1307
while (! (loop_cnt == 100 ) && rand_mc_latency > 0 ) begin
1305
1308
int p_rand_mc_latency = rand_mc_latency;
@@ -1426,7 +1429,7 @@ class cv32e40p_fp_op_fwd_instr_stream extends cv32e40p_float_zfinx_base_instr_st
1426
1429
en_clr_fflags_af_instr = 0 ;
1427
1430
num_of_instr_per_block = 10 ;
1428
1431
include_load_store_base_sp = 0 ; // exclude store instrs for this stream
1429
- assert (num_of_instr_per_block != 0 && num_of_instr_per_block% 10 == 0 );
1432
+ assert (num_of_instr_per_block != 0 && num_of_instr_per_block% 10 == 0 ) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
1430
1433
endfunction : pre_randomize
1431
1434
1432
1435
virtual function void print_stream_setting ();
@@ -1699,7 +1702,7 @@ class cv32e40p_fp_op_fwd_instr_w_loadstore_stream extends cv32e40p_float_zfinx_b
1699
1702
1700
1703
riscv_fpr_t i_fs1 = (is_zfinx) ? FT0 : p_instr_f.fs1;
1701
1704
1702
- assert (! (p_instr_zfinx == null && p_instr_f == null ));
1705
+ assert (! (p_instr_zfinx == null && p_instr_f == null )) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
1703
1706
`SET_GPR_VALUE (i_rd, v_rd);
1704
1707
1705
1708
if (p_instr_zfinx != null ) begin
@@ -1719,8 +1722,8 @@ class cv32e40p_fp_op_fwd_instr_w_loadstore_stream extends cv32e40p_float_zfinx_b
1719
1722
end
1720
1723
else begin
1721
1724
unique case (p_instr_f.instr_name)
1722
- FCVT_W_S , FCVT_WU_S : begin `SET_FPR_VALUE (i_fs1, F_POS_VAL1 ); end // rd(int) = fs1
1723
- FMV_X_W : begin `SET_FPR_VALUE (i_fs1, F_NEG_ZERO_DIV2 ); end // rd(int) <- fs1
1725
+ FCVT_W_S , FCVT_WU_S : begin `SET_FPR_VALUE (i_fs1, F_POS_VAL1 , xreg_for_set_fpr ); end // rd(int) = fs1
1726
+ FMV_X_W : begin `SET_FPR_VALUE (i_fs1, F_NEG_ZERO_DIV2 , xreg_for_set_fpr ); end // rd(int) <- fs1
1724
1727
endcase
1725
1728
end
1726
1729
@@ -1876,7 +1879,7 @@ class cv32e40p_fp_op_fwd_instr_w_loadstore_stream extends cv32e40p_float_zfinx_b
1876
1879
STORE , POST_INC_STORE : begin // S[B|H|WW], C_SW[SP], C_FSW[SP], CV_S[B|H|W]
1877
1880
instr2.rs1 = (is_zfinx) ? instr_zfinx.rd : instr_f.rd;
1878
1881
if (instr2.category == POST_INC_STORE && j != num_of_load_store_instr- 1 ) begin // no special handle on last load/store
1879
- assert (instr2.has_rd); // rd here is rs3 in spec
1882
+ assert (instr2.has_rd) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end // rd here is rs3 in spec
1880
1883
instr2.rd = ZERO ; // prevent post incr to update rs1 that target into code space
1881
1884
end
1882
1885
last_store_rs1 = instr2.rs1; has_store = 1 ;
@@ -1890,7 +1893,7 @@ class cv32e40p_fp_op_fwd_instr_w_loadstore_stream extends cv32e40p_float_zfinx_b
1890
1893
end
1891
1894
if (instr2.has_rd) begin last_load_rd = instr2.rd; has_load_rd = 1 ; end
1892
1895
if (instr2.category == POST_INC_LOAD && j != num_of_load_store_instr- 1 ) begin // no special handle on last load/store
1893
- assert (instr2.has_rs2);
1896
+ assert (instr2.has_rs2) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
1894
1897
instr2.rs2 = ZERO ; // prevent post incr to update rs1 that target into code space
1895
1898
end
1896
1899
cnt = 0 ;
@@ -2050,7 +2053,7 @@ class cv32e40p_mstatus_fs_stream extends cv32e40p_float_zfinx_base_instr_stream;
2050
2053
if (idx == 0 ) loop_cnt++ ;
2051
2054
else if (idx != 0 && idx% total_instr == 0 ) begin
2052
2055
loop_cnt++ ;
2053
- assert (loop_cnt <= loop_cnt_limit);
2056
+ assert (loop_cnt <= loop_cnt_limit) else begin `uvm_error (_header, $sformatf ( " assertion error " )); end
2054
2057
exclude_instr.delete ();
2055
2058
csr_mstatus_fs = 32'd2 ; // Clean
2056
2059
clr_csr_init_done = 0 ; // Update csrrw_val
0 commit comments