aboutsummaryrefslogtreecommitdiff
path: root/tests/slave_dispatcher/test.v
blob: ad85b1ff1bba5bdc2bca311ee91562d3836efb70 (about) (plain)
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
`default_nettype none

`include "messages.vh"

`ifndef MASTER_OPERATIONS_COUNT
 `error_MASTER_OPERATIONS_COUNT_must_be_defined
; /* Cause syntax error */
`endif

`ifndef SIMULATION
 `error_SIMULATION_not_defined
; /* Cause syntax error */
`endif

module slave_dispatcher_test();
   reg 	       CLK;
   reg 	       RST;

   wire        M_ACK_I;
   wire [19:0] M_ADR_O;
   wire [15:0] M_DAT_I;
   wire [15:0] M_DAT_O;
   wire        M_SEL_O; /* Ignored, assumed always high */
   wire        M_STB_O;
   wire        M_CYC_O;
   wire        M_WE_O;
   wire        M_STALL_I;

   wire        S0_ACK_O,   S1_ACK_O,   S2_ACK_O,
	       S3_ACK_O,   S4_ACK_O,   S5_ACK_O;
   wire        S0_CLK_I,   S1_CLK_I,   S2_CLK_I,
	       S3_CLK_I,   S4_CLK_I,   S5_CLK_I;
   wire [17:0] S0_ADR_I,   S1_ADR_I;
   wire [16:0] S2_ADR_I,   S3_ADR_I,   S4_ADR_I,   S5_ADR_I;
   wire [15:0] S0_DAT_I,   S1_DAT_I,   S2_DAT_I,
	       S3_DAT_I,   S4_DAT_I,   S5_DAT_I;
   wire [15:0] S0_DAT_O,   S1_DAT_O,   S2_DAT_O,
	       S3_DAT_O,   S4_DAT_O,   S5_DAT_O;
   wire        S0_SEL_I,   S1_SEL_I,   S2_SEL_I,
	       S3_SEL_I,   S4_SEL_I,   S5_SEL_I; /* Always high */
   wire        S0_RST_I,   S1_RST_I,   S2_RST_I,
	       S3_RST_I,   S4_RST_I,   S5_RST_I;
   wire        S0_STB_I,   S1_STB_I,   S2_STB_I,
	       S3_STB_I,   S4_STB_I,   S5_STB_I;
   wire        S0_WE_I,    S1_WE_I,    S2_WE_I,
	       S3_WE_I,    S4_WE_I,    S5_WE_I;
   wire        S0_STALL_O, S1_STALL_O, S2_STALL_O,
	       S3_STALL_O, S4_STALL_O, S5_STALL_O;

   wire        S_COMBINED_ACK_O;
   wire [19:0] S_COMBINED_ADR_I;
   wire [15:0] S_COMBINED_DAT_I;
   wire [15:0] S_COMBINED_DAT_O;
   wire        S_COMBINED_STB_I;
   wire        S_COMBINED_WE_I;
   wire        S_COMBINED_STALL_O;

   /* Non-wishbone */
   wire        M_finished;

   master_model
     #(.MASTER_NR(0),
       .OPERATIONS_FILE("operations.mem"),
       .OPERATIONS_COUNT(`MASTER_OPERATIONS_COUNT)
       ) master
       (
	.ACK_I(M_ACK_I),
 	.CLK_I(CLK),
	.ADR_O(M_ADR_O),
	.DAT_I(M_DAT_I),
	.DAT_O(M_DAT_O),
	.SEL_O(M_SEL_O),
 	.RST_I(RST),
	.STB_O(M_STB_O),
	.CYC_O(M_CYC_O),
	.WE_O(M_WE_O),
 	.STALL_I(M_STALL_I),

	.finished(M_finished)
	);

   memory_slave_model
     #(
       .SLAVE_NR(0)
       ) slave0
       (
	.ACK_O(S0_ACK_O),
      	.CLK_I(CLK),
	.ADR_I(S0_ADR_I),
	.DAT_I(S0_DAT_I),
	.DAT_O(S0_DAT_O),
	.SEL_I(S0_SEL_I),
      	.RST_I(RST),
      	.STB_I(S0_STB_I),
      	.WE_I(S0_WE_I),
	.STALL_O(S0_STALL_O)
	);

   memory_slave_model
     #(
       .SLAVE_NR(1)
       ) slave1
       (
	.ACK_O(S1_ACK_O),
      	.CLK_I(CLK),
	.ADR_I(S1_ADR_I),
	.DAT_I(S1_DAT_I),
	.DAT_O(S1_DAT_O),
	.SEL_I(S1_SEL_I),
      	.RST_I(RST),
      	.STB_I(S1_STB_I),
      	.WE_I(S1_WE_I),
	.STALL_O(S1_STALL_O)
	);

   memory_slave_model
     #(
       .SLAVE_NR(2),
       .ADR_BITS(17)
       ) slave2
       (
	.ACK_O(S2_ACK_O),
      	.CLK_I(CLK),
	.ADR_I(S2_ADR_I),
	.DAT_I(S2_DAT_I),
	.DAT_O(S2_DAT_O),
	.SEL_I(S2_SEL_I),
      	.RST_I(RST),
      	.STB_I(S2_STB_I),
      	.WE_I(S2_WE_I),
	.STALL_O(S2_STALL_O)
	);

   memory_slave_model
     #(
       .SLAVE_NR(3),
       .ADR_BITS(17)
       ) slave3
       (
	.ACK_O(S3_ACK_O),
      	.CLK_I(CLK),
	.ADR_I(S3_ADR_I),
	.DAT_I(S3_DAT_I),
	.DAT_O(S3_DAT_O),
	.SEL_I(S3_SEL_I),
      	.RST_I(RST),
      	.STB_I(S3_STB_I),
      	.WE_I(S3_WE_I),
	.STALL_O(S3_STALL_O)
	);

   memory_slave_model
     #(
       .SLAVE_NR(4),
       .ADR_BITS(17)
       ) slave4
       (
	.ACK_O(S4_ACK_O),
      	.CLK_I(CLK),
	.ADR_I(S4_ADR_I),
	.DAT_I(S4_DAT_I),
	.DAT_O(S4_DAT_O),
	.SEL_I(S4_SEL_I),
      	.RST_I(RST),
      	.STB_I(S4_STB_I),
      	.WE_I(S4_WE_I),
	.STALL_O(S4_STALL_O)
	);

   memory_slave_model
     #(
       .SLAVE_NR(3),
       .ADR_BITS(17)
       ) slave5
       (
	.ACK_O(S5_ACK_O),
      	.CLK_I(CLK),
	.ADR_I(S5_ADR_I),
	.DAT_I(S5_DAT_I),
	.DAT_O(S5_DAT_O),
	.SEL_I(S5_SEL_I),
      	.RST_I(RST),
      	.STB_I(S5_STB_I),
      	.WE_I(S5_WE_I),
	.STALL_O(S5_STALL_O)
	);

   slave_dispatcher dispatcher
     (
      .CLK(CLK),
      .RST(RST),

      .S0_ACK_O(S0_ACK_O),
      .S0_ADR_I(S0_ADR_I),
      .S0_DAT_I(S0_DAT_I),
      .S0_DAT_O(S0_DAT_O),
      .S0_STB_I(S0_STB_I),
      .S0_WE_I(S0_WE_I),
      .S0_STALL_O(S0_STALL_O),

      .S1_ACK_O(S1_ACK_O),
      .S1_ADR_I(S1_ADR_I),
      .S1_DAT_I(S1_DAT_I),
      .S1_DAT_O(S1_DAT_O),
      .S1_STB_I(S1_STB_I),
      .S1_WE_I(S1_WE_I),
      .S1_STALL_O(S1_STALL_O),

      .S2_ACK_O(S2_ACK_O),
      .S2_ADR_I(S2_ADR_I),
      .S2_DAT_I(S2_DAT_I),
      .S2_DAT_O(S2_DAT_O),
      .S2_STB_I(S2_STB_I),
      .S2_WE_I(S2_WE_I),
      .S2_STALL_O(S2_STALL_O),

      .S3_ACK_O(S3_ACK_O),
      .S3_ADR_I(S3_ADR_I),
      .S3_DAT_I(S3_DAT_I),
      .S3_DAT_O(S3_DAT_O),
      .S3_STB_I(S3_STB_I),
      .S3_WE_I(S3_WE_I),
      .S3_STALL_O(S3_STALL_O),

      .S4_ACK_O(S4_ACK_O),
      .S4_ADR_I(S4_ADR_I),
      .S4_DAT_I(S4_DAT_I),
      .S4_DAT_O(S4_DAT_O),
      .S4_STB_I(S4_STB_I),
      .S4_WE_I(S4_WE_I),
      .S4_STALL_O(S4_STALL_O),

      .S5_ACK_O(S5_ACK_O),
      .S5_ADR_I(S5_ADR_I),
      .S5_DAT_I(S5_DAT_I),
      .S5_DAT_O(S5_DAT_O),
      .S5_STB_I(S5_STB_I),
      .S5_WE_I(S5_WE_I),
      .S5_STALL_O(S5_STALL_O),

      .S_COMBINED_ACK_O(S_COMBINED_ACK_O),
      .S_COMBINED_ADR_I(S_COMBINED_ADR_I),
      .S_COMBINED_DAT_I(S_COMBINED_DAT_I),
      .S_COMBINED_DAT_O(S_COMBINED_DAT_O),
      .S_COMBINED_STB_I(S_COMBINED_STB_I),
      .S_COMBINED_WE_I(S_COMBINED_WE_I),
      .S_COMBINED_STALL_O(S_COMBINED_STALL_O)
      );

   assign M_ACK_I = S_COMBINED_ACK_O;
   assign M_DAT_I = S_COMBINED_DAT_O;
   assign M_STALL_I = S_COMBINED_STALL_O;

   assign S_COMBINED_ADR_I = M_ADR_O;
   assign S_COMBINED_DAT_I = M_DAT_O;
   assign S_COMBINED_STB_I = M_STB_O && M_CYC_O;
   assign S_COMBINED_WE_I = M_WE_O;

   assign S0_SEL_I = 1;
   assign S1_SEL_I = 1;
   assign S2_SEL_I = 1;
   assign S3_SEL_I = 1;
   assign S4_SEL_I = 1;
   assign S5_SEL_I = 1;

   integer     i;

   initial begin
      CLK <= 0;
      RST <= 1;

      for (i = 0; i < 500; i++) begin
	 #1;

	 CLK <= ~CLK;

	 if (CLK)
	   RST <= 0;

	 if (M_finished)
	   $finish;
      end

      $display("error: master hasn't finished its opertaions in 300 ticks");
      $finish;
   end
endmodule // slave_dispatcher_test