@@ -45,28 +45,28 @@ module abr_masked_N_bit_Boolean_sub #(
4545 assign carry[0 ] = sub_i ? 2'b01 : 2'b00 ;
4646
4747 // Generate the full adders for each bit
48- genvar i ;
48+ genvar g_i ;
4949 generate
50- for (i = 0 ; i < WIDTH ; i = i + 1 ) begin : gen_full_adders
50+ for (g_i = 0 ; g_i < WIDTH ; g_i = g_i + 1 ) begin : gen_full_adders
5151 // Pipeline registers for x and y inputs
5252 always_ff @ (posedge clk or negedge rst_n) begin
5353 if (! rst_n) begin
54- x_reg[i ] <= '0 ;
55- y_reg[i ] <= '0 ;
54+ x_reg[g_i ] <= '0 ;
55+ y_reg[g_i ] <= '0 ;
5656 end
5757 else if (zeroize) begin
58- x_reg[i ] <= '0 ;
59- y_reg[i ] <= '0 ;
58+ x_reg[g_i ] <= '0 ;
59+ y_reg[g_i ] <= '0 ;
6060 end
6161 else begin
6262 for (int j = 0 ; j < WIDTH ; j = j + 1 ) begin
6363 if (j == 0 ) begin
64- x_reg[i ][j] <= x[i ];
65- y_reg[i ][j] <= y[i ];
64+ x_reg[g_i ][j] <= x[g_i ];
65+ y_reg[g_i ][j] <= y[g_i ];
6666 end
6767 else begin
68- x_reg[i ][j] <= x_reg[i ][j- 1 ];
69- y_reg[i ][j] <= y_reg[i ][j- 1 ];
68+ x_reg[g_i ][j] <= x_reg[g_i ][j- 1 ];
69+ y_reg[g_i ][j] <= y_reg[g_i ][j- 1 ];
7070 end
7171 end
7272 end
@@ -75,37 +75,37 @@ module abr_masked_N_bit_Boolean_sub #(
7575 // Pipeline registers for sum output
7676 always_ff @ (posedge clk or negedge rst_n) begin
7777 if (! rst_n) begin
78- sum_reg[i ] <= '0 ;
78+ sum_reg[g_i ] <= '0 ;
7979 end
8080 else if (zeroize) begin
81- sum_reg[i ] <= '0 ;
81+ sum_reg[g_i ] <= '0 ;
8282 end
8383 else begin
84- for (int j = i ; j < WIDTH ; j = j + 1 ) begin
85- if (j == i && i == WIDTH - 1 ) begin
86- sum_reg[i ][j] <= the_last_sum;
84+ for (int j = g_i ; j < WIDTH ; j = j + 1 ) begin
85+ if (j == g_i && g_i == WIDTH - 1 ) begin
86+ sum_reg[g_i ][j] <= the_last_sum;
8787 end
88- else if (j == i ) begin
89- sum_reg[i ][j] <= sum[i ];
88+ else if (j == g_i ) begin
89+ sum_reg[g_i ][j] <= sum[g_i ];
9090 end
9191 else begin
92- sum_reg[i ][j] <= sum_reg[i ][j- 1 ];
92+ sum_reg[g_i ][j] <= sum_reg[g_i ][j- 1 ];
9393 end
9494 end
9595 end
9696 end
97- if (i < (WIDTH - 1 )) begin : gen_masked_full_adder
97+ if (g_i < (WIDTH - 1 )) begin : gen_masked_full_adder
9898 // Instance of abr_masked_full_adder
9999 abr_masked_full_adder u_abr_masked_full_adder (
100100 .clk (clk), // Connect clk to clk
101101 .rst_n (rst_n), // Connect rst_n to rst_n
102102 .zeroize (zeroize), // Connect zeroize to zeroize
103- .x (x_reg[i][i ]), // Connect x to the last stage of the x pipeline
104- .y (y_reg[i][i ]), // Connect y to the last stage of the y pipeline
105- .c_in (carry[i ]), // Connect c_in to carry[i ]
106- .rnd (rnd[i ]), // Connect rnd to corresponding random bit
107- .s (sum[i ]), // Connect sum to sum[i ]
108- .c_out (carry[i + 1 ]) // Connect carry out to carry[i +1]
103+ .x (x_reg[g_i][g_i ]), // Connect x to the last stage of the x pipeline
104+ .y (y_reg[g_i][g_i ]), // Connect y to the last stage of the y pipeline
105+ .c_in (carry[g_i ]), // Connect c_in to carry[g_i ]
106+ .rnd (rnd[g_i ]), // Connect rnd to corresponding random bit
107+ .s (sum[g_i ]), // Connect sum to sum[g_i ]
108+ .c_out (carry[g_i + 1 ]) // Connect carry out to carry[g_i +1]
109109 );
110110 end
111111 end
0 commit comments