1 |
2 |
howe.r.j.8 |
# BIT SERIAL CPU and TOOL-CHAIN
|
2 |
|
|
|
3 |
|
|
* Project: Bit-Serial CPU in VHDL
|
4 |
|
|
* Author: Richard James Howe
|
5 |
|
|
* Copyright: 2019,2020 Richard James Howe
|
6 |
|
|
* License: MIT
|
7 |
|
|
* Email: howe.r.j.89@gmail.com
|
8 |
|
|
* Website:
|
9 |
|
|
|
10 |
|
|
*Processing data one bit at a time, since 2019*.
|
11 |
|
|
|
12 |
|
|
# Introduction
|
13 |
|
|
|
14 |
|
|
This is a project for a [bit-serial CPU][], which is a CPU that has an architecture
|
15 |
|
|
which processes a single bit at a time instead of in parallel like a normal
|
16 |
|
|
CPU. This allows the CPU itself to be a lot smaller, the penalty is that it is
|
17 |
|
|
*a lot* slower. The CPU itself is called *bcpu*.
|
18 |
|
|
|
19 |
|
|
The CPU is incredibly basic, lacking features required to support
|
20 |
|
|
higher level programming (such as function calls). Instead such features can
|
21 |
|
|
be emulated if they are needed. If such features are needed, or faster
|
22 |
|
|
throughput (whilst still remaining quite small) other [Soft-Core][] CPUs are
|
23 |
|
|
available, such as the [H2][].
|
24 |
|
|
|
25 |
|
|
To build and run the C based simulator for the project, you will need a C
|
26 |
|
|
compiler and 'make'. To build and run the [VHDL][] simulator, you will need [GHDL][]
|
27 |
|
|
installed.
|
28 |
|
|
|
29 |
|
|
The cross compiler requires [gforth][], although a pre-compiled image is
|
30 |
|
|
provided in case you do not have access to it, called '[bit.hex][]', this hex file
|
31 |
|
|
contains a working [Forth][] image. To run this:
|
32 |
|
|
|
33 |
|
|
make bit
|
34 |
|
|
./bit bit.hex
|
35 |
|
|
|
36 |
|
|
An example session of the simulator running is:
|
37 |
|
|
|
38 |
|
|
![C Simulator Running eForth](bit-sim.gif)
|
39 |
|
|
|
40 |
|
|
You should be greeted by a [Forth][] prompt, type 'words' and hit a carriage
|
41 |
|
|
return to get a list of defined functions.
|
42 |
|
|
|
43 |
|
|
The target [FPGA][] that the system is built for is a [Spartan-6][], for a
|
44 |
|
|
[Nexys 3][] development board. [Xilinx ISE 14.7][] was used to build the
|
45 |
|
|
project.
|
46 |
|
|
|
47 |
|
|
The following 'make' targets are available:
|
48 |
|
|
|
49 |
|
|
make
|
50 |
|
|
|
51 |
|
|
By default the [VHDL][] test bench is built and simulated in [GHDL][]. This
|
52 |
|
|
requires [gforth][] to assemble the test program [bit.fth][] into a file
|
53 |
|
|
readable by the simulator.
|
54 |
|
|
|
55 |
|
|
make run
|
56 |
|
|
|
57 |
|
|
This target builds the C based simulator, assembles the test program
|
58 |
|
|
and runs the simulator on the assembled program.
|
59 |
|
|
|
60 |
|
|
make synthesis implementation bitfile
|
61 |
|
|
|
62 |
|
|
This builds the project for the [FPGA][].
|
63 |
|
|
|
64 |
|
|
make upload
|
65 |
|
|
|
66 |
|
|
This uploads the project to the [Nexys 3][] board. This requires that
|
67 |
|
|
'djtgcfg' is installed, which is a tool provided by [Digilent][].
|
68 |
|
|
|
69 |
|
|
make documentation
|
70 |
|
|
|
71 |
|
|
This turns this 'readme.md' file into a HTML file.
|
72 |
|
|
|
73 |
|
|
make clean
|
74 |
|
|
|
75 |
|
|
Cleans up the project.
|
76 |
|
|
|
77 |
|
|
# eForth
|
78 |
|
|
|
79 |
|
|
The tool-chain for the device is used to build an image for a Forth
|
80 |
|
|
interpreter, more specifically a Forth interpreter similar to a dialect of
|
81 |
|
|
Forth known as 'eForth', it differs between eForth in order to save on space
|
82 |
|
|
which is at a premium. You should be greeted with an eForth prompt when running
|
83 |
|
|
the 'make run' target that looks something like this:
|
84 |
|
|
|
85 |
|
|
$ make run
|
86 |
|
|
./bit bit.hex
|
87 |
|
|
eForth 3.1
|
88 |
|
|
|
89 |
|
|
You can see all of the defined words (or functions) by typing in 'words' and
|
90 |
|
|
hitting return.
|
91 |
|
|
|
92 |
|
|
$ make run
|
93 |
|
|
./bit bit.hex
|
94 |
|
|
eForth 3.1
|
95 |
|
|
words
|
96 |
|
|
|
97 |
|
|
Arithmetic in Forth in done using Reverse Polish Notation:
|
98 |
|
|
|
99 |
|
|
2 2 + . cr
|
100 |
|
|
|
101 |
|
|
Will print out '4'. This is not the place for a Forth tutorial, the Forth
|
102 |
|
|
interpreter is mainly here to demonstrate that the bit-serial CPU is working
|
103 |
|
|
correctly and can be used for useful purposes. No demonstration would be
|
104 |
|
|
complete without a 'Hello, World' program, however:
|
105 |
|
|
|
106 |
|
|
: hello cr ." Hello, World!" ;
|
107 |
|
|
hello
|
108 |
|
|
|
109 |
|
|
Go use your favorite search engine to find a Forth tutorial.
|
110 |
|
|
|
111 |
|
|
# Use Case
|
112 |
|
|
|
113 |
|
|
Often in an [FPGA][] design there is spare Dual Port Block RAM (BRAM) available,
|
114 |
|
|
either because only part of the BRAM module is being used or because it is not
|
115 |
|
|
needed entirely. Adding a new CPU however is a bigger decision than using spare
|
116 |
|
|
BRAM capacity, it can take up quite a lot of floor space, and perhaps other
|
117 |
|
|
precious resources. If this is the case then adding this CPU costs practically
|
118 |
|
|
nothing in terms of floor space, the main cost will be in development time.
|
119 |
|
|
|
120 |
|
|
In short, the project may be useful if:
|
121 |
|
|
|
122 |
|
|
* FPGA Floor space is at a premium in your design.
|
123 |
|
|
* You have spare memory for the program and storage.
|
124 |
|
|
* You need a programmable CPU that supports a reasonable instruction set.
|
125 |
|
|
* *Execution speed is not a concern*.
|
126 |
|
|
|
127 |
|
|
There were two use cases that the author had in mind when setting out to build
|
128 |
|
|
this system:
|
129 |
|
|
|
130 |
|
|
* As a CPU driving a low-baud UART
|
131 |
|
|
* As a controller for a VT100 terminal emulator that would control cursor
|
132 |
|
|
position and parse escape codes, setting colors and attributes in a hardware
|
133 |
|
|
based text-terminal (this was to replace an existing VHDL only system that
|
134 |
|
|
had spare capacity in the FPGAs dual-port block RAMs used to store the Font
|
135 |
|
|
and text).
|
136 |
|
|
|
137 |
|
|
# Tool-chain
|
138 |
|
|
|
139 |
|
|
The tool-chain consists of a cross compiler written in Forth, it itself
|
140 |
|
|
implements a virtual machine on top of which a Forth interpreter is written.
|
141 |
|
|
The accumulator machine lacks call/returns, and a stack, so these have to be
|
142 |
|
|
implemented. The meta-compiler (a Forth specific term for what is a
|
143 |
|
|
more widely known as a cross-compiler) is available in [bit.fth][].
|
144 |
|
|
|
145 |
|
|
As the instruction set is anemic and CPU features lacking it is best to target
|
146 |
|
|
the virtual machine and program in Forth than it is to program in assembly.
|
147 |
|
|
|
148 |
|
|
Despite the inherently slow speed of the design and the further slow down
|
149 |
|
|
executing code on top of a virtual machine the interpreter is plenty fast
|
150 |
|
|
enough for interactive use, slowing down noticeably when division has to be
|
151 |
|
|
performed.
|
152 |
|
|
|
153 |
|
|
# CPU Specification
|
154 |
|
|
|
155 |
|
|
The CPU is a 16-bit design, in principle a normal bit parallel CPU design could
|
156 |
|
|
be implemented of the same CPU, but in practice you not end up with a CPU like
|
157 |
|
|
this one if you remove the bit-serial restriction.
|
158 |
|
|
|
159 |
|
|
The CPU has 16 operation, each instruction consists of a 4-bit operation field
|
160 |
|
|
and a 12-bit operand. Depending on the CPU mode that operand and instruction
|
161 |
|
|
that operand can either be a literal or an address to load a 16-bit word from
|
162 |
|
|
(addresses are word and not byte oriented, so the lowest bit of an address
|
163 |
|
|
specifies the next word not byte). Only the first 8 operations can have their
|
164 |
|
|
operand indirected, which is deliberate.
|
165 |
|
|
|
166 |
|
|
The CPU is an accumulator machine, all instructions either modify or use the
|
167 |
|
|
accumulator to store operation results in them. The CPU has three registers
|
168 |
|
|
including the accumulator, the other two are the program counter which is
|
169 |
|
|
automatically incremented after each instruction excluding the jump
|
170 |
|
|
instructions (the SET instruction is also excluded when setting the program
|
171 |
|
|
counter only) and a flags register.
|
172 |
|
|
|
173 |
|
|
The instructions are:
|
174 |
|
|
|
175 |
|
|
| ----------- | -------------------------------------- | --------------------------------- | ---------------- |
|
176 |
|
|
| Instruction | C Operation | Description | Cycles |
|
177 |
|
|
| ----------- | -------------------------------------- | --------------------------------- | ---------------- |
|
178 |
|
|
| OR | acc |= lop | Bitwise Or | [3 or 5]*(N+1) |
|
179 |
|
|
| AND | acc &= lop | Bitwise And | [3 or 5]*(N+1) |
|
180 |
|
|
| XOR | acc ^= lop | Bitwise Exclusive Or | [3 or 5]*(N+1) |
|
181 |
|
|
| ADD | acc += lop | Add with carry, sets carry | [3 or 5]*(N+1) |
|
182 |
|
|
| LSHIFT | acc = acc << lop (or rotate left) | Shift left or Rotate left | [3 or 5]*(N+1) |
|
183 |
|
|
| RSHIFT | acc = acc >> lop (or rotate right) | Shift right or Rotate right | [3 or 5]*(N+1) |
|
184 |
|
|
| LOAD | acc = memory(lop) | Load | [4 or 6]*(N+1) |
|
185 |
|
|
| STORE | memory(lop) = acc | Store | [4 or 6]*(N+1) |
|
186 |
|
|
| LOADC | acc = memory(op) | Load from memory constant addr | 4*(N+1) |
|
187 |
|
|
| STOREC | memory(op) = acc | Store to memory constant addr | 4*(N+1) |
|
188 |
|
|
| LITERAL | acc = op | Load literal into accumulator | 3*(N+1) |
|
189 |
|
|
| UNUSED | N/A | Unused instruction | 3*(N+1) |
|
190 |
|
|
| JUMP | pc = op | Unconditional Jump | 2*(N+1) |
|
191 |
|
|
| JUMPZ | if(!acc){pc = op } | Jump If Zero | [2 or 3]*(N+1) |
|
192 |
|
|
| SET | if(op&1){flg=acc}else{pc=acc} | Set Register | 3*(N+1) |
|
193 |
|
|
| GET | if(op&1){acc=flg}else{acc=pc} | Get Register | 3*(N+1) |
|
194 |
|
|
| ----------- | -------------------------------------- | --------------------------------- | ---------------- |
|
195 |
|
|
|
196 |
|
|
* pc = program counter
|
197 |
|
|
* acc = accumulator
|
198 |
|
|
* indir = indirect flag
|
199 |
|
|
* lop = instruction operand if indirect flag not set, otherwise it equals to the memory
|
200 |
|
|
location pointed to by the operand
|
201 |
|
|
* op = instruction operand
|
202 |
|
|
* flg = flags register
|
203 |
|
|
* N = bit width, which is 16.
|
204 |
|
|
|
205 |
|
|
The number of cycles an instruction takes to complete depends on whether it
|
206 |
|
|
performs an indirection, or in the case of GET/SET it depends if it it setting
|
207 |
|
|
the program counter (2 cycles only) or the flags register (3 cycles), or performing
|
208 |
|
|
an I/O operation (4 cycles), getting the flags or program counter always costs
|
209 |
|
|
3 cycles.
|
210 |
|
|
|
211 |
|
|
The flags in the 'flg' register are:
|
212 |
|
|
|
213 |
|
|
| ---- | --- | --------------------------------------- |
|
214 |
|
|
| Flag | Bit | Description |
|
215 |
|
|
| ---- | --- | --------------------------------------- |
|
216 |
|
|
| Cy | 0 | Carry flag, set by addition instruction |
|
217 |
|
|
| Z | 1 | Zero flag |
|
218 |
|
|
| Ng | 2 | Negative flag |
|
219 |
|
|
| R | 3 | Reset Flag - Resets the CPU |
|
220 |
|
|
| HLT | 4 | Halt Flag - Stops the CPU |
|
221 |
|
|
| ---- | --- | --------------------------------------- |
|
222 |
|
|
|
223 |
|
|
* The carry flag (Cy) is set by the ADD instruction, it can also be set and cleared
|
224 |
|
|
with the GET/SET instructions.
|
225 |
|
|
* 'Z' is set whenever the accumulator is zero.
|
226 |
|
|
* 'Ng' is set whenever the accumulator has its highest bit set, indicating that
|
227 |
|
|
the accumulator is negative.
|
228 |
|
|
* 'R', Reset flag, this resets the CPU immediately, only the HLT flag takes
|
229 |
|
|
precedence.
|
230 |
|
|
* 'HLT', The halt flag takes priority over everything else, sending the CPU
|
231 |
|
|
into a halt state.
|
232 |
|
|
|
233 |
|
|
There is really not much else to this CPU from the point of view of a user of
|
234 |
|
|
this core, integrating this core into another system is more complicated
|
235 |
|
|
however, you will need to be far more aware of timing of signals and their
|
236 |
|
|
enable lines. Much like the processor, a single bit bus in conjunction with an
|
237 |
|
|
enable is used to communicate with the outside world.
|
238 |
|
|
|
239 |
|
|
The internal state of the CPU is minimal, to make a working system the memory
|
240 |
|
|
and I/O controller will need (shift) registers to store the address and
|
241 |
|
|
input/output.
|
242 |
|
|
|
243 |
|
|
The CPU state-machine is:
|
244 |
|
|
|
245 |
|
|
![CPU State Machine](bit-state.png)
|
246 |
|
|
|
247 |
|
|
And the CPU bus timing diagram:
|
248 |
|
|
|
249 |
|
|
![CPU Bus timing](bit-wave.png)
|
250 |
|
|
|
251 |
|
|
|
252 |
|
|
# Peripherals
|
253 |
|
|
|
254 |
|
|
The system has a minimal set of peripherals; a bank of switches with LEDs next
|
255 |
|
|
to each switch and a UART capable of transmission and reception, other
|
256 |
|
|
peripherals could be added as needed.
|
257 |
|
|
|
258 |
|
|
## Register Map
|
259 |
|
|
|
260 |
|
|
The I/O register map for the device is very small as there are very few
|
261 |
|
|
peripherals.
|
262 |
|
|
|
263 |
|
|
| ------- | -------------- |
|
264 |
|
|
| Address | Name |
|
265 |
|
|
| ------- | -------------- |
|
266 |
|
|
| 0x4000 | LED/Switches |
|
267 |
|
|
| 0x4001 | UART TX/RX |
|
268 |
|
|
| 0x4002 | UART Clock TX* |
|
269 |
|
|
| 0x4003 | UART Clock RX* |
|
270 |
|
|
| 0x4004 | UART Control* |
|
271 |
|
|
| ------- | -------------- |
|
272 |
|
|
These registers are turned off by default
|
273 |
|
|
and will need to be enabled during synthesis.
|
274 |
|
|
|
275 |
|
|
* LED/Switches
|
276 |
|
|
|
277 |
|
|
A bank of switches, non-debounced, with LED lights next to them.
|
278 |
|
|
|
279 |
|
|
+---------------------------------------------------------------+
|
280 |
|
|
| F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
281 |
|
|
+---------------------------------------------------------------+
|
282 |
|
|
| | Switches 1 = on, 0 = off | READ
|
283 |
|
|
+---------------------------------------------------------------+
|
284 |
|
|
| | LED 1 = on, 0 = off | WRITE
|
285 |
|
|
+---------------------------------------------------------------+
|
286 |
|
|
|
287 |
|
|
* UART TX/RX
|
288 |
|
|
|
289 |
|
|
The UART TX/RX register is used to read and write data bytes to the UART and
|
290 |
|
|
check on the UART status. The UART has a FIFO that is used to capture the
|
291 |
|
|
results of the UART. The usage of which is non-optional.
|
292 |
|
|
|
293 |
|
|
+---------------------------------------------------------------+
|
294 |
|
|
| F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
295 |
|
|
+---------------------------------------------------------------+
|
296 |
|
|
| |TFF|TFE| |RFF|RFE| RX DATA BYTE | READ
|
297 |
|
|
+---------------------------------------------------------------+
|
298 |
|
|
| |TFW| |RFR| | TX DATA BYTE | WRITE
|
299 |
|
|
+---------------------------------------------------------------+
|
300 |
|
|
RFE = RX FIFO EMPTY
|
301 |
|
|
RFF = RX FIFO FULL
|
302 |
|
|
RFR = RX FIFO READ ENABLE
|
303 |
|
|
TFE = TX FIFO EMPTY
|
304 |
|
|
TFF = TX FIFO FULL
|
305 |
|
|
TFW = TX FIFO WRITE ENABLE
|
306 |
|
|
|
307 |
|
|
* UART Clock TX
|
308 |
|
|
|
309 |
|
|
The UART Transmission clock, independent from the Reception Clock, is
|
310 |
|
|
controllable via this register.
|
311 |
|
|
|
312 |
|
|
Defaults are: 115200 Baud
|
313 |
|
|
|
314 |
|
|
+---------------------------------------------------------------+
|
315 |
|
|
| F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
316 |
|
|
+---------------------------------------------------------------+
|
317 |
|
|
| | READ
|
318 |
|
|
+---------------------------------------------------------------+
|
319 |
|
|
| UART TX CLOCK DIVISOR | WRITE
|
320 |
|
|
+---------------------------------------------------------------+
|
321 |
|
|
|
322 |
|
|
* UART Clock RX
|
323 |
|
|
|
324 |
|
|
The UART Reception clock, independent from the Transmission Clock, is
|
325 |
|
|
controllable via this register.
|
326 |
|
|
|
327 |
|
|
Defaults are: 115200 Baud
|
328 |
|
|
|
329 |
|
|
+---------------------------------------------------------------+
|
330 |
|
|
| F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
331 |
|
|
+---------------------------------------------------------------+
|
332 |
|
|
| | READ
|
333 |
|
|
+---------------------------------------------------------------+
|
334 |
|
|
| UART RX CLOCK DIVISOR | WRITE
|
335 |
|
|
+---------------------------------------------------------------+
|
336 |
|
|
|
337 |
|
|
* UART Clock Control
|
338 |
|
|
|
339 |
|
|
This clock is used to control UART options such as the number of bits,
|
340 |
|
|
|
341 |
|
|
Defaults are: 8N1, no parity
|
342 |
|
|
|
343 |
|
|
+---------------------------------------------------------------+
|
344 |
|
|
| F | E | D | C | B | A | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|
345 |
|
|
+---------------------------------------------------------------+
|
346 |
|
|
| | READ
|
347 |
|
|
+---------------------------------------------------------------+
|
348 |
|
|
| | DATA BITS |STPBITS|EPA|UPA| WRITE
|
349 |
|
|
+---------------------------------------------------------------+
|
350 |
|
|
UPA = USE PARITY BITS
|
351 |
|
|
EPA = EVEN PARITY
|
352 |
|
|
STPBITS = Number of stop bits
|
353 |
|
|
DATA BITS = Number of data bits
|
354 |
|
|
|
355 |
|
|
|
356 |
|
|
# Other Soft Microprocessors
|
357 |
|
|
|
358 |
|
|
This is a *very* specialized core, that cannot be emphasized enough. It
|
359 |
|
|
executes slowly, but is small. Other, larger core (but still relatively small)
|
360 |
|
|
may be useful for your needs. In terms of engineering trade offs this design
|
361 |
|
|
takes things to the extreme in one direction only.
|
362 |
|
|
|
363 |
|
|
The core should be written to be portable to different [FPGA][]s, however the
|
364 |
|
|
author only tests what they have available (Xilinx, Spartan-6).
|
365 |
|
|
|
366 |
|
|
* The H2
|
367 |
|
|
|
368 |
|
|
Another small core, based on the J1. This core executes quite quickly (1
|
369 |
|
|
instruction per CPU cycle) and uses
|
370 |
|
|
few resources, although much more than this core. The instruction set is quite
|
371 |
|
|
dense and allows for higher level programming than just using straight
|
372 |
|
|
assembler. See .
|
373 |
|
|
|
374 |
|
|
This CPU core has deeper stacks, more instructions, and interrupts, which the
|
375 |
|
|
original J1 core lacks. It is also written in VHDL instead of Verilog.
|
376 |
|
|
|
377 |
|
|
* Tiny CPU in a CPLD
|
378 |
|
|
|
379 |
|
|
This is a 8-bit CPU designed to fit in the limited resources of a CPLD:
|
380 |
|
|
|
381 |
|
|
See and
|
382 |
|
|
.
|
383 |
|
|
|
384 |
|
|
It is written in Verilog, it is based on the 6502, implementing a subset of its
|
385 |
|
|
instructions. It is probably easier to directly program than this bit-serial
|
386 |
|
|
CPU, and roughly the same size (although a direct comparison is difficult).
|
387 |
|
|
It can address less memory (1K) without bank-switching. There is also a
|
388 |
|
|
different version made with 7400 series logic gates
|
389 |
|
|
.
|
390 |
|
|
|
391 |
|
|
* Leros and Lipsi
|
392 |
|
|
|
393 |
|
|
See ,
|
394 |
|
|
also ,
|
395 |
|
|
|
396 |
|
|
# References / Appendix
|
397 |
|
|
|
398 |
|
|
The state-machine diagram was made using [Graphviz][], and can be viewed and
|
399 |
|
|
edited immediately by copying the following text into [GraphvizOnline][].
|
400 |
|
|
|
401 |
|
|
|
402 |
|
|
digraph bcpu {
|
403 |
|
|
reset -> fetch [label="start"]
|
404 |
|
|
fetch -> execute
|
405 |
|
|
fetch -> indirect [label="flag(IND) = '1'\n and op < 8"]
|
406 |
|
|
fetch -> reset [label="flag(RST) = '1'"]
|
407 |
|
|
fetch -> halt [label="flag(HLT) = '1'"]
|
408 |
|
|
indirect -> operand
|
409 |
|
|
operand -> execute
|
410 |
|
|
execute -> advance
|
411 |
|
|
execute -> store [label="op = 'store'"]
|
412 |
|
|
execute -> load [label="op = 'load'"]
|
413 |
|
|
execute -> fetch [label="(op = 'jumpz' and acc = 0)\n or op ='jump'"]
|
414 |
|
|
store -> advance
|
415 |
|
|
load -> advance
|
416 |
|
|
advance -> fetch
|
417 |
|
|
halt -> halt
|
418 |
|
|
}
|
419 |
|
|
|
420 |
|
|
|
421 |
|
|
For timing diagrams, use [Wavedrom][] with the following text:
|
422 |
|
|
|
423 |
|
|
|
424 |
|
|
{signal: [
|
425 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
426 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
427 |
|
|
{name: 'cmd', wave: 'x2..................', data: ['HALT']},
|
428 |
|
|
{name: 'ie', wave: 'x0..................'},
|
429 |
|
|
{name: 'oe', wave: 'x0..................'},
|
430 |
|
|
{name: 'ae', wave: 'x0..................'},
|
431 |
|
|
{name: 'o', wave: 'x0..................'},
|
432 |
|
|
{name: 'i', wave: 'x...................'},
|
433 |
|
|
{name: 'halt', wave: 'x1..................'},
|
434 |
|
|
{},
|
435 |
|
|
|
436 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
437 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
438 |
|
|
{name: 'cmd', wave: 'x2................xx', data: ['ADVANCE']},
|
439 |
|
|
{name: 'ie', wave: 'x0.................x'},
|
440 |
|
|
{name: 'oe', wave: 'x0.................x'},
|
441 |
|
|
{name: 'ae', wave: 'x01...............0x'},
|
442 |
|
|
{name: 'o', wave: 'x0================0x', data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', 'F12', 'F13', 'F14', 'F15']},
|
443 |
|
|
{name: 'i', wave: 'x.................xx'},
|
444 |
|
|
{name: 'halt', wave: 'x0.................x'},
|
445 |
|
|
{},
|
446 |
|
|
|
447 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
448 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
449 |
|
|
{name: 'cmd', wave: 'x2................xx', data: ['OPERAND or LOAD']},
|
450 |
|
|
{name: 'ie', wave: 'x01...............0x'},
|
451 |
|
|
{name: 'oe', wave: 'x0.................x'},
|
452 |
|
|
{name: 'ae', wave: 'x0.................x'},
|
453 |
|
|
{name: 'o', wave: 'x0.................x'},
|
454 |
|
|
{name: 'i', wave: 'x.================xx', data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15']},
|
455 |
|
|
{name: 'halt', wave: 'x0.................x'},
|
456 |
|
|
{},
|
457 |
|
|
|
458 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
459 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
460 |
|
|
{name: 'cmd', wave: 'x2................xx', data: ['STORE']},
|
461 |
|
|
{name: 'ie', wave: 'x0.................x'},
|
462 |
|
|
{name: 'oe', wave: 'x01...............0x'},
|
463 |
|
|
{name: 'ae', wave: 'x0.................x'},
|
464 |
|
|
{name: 'o', wave: 'x0================0x', data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15']},
|
465 |
|
|
{name: 'i', wave: 'x.................xx'},
|
466 |
|
|
{name: 'halt', wave: 'x0.................x'},
|
467 |
|
|
{},
|
468 |
|
|
|
469 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
470 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
471 |
|
|
{name: 'cmd', wave: 'x2................xx', data: ['INDIRECT or EXECUTE: LOAD, STORE, JUMP, JUMPZ']},
|
472 |
|
|
{name: 'ie', wave: 'x0.................x'},
|
473 |
|
|
{name: 'oe', wave: 'x0.................x'},
|
474 |
|
|
{name: 'ae', wave: 'x01...............0x'},
|
475 |
|
|
{name: 'o', wave: 'x0================0x', data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', 'F12', 'F13', 'F14', 'F15']},
|
476 |
|
|
{name: 'i', wave: 'x.................xx'},
|
477 |
|
|
{name: 'halt', wave: 'x0.................x'},
|
478 |
|
|
{},
|
479 |
|
|
|
480 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
481 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
482 |
|
|
{name: 'cmd', wave: 'x2................xx', data: ['EXECUTE: NORMAL INSTRUCTION']},
|
483 |
|
|
{name: 'ie', wave: 'x0.................x'},
|
484 |
|
|
{name: 'oe', wave: 'x0.................x'},
|
485 |
|
|
{name: 'ae', wave: 'x0.................x'},
|
486 |
|
|
{name: 'o', wave: 'x0.................x'},
|
487 |
|
|
{name: 'i', wave: 'x.................xx'},
|
488 |
|
|
{name: 'halt', wave: 'x0.................x'},
|
489 |
|
|
{},
|
490 |
|
|
|
491 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
492 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
493 |
|
|
{name: 'cmd', wave: 'x2................xx', data: ['FETCH']},
|
494 |
|
|
{name: 'ie', wave: 'x01...............0x'},
|
495 |
|
|
{name: 'oe', wave: 'x0.................x'},
|
496 |
|
|
{name: 'ae', wave: 'x0.................x'},
|
497 |
|
|
{name: 'o', wave: 'x0.................x'},
|
498 |
|
|
{name: 'i', wave: 'x.================xx', data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15']},
|
499 |
|
|
{name: 'halt', wave: 'x0.................x'},
|
500 |
|
|
{},
|
501 |
|
|
|
502 |
|
|
{name: 'clk', wave: 'pp...p...p...p...p..'},
|
503 |
|
|
{name: 'cycle', wave: '22222222222222222222', data: ['prev', 'init','0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', 'next', 'rest']},
|
504 |
|
|
{name: 'cmd', wave: 'x2................xx', data: ['RESET']},
|
505 |
|
|
{name: 'ie', wave: 'x0.................x'},
|
506 |
|
|
{name: 'oe', wave: 'x0.................x'},
|
507 |
|
|
{name: 'ae', wave: 'x01...............0x'},
|
508 |
|
|
{name: 'o', wave: 'x0.................x'},
|
509 |
|
|
{name: 'i', wave: 'x.................xx'},
|
510 |
|
|
{name: 'halt', wave: 'x0.................x'},
|
511 |
|
|
{},
|
512 |
|
|
|
513 |
|
|
]}
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
That's all folks!
|
517 |
|
|
|
518 |
|
|
[C]: https://en.wikipedia.org/wiki/C_%28programming_language%29
|
519 |
|
|
[Digilent]: https://store.digilentinc.com/
|
520 |
|
|
[FPGA]: https://en.wikipedia.org/wiki/Field-programmable_gate_array
|
521 |
|
|
[Forth]: https://www.forth.com/forth/
|
522 |
|
|
[GHDL]: http://ghdl.free.fr/
|
523 |
|
|
[GraphvizOnline]: https://dreampuf.github.io/GraphvizOnline
|
524 |
|
|
[Graphviz]: https://graphviz.org/
|
525 |
|
|
[H2]: https://github.com/howerj/forth-cpu
|
526 |
|
|
[Nexys 3]: https://store.digilentinc.com/nexys-3-spartan-6-fpga-trainer-board-limited-time-see-nexys4-ddr/
|
527 |
|
|
[Soft-Core]: https://en.wikipedia.org/wiki/Soft_microprocessor#Core_comparison
|
528 |
|
|
[Spartan-6]: https://www.xilinx.com/products/silicon-devices/fpga/spartan-6.html
|
529 |
|
|
[VHDL]: https://en.wikipedia.org/wiki/VHDL
|
530 |
|
|
[Wavedrom]: https://wavedrom.com/editor.html
|
531 |
|
|
[Xilinx ISE 14.7]: https://www.xilinx.com/products/design-tools/ise-design-suite/ise-webpack.html
|
532 |
|
|
[bit-serial CPU]: https://en.wikipedia.org/wiki/Bit-serial_architecture
|
533 |
|
|
[bit.c]: bit.c
|
534 |
|
|
[bit.fth]: bit.fth
|
535 |
|
|
[bit.fth]: bit.fth
|
536 |
|
|
[bit.hex]: bit.hex
|
537 |
|
|
[bit.vhd]: bit.vhd
|
538 |
|
|
[gforth]: https://gforth.org/
|
539 |
|
|
|
540 |
|
|
|
541 |
|
|
body{
|
542 |
|
|
max-width: 50rem;
|
543 |
|
|
padding: 2rem;
|
544 |
|
|
margin: auto;
|
545 |
|
|
line-height: 1.6;
|
546 |
|
|
font-size: 1rem;
|
547 |
|
|
color: #444;
|
548 |
|
|
}
|
549 |
|
|
h1,h2,h3 {
|
550 |
|
|
line-height:1.2;
|
551 |
|
|
}
|
552 |
|
|
table {
|
553 |
|
|
width: 100%;
|
554 |
|
|
border-collapse: collapse;
|
555 |
|
|
}
|
556 |
|
|
table, th, td{
|
557 |
|
|
border: 0.1rem solid black;
|
558 |
|
|
}
|
559 |
|
|
img {
|
560 |
|
|
display: block;
|
561 |
|
|
margin: 0 auto;
|
562 |
|
|
margin-left: auto;
|
563 |
|
|
margin-right: auto;
|
564 |
|
|
}
|
565 |
|
|
code {
|
566 |
|
|
color: #091992;
|
567 |
|
|
display: block;
|
568 |
|
|
margin: 0 auto;
|
569 |
|
|
margin-left: auto;
|
570 |
|
|
margin-right: auto;
|
571 |
|
|
|
572 |
|
|
}
|
573 |
|
|
|
574 |
|
|
|