From 29fb6afd018c601a2e0c7376656d5e37beb565d6 Mon Sep 17 00:00:00 2001 From: "Pavel V. Shatov (Meister)" Date: Tue, 1 Oct 2019 15:01:43 +0300 Subject: Started working on the pipelined Montgomery modular multiplier. Currently can do the "square" part of the multiplication, i.e. compute the twice larger intermediate product AB = A * B. --- rtl/modexpng_mac_array.v | 116 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 rtl/modexpng_mac_array.v (limited to 'rtl/modexpng_mac_array.v') diff --git a/rtl/modexpng_mac_array.v b/rtl/modexpng_mac_array.v new file mode 100644 index 0000000..067929e --- /dev/null +++ b/rtl/modexpng_mac_array.v @@ -0,0 +1,116 @@ +module modexpng_mac_array +( + clk, + ce, clr, + ce_aux, clr_aux, + casc_a, casc_a_aux, + a_in, b_in, p_out, + a_in_aux, p_out_aux +); + + + // + // Includes + // + `include "modexpng_parameters.vh" + `include "modexpng_parameters_x8.vh" + + + // + // Ports + // + input clk; + input ce; + input [NUM_MULTS -1:0] clr; + input ce_aux; + input clr_aux; + input [NUM_MULTS -2:0] casc_a; + input casc_a_aux; + input [NUM_MULTS * WORD_WIDTH -1:0] a_in; + input [ 1 * WORD_WIDTH -1:0] b_in; + output [NUM_MULTS * MAC_WIDTH -1:0] p_out; + input [ 1 * WORD_WIDTH -1:0] a_in_aux; + output [ 1 * MAC_WIDTH -1:0] p_out_aux; + + + // + // A-Cascade Paths + // + wire [WORD_WIDTH-1:0] a_casc_int[0:NUM_MULTS-2]; + wire [WORD_WIDTH-1:0] a_casc_int_aux; + + + // + // LSB + // + modexpng_mac mac_lsb + ( + .clk (clk), + .ce (ce), + .clr (clr[0]), + .casc_a (1'b0), + .a_in (a_in[0+:WORD_WIDTH]), + .b_in (b_in), + .p_out (p_out[0+:MAC_WIDTH]), + .a_casc_in ({WORD_WIDTH{1'b0}}), + .a_casc_out (a_casc_int[0]) + ); + + + // + // INT + // + genvar z; + generate for (z=1; z<(NUM_MULTS-1); z=z+1) + begin : gen_modexpng_mac_int + modexpng_mac mac_int + ( + .clk (clk), + .ce (ce), + .clr (clr[z]), + .casc_a (casc_a[z-1]), + .a_in (a_in[z*WORD_WIDTH+:WORD_WIDTH]), + .b_in (b_in), + .p_out (p_out[z*MAC_WIDTH+:MAC_WIDTH]), + .a_casc_in (a_casc_int[z-1]), + .a_casc_out (a_casc_int[z]) + ); + end + endgenerate + + + // + // MSB + // + modexpng_mac mac_msb + ( + .clk (clk), + .ce (ce), + .clr (clr[NUM_MULTS-1]), + .casc_a (casc_a[NUM_MULTS-2]), + .a_in (a_in[(NUM_MULTS-1)*WORD_WIDTH+:WORD_WIDTH]), + .b_in (b_in), + .p_out (p_out[(NUM_MULTS-1)*MAC_WIDTH+:MAC_WIDTH]), + .a_casc_in (a_casc_int[NUM_MULTS-2]), + .a_casc_out (a_casc_int_aux) + ); + + + // + // AUX + // + modexpng_mac mac_aux + ( + .clk (clk), + .ce (ce_aux), + .clr (clr_aux), + .casc_a (casc_a_aux), + .a_in (a_in_aux), + .b_in (b_in), + .p_out (p_out_aux), + .a_casc_in (a_casc_int_aux), + .a_casc_out () + ); + + +endmodule -- cgit v1.2.3