1 |
10 |
maheshpalv |
////////////////////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// ////
|
4 |
|
|
//// This file is part of the project ////
|
5 |
|
|
//// "instruction_list_pipelined_processor_with_peripherals" ////
|
6 |
|
|
//// ////
|
7 |
|
|
//// http://opencores.org/project,instruction_list_pipelined_processor_with_peripherals ////
|
8 |
|
|
//// ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// Author: ////
|
11 |
|
|
//// - Mahesh Sukhdeo Palve ////
|
12 |
|
|
//// ////
|
13 |
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
14 |
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
15 |
|
|
//// ////
|
16 |
|
|
//// ////
|
17 |
|
|
//// ////
|
18 |
|
|
//// This source file may be used and distributed without ////
|
19 |
|
|
//// restriction provided that this copyright statement is not ////
|
20 |
|
|
//// removed from the file and that any derivative work contains ////
|
21 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
22 |
|
|
//// ////
|
23 |
|
|
//// This source file is free software; you can redistribute it ////
|
24 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
25 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
26 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
27 |
|
|
//// later version. ////
|
28 |
|
|
//// ////
|
29 |
|
|
//// This source is distributed in the hope that it will be ////
|
30 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
31 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
32 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
33 |
|
|
//// details. ////
|
34 |
|
|
//// ////
|
35 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
36 |
|
|
//// Public License along with this source; if not, download it ////
|
37 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
38 |
|
|
//// ////
|
39 |
|
|
////////////////////////////////////////////////////////////////////////////////////////////////
|
40 |
3 |
maheshpalv |
|
41 |
8 |
maheshpalv |
// 8-bit Pipelined Processor defines
|
42 |
|
|
|
43 |
3 |
maheshpalv |
`define immDataLen 8
|
44 |
|
|
|
45 |
|
|
// program counter & instruction register
|
46 |
7 |
maheshpalv |
`define instAddrLen 10 // 10-bit address => 1024 inst in rom
|
47 |
3 |
maheshpalv |
`define instLen 15 // 15-bit fixed-length instructions
|
48 |
|
|
`define instOpCodeLen 5
|
49 |
|
|
`define instFieldLen 10
|
50 |
|
|
|
51 |
5 |
maheshpalv |
|
52 |
|
|
// control unit
|
53 |
|
|
`define cuStateLen 4 // max 16 states
|
54 |
|
|
`define END `instOpCodeLen'b0
|
55 |
|
|
`define JMP `instOpCodeLen'b1
|
56 |
|
|
`define Ld `instOpCodeLen'b10
|
57 |
|
|
`define Ldi `instOpCodeLen'b11
|
58 |
|
|
`define ST `instOpCodeLen'b100
|
59 |
|
|
`define ADD `instOpCodeLen'b101
|
60 |
|
|
`define SUB `instOpCodeLen'b110
|
61 |
|
|
`define MUL `instOpCodeLen'b111
|
62 |
|
|
`define DIV `instOpCodeLen'b1000
|
63 |
|
|
`define AND `instOpCodeLen'b1001
|
64 |
|
|
`define OR `instOpCodeLen'b1010
|
65 |
|
|
`define XOR `instOpCodeLen'b1011
|
66 |
|
|
`define GrT `instOpCodeLen'b1100
|
67 |
|
|
`define GE `instOpCodeLen'b1101
|
68 |
|
|
`define EQ `instOpCodeLen'b1110
|
69 |
|
|
`define LE `instOpCodeLen'b1111
|
70 |
|
|
`define LT `instOpCodeLen'b10000
|
71 |
|
|
`define PRE `instOpCodeLen'b10001
|
72 |
|
|
`define ETY `instOpCodeLen'b10010
|
73 |
|
|
`define RST `instOpCodeLen'b10011
|
74 |
|
|
`define LdTC `instOpCodeLen'b10100
|
75 |
|
|
`define LdACC `instOpCodeLen'b10101
|
76 |
|
|
`define UARTrd `instOpCodeLen'b10110
|
77 |
|
|
`define UARTwr `instOpCodeLen'b10111
|
78 |
7 |
maheshpalv |
`define UARTstat `instOpCodeLen'b11000
|
79 |
12 |
maheshpalv |
//`define SPIxFER `instOpCodeLen'b11001
|
80 |
|
|
//`define SPIstat `instOpCodeLen'b11010
|
81 |
|
|
//`define SPIwBUF `instOpCodeLen'b11011
|
82 |
|
|
//`define SPIrBUF `instOpCodeLen'b11100
|
83 |
5 |
maheshpalv |
|
84 |
3 |
maheshpalv |
// alu opcodes
|
85 |
|
|
`define aluOpcodeLen 4
|
86 |
|
|
`define AND_alu `aluOpcodeLen'b0
|
87 |
|
|
`define OR_alu `aluOpcodeLen'b1
|
88 |
|
|
`define XOR_alu `aluOpcodeLen'b10
|
89 |
|
|
`define GT_alu `aluOpcodeLen'b11
|
90 |
|
|
`define GE_alu `aluOpcodeLen'b100
|
91 |
|
|
`define EQ_alu `aluOpcodeLen'b101
|
92 |
|
|
`define LE_alu `aluOpcodeLen'b110
|
93 |
|
|
`define LT_alu `aluOpcodeLen'b111
|
94 |
|
|
`define ADD_alu `aluOpcodeLen'b1000
|
95 |
|
|
`define SUB_alu `aluOpcodeLen'b1001
|
96 |
|
|
`define MUL_alu `aluOpcodeLen'b1010
|
97 |
|
|
`define DIV_alu `aluOpcodeLen'b1011
|
98 |
5 |
maheshpalv |
`define LD_data `aluOpcodeLen'b1100
|
99 |
3 |
maheshpalv |
|
100 |
|
|
// bit RAM
|
101 |
|
|
`define bitRamAddrLen 7 // 7-bit address
|
102 |
|
|
`define bitRamDepth 128 // 2^7 = 128 locations
|
103 |
|
|
|
104 |
|
|
// byte RAM
|
105 |
|
|
`define byteRamLen 8 // 8-bit input
|
106 |
|
|
`define byteRamAddrLen 7 // 7-bit address
|
107 |
|
|
`define byteRamDepth 128 // 2^7 = 128 locations
|
108 |
|
|
|
109 |
|
|
// input register
|
110 |
|
|
`define inputNumber 128 // 128 inputs
|
111 |
|
|
`define inputAddrLen 7 // 7-bit address
|
112 |
|
|
|
113 |
|
|
// output register
|
114 |
|
|
`define outputNumber 128 // 128 outputs
|
115 |
|
|
`define outputAddrLen 7 // 7-bit address
|
116 |
|
|
|
117 |
|
|
// accumulator multiplexer
|
118 |
5 |
maheshpalv |
`define accMuxSelLen 4 // 2^4 = 16 selections available for accumulator
|
119 |
|
|
`define accMuxSelImmData `accMuxSelLen'b0
|
120 |
|
|
`define accMuxSelAluOut `accMuxSelLen'b1
|
121 |
|
|
`define accMuxSelTcLoad `accMuxSelLen'b10
|
122 |
|
|
`define accMuxSelTcAcc `accMuxSelLen'b11
|
123 |
7 |
maheshpalv |
`define accMuxSelUartData `accMuxSelLen'b100
|
124 |
|
|
`define accMuxSelUartStat `accMuxSelLen'b101
|
125 |
3 |
maheshpalv |
|
126 |
|
|
// operand2 multiplexer
|
127 |
5 |
maheshpalv |
`define op2MuxSelLen 4 // 2^4 = 16 selections available for op2
|
128 |
|
|
`define op2MuxSelInput `op2MuxSelLen'b0
|
129 |
|
|
`define op2MuxSelOutput `op2MuxSelLen'b1
|
130 |
|
|
`define op2MuxSelBitRam `op2MuxSelLen'b10
|
131 |
|
|
`define op2MuxSelByteRam `op2MuxSelLen'b11
|
132 |
3 |
maheshpalv |
`define op2MuxSel4 `op2MuxSelLen'b100
|
133 |
|
|
`define op2MuxSel5 `op2MuxSelLen'b101
|
134 |
|
|
`define op2MuxSel6 `op2MuxSelLen'b110
|
135 |
|
|
|
136 |
|
|
//-----------------------------------------------------------------------------------------------------
|
137 |
|
|
|
138 |
|
|
// peripheral defines
|
139 |
|
|
`define timerAndCounter_peripheral
|
140 |
|
|
`define UART_peripheral
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
//-----------------------------------------------------------------------------------------------------
|
144 |
|
|
|
145 |
|
|
// Timer-Counter
|
146 |
|
|
`define tcAccLen 8 // 8-bit accumulated value
|
147 |
|
|
`define tcPresetLen 8 // 8-bit preset value
|
148 |
|
|
`define tcAddrLen 4
|
149 |
|
|
`define tcTypeLen 2 // max 4-types
|
150 |
7 |
maheshpalv |
`define tcNumbers 8 // total 8 modules (4-timers, 4-counters)
|
151 |
3 |
maheshpalv |
|
152 |
|
|
`define timerType1 `tcTypeLen'b0
|
153 |
|
|
`define timerType2 `tcTypeLen'b1
|
154 |
|
|
`define timerType3 `tcTypeLen'b10
|
155 |
|
|
|
156 |
|
|
`define counterType1 `tcTypeLen'b1
|
157 |
|
|
`define counterType2 `tcTypeLen'b10
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
//-----------------------------------------------------------------------------------------------------
|
161 |
|
|
|
162 |
|
|
// UART
|
163 |
|
|
`define dataBits 8
|
164 |
|
|
`define sbTick 16 // ticks for stop bits (16 for 1-stopBit)
|
165 |
|
|
`define fifoWidth 4
|
166 |
|
|
`define number_fifo_regs 16
|
167 |
|
|
`define fifoCntrWidth 5
|
168 |
|
|
`define fifoDepth 16
|