Skip to content

Commit 7aba1e5

Browse files
committed
compile time bug insertion
make BUG=1 -> addsub make BUG=2 -> muldiv make BUG=3 -> addsub and muldiv
1 parent 3e3ec19 commit 7aba1e5

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ ifdef TEST_PRINT
3333
vsim_args += +TEST_PRINT
3434
endif
3535

36+
ifeq ($(BUG), 1)
37+
vlog_args += +define+BUG_ADDSUB
38+
else
39+
ifeq ($(BUG), 2)
40+
vlog_args += +define+BUG_MULDIV
41+
else
42+
ifeq ($(BUG), 3)
43+
vlog_args += +define+BUG_ADDSUB +define+BUG_MULDIV
44+
endif
45+
endif
46+
endif
47+
3648
build:
3749
vlog $(vlog_args) $(SV_TARGET)
3850

duv/pfpu32_addsub.v

+6
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,15 @@ module pfpu32_addsub
112112
addsub_agtb_i ? fract24b_i : fract24a_i;
113113

114114
// shift amount
115+
`ifdef BUG_ADDSUB
116+
wire [9:0] s1t_exp_diff =
117+
addsub_agtb_i ? (exp10a_i + exp10b_i) :
118+
(exp10b_i + exp10a_i);
119+
`else
115120
wire [9:0] s1t_exp_diff =
116121
addsub_agtb_i ? (exp10a_i - exp10b_i) :
117122
(exp10b_i - exp10a_i);
123+
`endif
118124

119125
// limiter by 31
120126
wire [4:0] s1t_shr = s1t_exp_diff[4:0] | {5{|s1t_exp_diff[9:5]}};

duv/pfpu32_muldiv.v

+4
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@ module pfpu32_muldiv
586586
// In fact, as the dividend and divisor was normalized
587587
// and the result is non-zero
588588
// the '1' is maximum number of leading zeros in the quotient.
589+
`ifdef BUG_MULDIV
590+
wire s4t_nlz = s3o_res_qtnt26[25];
591+
`else
589592
wire s4t_nlz = ~s3o_res_qtnt26[25];
593+
`endif
590594
// left shift flag and corrected exponent
591595
wire s4t_shlx =
592596
// shift isn't needed (includes zero result)

0 commit comments

Comments
 (0)