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

Subversion Repositories instruction_list_pipelined_processor_with_peripherals

[/] [instruction_list_pipelined_processor_with_peripherals/] [trunk/] [hdl/] [controlUnit.v] - Blame information for rev 9

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

Line No. Rev Author Line
1 3 maheshpalv
 
2
`include "timescale.v"
3
`include "defines.v"
4
 
5
 
6 5 maheshpalv
module controlUnit (clk, reset, instOpCode, acc0, iomemCode,
7 3 maheshpalv
                                                        branch,
8 6 maheshpalv
                                                        accMuxSel, accEn, op2MuxSel, aluEn, aluOpcode,
9 3 maheshpalv
                                                        bitRamEn, bitRamRw, byteRamEn, byteRamRw,
10
                                                        inputRead, outputRw
11
 
12
                                                        `ifdef timerAndCounter_peripheral
13
                                                                , entypeEn, tcAccRead, tcResetEn, tcPresetEn, tcLoadEn
14
                                                        `endif
15
 
16
                                                        `ifdef UART_peripheral
17
                                                                , uartRead, uartWrite
18
                                                        `endif
19
 
20
                                                        `ifdef SPI_peripheral
21
                                                                , sconEn, spiStatRead, spiBufRead, spiBufWrite, spiBufShift
22
                                                        `endif
23
 
24
                                                        );
25
 
26
 
27
        input clk, reset;
28
        input [`instOpCodeLen-1:0] instOpCode;
29
        input acc0;
30
        input [1:0] iomemCode;
31
 
32
        output branch;
33
        output [`accMuxSelLen-1:0]       accMuxSel;
34
        output accEn;
35
        output [`op2MuxSelLen-1:0]       op2MuxSel;
36 6 maheshpalv
        output aluEn;
37 3 maheshpalv
        output [`aluOpcodeLen-1:0] aluOpcode;
38
        output bitRamEn, bitRamRw, byteRamEn, byteRamRw;
39
        output inputRead, outputRw;
40
 
41
        `ifdef timerAndCounter_peripheral
42
        output entypeEn, tcAccRead, tcResetEn, tcPresetEn, tcLoadEn;
43 5 maheshpalv
        `endif
44 3 maheshpalv
 
45
        `ifdef UART_peripheral
46
        output uartRead, uartWrite;
47
        `endif
48
 
49
        `ifdef SPI_peripheral
50
        output sconEn, spiStatRead, spiBufRead, spiBufWrite, spiBufShift;
51
        `endif
52 5 maheshpalv
 
53
        reg branch;
54
        reg [`accMuxSelLen-1:0]  accMuxSel;
55
        reg accEn;
56
        reg [`op2MuxSelLen-1:0]  op2MuxSel;
57 6 maheshpalv
        reg aluEn;
58 5 maheshpalv
        reg [`aluOpcodeLen-1:0] aluOpcode;
59
        reg bitRamEn, bitRamRw, byteRamEn, byteRamRw;
60
        reg inputRead, outputRw;
61
 
62
        `ifdef timerAndCounter_peripheral
63
        reg entypeEn, tcAccRead, tcResetEn, tcPresetEn, tcLoadEn;
64
        `endif
65
 
66
        `ifdef UART_peripheral
67
        reg uartRead, uartWrite;
68
        `endif
69 3 maheshpalv
 
70 5 maheshpalv
        `ifdef SPI_peripheral
71
        reg sconEn, spiStatRead, spiBufRead, spiBufWrite, spiBufShift;
72
        `endif
73
 
74
        reg [`cuStateLen-1:0] state;
75
 
76
        // control unit FSM states:
77
 
78
        parameter       s               = `cuStateLen'b0;
79
        parameter       sTc     = `cuStateLen'b1;
80
        parameter       sBr     = `cuStateLen'b10;
81
        parameter       sLd     = `cuStateLen'b11;
82
        parameter       sSt     = `cuStateLen'b100;
83
        parameter       sUart   = `cuStateLen'b101;
84
        parameter       sSpi    = `cuStateLen'b110;
85
        parameter       sAlu    = `cuStateLen'b111;
86
 
87
 
88
 
89
 
90
        always @ (negedge clk)
91
        begin
92
 
93
 
94
                if (reset)
95
                begin
96
                        state = s;
97
 
98 6 maheshpalv
                        branch = 0;      accMuxSel = 0;   accEn = 0;       op2MuxSel = 0;   aluEn = 0; aluOpcode = 0; bitRamEn = 0;
99 5 maheshpalv
                        bitRamRw = 1;   byteRamEn = 0;   byteRamRw = 1;  inputRead = 0;   outputRw = 1;
100
 
101
                        `ifdef timeAndCounter_peripheral
102
                                entypeEn = 0;    tcAccRead = 0;   tcResetEn = 0;           tcPresetEn = 0;  tcLoadEn = 0;
103
                        `endif
104
 
105
                        `ifdef UART_peripheral
106
                                uartRead = 0;    uartWrite = 0;
107
                        `endif
108
 
109
                        `ifdef SPI_peripheral
110
                                sconEn = 0;              spiStatRead = 0; spiBufRead = 0;  spiBufWrite = 0; spiBufShift = 0;
111
                        `endif
112
                end
113
 
114
                else
115
                begin
116
 
117
                        // execution unit control signals
118
 
119
                        case (state)
120
 
121
                        s               :               begin
122
 
123 3 maheshpalv
 
124 5 maheshpalv
                                case (instOpCode)
125
 
126
                                `END                    :       begin
127
 
128
                                                state = sBr;
129
 
130
                                                branch = 1;                     // branch to some address . . .
131
                                                accMuxSel = 0;
132
                                                accEn = 0;
133
                                                op2MuxSel = 0;
134 6 maheshpalv
                                                aluEn = 0;
135 5 maheshpalv
                                                aluOpcode = 0;
136
                                                bitRamEn = 0;
137
                                                bitRamRw = 1;
138
                                                byteRamEn = 0;
139
                                                byteRamRw = 1;
140
                                                inputRead = 0;
141
                                                outputRw = 1;
142
 
143
                                                `ifdef timeAndCounter_peripheral
144
                                                        entypeEn = 0;            tcAccRead = 0;   tcResetEn = 0;           tcPresetEn = 0;  tcLoadEn = 0;
145
                                                `endif
146
 
147
                                                `ifdef UART_peripheral
148
                                                        uartRead = 0;            uartWrite = 0;
149
                                                `endif
150
 
151
                                                `ifdef SPI_peripheral
152
                                                        sconEn = 0;              spiStatRead = 0; spiBufRead = 0;  spiBufWrite = 0;
153
                                                        spiBufShift = 0;
154
                                                `endif
155
 
156
                                end     // end case END
157 3 maheshpalv
 
158
 
159 5 maheshpalv
 
160
                                `JMP                    :       begin
161
 
162
                                                state = sBr;
163
 
164 6 maheshpalv
                                                if (acc0)
165
                                                        branch = 1;                     // branch to some address . . .
166
                                                else
167
                                                        branch = 0;
168 5 maheshpalv
                                                accMuxSel = 0;
169
                                                accEn = 0;
170
                                                op2MuxSel = 0;
171 6 maheshpalv
                                                aluEn = 0;
172 5 maheshpalv
                                                aluOpcode = 0;
173
                                                bitRamEn = 0;
174
                                                bitRamRw = 1;
175
                                                byteRamEn = 0;
176
                                                byteRamRw = 1;
177
                                                inputRead = 0;
178
                                                outputRw = 1;
179
 
180
                                                `ifdef timeAndCounter_peripheral
181
                                                        entypeEn = 0;            tcAccRead = 0;   tcResetEn = 0;           tcPresetEn = 0;  tcLoadEn = 0;
182
                                                `endif
183
 
184
                                                `ifdef UART_peripheral
185
                                                        uartRead = 0;            uartWrite = 0;
186
                                                `endif
187
 
188
                                                `ifdef SPI_peripheral
189
                                                        sconEn = 0;              spiStatRead = 0; spiBufRead = 0;  spiBufWrite = 0; spiBufShift = 0;
190
                                                `endif
191
 
192
                                end     // end case JMP
193
 
194
 
195
 
196
                                `Ld                     :       begin
197
                                // load thr. op2 MUX and alu.... enable acc in next cycle
198 9 maheshpalv
                                                state = sAlu;
199 5 maheshpalv
 
200
                                                branch = 0;
201 9 maheshpalv
//                                              accMuxSel = `accMuxSelAluOut;
202 5 maheshpalv
                                                accMuxSel = 0;
203
                                                accEn = 0;
204
 
205
                                                        case (iomemCode)
206
                                                        2'b00   :       op2MuxSel = `op2MuxSelInput;
207
                                                        2'b01   :       op2MuxSel = `op2MuxSelOutput;
208
                                                        2'b10   :       op2MuxSel = `op2MuxSelBitRam;
209
                                                        2'b11   :       op2MuxSel = `op2MuxSelByteRam;
210
                                                        default:        op2MuxSel = `op2MuxSelInput;
211
                                                        endcase
212 7 maheshpalv
                                                        aluEn = 1'b1;
213 5 maheshpalv
                                                        aluOpcode = `LD_data;
214
 
215 7 maheshpalv
                                                bitRamEn = 1'b1;
216
                                                bitRamRw = 1'b1;
217
                                                byteRamEn = 1'b1;
218
                                                byteRamRw = 1'b1;
219
                                                inputRead = 1'b1;
220
                                                outputRw = 1'b1;
221 5 maheshpalv
 
222
                                                `ifdef timeAndCounter_peripheral
223 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
224 5 maheshpalv
                                                `endif
225
 
226
                                                `ifdef UART_peripheral
227 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
228 5 maheshpalv
                                                `endif
229
 
230
                                                `ifdef SPI_peripheral
231 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
232 5 maheshpalv
                                                `endif
233
 
234
                                end     // end case Ld
235
 
236
 
237
 
238
 
239
                                `Ldi                    :       begin
240 9 maheshpalv
                                                state = sLd;
241 5 maheshpalv
 
242 7 maheshpalv
                                                branch = 1'b0;
243 5 maheshpalv
                                                        accMuxSel = `accMuxSelImmData;  // select imm data thr mux
244 7 maheshpalv
                                                        accEn = 1'b1;           // acc enabled
245
                                                op2MuxSel = 1'b0;
246
                                                aluOpcode = 1'b0;
247
                                                aluEn = 1'b0;
248
                                                bitRamEn = 1'b0;
249
                                                bitRamRw = 1'b1;
250
                                                byteRamEn = 1'b0;
251
                                                byteRamRw = 1'b1;
252
                                                inputRead = 1'b0;
253
                                                outputRw = 1'b1;
254 5 maheshpalv
 
255
                                                `ifdef timeAndCounter_peripheral
256 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
257 5 maheshpalv
                                                `endif
258
 
259
                                                `ifdef UART_peripheral
260 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
261 5 maheshpalv
                                                `endif
262
 
263
                                                `ifdef SPI_peripheral
264 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
265 5 maheshpalv
                                                `endif
266
 
267
                                end             // end case Ldi
268
 
269
 
270
 
271
                                `ST                     :       begin
272
                                                state = sSt;
273
 
274 7 maheshpalv
                                                branch = 1'b0;
275
                                                accMuxSel = 1'b0;
276
                                                accEn = 1'b0;
277
                                                op2MuxSel = 1'b0;
278
                                                aluEn = 1'b0;
279
                                                aluOpcode = 1'b0;
280
                                                inputRead = 1'b0;
281 5 maheshpalv
 
282
                                                        case (iomemCode)
283 9 maheshpalv
                                                        2'b10   :       begin   bitRamRw = 1'b0;        byteRamRw = 1'b1;       outputRw = 1'b1; bitRamEn = 1'b1;       byteRamEn = 1'b1;       end
284
                                                        2'b11   :       begin   bitRamRw = 1'b1;        byteRamRw = 1'b0;       outputRw = 1'b1; bitRamEn = 1'b1;       byteRamEn = 1'b1;       end
285
                                                        2'b01   :       begin   bitRamRw = 1'b1;        byteRamRw = 1'b1;       outputRw = 1'b0; end
286 7 maheshpalv
                                                        default:        begin   bitRamRw = 1'b1;        byteRamRw = 1'b1;       outputRw = 1'b1;        end
287 5 maheshpalv
                                                        endcase
288
 
289
                                                `ifdef timeAndCounter_peripheral
290 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
291 5 maheshpalv
                                                `endif
292
 
293
                                                `ifdef UART_peripheral
294 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
295 5 maheshpalv
                                                `endif
296
 
297
                                                `ifdef SPI_peripheral
298 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
299 5 maheshpalv
                                                `endif
300
 
301
                                end
302
 
303
 
304
 
305
                                `ADD                    :       begin
306
                                                state = sAlu;
307
                                                aluOpcode = `ADD_alu;
308 7 maheshpalv
                                                aluEn = 1'b1;
309
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
310
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
311 5 maheshpalv
 
312
                                                `ifdef timeAndCounter_peripheral
313 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
314 5 maheshpalv
                                                `endif
315
 
316
                                                `ifdef UART_peripheral
317 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
318 5 maheshpalv
                                                `endif
319
 
320
                                                `ifdef SPI_peripheral
321 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
322 5 maheshpalv
                                                `endif
323
 
324
                                end
325
 
326
 
327
                                `SUB                    :       begin
328
                                                state = sAlu;
329
                                                aluOpcode = `SUB_alu;
330 7 maheshpalv
                                                aluEn = 1'b1;
331
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
332
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
333 5 maheshpalv
 
334
                                                `ifdef timeAndCounter_peripheral
335 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
336 5 maheshpalv
                                                `endif
337
 
338
                                                `ifdef UART_peripheral
339 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
340 5 maheshpalv
                                                `endif
341
 
342
                                                `ifdef SPI_peripheral
343 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
344 5 maheshpalv
                                                `endif
345
 
346
                                end
347
 
348
                                // MUL & DIV are not implemented
349
 
350
 
351
 
352
                                `AND                    :       begin
353
                                                state = sAlu;
354
                                                aluOpcode = `AND_alu;
355 7 maheshpalv
                                                aluEn = 1'b1;
356
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
357
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
358 5 maheshpalv
 
359
                                                `ifdef timeAndCounter_peripheral
360 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
361 5 maheshpalv
                                                `endif
362
 
363
                                                `ifdef UART_peripheral
364 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
365 5 maheshpalv
                                                `endif
366
 
367
                                                `ifdef SPI_peripheral
368 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
369 5 maheshpalv
                                                `endif
370
 
371
                                end
372
 
373
 
374
 
375
                                `OR                     :       begin
376
                                                state = sAlu;
377
                                                aluOpcode = `OR_alu;
378 7 maheshpalv
                                                aluEn = 1'b1;
379
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
380
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
381 5 maheshpalv
 
382
                                                `ifdef timeAndCounter_peripheral
383 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
384 5 maheshpalv
                                                `endif
385
 
386
                                                `ifdef UART_peripheral
387 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
388 5 maheshpalv
                                                `endif
389
 
390
                                                `ifdef SPI_peripheral
391 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
392 5 maheshpalv
                                                `endif
393
 
394
                                end
395
 
396
 
397
 
398
                                `XOR                    :       begin
399
                                                state = sAlu;
400
                                                aluOpcode = `XOR_alu;
401 7 maheshpalv
                                                aluEn = 1'b1;
402
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
403
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
404 5 maheshpalv
 
405
                                                `ifdef timeAndCounter_peripheral
406 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
407 5 maheshpalv
                                                `endif
408
 
409
                                                `ifdef UART_peripheral
410 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
411 5 maheshpalv
                                                `endif
412
 
413
                                                `ifdef SPI_peripheral
414 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
415 5 maheshpalv
                                                `endif
416
 
417
                                end
418
 
419
 
420
 
421
                                `GrT                    :       begin
422
                                                state = sAlu;
423
                                                aluOpcode = `GT_alu;
424 7 maheshpalv
                                                aluEn = 1'b1;
425
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
426
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
427 5 maheshpalv
 
428
                                                `ifdef timeAndCounter_peripheral
429 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
430 5 maheshpalv
                                                `endif
431
 
432
                                                `ifdef UART_peripheral
433 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
434 5 maheshpalv
                                                `endif
435
 
436
                                                `ifdef SPI_peripheral
437 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
438 5 maheshpalv
                                                `endif
439
 
440
                                end
441
 
442
 
443
 
444
 
445
 
446
                                `GE                     :       begin
447
                                                state = sAlu;
448
                                                aluOpcode = `GE_alu;
449 7 maheshpalv
                                                aluEn = 1'b1;
450
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
451
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
452 5 maheshpalv
 
453
                                                `ifdef timeAndCounter_peripheral
454 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
455 5 maheshpalv
                                                `endif
456
 
457
                                                `ifdef UART_peripheral
458 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
459 5 maheshpalv
                                                `endif
460
 
461
                                                `ifdef SPI_peripheral
462 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
463 5 maheshpalv
                                                `endif
464
 
465
                                end
466
 
467
 
468
 
469
 
470
 
471
                                `EQ                     :       begin
472
                                                state = sAlu;
473
                                                aluOpcode = `EQ_alu;
474 7 maheshpalv
                                                aluEn = 1'b1;
475
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
476
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
477 5 maheshpalv
 
478
                                                `ifdef timeAndCounter_peripheral
479 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
480 5 maheshpalv
                                                `endif
481
 
482
                                                `ifdef UART_peripheral
483 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
484 5 maheshpalv
                                                `endif
485
 
486
                                                `ifdef SPI_peripheral
487 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
488 5 maheshpalv
                                                `endif
489
 
490
                                end
491
 
492
 
493
 
494
 
495
 
496
                                `LE                     :       begin
497
                                                state = sAlu;
498
                                                aluOpcode = `LE_alu;
499 7 maheshpalv
                                                aluEn = 1'b1;
500
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
501
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
502 5 maheshpalv
 
503
                                                `ifdef timeAndCounter_peripheral
504 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
505 5 maheshpalv
                                                `endif
506
 
507
                                                `ifdef UART_peripheral
508 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
509 5 maheshpalv
                                                `endif
510
 
511
                                                `ifdef SPI_peripheral
512 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
513 5 maheshpalv
                                                `endif
514
 
515
                                end
516
 
517
 
518
 
519
 
520
 
521
                                `LT                     :       begin
522
                                                state = sAlu;
523
                                                aluOpcode = `LT_alu;
524 7 maheshpalv
                                                aluEn = 1'b1;
525
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
526
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
527 5 maheshpalv
 
528
                                                `ifdef timeAndCounter_peripheral
529 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
530 5 maheshpalv
                                                `endif
531
 
532
                                                `ifdef UART_peripheral
533 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
534 5 maheshpalv
                                                `endif
535
 
536
                                                `ifdef SPI_peripheral
537 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
538 5 maheshpalv
                                                `endif
539
 
540
                                end
541
 
542
 
543
                                `ifdef timeAndCounter_peripheral
544
                                `PRE                    :       begin
545
                                                state = sTc;
546
 
547 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b1;      tcLoadEn = 1'b0;
548 5 maheshpalv
 
549
 
550 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
551
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
552 5 maheshpalv
 
553
 
554
                                                `ifdef UART_peripheral
555 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
556 5 maheshpalv
                                                `endif
557
 
558
                                                `ifdef SPI_peripheral
559 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
560 5 maheshpalv
                                                `endif
561
                                end
562
                                `endif
563
 
564
 
565
                                `ifdef timeAndCounter_peripheral
566
                                `ETY                    :       begin
567
                                                state = sTc;
568
 
569 7 maheshpalv
                                                entypeEn = 1'b1;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
570 5 maheshpalv
 
571
 
572 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
573
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
574 5 maheshpalv
 
575
 
576
                                                `ifdef UART_peripheral
577 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
578 5 maheshpalv
                                                `endif
579
 
580
                                                `ifdef SPI_peripheral
581 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
582 5 maheshpalv
                                                `endif
583
                                end
584
                                `endif
585
 
586
 
587
 
588
                                `ifdef timeAndCounter_peripheral
589
                                `RST                    :       begin
590
                                                state = sTc;
591
 
592 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b1;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
593 5 maheshpalv
 
594
 
595 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
596
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
597 5 maheshpalv
 
598
 
599
                                                `ifdef UART_peripheral
600 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
601 5 maheshpalv
                                                `endif
602
 
603
                                                `ifdef SPI_peripheral
604 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
605 5 maheshpalv
                                                `endif
606
                                end
607
                                `endif
608
 
609
 
610
 
611
                                `ifdef timeAndCounter_peripheral
612
                                `LdTC                   :       begin
613
                                                state = sTc;
614
 
615 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b1;
616 5 maheshpalv
 
617 7 maheshpalv
                                                accMuxSel = `accMuxSelTcLoad;           accEn = 1'b1;   // loading TC status data
618 5 maheshpalv
 
619 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;                  op2MuxSel = 1'b0;
620
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
621 5 maheshpalv
 
622
 
623
                                                `ifdef UART_peripheral
624 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
625 5 maheshpalv
                                                `endif
626
 
627
                                                `ifdef SPI_peripheral
628 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
629 5 maheshpalv
                                                `endif
630
                                end
631
                                `endif
632
 
633
 
634
 
635
                                `ifdef timeAndCounter_peripheral
636
                                `LdACC                  :       begin
637
                                                state = sTc;
638
 
639 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b1;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
640 5 maheshpalv
 
641 7 maheshpalv
                                                accMuxSel = `accMuxSelTcAcc;            accEn = 1'b1;   // loading TC ACC data
642 5 maheshpalv
 
643 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          op2MuxSel = 1'b0;
644
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
645 5 maheshpalv
 
646
 
647
                                                `ifdef UART_peripheral
648 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
649 5 maheshpalv
                                                `endif
650
 
651
                                                `ifdef SPI_peripheral
652 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
653 5 maheshpalv
                                                `endif
654
                                end
655
                                `endif
656
 
657
 
658
 
659
 
660
                                `ifdef UART_peripheral
661
                                `UARTrd                 :       begin
662
                                                state = sUart;
663
 
664 7 maheshpalv
                                                uartRead = 1'b1;                uartWrite = 1'b0;
665 5 maheshpalv
 
666 7 maheshpalv
                                                accMuxSel = `accMuxSelUartData;         accEn = 1'b1;   // loading UART data
667 5 maheshpalv
 
668 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          op2MuxSel = 1'b0;
669
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
670 5 maheshpalv
 
671
                                                `ifdef timerAndCounter_peripheral
672 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
673 5 maheshpalv
                                                `endif
674
 
675
 
676
                                                `ifdef SPI_peripheral
677 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
678 5 maheshpalv
                                                `endif
679
                                end
680
                                `endif
681
 
682
 
683
 
684 7 maheshpalv
                                `ifdef UART_peripheral
685
                                `UARTstat                       :       begin
686
                                                state = sUart;
687
 
688
                                                uartRead = 1'b0;                uartWrite = 1'b0;
689
 
690
                                                accMuxSel = `accMuxSelUartStat;         accEn = 1'b1;   // loading UART status
691
 
692
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          op2MuxSel = 1'b0;
693
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
694
 
695
                                                `ifdef timerAndCounter_peripheral
696
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
697
                                                `endif
698
 
699
 
700
                                                `ifdef SPI_peripheral
701
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
702
                                                `endif
703
                                end
704
                                `endif
705 5 maheshpalv
 
706 7 maheshpalv
 
707
 
708
 
709 5 maheshpalv
                                `ifdef UART_peripheral
710
                                `UARTwr                 :       begin
711
                                                state = sUart;
712
 
713 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b1;
714 5 maheshpalv
 
715 7 maheshpalv
                                                aluEn = 1'b0;   aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
716
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
717 5 maheshpalv
 
718
                                                `ifdef timerAndCounter_peripheral
719 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
720 5 maheshpalv
                                                `endif
721
 
722
 
723
                                                `ifdef SPI_peripheral
724 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
725 5 maheshpalv
                                                `endif
726
                                end
727
                                `endif
728
 
729
 
730
 
731
 
732
                                `ifdef SPI_peripheral
733
                                `SPIxFER                        :       begin
734
                                                state = sSpi;
735
 
736 7 maheshpalv
                                                sconEn = 1'b1;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
737 5 maheshpalv
 
738
 
739 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
740
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
741 5 maheshpalv
 
742
                                                `ifdef timerAndCounter_peripheral
743 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
744 5 maheshpalv
                                                `endif
745
 
746
                                                `ifdef UART_peripheral
747 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
748 5 maheshpalv
                                                `endif
749
 
750
                                end
751
                                `endif
752
 
753
 
754
 
755
                                `ifdef SPI_peripheral
756
                                `SPIstat                        :       begin
757
                                                state = sSpi;
758
 
759 7 maheshpalv
                                                sconEn = 1'b0;          spiStatRead = 1'b1;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
760 5 maheshpalv
 
761
 
762 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
763
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
764 5 maheshpalv
 
765
                                                `ifdef timerAndCounter_peripheral
766 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
767 5 maheshpalv
                                                `endif
768
 
769
                                                `ifdef UART_peripheral
770 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
771 5 maheshpalv
                                                `endif
772
 
773
                                end
774
                                `endif
775
 
776
 
777
 
778
                                `ifdef SPI_peripheral
779
                                `SPIwBUF                        :       begin
780
                                                state = sSpi;
781
 
782 7 maheshpalv
                                                sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b1;     spiBufShift = 1'b0;
783 5 maheshpalv
 
784
 
785 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
786
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
787 5 maheshpalv
 
788
                                                `ifdef timerAndCounter_peripheral
789 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
790 5 maheshpalv
                                                `endif
791
 
792
                                                `ifdef UART_peripheral
793 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
794 5 maheshpalv
                                                `endif
795
 
796
                                end
797
                                `endif
798
 
799
 
800
 
801
                                `ifdef SPI_peripheral
802
                                `SPIrBUF                        :       begin
803
                                                state = sSpi;
804
 
805 7 maheshpalv
                                                sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b1;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
806 5 maheshpalv
 
807
 
808 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
809
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
810 5 maheshpalv
 
811
                                                `ifdef timerAndCounter_peripheral
812 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
813 5 maheshpalv
                                                `endif
814
 
815
                                                `ifdef UART_peripheral
816 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
817 5 maheshpalv
                                                `endif
818
 
819
                                end
820
                                `endif
821
 
822
                                default         :       begin
823
 
824 9 maheshpalv
                                $write ("\n", $time, "ns unknown/unused instruction op-code encountered by control unit");
825 8 maheshpalv
//                              $stop;
826 5 maheshpalv
                                end
827
                                endcase // end  case (instOpCode)
828
 
829
 
830
 
831
                        end     // end case (s)
832
 
833
 
834
                        sBr             :       begin
835 7 maheshpalv
                                                        branch = 1'b0;
836 5 maheshpalv
                                                        state = s;
837
                                                        end             // end case sBr
838
 
839
 
840
                        sLd             :       begin
841 9 maheshpalv
                                                        accEn = 1'b0;
842 5 maheshpalv
                                                        state = s;
843
                                                        end             // end case sLd
844
 
845
                        sSt             :       begin
846 7 maheshpalv
                                                        bitRamRw = 1'b1;        byteRamRw = 1'b1; outputRw = 1'b1;
847 5 maheshpalv
                                                        state = s;
848
                                                        end
849
 
850
                        sAlu            :       begin
851 7 maheshpalv
                                                        aluEn = 1'b0;
852
                                                        accEn = 1'b1;
853 5 maheshpalv
                                                        accMuxSel = `accMuxSelAluOut;
854
                                                        state = s;
855
                                                        end
856
 
857
                        `ifdef timerAndCounter_peripheral
858
                        sTc             :       begin
859 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
860 5 maheshpalv
                                                        state = s;
861
                                                        end
862
                        `endif
863
 
864
                        `ifdef UART_peripheral
865
                        sUart           :       begin
866 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
867 5 maheshpalv
                                                        state = s;
868
                                                        end
869
                        `endif
870
 
871
                        `ifdef SPI_peripheral
872
                        sSpi            :       begin
873 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
874 5 maheshpalv
                                                        state = s;
875
                                                        end
876
                        `endif
877
 
878
                        default         :       begin
879
                        $write ("       control unit FSM in unknown state.      ");
880
                        end
881
                        endcase // end  case (state)
882
                end     // end else part (outermost)
883
 
884
 
885
 
886
        end     // end always
887
 
888
 
889 3 maheshpalv
endmodule

powered by: WebSVN 2.1.0

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