OpenCores
URL https://opencores.org/ocsvn/async_sdm_noc/async_sdm_noc/trunk

Subversion Repositories async_sdm_noc

[/] [async_sdm_noc/] [branches/] [clos_opt/] [clos_opt/] [src/] [input_buf.v] - Blame information for rev 72

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 16 wsong0210
/*
2
 Asynchronous SDM NoC
3
 (C)2011 Wei Song
4
 Advanced Processor Technologies Group
5
 Computer Science, the Univ. of Manchester, UK
6
 
7
 Authors:
8
 Wei Song     wsong83@gmail.com
9
 
10
 License: LGPL 3.0 or later
11
 
12
 Input buffer for Wormhole/SDM routers.
13
 *** SystemVerilog is used ***
14
 
15
 References
16
 * Lookahead pipelines
17 17 wsong0210
     Montek Singh and Steven M. Nowick, The design of high-performance dynamic asynchronous pipelines: lookahead style, IEEE Transactions on Very Large Scale Integration (VLSI) Systems, 2007(15), 1256-1269. doi:10.1109/TVLSI.2007.902205
18 16 wsong0210
 * Channel slicing
19
     Wei Song and Doug Edwards, A low latency wormhole router for asynchronous on-chip networks, Asia and South Pacific Design Automation Conference, 2010, 437-443.
20
 * SDM
21
     Wei Song and Doug Edwards, Asynchronous spatial division multiplexing router, Microprocessors and Microsystems, 2011(35), 85-97.
22
 
23
 History:
24
 05/05/2009  Initial version. <wsong83@gmail.com>
25
 20/09/2010  Supporting channel slicing and SDM using macro difinitions. <wsong83@gmail.com>
26
 24/05/2011  Clean up for opensource. <wsong83@gmail.com>
27 47 wsong0210
 01/06/2011  Use the comp4 common comparator rather than the chain_comparator defined in this module. <wsong83@gmail.com>
28 62 wsong0210
 21/06/2011  Move the eof logic in every pipeline stage outside the pipe4 module. <wsong83@gmail.com>
29 72 wsong0210
 12/07/2011  Preparation for the buffered Clos switch. <wsong83@gmail.com>
30
 
31 16 wsong0210
*/
32
 
33
// the router structure definitions
34
`include "define.v"
35
 
36
module inp_buf (/*AUTOARG*/
37
   // Outputs
38 72 wsong0210
   o0, o1, o2, o3, o4, ia, deco,
39 16 wsong0210
   // Inputs
40 72 wsong0210
   rst_n, i0, i1, i2, i3, i4, oa, addrx, addry
41 16 wsong0210
   );
42
 
43
   //-------------------------- parameters ---------------------------------------//
44
   parameter DIR = 0;              // the port direction: south, west, north, east, and local
45
   parameter RN = 4;               // the number of request outputs, must match the direction
46
   parameter DW = 16;              // the data-width of the data-path
47
   parameter PD = 2;               // the depth of the input buffer
48
   parameter SCN = DW/2;
49
 
50
   //-------------------------- I/O ports ---------------------------------------//
51
   input                  rst_n;          // global reset, active low
52
   input [SCN-1:0]         i0, i1, i2, i3; // data input
53
   output [SCN-1:0]        o0, o1, o2, o3; // data output
54
`ifdef ENABLE_CHANNEL_SLICING
55
   input [SCN-1:0]         i4, oa;
56
   output [SCN-1:0]        o4, ia;
57
`else
58
   input                  i4, oa;
59
   output                 o4, ia;
60
`endif
61 72 wsong0210
   input [7:0]             addrx, addry; // local addresses in 1-of-4 encoding
62
   output [RN-1:0]         deco; // the decoded routing requests
63 16 wsong0210
 
64
   //-------------------------- control signals ---------------------------------------//
65
   wire                   rten;                // routing enable
66
   wire                   frame_end;           // identify the end of a frame
67
   wire [7:0]              pipe_xd, pipe_yd;    // the target address from the incoming frame
68
   wire [PD:0][SCN-1:0]   pd0, pd1, pd2, pd3;  // data wires for the internal pipeline satges
69
   wire [5:0]              raw_dec;             // the routing decision from the comparator
70
   wire [4:0]              dec_reg;             // the routing decision kept by C-gates
71
   wire                   x_equal;             // addr x = target x
72
   wire                   rt_err;              // route decoder error
73
 
74
`ifdef ENABLE_CHANNEL_SLICING
75 72 wsong0210
   wire [SCN-1:0]          deca; // the ack for routing requests
76 62 wsong0210
   wire [PD:0][SCN-1:0]   pd4, pda, pdan, pd4an; // data wires for the internal pipeline stages
77 16 wsong0210
 
78
`else
79 72 wsong0210
   wire                   deca; // the ack for routing requests
80 62 wsong0210
   wire [PD:0]             pd4, pda, pdan, pd4an; // data wires for the internal pipeline satges
81 16 wsong0210
`endif // !`ifdef ENABLE_CHANNEL_SLICING
82 72 wsong0210
   wire                   decan;
83 16 wsong0210
 
84
   genvar                 i, j;
85
 
86
   //------------------------- pipelines ------------------------------------- //
87
   generate for(i=0; i<PD; i++) begin: DP
88
`ifdef ENABLE_CHANNEL_SLICING
89
      for(j=0; j<SCN; j++) begin: SC
90
         pipe4 #(.DW(2))
91
         P (
92
            .o0  ( pd0[i][j]   ),
93
            .o1  ( pd1[i][j]   ),
94
            .o2  ( pd2[i][j]   ),
95
            .o3  ( pd3[i][j]   ),
96
            .ia  ( pda[i+1][j] ),
97
            .i0  ( pd0[i+1][j] ),
98
            .i1  ( pd1[i+1][j] ),
99
            .i2  ( pd2[i+1][j] ),
100
            .i3  ( pd3[i+1][j] ),
101
            .oa  ( pdan[i][j]  )
102
            );
103 62 wsong0210
 
104
         pipen #(.DW(1))
105
         PEoF (
106
               .d_in_a  (             ),
107
               .d_out   ( pd4[i][j]   ),
108
               .d_in    ( pd4[i+1][j] ),
109
               .d_out_a ( pd4an[i][j] )
110
               );
111
 
112 16 wsong0210
      end // block: SC
113 62 wsong0210
 
114 16 wsong0210
 
115
`else // !`ifdef ENABLE_CHANNEL_SLICING
116
      pipe4 #(.DW(DW))
117
      P (
118
         .o0  ( pd0[i]   ),
119
         .o1  ( pd1[i]   ),
120
         .o2  ( pd2[i]   ),
121
         .o3  ( pd3[i]   ),
122
         .ia  ( pda[i+1] ),
123
         .i0  ( pd0[i+1] ),
124
         .i1  ( pd1[i+1] ),
125
         .i2  ( pd2[i+1] ),
126
         .i3  ( pd3[i+1] ),
127
         .oa  ( pdan[i]  )
128
         );
129 62 wsong0210
 
130
      pipen #(.DW(1))
131
      PEoF (
132
            .d_in_a  (          ),
133
            .d_out   ( pd4[i]   ),
134
            .d_in    ( pd4[i+1] ),
135
            .d_out_a ( pd4an[i] )
136
            );
137
 
138 16 wsong0210
`endif // !`ifdef ENABLE_CHANNEL_SLICING
139
   end // block: DP
140
   endgenerate
141
 
142
   generate for(i=1; i<PD; i++) begin: DPA
143
      assign pdan[i] = rst_n ? ~(pda[i]|pd4[i-1]) : 0;
144 62 wsong0210
      assign pd4an[i] = pdan[i];
145 16 wsong0210
   end
146
   endgenerate
147
 
148
   assign ia = pda[PD]|pd4[PD-1];
149
   assign pd0[PD] = i0;
150
   assign pd1[PD] = i1;
151
   assign pd2[PD] = i2;
152
   assign pd3[PD] = i3;
153
   assign pd4[PD] = i4;
154
   assign o0 = pd0[0];
155
   assign o1 = pd1[0];
156
   assign o2 = pd2[0];
157
   assign o3 = pd3[0];
158
   assign o4 = pd4[0];
159
 
160
   //---------------------------- route decoder related -------------------------- //
161
   // fetch the x and y target
162
   and Px_0 (pipe_xd[0], rten, pd0[1][0]);
163
   and Px_1 (pipe_xd[1], rten, pd1[1][0]);
164
   and Px_2 (pipe_xd[2], rten, pd2[1][0]);
165
   and Px_3 (pipe_xd[3], rten, pd3[1][0]);
166
   and Px_4 (pipe_xd[4], rten, pd0[1][1]);
167
   and Px_5 (pipe_xd[5], rten, pd1[1][1]);
168
   and Px_6 (pipe_xd[6], rten, pd2[1][1]);
169
   and Px_7 (pipe_xd[7], rten, pd3[1][1]);
170
   and Py_0 (pipe_yd[0], rten, pd0[1][2]);
171
   and Py_1 (pipe_yd[1], rten, pd1[1][2]);
172
   and Py_2 (pipe_yd[2], rten, pd2[1][2]);
173
   and Py_3 (pipe_yd[3], rten, pd3[1][2]);
174
   and Py_4 (pipe_yd[4], rten, pd0[1][3]);
175
   and Py_5 (pipe_yd[5], rten, pd1[1][3]);
176
   and Py_6 (pipe_yd[6], rten, pd2[1][3]);
177
   and Py_7 (pipe_yd[7], rten, pd3[1][3]);
178
 
179
 
180
   routing_decision      // the comparator
181
   RTD(
182
       .addrx      ( addrx   )
183
       ,.addry     ( addry   )
184
       ,.pipe_xd   ( pipe_xd )
185
       ,.pipe_yd   ( pipe_yd )
186
       ,.decision  ( raw_dec )
187
       );
188
 
189
   // keep the routing decision until the tail flit is received by all sub-channels
190 28 wsong0210
   c2p C_RTD0  ( .b(raw_dec[0]),      .a((~frame_end)&rst_n),    .q(dec_reg[0]));
191
   c2p C_RTD1  ( .b(raw_dec[1]),      .a((~frame_end)&rst_n),    .q(dec_reg[1]));
192
   c2p C_RT_XEQ (.b(raw_dec[2]),      .a((~frame_end)&rst_n),    .q(x_equal) );
193
   c2p C_RTD2  ( .b(raw_dec[3]),      .a(x_equal),               .q(dec_reg[2]));
194
   c2p C_RTD3  ( .b(raw_dec[4]),      .a(x_equal),               .q(dec_reg[3]));
195
   c2p C_RTD4  ( .b(raw_dec[5]),      .a(x_equal),               .q(dec_reg[4]));
196 16 wsong0210
 
197
   // generate the arbiter request signals
198
   assign arb_r =
199
                  DIR == 0 ? {dec_reg[4],dec_reg[2],dec_reg[1],dec_reg[3]} :   // south port
200
                  DIR == 1 ? {dec_reg[4],dec_reg[2]}                       :   // west port
201
                  DIR == 2 ? {dec_reg[4],dec_reg[2],dec_reg[3],dec_reg[0]} :   // north port
202
                  DIR == 3 ? {dec_reg[4],dec_reg[3]}                       :   // east port
203
                             {dec_reg[2],dec_reg[1],dec_reg[3],dec_reg[0]} ;   // local port
204
 
205
 
206
   assign rt_err =
207
                  DIR == 0 ? |{dec_reg[0]}                        :   // south port
208
                  DIR == 1 ? |{dec_reg[0],dec_reg[1],dec_reg[3]}  :   // west port
209
                  DIR == 2 ? |{dec_reg[1]}                        :   // north port
210
                  DIR == 3 ? |{dec_reg[0],dec_reg[1],dec_reg[2]}  :   // east port
211
                             |{dec_reg[4]}                        ;   // local port
212
 
213
   or IP_RTACK (rt_ack, rt_err, arb_ra);
214
 
215
   // ------------------------ pipeline control ------------------------------ //
216
 
217
`ifdef ENABLE_CHANNEL_SLICING
218
   for(j=0; j<SCN; j++) begin: SC
219
      // the sub-channel controller
220
      subc_ctl SCH_C (
221
                      .nack     ( pdan[0][j]  ),
222
                      .rt_rst   ( rtrst[j]    ),
223
                      .ai2cb    ( oa[j]       ),
224
                      .ack      ( pda[1][j]   ),
225
                      .eof      ( pd4[0][j]   ),
226
                      .rt_ra    ( rt_ack      ),
227
                      .rt_err   ( rt_err      ),
228
                      .rst_n    ( rst_n       )
229
                      );
230 62 wsong0210
      assign pd4an[0][j] = pdan[0][j];
231 16 wsong0210
   end // block: SC
232
`else // !`ifdef ENABLE_CHANNEL_SLICING
233
   subc_ctl SCH_C (
234
                   .nack     ( pdan[0]  ),
235
                   .rt_rst   ( rtrst    ),
236
                   .ai2cb    ( oa       ),
237
                   .ack      ( pda[1]   ),
238
                   .eof      ( pd4[0]   ),
239
                   .rt_ra    ( rt_ack   ),
240
                   .rt_err   ( rt_err   ),
241
                   .rst_n    ( rst_n    )
242
                   );
243 62 wsong0210
   assign pd4an[0] = pdan[0];
244 16 wsong0210
`endif // !`ifdef ENABLE_CHANNEL_SLICING
245
 
246
   // the router controller part
247
   assign rten = ~rt_ack;
248
   assign frame_end = &rtrst;
249
 
250
endmodule // inp_buf
251
 
252
 
253
// the routing decision making procedure, comparitors
254
module routing_decision (
255
                         addrx
256
                         ,addry
257
                         ,pipe_xd
258
                         ,pipe_yd
259
                         ,decision
260
                         );
261
 
262
   // compare with (2,3)
263
   input [7:0] addrx;
264
   input [7:0] addry;
265
 
266
   input   [7:0]   pipe_xd;
267
   input [7:0]      pipe_yd;
268
   output [5:0]    decision;
269
 
270
   wire [2:0]       x_cmp [1:0];
271
   wire [2:0]       y_cmp [1:0];
272
 
273 47 wsong0210
   comp4 X0 ( .a(pipe_xd[3:0]), .b(addrx[3:0]), .q(x_cmp[0]));
274
   comp4 X1 ( .a(pipe_xd[7:4]), .b(addrx[7:4]), .q(x_cmp[1]));
275
   comp4 Y0 ( .a(pipe_yd[3:0]), .b(addry[3:0]), .q(y_cmp[0]));
276
   comp4 Y1 ( .a(pipe_yd[7:4]), .b(addry[7:4]), .q(y_cmp[1]));
277 16 wsong0210
 
278
   assign decision[0] = x_cmp[1][0] | (x_cmp[1][2]&x_cmp[0][0]);       // frame x > addr x
279
   assign decision[1] = x_cmp[1][1] | (x_cmp[1][2]&x_cmp[0][1]);       // frame x < addr x
280
   assign decision[2] = x_cmp[1][2] & x_cmp[0][2];                     // frame x = addr x
281
   assign decision[3] = y_cmp[1][0] | (y_cmp[1][2]&y_cmp[0][0]);       // frame y > addr y
282
   assign decision[4] = y_cmp[1][1] | (y_cmp[1][2]&y_cmp[0][1]);       // frame y < addr y
283
   assign decision[5] = y_cmp[1][2] & y_cmp[0][2];                     // frame y = addr y
284
 
285
endmodule // routing_decision

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.