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 7

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
        wire    [`instLen-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
// wires (interconnects) of UART
104
 
105
        `ifdef UART_peripheral
106
 
107
 
108
 
109 3 maheshpalv
        `endif
110 5 maheshpalv
 
111
// wires (interconnects) of SPI
112 3 maheshpalv
 
113 5 maheshpalv
        `ifdef SPI_peripheral
114 3 maheshpalv
 
115 5 maheshpalv
        `endif
116 3 maheshpalv
 
117 5 maheshpalv
 
118
 
119
 
120 3 maheshpalv
//-------- Fetch Unit Module Instances
121
// all necessary
122
 
123 7 maheshpalv
        pgmCounter              ProgramCounter (clk, reset, branchOutc, instField[9:0], pcOut);
124 3 maheshpalv
 
125
 
126
// instruction ROM is declared using xilinx primitive
127
        RAMB16_S18 rom ( .DI(),
128
                                 .DIP(),
129 5 maheshpalv
                                 .ADDR(pcOut),
130 3 maheshpalv
                                 .EN(1'b1),
131
                                 .WE(),
132
                                 .SSR(1'b0),
133 5 maheshpalv
                                 .CLK(clk),
134
                                 .DO(romOut),
135 3 maheshpalv
                                 .DOP());
136
 
137 7 maheshpalv
//      instReg                 IntructionRegister (romOut, instOpCode, instField);
138 3 maheshpalv
 
139
 
140 5 maheshpalv
// pipeline register
141
 
142
        wire    [`instOpCodeLen-1:0] instOpCode1;
143
        wire    [`instFieldLen-1:0] instField1;
144
        wire    [`instFieldLen-1:0] instField2;
145
 
146 7 maheshpalv
        ppReg1  PipeLine_Reg1 (clk, romOut[`instLen-1:`instLen-`instOpCodeLen], romOut[`instFieldLen-1:0], instOpCode1, instField1);
147 5 maheshpalv
 
148
 
149
//-------- Control Unit Module Instance
150
 
151
        controlUnit             CONTROL_UNIT (clk, reset, instOpCode1, accOut[0], instField2[8:7],
152 6 maheshpalv
                                                                                        branchOutc,
153
                                                                        accMuxSelOutc, accEnOutc, op2MuxSelOutc, aluEnc, aluOpcodeOutc, bitRamEnOutc,
154
                                                                        bitRamRwOutc, byteRamEnOutc, byteRamRwOutc, inputReadOutc, outputRwOutc
155
                                                                `ifdef timerAndCounter_peripheral
156
                                                                , entypeEnOutc, tcAccReadOutc, tcResetEnOutc, tcPresetEnOutc, tcLoadEnOutc
157
                                                                `endif
158
                                                                `ifdef UART_peripheral
159
                                                                , uartReadOutc, uartWriteOutcc
160
                                                                `endif
161
                                                                `ifdef SPI_peripheral
162
                                                                , sconEnOutc, spiStatReadOutc, spiBufReadOutc, spiBufWriteOutc, spiBufShiftOutc
163
                                                                `endif
164 5 maheshpalv
 
165
                                                                                        );
166
 
167
 
168
 
169
// pipeline register
170
 
171
 
172
 
173
        ppReg2  PipeLine_Reg2 (clk,
174
                                                                        branchOutc,
175 6 maheshpalv
                                                                        accMuxSelOutc, accEnOutc, op2MuxSelOutc, aluEnc, aluOpcodeOutc, bitRamEnOutc,
176 5 maheshpalv
                                                                        bitRamRwOutc, byteRamEnOutc, byteRamRwOutc, inputReadOutc, outputRwOutc
177
                                                                `ifdef timerAndCounter_peripheral
178
                                                                , entypeEnOutc, tcAccReadOutc, tcResetEnOutc, tcPresetEnOutc, tcLoadEnOutc
179
                                                                `endif
180
                                                                `ifdef UART_peripheral
181
                                                                , uartReadOutc, uartWriteOutcc
182
                                                                `endif
183
                                                                `ifdef SPI_peripheral
184
                                                                , sconEnOutc, spiStatReadOutc, spiBufReadOutc, spiBufWriteOutc, spiBufShiftOutc
185
                                                                `endif
186
                                                                , instField1
187
 
188
                                                                        , branchOut,
189 6 maheshpalv
                                                                        accMuxSelOut, accEnOut, op2MuxSelOut, aluEn, aluOpcodeOut,
190 5 maheshpalv
                                                                        bitRamEnOut, bitRamRwOut, byteRamEnOut, byteRamRwOut,
191
                                                                        inputReadOut, outputRwOut
192
 
193
                                                                        `ifdef timerAndCounter_peripheral
194
                                                                                , entypeEnOut, tcAccReadOut, tcResetEnOut, tcPresetEnOut, tcLoadEnOut
195
                                                                        `endif
196
 
197
                                                                        `ifdef UART_peripheral
198
                                                                                , uartReadOut, uartWriteOut
199
                                                                        `endif
200
 
201
                                                                        `ifdef SPI_peripheral
202
                                                                                , sconEnOut, spiStatReadOut, spiBufReadOut, spiBufWriteOut, spiBufShiftOut
203
                                                                        `endif
204
 
205
                                                                        , instField2
206
                                                                );
207
 
208
 
209 3 maheshpalv
//-------- Execute Unit Modules Instances
210
// all necessary
211
 
212
 
213
 
214
 
215 5 maheshpalv
        accumulatorMUX          accMUX1 (accMuxSelOut, instField2[7:0], aluOut
216
                                                                                `ifdef timerAndCounter_peripheral
217
                                                                                , tcLoadOut, tcAccOut
218
                                                                                `endif
219
                                                                                `ifdef UART_peripheral
220 7 maheshpalv
                                                                                , uartDataOut, {rxEmpty, txFull}
221 5 maheshpalv
                                                                                `endif
222
                                                                                `ifdef SPI_peripheral
223
                                                                                , spiStatOut, spiBufOut
224
                                                                                `endif
225
                                                                                , accMuxOut
226
                                                                                );
227
 
228 3 maheshpalv
 
229 5 maheshpalv
        accumulator                     acc             (accMuxOut, accEnOut, accOut);
230 3 maheshpalv
 
231 5 maheshpalv
        op2Mux                          op2MUX1 (op2MuxSelOut, inputReadOutData, outputReadOut, bitOut, byteOut, op2MuxOut);
232 3 maheshpalv
 
233 5 maheshpalv
        wire [7:0] op2Out;
234 3 maheshpalv
 
235 5 maheshpalv
        byteNegator                     byteNegatorForOp2Mux (op2MuxOut, instField2[9], op2Out);
236 3 maheshpalv
 
237 6 maheshpalv
        alu                                     arithLogicUnit  (aluOpcodeOut, accOut, op2Out, aluEn, aluOut, carryOut);
238 3 maheshpalv
 
239 5 maheshpalv
        wire bitIn;
240 3 maheshpalv
 
241 5 maheshpalv
        bitNegator                      bitNegatorForBitRam     (accOut[0], instField2[9], bitIn);
242 3 maheshpalv
 
243 5 maheshpalv
        bitRam                          RAM_Bit (clk, reset, bitRamEnOut, bitRamRwOut, bitIn, instField2[6:0], bitOut);
244 3 maheshpalv
 
245 5 maheshpalv
        wire [7:0] byteIn;
246 3 maheshpalv
 
247 5 maheshpalv
        byteNegator                     byteNegatorForByteRam   (accOut, instField2[9], byteIn);
248 3 maheshpalv
 
249 5 maheshpalv
        byteRam                         RAM_Byte        (clk, reset, byteRamEnOut, byteRamRwOut, byteIn, instField2[6:0], byteOut);
250
 
251
        inputRegister           inputStorage    (reset, IN, inputReadOut, instField2[6:0], inputReadOutData);
252
 
253
        outputReg                       outputStorage   (reset, outputRwOut, instField2[6:0], accOut[0], outputReadOut, OUT);
254
 
255 3 maheshpalv
 
256
//---------- Timer & Counter Modules
257
// optional
258
 
259
`ifdef timerAndCounter_peripheral
260
 
261 5 maheshpalv
 
262
 
263
 
264
        tcEnableAndType tcEnableAndTypeModule(entypeEnOut, instField2[6], instField2[5:4], instField2[3:0], enWires, typeWires);
265 3 maheshpalv
 
266 7 maheshpalv
        tcAccum                         tcAccumModule(tcAccReadOut, instField2[3:0], tcAccWires, tcAccOut);
267 3 maheshpalv
 
268 5 maheshpalv
        tcReset                         tcResetModule(tcResetEnOut, instField2[4], instField2[3:0], resetWires);
269 3 maheshpalv
 
270 5 maheshpalv
        tcPreset                                tcPresetModule(tcPresetEnOut, accOut, instField2[3:0], presetWires);
271 3 maheshpalv
 
272 5 maheshpalv
        tcLoad                          tcLoadModule(tcLoadEnOut, instField2[3:0], dnWires, ttWires, cuWires, cdWires, tcLoadOut);
273 3 maheshpalv
 
274 5 maheshpalv
        timer                                   timer0  (clk, enWires[0], resetWires[0], typeWires[1:0], presetWires[7:0], dnWires[0], ttWires[0], tcAccWires[7:0]);
275 3 maheshpalv
 
276 5 maheshpalv
        timer                                   timer1  (clk, enWires[1], resetWires[1], typeWires[3:2], presetWires[15:8], dnWires[1], ttWires[1], tcAccWires[15:8]);
277 3 maheshpalv
 
278 5 maheshpalv
        timer                                   timer2  (clk, enWires[2], resetWires[2], typeWires[5:4], presetWires[23:16], dnWires[2], ttWires[2], tcAccWires[23:16]);
279 3 maheshpalv
 
280 5 maheshpalv
        timer                                   timer3  (clk, enWires[3], resetWires[3], typeWires[7:6], presetWires[31:24], dnWires[3], ttWires[3], tcAccWires[31:24]);
281 3 maheshpalv
 
282 5 maheshpalv
        counter                         counter0        (enWires[4], resetWires[4], presetWires[39:32], typeWires[9:8], dnWires[4], cuWires[0], cdWires[0], tcAccWires[39:32]);
283 3 maheshpalv
 
284 5 maheshpalv
        counter                         counter1        (enWires[5], resetWires[5], presetWires[47:40], typeWires[11:10], dnWires[5], cuWires[1], cdWires[1], tcAccWires[47:40]);
285 3 maheshpalv
 
286 5 maheshpalv
        counter                         counter2        (enWires[6], resetWires[6], presetWires[55:48], typeWires[13:12], dnWires[6], cuWires[2], cdWires[2], tcAccWires[55:48]);
287 3 maheshpalv
 
288 5 maheshpalv
        counter                         counter3        (enWires[7], resetWires[7], presetWires[63:56], typeWires[15:14], dnWires[7], cuWires[3], cdWires[3], tcAccWires[63:56]);
289 3 maheshpalv
 
290
`endif
291
 
292
//---------- UART Modules
293
// optional
294
 
295
`ifdef UART_peripheral
296
 
297 5 maheshpalv
        wire    brgOut;
298
        wire txDoneTick, txStart;
299
        wire rxDoneTick;
300
        wire [7:0] recFifoData, transFifoData;
301
 
302 3 maheshpalv
 
303 5 maheshpalv
        uartTrans       UART_TRANSMITTER (clk, reset, brgOut, txDoneTick, transFifoData, tx, ~txStart);
304 3 maheshpalv
 
305 5 maheshpalv
        uartRec         UART_RECIEVER (clk, reset, brgOut, rx, rxDoneTick, recFifoData);
306 3 maheshpalv
 
307 5 maheshpalv
        uartBrg         UART_BitRateGenerator (.clk(clk), .reset(reset), .outp(brgOut));
308 3 maheshpalv
 
309 5 maheshpalv
        uartFifo                UART_TRANS_FIFO (clk, reset, accOut, transFifoData, uartWriteOut, txDoneTick, txFull, txStart);
310 3 maheshpalv
 
311 5 maheshpalv
        uartFifo                UART_REC_FIFO (clk, reset, recFifoData, uartDataOut, rxDoneTick, uartReadOut, rxFull, rxEmpty);
312
 
313 3 maheshpalv
`endif
314
 
315
//---------- SPI Modules
316
// optional
317
 
318
`ifdef SPI_peripheral
319
 
320 6 maheshpalv
 
321
        spi_top         SPI_TOP (clk, sconEnOut, spiStatReadOut, instField2[7:0], spiStatOut, spiBufWriteOut, spiBufReadOut, aluOut, spiBufOut, MI, MO, SCK);
322
 
323
 
324 3 maheshpalv
`endif
325
 
326
endmodule

powered by: WebSVN 2.1.0

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