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 7

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
                                                state = sLd;
199
 
200
                                                branch = 0;
201
                                                accMuxSel = 0;
202
                                                accEn = 0;
203
 
204
                                                        case (iomemCode)
205
                                                        2'b00   :       op2MuxSel = `op2MuxSelInput;
206
                                                        2'b01   :       op2MuxSel = `op2MuxSelOutput;
207
                                                        2'b10   :       op2MuxSel = `op2MuxSelBitRam;
208
                                                        2'b11   :       op2MuxSel = `op2MuxSelByteRam;
209
                                                        default:        op2MuxSel = `op2MuxSelInput;
210
                                                        endcase
211 7 maheshpalv
                                                        aluEn = 1'b1;
212 5 maheshpalv
                                                        aluOpcode = `LD_data;
213
 
214 7 maheshpalv
                                                bitRamEn = 1'b1;
215
                                                bitRamRw = 1'b1;
216
                                                byteRamEn = 1'b1;
217
                                                byteRamRw = 1'b1;
218
                                                inputRead = 1'b1;
219
                                                outputRw = 1'b1;
220 5 maheshpalv
 
221
                                                `ifdef timeAndCounter_peripheral
222 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
223 5 maheshpalv
                                                `endif
224
 
225
                                                `ifdef UART_peripheral
226 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
227 5 maheshpalv
                                                `endif
228
 
229
                                                `ifdef SPI_peripheral
230 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
231 5 maheshpalv
                                                `endif
232
 
233
                                end     // end case Ld
234
 
235
 
236
 
237
 
238
                                `Ldi                    :       begin
239
                                                state = sAlu;
240
 
241 7 maheshpalv
                                                branch = 1'b0;
242 5 maheshpalv
                                                        accMuxSel = `accMuxSelImmData;  // select imm data thr mux
243 7 maheshpalv
                                                        accEn = 1'b1;           // acc enabled
244
                                                op2MuxSel = 1'b0;
245
                                                aluOpcode = 1'b0;
246
                                                aluEn = 1'b0;
247
                                                bitRamEn = 1'b0;
248
                                                bitRamRw = 1'b1;
249
                                                byteRamEn = 1'b0;
250
                                                byteRamRw = 1'b1;
251
                                                inputRead = 1'b0;
252
                                                outputRw = 1'b1;
253 5 maheshpalv
 
254
                                                `ifdef timeAndCounter_peripheral
255 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
256 5 maheshpalv
                                                `endif
257
 
258
                                                `ifdef UART_peripheral
259 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
260 5 maheshpalv
                                                `endif
261
 
262
                                                `ifdef SPI_peripheral
263 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
264 5 maheshpalv
                                                `endif
265
 
266
                                end             // end case Ldi
267
 
268
 
269
 
270
                                `ST                     :       begin
271
                                                state = sSt;
272
 
273 7 maheshpalv
                                                branch = 1'b0;
274
                                                accMuxSel = 1'b0;
275
                                                accEn = 1'b0;
276
                                                op2MuxSel = 1'b0;
277
                                                aluEn = 1'b0;
278
                                                aluOpcode = 1'b0;
279
                                                inputRead = 1'b0;
280 5 maheshpalv
 
281
                                                        case (iomemCode)
282 7 maheshpalv
                                                        2'b01   :       begin   bitRamRw = 1'b0;        byteRamRw = 1'b1;       outputRw = 1'b1; bitRamEn = 1'b1;       byteRamEn = 1'b1;       end
283
                                                        2'b10   :       begin   bitRamRw = 1'b1;        byteRamRw = 1'b0;       outputRw = 1'b1; bitRamEn = 1'b1;       byteRamEn = 1'b1;       end
284
                                                        2'b11   :       begin   bitRamRw = 1'b1;        byteRamRw = 1'b1;       outputRw = 1'b0; end
285
                                                        default:        begin   bitRamRw = 1'b1;        byteRamRw = 1'b1;       outputRw = 1'b1;        end
286 5 maheshpalv
                                                        endcase
287
 
288
                                                `ifdef timeAndCounter_peripheral
289 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
290 5 maheshpalv
                                                `endif
291
 
292
                                                `ifdef UART_peripheral
293 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
294 5 maheshpalv
                                                `endif
295
 
296
                                                `ifdef SPI_peripheral
297 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
298 5 maheshpalv
                                                `endif
299
 
300
                                end
301
 
302
 
303
 
304
                                `ADD                    :       begin
305
                                                state = sAlu;
306
                                                aluOpcode = `ADD_alu;
307 7 maheshpalv
                                                aluEn = 1'b1;
308
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
309
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
310 5 maheshpalv
 
311
                                                `ifdef timeAndCounter_peripheral
312 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
313 5 maheshpalv
                                                `endif
314
 
315
                                                `ifdef UART_peripheral
316 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
317 5 maheshpalv
                                                `endif
318
 
319
                                                `ifdef SPI_peripheral
320 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
321 5 maheshpalv
                                                `endif
322
 
323
                                end
324
 
325
 
326
                                `SUB                    :       begin
327
                                                state = sAlu;
328
                                                aluOpcode = `SUB_alu;
329 7 maheshpalv
                                                aluEn = 1'b1;
330
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
331
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
332 5 maheshpalv
 
333
                                                `ifdef timeAndCounter_peripheral
334 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
335 5 maheshpalv
                                                `endif
336
 
337
                                                `ifdef UART_peripheral
338 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
339 5 maheshpalv
                                                `endif
340
 
341
                                                `ifdef SPI_peripheral
342 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
343 5 maheshpalv
                                                `endif
344
 
345
                                end
346
 
347
                                // MUL & DIV are not implemented
348
 
349
 
350
 
351
                                `AND                    :       begin
352
                                                state = sAlu;
353
                                                aluOpcode = `AND_alu;
354 7 maheshpalv
                                                aluEn = 1'b1;
355
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
356
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
357 5 maheshpalv
 
358
                                                `ifdef timeAndCounter_peripheral
359 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
360 5 maheshpalv
                                                `endif
361
 
362
                                                `ifdef UART_peripheral
363 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
364 5 maheshpalv
                                                `endif
365
 
366
                                                `ifdef SPI_peripheral
367 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
368 5 maheshpalv
                                                `endif
369
 
370
                                end
371
 
372
 
373
 
374
                                `OR                     :       begin
375
                                                state = sAlu;
376
                                                aluOpcode = `OR_alu;
377 7 maheshpalv
                                                aluEn = 1'b1;
378
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
379
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
380 5 maheshpalv
 
381
                                                `ifdef timeAndCounter_peripheral
382 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
383 5 maheshpalv
                                                `endif
384
 
385
                                                `ifdef UART_peripheral
386 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
387 5 maheshpalv
                                                `endif
388
 
389
                                                `ifdef SPI_peripheral
390 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
391 5 maheshpalv
                                                `endif
392
 
393
                                end
394
 
395
 
396
 
397
                                `XOR                    :       begin
398
                                                state = sAlu;
399
                                                aluOpcode = `XOR_alu;
400 7 maheshpalv
                                                aluEn = 1'b1;
401
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
402
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
403 5 maheshpalv
 
404
                                                `ifdef timeAndCounter_peripheral
405 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
406 5 maheshpalv
                                                `endif
407
 
408
                                                `ifdef UART_peripheral
409 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
410 5 maheshpalv
                                                `endif
411
 
412
                                                `ifdef SPI_peripheral
413 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
414 5 maheshpalv
                                                `endif
415
 
416
                                end
417
 
418
 
419
 
420
                                `GrT                    :       begin
421
                                                state = sAlu;
422
                                                aluOpcode = `GT_alu;
423 7 maheshpalv
                                                aluEn = 1'b1;
424
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
425
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
426 5 maheshpalv
 
427
                                                `ifdef timeAndCounter_peripheral
428 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
429 5 maheshpalv
                                                `endif
430
 
431
                                                `ifdef UART_peripheral
432 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
433 5 maheshpalv
                                                `endif
434
 
435
                                                `ifdef SPI_peripheral
436 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
437 5 maheshpalv
                                                `endif
438
 
439
                                end
440
 
441
 
442
 
443
 
444
 
445
                                `GE                     :       begin
446
                                                state = sAlu;
447
                                                aluOpcode = `GE_alu;
448 7 maheshpalv
                                                aluEn = 1'b1;
449
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
450
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
451 5 maheshpalv
 
452
                                                `ifdef timeAndCounter_peripheral
453 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
454 5 maheshpalv
                                                `endif
455
 
456
                                                `ifdef UART_peripheral
457 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
458 5 maheshpalv
                                                `endif
459
 
460
                                                `ifdef SPI_peripheral
461 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
462 5 maheshpalv
                                                `endif
463
 
464
                                end
465
 
466
 
467
 
468
 
469
 
470
                                `EQ                     :       begin
471
                                                state = sAlu;
472
                                                aluOpcode = `EQ_alu;
473 7 maheshpalv
                                                aluEn = 1'b1;
474
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
475
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
476 5 maheshpalv
 
477
                                                `ifdef timeAndCounter_peripheral
478 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
479 5 maheshpalv
                                                `endif
480
 
481
                                                `ifdef UART_peripheral
482 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
483 5 maheshpalv
                                                `endif
484
 
485
                                                `ifdef SPI_peripheral
486 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
487 5 maheshpalv
                                                `endif
488
 
489
                                end
490
 
491
 
492
 
493
 
494
 
495
                                `LE                     :       begin
496
                                                state = sAlu;
497
                                                aluOpcode = `LE_alu;
498 7 maheshpalv
                                                aluEn = 1'b1;
499
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
500
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
501 5 maheshpalv
 
502
                                                `ifdef timeAndCounter_peripheral
503 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
504 5 maheshpalv
                                                `endif
505
 
506
                                                `ifdef UART_peripheral
507 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
508 5 maheshpalv
                                                `endif
509
 
510
                                                `ifdef SPI_peripheral
511 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
512 5 maheshpalv
                                                `endif
513
 
514
                                end
515
 
516
 
517
 
518
 
519
 
520
                                `LT                     :       begin
521
                                                state = sAlu;
522
                                                aluOpcode = `LT_alu;
523 7 maheshpalv
                                                aluEn = 1'b1;
524
                                                branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
525
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
526 5 maheshpalv
 
527
                                                `ifdef timeAndCounter_peripheral
528 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
529 5 maheshpalv
                                                `endif
530
 
531
                                                `ifdef UART_peripheral
532 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
533 5 maheshpalv
                                                `endif
534
 
535
                                                `ifdef SPI_peripheral
536 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
537 5 maheshpalv
                                                `endif
538
 
539
                                end
540
 
541
 
542
                                `ifdef timeAndCounter_peripheral
543
                                `PRE                    :       begin
544
                                                state = sTc;
545
 
546 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b1;      tcLoadEn = 1'b0;
547 5 maheshpalv
 
548
 
549 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
550
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
551 5 maheshpalv
 
552
 
553
                                                `ifdef UART_peripheral
554 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
555 5 maheshpalv
                                                `endif
556
 
557
                                                `ifdef SPI_peripheral
558 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
559 5 maheshpalv
                                                `endif
560
                                end
561
                                `endif
562
 
563
 
564
                                `ifdef timeAndCounter_peripheral
565
                                `ETY                    :       begin
566
                                                state = sTc;
567
 
568 7 maheshpalv
                                                entypeEn = 1'b1;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
569 5 maheshpalv
 
570
 
571 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
572
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
573 5 maheshpalv
 
574
 
575
                                                `ifdef UART_peripheral
576 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
577 5 maheshpalv
                                                `endif
578
 
579
                                                `ifdef SPI_peripheral
580 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
581 5 maheshpalv
                                                `endif
582
                                end
583
                                `endif
584
 
585
 
586
 
587
                                `ifdef timeAndCounter_peripheral
588
                                `RST                    :       begin
589
                                                state = sTc;
590
 
591 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b1;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
592 5 maheshpalv
 
593
 
594 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
595
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
596 5 maheshpalv
 
597
 
598
                                                `ifdef UART_peripheral
599 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
600 5 maheshpalv
                                                `endif
601
 
602
                                                `ifdef SPI_peripheral
603 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
604 5 maheshpalv
                                                `endif
605
                                end
606
                                `endif
607
 
608
 
609
 
610
                                `ifdef timeAndCounter_peripheral
611
                                `LdTC                   :       begin
612
                                                state = sTc;
613
 
614 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b1;
615 5 maheshpalv
 
616 7 maheshpalv
                                                accMuxSel = `accMuxSelTcLoad;           accEn = 1'b1;   // loading TC status data
617 5 maheshpalv
 
618 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;                  op2MuxSel = 1'b0;
619
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
620 5 maheshpalv
 
621
 
622
                                                `ifdef UART_peripheral
623 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
624 5 maheshpalv
                                                `endif
625
 
626
                                                `ifdef SPI_peripheral
627 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
628 5 maheshpalv
                                                `endif
629
                                end
630
                                `endif
631
 
632
 
633
 
634
                                `ifdef timeAndCounter_peripheral
635
                                `LdACC                  :       begin
636
                                                state = sTc;
637
 
638 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b1;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
639 5 maheshpalv
 
640 7 maheshpalv
                                                accMuxSel = `accMuxSelTcAcc;            accEn = 1'b1;   // loading TC ACC data
641 5 maheshpalv
 
642 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          op2MuxSel = 1'b0;
643
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
644 5 maheshpalv
 
645
 
646
                                                `ifdef UART_peripheral
647 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
648 5 maheshpalv
                                                `endif
649
 
650
                                                `ifdef SPI_peripheral
651 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
652 5 maheshpalv
                                                `endif
653
                                end
654
                                `endif
655
 
656
 
657
 
658
 
659
                                `ifdef UART_peripheral
660
                                `UARTrd                 :       begin
661
                                                state = sUart;
662
 
663 7 maheshpalv
                                                uartRead = 1'b1;                uartWrite = 1'b0;
664 5 maheshpalv
 
665 7 maheshpalv
                                                accMuxSel = `accMuxSelUartData;         accEn = 1'b1;   // loading UART data
666 5 maheshpalv
 
667 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          op2MuxSel = 1'b0;
668
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
669 5 maheshpalv
 
670
                                                `ifdef timerAndCounter_peripheral
671 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
672 5 maheshpalv
                                                `endif
673
 
674
 
675
                                                `ifdef SPI_peripheral
676 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
677 5 maheshpalv
                                                `endif
678
                                end
679
                                `endif
680
 
681
 
682
 
683 7 maheshpalv
                                `ifdef UART_peripheral
684
                                `UARTstat                       :       begin
685
                                                state = sUart;
686
 
687
                                                uartRead = 1'b0;                uartWrite = 1'b0;
688
 
689
                                                accMuxSel = `accMuxSelUartStat;         accEn = 1'b1;   // loading UART status
690
 
691
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          op2MuxSel = 1'b0;
692
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
693
 
694
                                                `ifdef timerAndCounter_peripheral
695
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
696
                                                `endif
697
 
698
 
699
                                                `ifdef SPI_peripheral
700
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
701
                                                `endif
702
                                end
703
                                `endif
704 5 maheshpalv
 
705 7 maheshpalv
 
706
 
707
 
708 5 maheshpalv
                                `ifdef UART_peripheral
709
                                `UARTwr                 :       begin
710
                                                state = sUart;
711
 
712 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b1;
713 5 maheshpalv
 
714 7 maheshpalv
                                                aluEn = 1'b0;   aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
715
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
716 5 maheshpalv
 
717
                                                `ifdef timerAndCounter_peripheral
718 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
719 5 maheshpalv
                                                `endif
720
 
721
 
722
                                                `ifdef SPI_peripheral
723 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
724 5 maheshpalv
                                                `endif
725
                                end
726
                                `endif
727
 
728
 
729
 
730
 
731
                                `ifdef SPI_peripheral
732
                                `SPIxFER                        :       begin
733
                                                state = sSpi;
734
 
735 7 maheshpalv
                                                sconEn = 1'b1;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
736 5 maheshpalv
 
737
 
738 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
739
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
740 5 maheshpalv
 
741
                                                `ifdef timerAndCounter_peripheral
742 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
743 5 maheshpalv
                                                `endif
744
 
745
                                                `ifdef UART_peripheral
746 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
747 5 maheshpalv
                                                `endif
748
 
749
                                end
750
                                `endif
751
 
752
 
753
 
754
                                `ifdef SPI_peripheral
755
                                `SPIstat                        :       begin
756
                                                state = sSpi;
757
 
758 7 maheshpalv
                                                sconEn = 1'b0;          spiStatRead = 1'b1;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
759 5 maheshpalv
 
760
 
761 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
762
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
763 5 maheshpalv
 
764
                                                `ifdef timerAndCounter_peripheral
765 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
766 5 maheshpalv
                                                `endif
767
 
768
                                                `ifdef UART_peripheral
769 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
770 5 maheshpalv
                                                `endif
771
 
772
                                end
773
                                `endif
774
 
775
 
776
 
777
                                `ifdef SPI_peripheral
778
                                `SPIwBUF                        :       begin
779
                                                state = sSpi;
780
 
781 7 maheshpalv
                                                sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b1;     spiBufShift = 1'b0;
782 5 maheshpalv
 
783
 
784 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
785
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
786 5 maheshpalv
 
787
                                                `ifdef timerAndCounter_peripheral
788 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
789 5 maheshpalv
                                                `endif
790
 
791
                                                `ifdef UART_peripheral
792 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
793 5 maheshpalv
                                                `endif
794
 
795
                                end
796
                                `endif
797
 
798
 
799
 
800
                                `ifdef SPI_peripheral
801
                                `SPIrBUF                        :       begin
802
                                                state = sSpi;
803
 
804 7 maheshpalv
                                                sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b1;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
805 5 maheshpalv
 
806
 
807 7 maheshpalv
                                                aluEn = 1'b0;   aluOpcode = 1'b0;               branch = 1'b0;          accMuxSel = 1'b0;               accEn = 1'b0;   op2MuxSel = 1'b0;
808
                                                bitRamEn = 1'b0;        bitRamRw = 1'b1;        byteRamEn = 1'b0;               byteRamRw = 1'b1;               inputRead = 1'b0;               outputRw = 1'b1;
809 5 maheshpalv
 
810
                                                `ifdef timerAndCounter_peripheral
811 7 maheshpalv
                                                entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
812 5 maheshpalv
                                                `endif
813
 
814
                                                `ifdef UART_peripheral
815 7 maheshpalv
                                                uartRead = 1'b0;                uartWrite = 1'b0;
816 5 maheshpalv
                                                `endif
817
 
818
                                end
819
                                `endif
820
 
821
                                default         :       begin
822
 
823
                                $write ("       unknown/unused instruction op-code encountered by control unit  ");
824
                                $stop;
825
                                end
826
                                endcase // end  case (instOpCode)
827
 
828
 
829
 
830
                        end     // end case (s)
831
 
832
 
833
                        sBr             :       begin
834 7 maheshpalv
                                                        branch = 1'b0;
835 5 maheshpalv
                                                        state = s;
836
                                                        end             // end case sBr
837
 
838
 
839
                        sLd             :       begin
840 7 maheshpalv
                                                        aluEn = 1'b0;
841
                                                        accEn = 1'b1;
842 6 maheshpalv
                                                        accMuxSel = `accMuxSelAluOut;
843 5 maheshpalv
                                                        state = s;
844
                                                        end             // end case sLd
845
 
846
                        sSt             :       begin
847 7 maheshpalv
                                                        bitRamRw = 1'b1;        byteRamRw = 1'b1; outputRw = 1'b1;
848 5 maheshpalv
                                                        state = s;
849
                                                        end
850
 
851
                        sAlu            :       begin
852 7 maheshpalv
                                                        aluEn = 1'b0;
853
                                                        accEn = 1'b1;
854 5 maheshpalv
                                                        accMuxSel = `accMuxSelAluOut;
855
                                                        state = s;
856
                                                        end
857
 
858
                        `ifdef timerAndCounter_peripheral
859
                        sTc             :       begin
860 7 maheshpalv
                                                        entypeEn = 1'b0;                tcAccRead = 1'b0;       tcResetEn = 1'b0;               tcPresetEn = 1'b0;      tcLoadEn = 1'b0;
861 5 maheshpalv
                                                        state = s;
862
                                                        end
863
                        `endif
864
 
865
                        `ifdef UART_peripheral
866
                        sUart           :       begin
867 7 maheshpalv
                                                        uartRead = 1'b0;                uartWrite = 1'b0;
868 5 maheshpalv
                                                        state = s;
869
                                                        end
870
                        `endif
871
 
872
                        `ifdef SPI_peripheral
873
                        sSpi            :       begin
874 7 maheshpalv
                                                        sconEn = 1'b0;          spiStatRead = 1'b0;     spiBufRead = 1'b0;      spiBufWrite = 1'b0;     spiBufShift = 1'b0;
875 5 maheshpalv
                                                        state = s;
876
                                                        end
877
                        `endif
878
 
879
                        default         :       begin
880
                        $write ("       control unit FSM in unknown state.      ");
881
                        end
882
                        endcase // end  case (state)
883
                end     // end else part (outermost)
884
 
885
 
886
 
887
        end     // end always
888
 
889
 
890 3 maheshpalv
endmodule

powered by: WebSVN 2.1.0

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