Skip to content

Commit 08cb3fb

Browse files
author
Maurus Item
committed
Fixed Various internals that caused problems when bitflips occur.
- Removed recursive assignments that can cause trouble in simulation - Removed repeated assignments in always_comb of classifier that cause trouble in simulation - Fixed format selection can evaluate to X when faults are injected into Enum in simulation.
1 parent 010ca4e commit 08cb3fb

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

src/fpnew_classifier.sv

+11-10
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,21 @@ module fpnew_classifier #(
5555
is_boxed = is_boxed_i[op];
5656
is_normal = is_boxed && (value.exponent != '0) && (value.exponent != '1);
5757
is_zero = is_boxed && (value.exponent == '0) && (value.mantissa == '0);
58-
is_subnormal = is_boxed && (value.exponent == '0) && !is_zero;
5958
is_inf = is_boxed && ((value.exponent == '1) && (value.mantissa == '0));
59+
is_subnormal = is_boxed && (value.exponent == '0) && !is_zero;
6060
is_nan = !is_boxed || ((value.exponent == '1) && (value.mantissa != '0));
6161
is_signalling = is_boxed && is_nan && (value.mantissa[MAN_BITS-1] == 1'b0);
6262
is_quiet = is_nan && !is_signalling;
63-
// Assign output for current input
64-
info_o[op].is_normal = is_normal;
65-
info_o[op].is_subnormal = is_subnormal;
66-
info_o[op].is_zero = is_zero;
67-
info_o[op].is_inf = is_inf;
68-
info_o[op].is_nan = is_nan;
69-
info_o[op].is_signalling = is_signalling;
70-
info_o[op].is_quiet = is_quiet;
71-
info_o[op].is_boxed = is_boxed;
7263
end
64+
65+
// Assign output for current input
66+
assign info_o[op].is_normal = is_normal;
67+
assign info_o[op].is_subnormal = is_subnormal;
68+
assign info_o[op].is_zero = is_zero;
69+
assign info_o[op].is_inf = is_inf;
70+
assign info_o[op].is_nan = is_nan;
71+
assign info_o[op].is_signalling = is_signalling;
72+
assign info_o[op].is_quiet = is_quiet;
73+
assign info_o[op].is_boxed = is_boxed;
7374
end
7475
endmodule

src/fpnew_fma.sv

+12-6
Original file line numberDiff line numberDiff line change
@@ -147,22 +147,28 @@ module fpnew_fma #(
147147
// | MUL | \c 0 | MUL: Set operand C to +0.0 or -0.0 depending on the rounding mode
148148
// | *others* | \c - | *invalid*
149149
// \note \c op_mod_q always inverts the sign of the addend.
150-
always_comb begin : op_select
151150

151+
// Fix for InjectaFault
152+
fp_t operand_a_base, operand_b_base, operand_c_base;
153+
assign operand_a_base = inp_pipe_operands_q[NUM_INP_REGS][0];
154+
assign operand_b_base = inp_pipe_operands_q[NUM_INP_REGS][1];
155+
assign operand_c_base = inp_pipe_operands_q[NUM_INP_REGS][2];
156+
157+
always_comb begin : op_select
152158
// Default assignments - packing-order-agnostic
153-
operand_a = inp_pipe_operands_q[NUM_INP_REGS][0];
154-
operand_b = inp_pipe_operands_q[NUM_INP_REGS][1];
155-
operand_c = inp_pipe_operands_q[NUM_INP_REGS][2];
159+
operand_a = operand_a_base;
160+
operand_b = operand_b_base;
161+
operand_c = operand_c_base;
156162
info_a = info_q[0];
157163
info_b = info_q[1];
158164
info_c = info_q[2];
159165

160166
// op_mod_q inverts sign of operand C
161-
operand_c.sign = operand_c.sign ^ inp_pipe_op_mod_q[NUM_INP_REGS];
167+
operand_c.sign = operand_c_base.sign ^ inp_pipe_op_mod_q[NUM_INP_REGS];
162168

163169
unique case (inp_pipe_op_q[NUM_INP_REGS])
164170
fpnew_pkg::FMADD: ; // do nothing
165-
fpnew_pkg::FNMSUB: operand_a.sign = ~operand_a.sign; // invert sign of product
171+
fpnew_pkg::FNMSUB: operand_a.sign = ~operand_a_base.sign; // invert sign of product
166172
fpnew_pkg::ADD: begin // Set multiplicand to +1
167173
operand_a = '{sign: 1'b0, exponent: BIAS, mantissa: '0};
168174
info_a = '{is_normal: 1'b1, is_boxed: 1'b1, default: 1'b0}; //normal, boxed value.

src/fpnew_fma_multi.sv

+12-5
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,29 @@ module fpnew_fma_multi #(
196196
// | MUL | \c 0 | MUL: Set operand C to +0.0 or -0.0 depending on the rounding mode
197197
// | *others* | \c - | *invalid*
198198
// \note \c op_mod_q always inverts the sign of the addend.
199+
200+
// Fix for InjectaFault
201+
fp_t operand_a_base, operand_b_base, operand_c_base;
202+
assign operand_a_base = {fmt_sign[src_fmt_q][0], fmt_exponent[src_fmt_q][0], fmt_mantissa[src_fmt_q][0]};
203+
assign operand_b_base = {fmt_sign[src_fmt_q][1], fmt_exponent[src_fmt_q][1], fmt_mantissa[src_fmt_q][1]};
204+
assign operand_c_base = {fmt_sign[dst_fmt_q][2], fmt_exponent[dst_fmt_q][2], fmt_mantissa[dst_fmt_q][2]};
205+
199206
always_comb begin : op_select
200207

201208
// Default assignments - packing-order-agnostic
202-
operand_a = {fmt_sign[src_fmt_q][0], fmt_exponent[src_fmt_q][0], fmt_mantissa[src_fmt_q][0]};
203-
operand_b = {fmt_sign[src_fmt_q][1], fmt_exponent[src_fmt_q][1], fmt_mantissa[src_fmt_q][1]};
204-
operand_c = {fmt_sign[dst_fmt_q][2], fmt_exponent[dst_fmt_q][2], fmt_mantissa[dst_fmt_q][2]};
209+
operand_a = operand_a_base;
210+
operand_b = operand_b_base;
211+
operand_c = operand_c_base;
205212
info_a = info_q[src_fmt_q][0];
206213
info_b = info_q[src_fmt_q][1];
207214
info_c = info_q[dst_fmt_q][2];
208215

209216
// op_mod_q inverts sign of operand C
210-
operand_c.sign = operand_c.sign ^ inp_pipe_op_mod_q[NUM_INP_REGS];
217+
operand_c.sign = operand_c_base.sign ^ inp_pipe_op_mod_q[NUM_INP_REGS];
211218

212219
unique case (inp_pipe_op_q[NUM_INP_REGS])
213220
fpnew_pkg::FMADD: ; // do nothing
214-
fpnew_pkg::FNMSUB: operand_a.sign = ~operand_a.sign; // invert sign of product
221+
fpnew_pkg::FNMSUB: operand_a.sign = ~operand_a_base.sign; // invert sign of product
215222
fpnew_pkg::ADD: begin // Set multiplicand to +1
216223
operand_a = '{sign: 1'b0, exponent: fpnew_pkg::bias(src_fmt_q), mantissa: '0};
217224
info_a = '{is_normal: 1'b1, is_boxed: 1'b1, default: 1'b0}; //normal, boxed value.

src/fpnew_opgroup_block.sv

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ module fpnew_opgroup_block #(
176176

177177
logic in_valid;
178178

179-
assign in_valid = in_valid_i & (FmtUnitTypes[dst_fmt_i] == fpnew_pkg::MERGED);
179+
assign in_valid = in_valid_i & (FmtUnitTypes[dst_fmt_i] == fpnew_pkg::MERGED && dst_fmt_i < dst_fmt_i.num());
180180

181181
fpnew_opgroup_multifmt_slice #(
182182
.OpGroup ( OpGroup ),

src/fpnew_pkg.sv

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ package fpnew_pkg;
9999
INT64: return 64;
100100
default: begin
101101
// pragma translate_off
102-
$fatal(1, "Invalid INT format supplied");
102+
$error(1, "Invalid INT format supplied");
103103
// pragma translate_on
104104
// just return any integer to avoid any latches
105105
// hopefully this error is caught by simulation

0 commit comments

Comments
 (0)