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/] [top.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
`include "timescale.v"
2
`include "defines.v"
3
 
4
module top(clk, reset, IN, OUT
5
 
6
                                `ifdef UART_peripheral
7
                                        , rx, tx
8
                                `endif
9
 
10
                                `ifdef SPI_peripheral
11
                                        , MISO, MOSI, SCK
12
                                `endif
13
 
14
                                );
15
 
16
 
17
        input   clk,reset;
18
        input [`inputNumber-1:0] IN;
19
        output [`outputNumber-1:0] OUT;
20
 
21
        `ifdef UART_peripheral
22
        input rx;
23
        output tx;
24
        `endif
25
 
26
        `ifdef SPI_peripheral
27
        input MISO;
28
        output MOSI, SCK;
29
        `endif
30
 
31
// wires (interconnects) of execution unit
32
 
33 8 maheshpalv
        wire    [`instAddrLen-1:0]                       pcOut;
34 5 maheshpalv
        wire    [`instOpCodeLen+`instFieldLen-1:0] romOut;
35 3 maheshpalv
        wire    [`instOpCodeLen-1:0]     instOpCode;
36
        wire    [`instFieldLen-1:0]      instField;
37
 
38
        wire    [7:0]            accMuxOut;
39
        wire    [7:0]            accOut;
40
        wire    [7:0]            op2MuxOut;
41
        wire    [7:0]            aluOut;
42
 
43
        wire    bitNegatorRamOut, bitOut;
44
        wire    [7:0]    byteNegatorRamOut, byteOut;
45
 
46 5 maheshpalv
        wire    inputReadOutData, outputReadOut;
47 3 maheshpalv
 
48 5 maheshpalv
        wire branchOutc;
49
        wire [`accMuxSelLen-1:0] accMuxSelOutc;
50
        wire accEnOutc;
51
        wire [`op2MuxSelLen-1:0] op2MuxSelOutc;
52 6 maheshpalv
        wire aluEnc;
53 5 maheshpalv
        wire [`aluOpcodeLen-1:0] aluOpcodeOutc;
54
        wire bitRamEnOutc, bitRamRwOutc, byteRamEnOutc, byteRamRwOutc;
55
        wire inputReadOutc, outputRwOutc;
56
        `ifdef timerAndCounter_peripheral
57
        wire entypeEnOutc, tcAccReadOutc, tcResetEnOutc, tcPresetEnOutc, tcLoadEnOutc;
58
        `endif
59
        `ifdef UART_peripheral
60
        wire uartReadOutc, uartWriteOutc;
61 7 maheshpalv
        wire [7:0] uartDataOut;
62
        wire rxEmpty, txFull;
63 5 maheshpalv
        `endif
64
        `ifdef SPI_peripheral
65
        wire sconEnOutc, spiStatReadOutc, spiBufReadOutc, spiBufWriteOutc, spiBufShiftOutc;
66
        `endif
67 3 maheshpalv
 
68 5 maheshpalv
        wire branchOut;
69
        wire [`accMuxSelLen-1:0] accMuxSelOut;
70
        wire accEnOut;
71
        wire [`op2MuxSelLen-1:0] op2MuxSelOut;
72 6 maheshpalv
        wire aluEn;
73 5 maheshpalv
        wire [`aluOpcodeLen-1:0] aluOpcodeOut;
74
        wire bitRamEnOut, bitRamRwOut, byteRamEnOut, byteRamRwOut;
75
        wire inputReadOut, outputRwOut;
76 3 maheshpalv
        `ifdef timerAndCounter_peripheral
77 5 maheshpalv
        wire entypeEnOut, tcAccReadOut, tcResetEnOut, tcPresetEnOut, tcLoadEnOut;
78
        `endif
79
        `ifdef UART_peripheral
80
        wire uartReadOut, uartWriteOut;
81
        `endif
82
        `ifdef SPI_peripheral
83
        wire sconEnOut, spiStatReadOut, spiBufReadOut, spiBufWriteOut, spiBufShiftOut;
84
        `endif
85
 
86 3 maheshpalv
 
87 5 maheshpalv
 
88
// wires (interconnects) of timer & counter
89
 
90
`ifdef timerAndCounter_peripheral
91
 
92
        wire    [(`tcNumbers*`tcPresetLen)-1:0] presetWires;
93 7 maheshpalv
        wire    [7:0] tcAccOut;
94 5 maheshpalv
        wire    [7:0] tcLoadOut;
95
        wire [`tcNumbers-1:0] enWires;
96
        wire [`tcNumbers-1:0] resetWires;
97
        wire [`tcNumbers-1:0] dnWires, ttWires, cuWires, cdWires;
98
        wire [(`tcNumbers*2)-1:0] typeWires;
99
        wire [(`tcNumbers*`tcAccLen)-1:0] tcAccWires;
100
 
101
`endif
102
 
103 8 maheshpalv
`ifdef SPI_peripheral
104 5 maheshpalv
 
105 8 maheshpalv
        wire [7:0] spiStatOut, spiBufOut;
106
`endif
107
 
108
 
109
        wire clk_d, clk_t;
110
        reg [10:0] cnt = 0;
111 5 maheshpalv
 
112 8 maheshpalv
        always @ (posedge clk or posedge reset)
113
        begin
114
                if (reset)
115
                begin
116
                        cnt =0;
117
                end
118
                else
119
                begin
120
                        cnt = cnt + 1'b1;
121
                end
122
        end
123 5 maheshpalv
 
124 8 maheshpalv
        assign clk_d = cnt[0];
125
        assign clk_t = cnt[10];
126 3 maheshpalv
 
127
 
128
 
129
//-------- Fetch Unit Module Instances
130
// all necessary
131 9 maheshpalv
 
132
        wire branch = (~romOut[14] & ~romOut[13] & ~romOut[12] & ~romOut[11] & ~romOut[10]) | ((romOut[10] & ~romOut[13] & ~romOut[12] & ~romOut[11] & ~romOut[14]) & accOut[0]);                                // END = 00000; JMP = 00001
133 3 maheshpalv
 
134 9 maheshpalv
        pgmCounter              ProgramCounter (clk_d, reset, branch, romOut[9:0], pcOut);
135 3 maheshpalv
 
136
 
137
// instruction ROM is declared using xilinx primitive
138 9 maheshpalv
//      RAMB16_S18 rom ( .DI(),
139
//                               .DIP(),
140
//                               .ADDR(pcOut),
141
//                               .EN(1'b1),
142
//                               .WE(),   
143
//                               .SSR(1'b0),
144
//                               .CLK(clk_d),
145
//                               .DO(romOut),
146
//                               .DOP());
147 3 maheshpalv
 
148 9 maheshpalv
        rom     CodeMem (clk_d, pcOut, romOut);
149 3 maheshpalv
 
150 5 maheshpalv
// pipeline register
151
 
152
        wire    [`instOpCodeLen-1:0] instOpCode1;
153
        wire    [`instFieldLen-1:0] instField1;
154
        wire    [`instFieldLen-1:0] instField2;
155
 
156 8 maheshpalv
        ppReg1  PipeLine_Reg1 (clk_d, romOut[`instLen-1:`instLen-`instOpCodeLen], romOut[`instFieldLen-1:0], instOpCode1, instField1);
157 5 maheshpalv
 
158
 
159
//-------- Control Unit Module Instance
160
 
161
        controlUnit             CONTROL_UNIT (clk, reset, instOpCode1, accOut[0], instField2[8:7],
162 6 maheshpalv
                                                                                        branchOutc,
163
                                                                        accMuxSelOutc, accEnOutc, op2MuxSelOutc, aluEnc, aluOpcodeOutc, bitRamEnOutc,
164
                                                                        bitRamRwOutc, byteRamEnOutc, byteRamRwOutc, inputReadOutc, outputRwOutc
165
                                                                `ifdef timerAndCounter_peripheral
166
                                                                , entypeEnOutc, tcAccReadOutc, tcResetEnOutc, tcPresetEnOutc, tcLoadEnOutc
167
                                                                `endif
168
                                                                `ifdef UART_peripheral
169
                                                                , uartReadOutc, uartWriteOutcc
170
                                                                `endif
171
                                                                `ifdef SPI_peripheral
172
                                                                , sconEnOutc, spiStatReadOutc, spiBufReadOutc, spiBufWriteOutc, spiBufShiftOutc
173
                                                                `endif
174 5 maheshpalv
 
175
                                                                                        );
176
 
177
 
178
 
179
// pipeline register
180
 
181
 
182
 
183
        ppReg2  PipeLine_Reg2 (clk,
184
                                                                        branchOutc,
185 6 maheshpalv
                                                                        accMuxSelOutc, accEnOutc, op2MuxSelOutc, aluEnc, aluOpcodeOutc, bitRamEnOutc,
186 5 maheshpalv
                                                                        bitRamRwOutc, byteRamEnOutc, byteRamRwOutc, inputReadOutc, outputRwOutc
187
                                                                `ifdef timerAndCounter_peripheral
188
                                                                , entypeEnOutc, tcAccReadOutc, tcResetEnOutc, tcPresetEnOutc, tcLoadEnOutc
189
                                                                `endif
190
                                                                `ifdef UART_peripheral
191
                                                                , uartReadOutc, uartWriteOutcc
192
                                                                `endif
193
                                                                `ifdef SPI_peripheral
194
                                                                , sconEnOutc, spiStatReadOutc, spiBufReadOutc, spiBufWriteOutc, spiBufShiftOutc
195
                                                                `endif
196
                                                                , instField1
197
 
198
                                                                        , branchOut,
199 6 maheshpalv
                                                                        accMuxSelOut, accEnOut, op2MuxSelOut, aluEn, aluOpcodeOut,
200 5 maheshpalv
                                                                        bitRamEnOut, bitRamRwOut, byteRamEnOut, byteRamRwOut,
201
                                                                        inputReadOut, outputRwOut
202
 
203
                                                                        `ifdef timerAndCounter_peripheral
204
                                                                                , entypeEnOut, tcAccReadOut, tcResetEnOut, tcPresetEnOut, tcLoadEnOut
205
                                                                        `endif
206
 
207
                                                                        `ifdef UART_peripheral
208
                                                                                , uartReadOut, uartWriteOut
209
                                                                        `endif
210
 
211
                                                                        `ifdef SPI_peripheral
212
                                                                                , sconEnOut, spiStatReadOut, spiBufReadOut, spiBufWriteOut, spiBufShiftOut
213
                                                                        `endif
214
 
215
                                                                        , instField2
216
                                                                );
217
 
218
 
219 3 maheshpalv
//-------- Execute Unit Modules Instances
220
// all necessary
221
 
222
 
223
 
224
 
225 5 maheshpalv
        accumulatorMUX          accMUX1 (accMuxSelOut, instField2[7:0], aluOut
226
                                                                                `ifdef timerAndCounter_peripheral
227
                                                                                , tcLoadOut, tcAccOut
228
                                                                                `endif
229
                                                                                `ifdef UART_peripheral
230 7 maheshpalv
                                                                                , uartDataOut, {rxEmpty, txFull}
231 5 maheshpalv
                                                                                `endif
232
                                                                                `ifdef SPI_peripheral
233
                                                                                , spiStatOut, spiBufOut
234
                                                                                `endif
235
                                                                                , accMuxOut
236
                                                                                );
237
 
238 3 maheshpalv
 
239 5 maheshpalv
        accumulator                     acc             (accMuxOut, accEnOut, accOut);
240 3 maheshpalv
 
241 5 maheshpalv
        op2Mux                          op2MUX1 (op2MuxSelOut, inputReadOutData, outputReadOut, bitOut, byteOut, op2MuxOut);
242 3 maheshpalv
 
243 5 maheshpalv
        wire [7:0] op2Out;
244 3 maheshpalv
 
245 5 maheshpalv
        byteNegator                     byteNegatorForOp2Mux (op2MuxOut, instField2[9], op2Out);
246 3 maheshpalv
 
247 6 maheshpalv
        alu                                     arithLogicUnit  (aluOpcodeOut, accOut, op2Out, aluEn, aluOut, carryOut);
248 3 maheshpalv
 
249 5 maheshpalv
        wire bitIn;
250 3 maheshpalv
 
251 5 maheshpalv
        bitNegator                      bitNegatorForBitRam     (accOut[0], instField2[9], bitIn);
252 3 maheshpalv
 
253 5 maheshpalv
        bitRam                          RAM_Bit (clk, reset, bitRamEnOut, bitRamRwOut, bitIn, instField2[6:0], bitOut);
254 3 maheshpalv
 
255 5 maheshpalv
        wire [7:0] byteIn;
256 3 maheshpalv
 
257 5 maheshpalv
        byteNegator                     byteNegatorForByteRam   (accOut, instField2[9], byteIn);
258 3 maheshpalv
 
259 5 maheshpalv
        byteRam                         RAM_Byte        (clk, reset, byteRamEnOut, byteRamRwOut, byteIn, instField2[6:0], byteOut);
260
 
261 9 maheshpalv
        inputRegister           inputStorage    (IN, instField2[6:0], inputReadOutData);
262 5 maheshpalv
 
263
        outputReg                       outputStorage   (reset, outputRwOut, instField2[6:0], accOut[0], outputReadOut, OUT);
264
 
265 3 maheshpalv
 
266
//---------- Timer & Counter Modules
267
// optional
268
 
269
`ifdef timerAndCounter_peripheral
270
 
271 5 maheshpalv
 
272
 
273
 
274
        tcEnableAndType tcEnableAndTypeModule(entypeEnOut, instField2[6], instField2[5:4], instField2[3:0], enWires, typeWires);
275 3 maheshpalv
 
276 7 maheshpalv
        tcAccum                         tcAccumModule(tcAccReadOut, instField2[3:0], tcAccWires, tcAccOut);
277 3 maheshpalv
 
278 5 maheshpalv
        tcReset                         tcResetModule(tcResetEnOut, instField2[4], instField2[3:0], resetWires);
279 3 maheshpalv
 
280 5 maheshpalv
        tcPreset                                tcPresetModule(tcPresetEnOut, accOut, instField2[3:0], presetWires);
281 3 maheshpalv
 
282 5 maheshpalv
        tcLoad                          tcLoadModule(tcLoadEnOut, instField2[3:0], dnWires, ttWires, cuWires, cdWires, tcLoadOut);
283 3 maheshpalv
 
284 8 maheshpalv
        timer                                   timer0  (clk_t, enWires[0], resetWires[0], typeWires[1:0], presetWires[7:0], dnWires[0], ttWires[0], tcAccWires[7:0]);
285 3 maheshpalv
 
286 8 maheshpalv
        timer                                   timer1  (clk_t, enWires[1], resetWires[1], typeWires[3:2], presetWires[15:8], dnWires[1], ttWires[1], tcAccWires[15:8]);
287 3 maheshpalv
 
288 8 maheshpalv
        timer                                   timer2  (clk_t, enWires[2], resetWires[2], typeWires[5:4], presetWires[23:16], dnWires[2], ttWires[2], tcAccWires[23:16]);
289 3 maheshpalv
 
290 8 maheshpalv
        timer                                   timer3  (clk_t, enWires[3], resetWires[3], typeWires[7:6], presetWires[31:24], dnWires[3], ttWires[3], tcAccWires[31:24]);
291 3 maheshpalv
 
292 5 maheshpalv
        counter                         counter0        (enWires[4], resetWires[4], presetWires[39:32], typeWires[9:8], dnWires[4], cuWires[0], cdWires[0], tcAccWires[39:32]);
293 3 maheshpalv
 
294 5 maheshpalv
        counter                         counter1        (enWires[5], resetWires[5], presetWires[47:40], typeWires[11:10], dnWires[5], cuWires[1], cdWires[1], tcAccWires[47:40]);
295 3 maheshpalv
 
296 5 maheshpalv
        counter                         counter2        (enWires[6], resetWires[6], presetWires[55:48], typeWires[13:12], dnWires[6], cuWires[2], cdWires[2], tcAccWires[55:48]);
297 3 maheshpalv
 
298 5 maheshpalv
        counter                         counter3        (enWires[7], resetWires[7], presetWires[63:56], typeWires[15:14], dnWires[7], cuWires[3], cdWires[3], tcAccWires[63:56]);
299 3 maheshpalv
 
300
`endif
301
 
302
//---------- UART Modules
303
// optional
304
 
305
`ifdef UART_peripheral
306
 
307 5 maheshpalv
        wire    brgOut;
308
        wire txDoneTick, txStart;
309
        wire rxDoneTick;
310
        wire [7:0] recFifoData, transFifoData;
311
 
312 3 maheshpalv
 
313 5 maheshpalv
        uartTrans       UART_TRANSMITTER (clk, reset, brgOut, txDoneTick, transFifoData, tx, ~txStart);
314 3 maheshpalv
 
315 5 maheshpalv
        uartRec         UART_RECIEVER (clk, reset, brgOut, rx, rxDoneTick, recFifoData);
316 3 maheshpalv
 
317 5 maheshpalv
        uartBrg         UART_BitRateGenerator (.clk(clk), .reset(reset), .outp(brgOut));
318 3 maheshpalv
 
319 5 maheshpalv
        uartFifo                UART_TRANS_FIFO (clk, reset, accOut, transFifoData, uartWriteOut, txDoneTick, txFull, txStart);
320 3 maheshpalv
 
321 5 maheshpalv
        uartFifo                UART_REC_FIFO (clk, reset, recFifoData, uartDataOut, rxDoneTick, uartReadOut, rxFull, rxEmpty);
322
 
323 3 maheshpalv
`endif
324
 
325
//---------- SPI Modules
326
// optional
327
 
328
`ifdef SPI_peripheral
329
 
330 6 maheshpalv
 
331
        spi_top         SPI_TOP (clk, sconEnOut, spiStatReadOut, instField2[7:0], spiStatOut, spiBufWriteOut, spiBufReadOut, aluOut, spiBufOut, MI, MO, SCK);
332
 
333
 
334 3 maheshpalv
`endif
335
 
336
endmodule

powered by: WebSVN 2.1.0

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