1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
|