├── README.md
└── TopCtrl.vhd
/README.md:
--------------------------------------------------------------------------------
1 | # NISC
2 | A single instruction set processor architecture
3 | This is my first time using Github.
4 | Currently only preliminary specifications are given and may be further refined.
5 | Suggestions and requests are welcome.
6 | When I figure out how to do it I would like to list proposals and have a vote on which to implement.
7 | Implementing this might be a good project for a processor design course.
8 | VHDL code to follow when specs are firm.
9 | ## About NISC
10 | NISC is my particular brand of One Instruction Set Computer (OISC) with Transport Triggered Architecture (TTA).
11 | The operation it performs is Move.
12 | I call it NISC for Null Instruction Set Computer because the set of all opcodes is the null set.
13 | There is no instruction which tells it to Move. It just Moves.
14 | It is not related to [No Instruction Set Computing](https://en.wikipedia.org/wiki/No_instruction_set_computing).
15 | I didn't want to call it SISC for Single Instruction Set Computer because SISC sounds like CISC and I like to avoid confusion. I wasn't sure how to pronounce OISC. I also ruled out Mono-Instuction Set Computer (MISC) because I didn't want it filed under Misc.
16 | Although there is no opcode, instructions take two (or three) arguments.
17 | The arguments are source address, destination address, and immediate data.
18 | The source address and destination address are always present but the immediate data is optional.
19 | NISC is an entire family with a scalable architecture.
20 | What will be described is NISC6 because data and addresses are 2 to the 6th power (64 bits). NISC5 has 32 bit data and addresses.
21 | ## The Controller
22 | - There is a state machine which controls overall operation.
23 | - There are 3 registers which are not directly visible to the programmer.
24 | 1. SAR Source Address Register
25 | 2. DAR Destination Address Register
26 | 3. TMP Temporary Register
27 | - Everything else is memory mapped starting at the beginning of memory. There is a single memory space.
28 | - The memory is not byte addressable like many processors. Each address holds a 64 bit Word.
29 | - It is Little Endian where applicable.
30 | - Peripherals should be memory mapped.
31 |
32 | This is the Von Neumann version with unified code and data address space.
33 | Using a Harvard architecture with separate code and data spaces would double throughput but would require instruction invalidation for Jumps and Calls. I wanted to keep it simple.
34 | Making data and address widths equal allows us to fetch an address in a single cycle. If the data width is less than address width then multiple cycles are needed to fetch an address. With a wider data width, both addresses may be read at once saving a cycle.
35 |
36 | The state machine controller normally cycles through 4 states:
37 | 1. Output AP, Fetch Source Address, Increment AP (Argument Pointer, same as a Program Counter)
38 | 2. Output AP, Fetch Destination Address, Increment AP
39 | 3. Read from Source Address into TMP
40 | 4. Write TMP to Destination Address
41 | and then it repeats.
42 |
43 | Before it gets to state 1 the machine looks for Int and DMA Requests and will go to other states to acknowledge them. Once state 1 starts Int and DMA Requests will not be accepted again until state 4 finishes. Block instructions also alter this cycle by repeating state 3 and/or state 4 a counted number of times.
44 | ## Address Definitions
45 | ### Overview
46 | Processor addresses start at the beginning of memory. 128K Words Reserved for processor internals.
47 | Peripherals should be mapped following the processor addresses.
48 | RAM is mapped after the peripherals and before ROM.
49 | ROM is expected at the highest part of memory.
50 | ### Processor Addresses
51 |
52 |
53 | Addr | Width | Name | Read | Write | DMA Rd | DMA Wr | NOTES 1, 2, 3 |
54 |
55 |
56 | 0000 | 64 | AP | AP | Jump | AP | AP | 4 |
57 |
58 |
59 | 0001 | 64 | APX | (AP++) | Call | 0 | no effect | 5 |
60 |
61 |
62 | 0002 | 64 | RND | Random | Rel Jump | RND | no effect | 6 |
63 |
64 |
65 | 0003 | 64 | CTR | Count | Rel Call | CTR | no effect | 7 |
66 |
67 |
68 | 0004 | 64 | IAR | Int Addr Reg | Int Addr | IAR | IAR | 8, 9 |
69 |
70 |
71 | 0005 | 64 | ICR | Int Ctrl Reg | Int Ctrl Reg | ICR | ICR | 10 |
72 |
73 |
74 | 0006 | 64 | DMACR | DMA Ctrl Reg | DMA Ctrl Reg | DMACR | DMACR | 11 |
75 |
76 |
77 | 0007 | 64 | BLKCNT | BLKCNT Reg | BLKCNT Reg | BLKCNT | BLKCNT | 12 |
78 |
79 |
80 | 0008 | 64 | BLKCTRL | BLKCTRL Reg | BLKCTRL Reg | BLKCTRL | BLKCTRL | 13 |
81 |
82 |
83 | 0009 | 64 | ACC | ACC | ACC | ACC | ACC | 14 |
84 |
85 |
86 | 000A | 64 | ACCI | (ACC) | (ACC) | ACC | no effect | 15 |
87 |
88 |
89 | 000B | 64 | AND | CY | TMP AND ACC=>ACC | CY | CY | 16, 17 |
90 |
91 |
92 | 000C | 64 | OR | ZF | TMP OR ACC=>ACC | ZF | ZF | 16, 18 |
93 |
94 |
95 | 000D | 64 | XOR | BITCNT | TMP XOR ACC=>ACC | BITCNT | BITCNT | 16, 19 |
96 |
97 |
98 | 000E | 64 | ADD | BCRZ | TMP + ACC=>ACC | BCRZ | BCRZ | 20 |
99 |
100 |
101 | 000F | 64 | ADC | BCRO | TMP + ACC + C=>ACC | BCRO | BCRO | 21 |
102 |
103 |
104 | 0010 | 64 | SUB | BCLZ | ACC - TMP=>ACC | BCLZ | BCLZ | 22 |
105 |
106 |
107 | 0011 | 64 | SBB | BCLO | ACC - TMP - C=>ACC | BCLO | BCLO | 23 |
108 |
109 |
110 | 0012 | 64 | CMP | all 1s | adjust ZF and CY | all 1s | no effect | 24 |
111 |
112 |
113 | 0013 | 6 | SWAP | TBD | ACC modified | TBD | no effect | 25 |
114 |
115 |
116 | 0014 | 64 | ILVI | High ILVI | Bit interleave | High ILVI | load only | 26 |
117 |
118 |
119 | 0015 | 64 | DLVI | High DLVI | Bit deinterleave | High DLVI | load only | 27 |
120 |
121 |
122 | 0016 | 64 | ILVP | High ILVP | Pair interleave | High ILVP | load only | 28 |
123 |
124 |
125 | 0017 | 64 | DLVP | High DLVP | Pair deinterleave | High DLVP | load only | 29 |
126 |
127 |
128 | 0018 | 64 | ILVN | High ILVN | Nibble interleave | High ILVN | load only | 30 |
129 |
130 |
131 | 0019 | 64 | DLVN | High DLVN | Nibble deinterleave | High DLVN | load only | 31 |
132 |
133 |
134 | 001A | 64 | ILVB | High ILVB | Byte interleave | High ILVB | load only | 32 |
135 |
136 |
137 | 001B | 64 | DLVB | High DLVB | Byte deinterleave | High DLVB | load only | 33 |
138 |
139 |
140 | 001C | 64 | ILVQ | High ILVQ | Quarter interleave | High ILVQ | load only | 34 |
141 |
142 |
143 | 001D | 64 | DLVQ | High DLVQ | Quarter deinterleave | High DLVQ | load only | 35 |
144 |
145 |
146 | 001E | 64 | ILVH | High ILVH | Half interleave | High ILVH | load only | 36 |
147 |
148 |
149 | 001F | 64 | DLVH | High DLVH | Half deinterleave | High DLVH | load only | 37 |
150 |
151 |
152 | 0020 | 64 | CV | CV/NC Value | CV Value | CV Value | CV Value | 38 |
153 |
154 |
155 | 0021 | 64 | NC | CV/NC Value | NC Value | NC Value | NC Value | 39 |
156 |
157 |
158 | 0022 | 64 | ZV | ZV/NZ Value | ZV Value | ZV Value | ZV Value | 40 |
159 |
160 |
161 | 0023 | 64 | NZ | ZV/NZ Value | NZ Value | NZ Value | NZ Value | 41 |
162 |
163 |
164 | 0024 | 64 | PO | PO/PE Value | PO Value | PO Value | PO Value | 42 |
165 |
166 |
167 | 0025 | 64 | PE | PO/PE Value | PE Value | PE Value | PE Value | 43 |
168 |
169 |
170 | | | | | | | | 44 |
171 |
172 |
173 | 0030 | 64 | WReg0 | WReg0 | WReg0 | WReg0 | WReg0 | 45 |
174 |
175 |
176 | 0031 | 64 | WReg1 | WReg1 | WReg1 | WReg1 | WReg1 | 45 |
177 |
178 |
179 | 0032 | 64 | WReg2 | WReg2 | WReg2 | WReg2 | WReg2 | 45 |
180 |
181 |
182 | 0033 | 64 | WReg3 | WReg3 | WReg3 | WReg3 | WReg3 | 45 |
183 |
184 |
185 | 0034 | 64 | WReg4 | WReg4 | WReg4 | WReg4 | WReg4 | 45 |
186 |
187 |
188 | 0035 | 64 | WReg5 | WReg5 | WReg5 | WReg5 | WReg5 | 45 |
189 |
190 |
191 | 0036 | 64 | WReg6 | WReg6 | WReg6 | WReg6 | WReg6 | 45 |
192 |
193 |
194 | 0037 | 64 | WReg7 | WReg7 | WReg7 | WReg7 | WReg7 | 45 |
195 |
196 |
197 | 0038 | 64 | WReg8 | WReg8 | WReg8 | WReg8 | WReg8 | 45 |
198 |
199 |
200 | 0039 | 64 | WReg9 | WReg9 | WReg9 | WReg9 | WReg9 | 45 |
201 |
202 |
203 | 003A | 64 | WRegA | WRegA | WRegA | WRegA | WRegA | 45 |
204 |
205 |
206 | 003B | 64 | WRegB | WRegB | WRegB | WRegB | WRegB | 45 |
207 |
208 |
209 | 003C | 64 | WRegC | WRegC | WRegC | WRegC | WRegC | 45 |
210 |
211 |
212 | 003D | 64 | WRegD | WRegD | WRegD | WRegD | WRegD | 45 |
213 |
214 |
215 | 003E | 64 | WRegE | WRegE | WRegE | WRegE | WRegE | 45 |
216 |
217 |
218 | 003F | 64 | WRegF | WRegF | WRegF | WRegF | WRegF | 45 |
219 |
220 |
221 | 0040 to 007F | 64 | BRLS | | | | | 46 |
222 |
223 |
224 | 0080 | 64 | Cnt1 | Cnt1 | Cnt1 | Cnt1 | Cnt1 | 47 |
225 |
226 |
227 | 0081 | 64 | Lim1 | Lim1 | Lim1 | Lim1 | Lim1 | 48 |
228 |
229 |
230 | 0082 | 64 | Und1 | Und1 or Ovr1 | Und1 | Und1 | Und1 | 49 |
231 |
232 |
233 | 0083 | 64 | Ovr1 | Und1 or Ovr1 | Ovr1 | Ovr1 | Ovr1 | 50 |
234 |
235 |
236 | 0084 | 64 | Cnt2 | Cnt2 | Cnt2 | Cnt2 | Cnt2 | 51 |
237 |
238 |
239 | 0085 | 64 | Lim2 | Lim2 | Lim2 | Lim2 | Lim2 | 52 |
240 |
241 |
242 | 0086 | 64 | Und2 | Und2 or Ovr2 | Und2 | Und2 | Und2 | 53 |
243 |
244 |
245 | 0087 | 64 | Ovr2 | Und2 or Ovr2 | Ovr2 | Ovr2 | Ovr2 | 54 |
246 |
247 |
248 | 0088 | 64 | Cnt3 | Cnt3 | Cnt3 | Cnt3 | Cnt3 | 51 |
249 |
250 |
251 | 0089 | 64 | Lim3 | Lim3 | Lim3 | Lim3 | Lim3 | 52 |
252 |
253 |
254 | 008A | 64 | Und3 | Und3 or Ovr3 | Und3 | Und3 | Und3 | 53 |
255 |
256 |
257 | 008B | 64 | Ovr3 | Und3 or Ovr3 | Ovr3 | Ovr3 | Ovr3 | 54 |
258 |
259 |
260 | 008C | 64 | Cnt4 | Cnt4 | Cnt4 | Cnt4 | Cnt4 | 51 |
261 |
262 |
263 | 008D | 64 | Lim4 | Lim4 | Lim4 | Lim4 | Lim4 | 52 |
264 |
265 |
266 | 008E | 64 | Und4 | Und4 or Ovr4 | Und4 | Und4 | Und4 | 53 |
267 |
268 |
269 | 008F | 64 | Ovr4 | Und4 or Ovr4 | Ovr4 | Ovr4 | Ovr4 | 54 |
270 |
271 |
272 | 0090 | 64 | Cnt5 | Cnt5 | Cnt5 | Cnt5 | Cnt5 | 51 |
273 |
274 |
275 | 0091 | 64 | Lim5 | Lim5 | Lim5 | Lim5 | Lim5 | 52 |
276 |
277 |
278 | 0092 | 64 | Und5 | Und5 or Ovr5 | Und5 | Und5 | Und5 | 53 |
279 |
280 |
281 | 0093 | 64 | Ovr5 | Und5 or Ovr5 | Ovr5 | Ovr5 | Ovr5 | 54 |
282 |
283 |
284 | 0094 | 64 | Cnt6 | Cnt6 | Cnt6 | Cnt6 | Cnt6 | 51 |
285 |
286 |
287 | 0095 | 64 | Lim6 | Lim6 | Lim6 | Lim6 | Lim6 | 52 |
288 |
289 |
290 | 0096 | 64 | Und6 | Und6 or Ovr6 | Und6 | Und6 | Und6 | 53 |
291 |
292 |
293 | 0097 | 64 | Ovr6 | Und6 or Ovr6 | Ovr6 | Ovr6 | Ovr6 | 54 |
294 |
295 |
296 | 0098 | 64 | Cnt7 | Cnt7 | Cnt7 | Cnt7 | Cnt7 | 51 |
297 |
298 |
299 | 0099 | 64 | Lim7 | Lim7 | Lim7 | Lim7 | Lim7 | 52 |
300 |
301 |
302 | 009A | 64 | Und7 | Und7 or Ovr7 | Und7 | Und7 | Und7 | 53 |
303 |
304 |
305 | 009B | 64 | Ovr7 | Und7 or Ovr7 | Ovr7 | Ovr7 | Ovr7 | 54 |
306 |
307 |
308 | 009C | 64 | Cnt8 | Cnt8 | Cnt8 | Cnt8 | Cnt8 | 51 |
309 |
310 |
311 | 009D | 64 | Lim8 | Lim8 | Lim8 | Lim8 | Lim8 | 52 |
312 |
313 |
314 | 009E | 64 | Und8 | Und8 or Ovr8 | Und8 | Und8 | Und8 | 53 |
315 |
316 |
317 | 009F | 64 | Ovr8 | Und8 or Ovr8 | Ovr8 | Ovr8 | Ovr8 | 54 |
318 |
319 |
320 | 00Ax | 64 | RegAx | RegAx | RegAx | RegAx | RegAx | 55, 56 |
321 |
322 |
323 | 00Bx | 64 | RegBx | (RegAx) | (RegAx) | RegAx | no effect | 55, 57 |
324 |
325 |
326 | 00Cx | 64 | RegCx | (RegAx--) | (++RegAx) | RegAx | no effect | 55, 58 |
327 |
328 |
329 | 00Dx | 64 | RegDx | (--RegAx) | (RegAx++) | RegAx | no effect | 55, 59 |
330 |
331 |
332 | 00Ex | 64 | RegEx | (RegAx++) | (--RegAx) | RegAx | no effect | 55, 60 |
333 |
334 |
335 | 00Fx | 64 | RegFx | (++RegAx) | (RegAx--) | RegAx | no effect | 55, 61 |
336 |
337 |
338 | 0100 | 64 | CHOP | CHOP | CHOP | CHOP | CHOP | 62 |
339 |
340 |
341 | 0101 | 64 | CHOPI | (CHOP) | (CHOP) | 0 | no effect | 63 |
342 |
343 |
344 | 0102 0103 | 32 | CHOPLH CHOPHH | CHOP(31 downto 0) CHOP(63 downto 32) | CHOP(31 downto 0) CHOP(63 downto 32) | 0 | no effect | 64 |
345 |
346 |
347 | 0104 0105 0106 0107 | 16 | CHOPQ0 CHOPQ1 CHOPQ2 CHOPQ3 | CHOP(15 downto 0) CHOP(31 downto 16) CHOP(47 downto 32) CHOP(63 downto 48) | CHOP(15 downto 0) CHOP(31 downto 16) CHOP(47 downto 32) CHOP(63 downto 48) | 0 | no effect | 65 |
348 |
349 |
350 | 0108 to 010F | 8 | CHOPB0 to CHOPB7 | CHOP(7 downto 0) to CHOP(63 downto 56) | CHOP(7 downto 0) to CHOP(63 downto 56) | 0 | no effect | 66 |
351 |
352 |
353 | 0110 to 011F | 4 | CHOPN0 to CHOPN15 | CHOP(3 downto 0) to CHOP(63 downto 60) | CHOP(3 downto 0) to CHOP(63 downto 60) | 0 | no effect | 67 |
354 |
355 |
356 | 0120 to 013F | 2 | CHOPP0 to CHOPP31 | CHOP(1 downto 0) to CHOP(63 downto 62) | CHOP(1 downto 0) to CHOP(63 downto 62) | 0 | no effect | 68 |
357 |
358 |
359 | 0140 to 017F | 1 | CHOPB0 to CHOPB63 | CHOP(0) to CHOP(63) | CHOP(0) to CHOP(63) | 0 | no effect | 69 |
360 |
361 |
362 | | | | | | | | 44 |
363 |
364 |
365 | 10000 to 1FFFF | 64 | CONST | 0000 to FFFF | no effect | 0000 to FFFF | no effect | 70 |
366 |
367 |
368 |
369 | NOTES:
370 | 1. DMA Read and Write must be different to avoid triggering the TTA effects.
371 | 2. Only the 4 lowest hex digits of address are shown. The high 12 digits are all 0's.
372 | 3. Addresses not shown (skipped) are undefined and should Read as 0. Write should have no effect.
373 | 4. Argument Pointer is the same as a Program Counter. Reset sets all bits.
374 | 5. Reading APX reads from memory pointed to by AP and increments AP. Writing APX pushes AP onto the stack and loads AP (Call).
375 | - Reading APX is the only instruction which uses the third argument as immediate data.
376 | 6. RND is an LFSR (Read only) which shifts on each clock. Writing adds to AP (Relative Jump).
377 | 7. CTR is an up-counter incremented on every clock. Writing CTR pushes AP onto the stack and adds to AP (Relative Call).
378 | 8. Interrupt Address Register holds the address of the ISR (Interrupt Service Routine) called during Interrupt Acknowledge.
379 | 9. Only one interrupt is implemented in processor. External interrupt controller may expand this.
380 | 10. Interrupt Control Register is a work in progress. Enable/Disable Bit is a minimum.
381 | 11. DMA Control defaults to enabled and can be used for debugging, allowing a single processor cycle then reading all registers.
382 | 12. BLKCNT is a counter with the number of times to repeat an instruction, counts after Write cycle when enabled.
383 | 13. BLKCTRL controls block operation. When loaded, the next instruction is a block instruction.
384 | - Bit 0 - Setting this bit starts a Block Instruction
385 | - Bit 1 - 0 = decrement Block Counter, 1 = increment Block Counter
386 | - Bit 2 - 1 = increment SAR
387 | - Bit 3 - 1 = decrement SAR, when Bit 2 and Bit 3 are the same SAR is unchanged
388 | - Bit 4 - 1 = increment DAR
389 | - Bit 5 - 1 = decrement DAR, when Bit 4 and Bit 5 sre the same DAR is unchanged
390 | - Bit 6 - 1 = read only once, write using same data. Bits 2 and 3 are ignored. Typically used for block fill.
391 | 14. Accumulator is affected by writes to this and the following 7 addresses.
392 | 15. Accumulator Indirect uses ACC as a pointer to memory.
393 | 16. Write clears Carry Flag. Zero Flag is set if all ACC bits are zero, cleared otherwise.
394 | 17. Write to AND causes data to be ANDed with ACC. Reading returns CY (Carry Flag).
395 | 18. Write to OR causes data to be ORed with ACC. Reading returns ZF (Zero Flag).
396 | 19. Write to XOR causes data to be XORed with ACC. Reading returns BITCNT (Count of set bits in ACC) from 0 to 64.
397 | 20. Write to ADD adds data to ACC. CY and ZF are adjusted appropriately. BCRZ is bit count from right (LSB) to first zero.
398 | 21. Write to ADC adds data and CY to ACC. CY and ZF are adjusted. BCRO is bit count from right to first 1 (0 to 64).
399 | 22. Write to SUB subtracts data from ACC. CY and ZF are adjusted. BCLZ is bit count from left (MSB) to first zero.
400 | 23. Write to SBB subtracts data and CY from ACC. CY and ZF are adjusted. BCLZ is bit count from left to first 1 bit.
401 | 24. CMP is compare. ZF and CY are adjusted as if value was subtracted from ACC. ACC is unchanged.
402 | 25. Swaps parts of ACC. TBD means To Be Determined.
403 | - Bit 0 swaps Bits within Pairs
404 | - Bit 1 swaps Pairs within Nibbles
405 | - Bit 2 swaps Nibbles within Bytes
406 | - Bit 3 swaps Bytes within Quarter Words
407 | - Bit 4 swaps Quarter Words within Half Words
408 | - Bit 5 swaps Half Words within ACC
409 | 26. Individual Bits are interleaved with Bits of ACC. Low order bits are in ACC. High order bits are available here.
410 | 27. Individual Bits are deinterleaved with Bits of ACC. Odd bits in ACC. Even bits are available here.
411 | 28. Bit Pairs are interleaved with Bits of ACC. Low order Pairs are in ACC. High order Pairs are available here.
412 | 29. Bit Pairs are deinterleaved with Bits of ACC. Odd Pairs in ACC. Even Pairs are available here.
413 | 30. Nibbles are interleaved with ACC. Low order Nibbles are in ACC. High order Nibbles are available here.
414 | 31. Nibbles are deinterleaved with ACC. Odd Nibbles in ACC. Even Nibbles are available here.
415 | 32. Bytes are interleaved with ACC. Low order Bytes are in ACC. High order Bytes are available here.
416 | 33. Byte are deinterleaved with ACC. Odd Bytes in ACC. Even Bytes are available here.
417 | 34. Quarter Words are interleaved with ACC. Low order Quarters are in ACC. High order Quarters are available here.
418 | 35. Quarter Words are deinterleaved with ACC. Odd Quarters in ACC. Even Quarters are available here.
419 | 36. Half Words are interleaved with ACC. Low Halves are in ACC. High Halves are available here.
420 | 37. Half Words are deinterleaved with ACC. Odd Halves in ACC. Even Halves are available here.
421 | 38. Write to CV sets the value returned when reading either CV or NC if CY is set when reading.
422 | 39. Write to NC sets the value returned when reading either CV or NC if CY is clear when reading.
423 | 40. Write to ZV sets the value returned when reading either ZV or NZ if ZF is set when reading.
424 | 41. Write to NZ sets the value returned when reading either ZV or NZ if ZF is clear when reading.
425 | 42. Write to PO sets the value returned when reading either PO or PE if BITCNT(0) is set when reading. Parity odd.
426 | 43. Write to PE sets the value returned when reading either PO or PE if BITCNT(0) is clear when reading. Parity even.
427 | 44. Space for more stuff.
428 | 45. Working Registers. These 16 registers do nothing special. They are just like RAM except they never generate wait states.
429 | 46. Barrel Rotate. There is only one register here. All addresses in this range read and write to it rotated relative to their addresses. Write to 30 and read from 31 rotates one bit to the right. Write to 38 and read from 30 rotates 8 bits to the left.
430 | 47. Unsigned counter which counts down when Und1 is read and counts up when Ovr1 is read.
431 | 48. Unsigned Limit register against which Cnt1 is compared.
432 | 49. Unsigned register which returns Und1 if Cnt1 =< Lim1 else returns Ovr1. Reading decrements Cnt1. DMA Rd does not affect Cnt1.
433 | 50. Unsigned register which returns Ovr1 if Cnt1 >= Lim1 else returns Und1. Reading increments Cnt1. DMA Rd does not affect Cnt1.
434 | 51. Unsigned counter similar to Cnt1.
435 | 52. Unsigned Limit register similar to Lim1.
436 | 53. Unsigned register similar to Und1.
437 | 54. Unsigned register similar to Ovr1.
438 | 55. x here means all values from 0 to F.
439 | 56. There are sixteen registers.
440 | 57. These addresses use the Ax registers as memory pointers for read and write.
441 | 58. These addresses use the Ax registers as stack pointers. Postdecremented read, Preincremented write.
442 | 59. These addresses use the Ax registers as stack pointers. Predecremented read, Postincremented write.
443 | 60. These addresses use the Ax registers as stack pointers. Postincremented read, Predecremented write.
444 | 61. These addresses use the Ax registers as stack pointers. Preincremented read, Postdecremented write.
445 | - 00FF is the system stack used for Call and Relative Call when the AP gets pushed.
446 | 62. There is only one register in the next 0x80 addresses. It gets CHOPped into pieces and put back together.
447 | 63. CHOP may be used as a memory pointer by using this address.
448 | 64. CHOP Low Half and Chop High Half are read and written here. They are in the low bits of a read. The high bits of the read are all zeroes. Only the low bits of a write are used. The high bits of the write are irrelevant and ignored.
449 | 65. CHOP in 4 16-bit quarters. Upper bits are zeroes for read and don't care for write.
450 | 66. CHOP 8 Bytes.
451 | 67. CHOP 16 Nibbles (4 Bits each).
452 | 68. CHOP Pairs of Bits. There are 32 of them.
453 | 69. CHOP Bits, all 64 of them individually addressable.
454 | 70. Small constant ROM. There is not actually a ROM here. With a little bit of hardware we can detect reads in this range and return the low 16 bits of address, eliminating the need to store small constants in the 0000-FFFF range in memory or to use them as immediate data in APX read instruction. With the huge memory space we have, I don't consider this wasteful.
455 |
--------------------------------------------------------------------------------
/TopCtrl.vhd:
--------------------------------------------------------------------------------
1 | -- TopCtrl.vhdl
2 | -- Version 2.0
3 | -- Overall Machine State Controller for NISC
4 | -- Word Size = Addr Size for this model
5 | -- Interrupt Control
6 | -- DMA Control
7 | -- 4 cycle and block multi-cycle
8 | -- Fetch Src Addr
9 | -- Fetch Dst Addr
10 | -- Read Src
11 | -- Write Dest
12 |
13 | library IEEE;
14 | use IEEE.STD_LOGIC_1164.ALL;
15 | use IEEE.STD_LOGIC_ARITH.ALL;
16 | use IEEE.STD_LOGIC_UNSIGNED.ALL;
17 |
18 | entity TopCtrl is
19 | Port ( CLK : in std_logic; -- System Clock
20 | Reset_In : in std_logic; -- Reset Signal
21 | Ready : in std_logic; -- Ready Signal
22 | Rept : in std_logic; -- Block Repeat (repeats Read and Write)
23 | UseFSrc : in std_logic; -- Use First Source (Reads once and repeats Write)
24 | BUSRQ : in std_logic; -- DMA Bus Request
25 | INTRQ : in std_logic; -- Interrupt Request
26 | DMA_EN : in std_logic; -- DMA Enabled Status
27 | INT_EN : in std_logic; -- Interrupt Enabled Status
28 | Reset_Out : out std_logic; -- System Reset
29 | BUSACK : out std_logic; -- Bus Grant Acknowledged
30 | INTACK : out std_logic; -- Interrupt Acknowledged
31 | Fetch : out std_logic; -- Instruction Fetch Cycle
32 | SorD : out std_logic; -- Fetch SrcAddr or DstAddr
33 | Mem_RD : out std_logic; -- Memory Read Cycle
34 | Mem_WR : out std_logic); -- Memory Write Cycle
35 | end TopCtrl;
36 |
37 | architecture Behavioral of TopCtrl is
38 |
39 | type CycleCtrl_type is (State_Reset, State_BusGrant, State_IntStart, State_IntFinish, State_FetchSA, State_FetchDA, State_SourceRd, State_DestWr);
40 |
41 | signal TopState : CycleCtrl_type := State_Reset;
42 |
43 | signal reset_i : std_logic;
44 | signal busack_p : std_logic;
45 | signal intack_p : std_logic;
46 | signal fetch_p : std_logic;
47 | signal Mem_RD_p : std_logic;
48 | signal Mem_WR_p : std_logic;
49 | signal ready_i : std_logic;
50 | signal DMA_EN_i : std_logic;
51 | signal INT_EN_i : std_logic;
52 | signal SorD_i : std_logic;
53 |
54 | begin
55 |
56 | TopCtrl_State : process (CLK, Reset_In) is
57 |
58 | begin
59 | if rising_edge(CLK) then
60 | if Reset_In='1' then
61 | TopState <= State_Reset;
62 | else
63 | case TopState is
64 | -- Reset
65 | when State_Reset =>
66 | if (Reset_In = '1') then
67 | TopState <= State_Reset;
68 | elsif (BUSRQ = '1' AND DMA_EN_i = '1') then
69 | TopState <= State_BusGrant;
70 | elsif (INTRQ = '1' AND INT_EN_i = '1') then
71 | TopState <= State_IntStart;
72 | else
73 | TopState <= State_FetchSA;
74 | end if;
75 | -- DMA (External)
76 | when State_BusGrant =>
77 | if (BUSRQ = '1') then
78 | TopState <= State_BusGrant; -- continue bus grant
79 | elsif (BUSRQ = '0') then
80 | if (INTRQ = '1' AND INT_EN_i = '1') then
81 | TopState <= State_IntStart; -- service interrupt
82 | else
83 | TopState <= State_FetchSA; -- resume processing
84 | end if;
85 | end if;
86 | -- INT
87 | when State_IntStart => -- PC --> Stack
88 | if (ready_i = '0') then
89 | TopState <= State_IntStart;
90 | elsif (ready_i = '1') then
91 | TopState <= State_IntFinish;
92 | end if;
93 |
94 | when State_IntFinish => -- ISR Addr --> PC
95 | if (ready_i = '0') then
96 | TopState <= State_IntFinish;
97 | elsif (ready_i = '1') then
98 | if (BUSRQ = '1' AND DMA_EN_i = '1') then
99 | TopState <= State_BusGrant; -- bus grant
100 | else
101 | TopState <= State_FetchSA; -- resume processing
102 | end if;
103 | end if;
104 | -- Source Addr Fetch
105 | when State_FetchSA => -- Get Src Addr
106 | if (ready_i = '0') then
107 | TopState <= State_FetchSA;
108 | elsif (ready_i = '1') then
109 | TopState <= State_FetchDA;
110 | end if;
111 |
112 | -- Dest Addr Fetch
113 | when State_FetchDA => -- Get Dest Addr
114 | if (ready_i = '0') then
115 | TopState <= State_FetchDA;
116 | elsif (ready_i = '1') then
117 | TopState <= State_SourceRd;
118 | end if;
119 | -- Source RD
120 | when State_SourceRd => -- Read from Src Addr
121 | if (ready_i = '0') then
122 | TopState <= State_SourceRd;
123 | elsif (ready_i = '1') then
124 | TopState <= State_DestWr;
125 | end if;
126 | -- Dest WR
127 | when State_DestWr => -- Write to Dest Addr
128 | if (ready_i = '0') then
129 | TopState <= State_DestWr;
130 | elsif (ready_i = '1') then
131 | if (Rept = '1') then -- Block Mode
132 | if (UseFSrc = '1') then -- Block Fill
133 | TopState <= State_DestWr;
134 | else
135 | TopState <= State_SourceRd;
136 | end if;
137 | elsif (BUSRQ = '1' AND DMA_EN_i = '1') then
138 | TopState <= State_BusGrant;
139 | elsif (INTRQ = '1' AND INT_EN_i = '1') then
140 | TopState <= State_IntStart;
141 | else
142 | TopState <= State_FetchSA;
143 | end if;
144 | end if;
145 | when others =>
146 | TopState <= State_Reset;
147 | end case;
148 | end if;
149 | end if;
150 | end process;
151 |
152 |
153 | ready_i <= Ready;
154 | DMA_EN_i <= DMA_EN;
155 | INT_EN_i <= INT_EN;
156 |
157 | -- signal assignment statements for combinatorial outputs
158 |
159 | reset_i <= '1' when (TopState = State_Reset) else
160 | '0';
161 |
162 | busack_p <= '1' when (TopState = State_BusGrant) else
163 | '0';
164 |
165 | intack_p <= '1' when (TopState = State_IntStart) else
166 | '1' when (TopState = State_IntFinish) else
167 | '0';
168 |
169 | fetch_p <= '1' when (TopState = State_FetchSA) or (TopState = State_FetchDA) else
170 | '0';
171 |
172 | SorD_i <= '1' when (TopState = State_FetchDA) else
173 | '0';
174 |
175 | Mem_RD_p <= '1' when (TopState = State_SourceRd) else
176 | '0';
177 |
178 | Mem_WR_p <= '1' when (TopState = State_DestWr) else
179 | '1' when (TopState = State_IntStart) else
180 | '0';
181 |
182 | Reset_Out <= reset_i;
183 | BUSACK <= busack_p;
184 | INTACK <= intack_p;
185 | Fetch <= fetch_p;
186 | SorD <= SorD_i;
187 | Mem_RD <= Mem_RD_p;
188 | Mem_WR <= Mem_WR_p;
189 |
190 | end Behavioral;
191 |
--------------------------------------------------------------------------------