forked from MEGA65/mega65-user-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nexys4ddr-setup.tex
447 lines (321 loc) · 19.3 KB
/
nexys4ddr-setup.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
\chapter{Using Nexys4 boards as a MEGA65}
\section{Building your own MEGA65 Compatible Computer}
You can build your own MEGA65-compatible computer by using either a Nexys4DDR (aka. Nexys A7) or the older Nexys4 (Non-DDR) FPGA development boards.
This appendix describes the process to set up a Nexys4DDR (Nexys A7) board for this purpose (which is the newer, preferred board).
The older non-DDR Nexys4 board is also supported, and the instructions are the same, except that
you must use a bitstream designed for that board.
Using a Nexys4DDR bitstream on a non-DDR Nexys4 board, or vice versa, may cause irreparable damage to your board, so make sure
you have the correct bitstream to suit your board.
DISCLAIMER: M.E.G.A cannot take any responsibility for any damage that may occur to your Nexys4DDR/NexysA7/Nexys4 boards.
\newpage
\section{Working Nexys4 Boards}
There are currently 3 Nexys FPGA boards which can be setup as a MEGA65:
\begin{minipage}{\linewidth}
\subsection{The Nexys4 board}
No longer manufactured but still available for sale on some websites with old stock.
\begin{center}
\includegraphics[width=0.4\linewidth]{images/img001_nexys4_board.jpg}
\end{center}
Documentation:
\begin{itemize}
\item \url{https://reference.digilentinc.com/reference/programmable-logic/nexys-4/reference-manual}
\item \url{https://reference.digilentinc.com/\_media/reference/programmable-logic/nexys-4/nexys4\_rm.pdf}
\end{itemize}
\end{minipage}
\begin{minipage}{\linewidth}
\subsection{The Nexys4DDR board}
No longer manufactured but still available for sale on some websites with old stock.
\begin{center}
\includegraphics[width=0.4\linewidth]{images/img002_nexys4_ddr_board.jpg}
\end{center}
Documentation:
\begin{itemize}
\item \url{https://reference.digilentinc.com/reference/programmable-logic/nexys-4-ddr/reference-manual}
\item \url{https://reference.digilentinc.com/\_media/reference/programmable-logic/nexys-4-ddr/nexys4ddr\_rm.pdf}
\end{itemize}
\end{minipage}
\begin{minipage}{\linewidth}
\subsection{The Nexys A7}
This is the re-branded version of the above Nexys4 DDR board:
\begin{center}
\includegraphics[width=0.4\linewidth]{images/img003_nexysA7_board.jpg}
\end{center}
Documentation:
\begin{itemize}
\item \url{https://reference.digilentinc.com/reference/programmable-logic/nexys-a7/reference-manual}
\item \url{https://reference.digilentinc.com/\_media/reference/programmable-logic/nexys-a7/nexys-a7\_rm.pdf}
\end{itemize}
\end{minipage}
\newpage
\section{Power, Jumpers, Switches and Buttons}
This top-down picture highlights the key jumper positions of interest on the Nexys4 board:
\begin{center}
\includegraphics[width=0.9\linewidth]{images/nexys4_jumpers.png}
\end{center}
The Nexys4 boards can be powered in two ways: using an external power supply, or from a standard USB port.
\subsection{Micro-USB Power}
\includegraphics[width=5cm]{images/illustrations/nexys-micro-usb-power.pdf}
Connect your micro-usb cable to a USB port on a USB charger or PC to provide power. Connect the other end to the Nexys4's micro-usb connector. Place the JP3 jumper on pins 1 and 2 to select USB power. Use the switch to power up the Nexys4.
\subsection{External Power Supply}
\hspace*{1.7cm}
\includegraphics[width=3.2cm]{images/illustrations/nexys-power-supply.pdf}
The MEGA65 core can consume a lot of power, and a standard USB port could potentionally be too little for the Nexys4 board. In particular, writing to the SD card might hang or perform odd behaviour. Therefore you should consider a 5V power supply.
Digilent sell a power supply for the Nexys4 board, and we recommend you use this to ensure you avoid the risk of damage to your Nexys4 board. The chosen power supply should be center positive, 2.1mm internal diameter plug, and should deliver 4.5VDC to 5.5VDC rated at least 1 Amp.
Connect the power supply cable to the supply plug of the Nexys4. Place the JP3 jumper on pins 2 and 3 to select WALL power. Use the switch to power up the Nexys4.
\subsection{Other Jumpers and Switches}
For your initial set up, we'd suggest you set the following jumpers on your Nexys4 board to these positions:
\begin{itemize}
\item{JP1} - USB/SD
\item{JP2} - SD
\end{itemize}
\begin{center}
\includegraphics[width=3.2cm]{images/illustrations/nexys-jumpers.pdf}
\end{center}
This will assure that the bitstream files will get loaded from your SD card on start-up.
At some later stage, you may prefer to load the bitstream from the on-board QSPI flash, and at that point, you can revisit your JP1 jumper setting and adjust it to the QSPI position.
% XXX - Image of board highlighting the jumpers
All 16 switches on the lower edge of the board must be set to the off position.
\subsection{Connections and Peripherals}
\includegraphics[width=\linewidth]{images/illustrations/nexys-connectors.pdf}
A USB keyboard can be connected to the USB port. Only a keyboard that lacks a USB hub will work with the Nexys4 board. Generally, extremely cheap keyboards will work, while more expensive keyboards tend to have a USB hub integrated, and will not work. You may need to try several keyboards before you find one that works.
You can connect a VGA monitor to the VGA port.
The mono audio-out jack can be connected to the line-in of an amplifier.
\subsection{Communicating with your PC}
There may be occasions where you wish to communicate with your Nexys4 board from your PC, in order to perform activities such as:
\begin{itemize}
\item Flash your QSPI flash chip via Vivado
\item Upload bitstream files directly from your PC (via m65 tool)
\item Make use of support tools such as M65Connect, m65, mega65\_ftp, m65dbg, etc
\end{itemize}
On such occasions, you will need to connect your micro-usb cable up to your PC.
\includegraphics[width=5cm]{images/illustrations/nexys-micro-usb-power.pdf}
\subsection{Onboard buttons}
\begin{center}
\includegraphics[width=3.2cm]{images/illustrations/nexys-reset-buttons.pdf}
\end{center}
The ``CPU RESET'' button will reset the MEGA65 when pressed, while the ``PROG'' button will cause the FPGA itself to reload the MEGA65
core. The main difference between the two is that CPU RESET is faster, and does not clear the contents of memory, while the FPGA button
is slower, and does reset the contents of memory.
\begin{center}
\includegraphics[width=3.2cm]{images/illustrations/nexys-five-buttons.pdf}
\end{center}
Two of the five buttons in the cross arrangement can also be used: BTND acts as though you have pressed \widekey{RESTORE}, while BTNC will trigger an IRQ, as though the IRQ line had been pulled to ground.
\section{Keyboard}
The keyboard layout is positional rather than logical.
This means that keys in similar positions to the keys on a C65 keyboard will have similar function.
This relationship assumes that your USB keyboard uses a US keyboard layout.
To help you locate what the various MEGA65 keys are mapped to, the MEGA65 has a built-in virtual keyboard test feature. This can be accessed in two ways.
The easiest way is to keep \specialkey{ALT} held down in while switching on the Nexys4, or resetting the Nexys4 with
the ``PROG'' button. The configure menu will be presented and by pressing 3, the virtual keyboard will be presented on a black background.
\includegraphics[width=\linewidth]{images/illustrations/virtual-keyboard.pdf}
Pressing a key on the USB keyboard will show the highlighted key on the virtual keyboard to help you identify the key mapping.
The other way to access the virtual keyboard is from within the MEGA65. Hold \megasymbolkey and press \specialkey{TAB} to access the Matrix Mode Debugger. From here, enter the following:
\screentextwide{s ffd3615 ff}
This will open a semi-transparent virtual keyboard at the top of the screen. Alternatively:
\screentextwide{s ffd3615 ff ff}
This will open a semi-transparent virtual keyboard in the centre of the screen.
Hold \megasymbolkey and press \specialkey{TAB} to exit Matrix Mode Debugger and return to the MEGA65.
\subsection{Some key mappings with a USB keyboard}
\widekey{RESTORE} is mapped to the PAGE UP key.
\specialkey{RUN STOP} is mapped to \specialkey{ESC}.
\newpage
\section{Preparing microSDHC card}
The MEGA65 requires an SDHC card of between 4GB and 64GB capacity. Some SDXC cards may work, however, this is not officially supported.
Preparation steps for the Nexys4 board's SD card share much in common with the
steps needed for real MEGA65 hardware, and as such, it is worth having a look
over
\ifdefined\printmanual
the {\bf MEGA65 Book}
\else
\bookvref{cha:configuringyourmega}
\fi
if you ever need details.
So in this section, we'll provide more details on the distinctive steps, and be more brief on the common steps.
One point of distinction between the Nexys board and the real MEGA65 hardware is that the latter already has a default bitstream/core provided, which permits you to format your SD card in the specific style required by the MEGA65.
For Nexys4 board owners however, you have no such default bitstream, so
see
\ifdefined\printmanual
the {\bf MEGA65 Book}
\else
\bookvref{sec:bitstreamfiles}
\fi
for more details on where the appropriate "nexys4.bit" or "nexys4ddr-widget.bit" files for your device can be downloaded from.
\subsection{Preparation Steps}
The steps are:
\begin{itemize}
\item{Format the SD card} in a convenient computer using the FAT32 file-system. The MEGA65 and Nexys4 boards do not understand other
file systems, especially the exFAT file system.
\item{Copy} your bitstream file (with name ending in ``.bit'') onto the SD card.
\item{Insert} the SD card into the SD card slot on the under-side of the Nexys4 board.
\item{Switch on} the Nexys4 board.
\item{Enter the Utility Menu} by holding \specialkey{ALT} down on the USB keyboard you have connected to the Nexys4 board.
\item{Enter the FDISK/FORMAT tool} by pressing 2 when the option appears on the MEGA65 boot screen.
\item{Follow the prompts} in the FDISK/FORMAT program to again format the SD card for use by the MEGA65. \\
\\
The FDISK tool will partition your SD card into two partitions and format them.
\begin{itemize}
\item One is type \$41 = MEGA65 System Partition, where the save slots, configuration data and other files live. \\
(This partition is invisible in i.e. Win PCs).
\item The other partition with type \$0C = VFAT32, where KERNAL, support files, games, and so on, will be copied to later. \\
(This partition is visible on i.e. Win PCs).
\end{itemize}
\item{Once formatting is complete}, switch off the Nexys4 board and remove the microSDHC card from the Nexys board and put it back into your PC
\item{This time, copy} the following items onto the SD card:
\begin{itemize}
\item The bitstream file
\item The extracted files from within either the "\textbf{SD essentials.rar}"
or "\textbf{SD essentialsNoROM.rar}" file that you downloaded from
the MEGA65 filehost. (See
\ifdefined\printmanual
the {\bf MEGA65 Book}
\else
\bookvref{sec:installingrometc}
\fi
for more details).
\item{If you have sourced your own preferred ROM file} (e.g. "\textbf{911001.BIN}"), copy it onto the SD card also, and rename it to "\textbf{MEGA65.ROM}" (uppercase is essential).
\item{Any .D81 disk image files} you wish to make use of.
\begin{itemize}
\item Note that if a file named MEGA65.D81 is added to the SD card, it will be mounted automatically on startup.
\item Make sure that all .D81 files have names that fit the old DOS 8.3 character limit, and are upper case. This restriction will be removed in a future release.
\end{itemize}
\end{itemize}
\item{Remove the SD card} and reinsert it into your Nexys4 board.
\item{Power the Nexys4} board back on. The MEGA65 should boot within 15 seconds.
\item On first start up, you will find yourself at the on-boarding screen, of which more
details can be found in
\ifdefined\printmanual
the {\bf MEGA65 Book}
\else
\bookvref{cha:configuringyourmega}
\fi
.
\end{itemize}
Congratulations. Your MEGA65 has been set up and is ready to use.
Please note that the above method of copying the bitstream file to the SD card means that the bitstream is loaded into the Nexys FPGA each time on boot - which takes around 13 seconds for the system to start. The bitstream can also be flashed using Vivado software into the QSPI flash to deliver a boot up time of 0.3 seconds.
For more detailed information on preparing and configuring your MEGA65, please refer
to
\ifdefined\printmanual
the {\bf MEGA65 Book}
\else
\bookvref{cha:configuringyourmega}
\fi
chapter.
\section{Loading the bitstream from QSPI}
While loading the bitstream from the SD card is the suggested (and well-trodden) path this document has chosen, of late, more nexys4 users have been exploring the alternative pathway of loading the bitstream from the QSPI flash. Some potential reasons they have chosen this pathway are:
\begin{itemize}
\item Faster loading times (0.3 seconds versus 13 seconds)
\item Some people were interested in the possibility of flashing multiple
cores onto their QSPI (via steps described in the
\ifdefined\printmanual
the {\bf MEGA65 Book}
\else
\bookvref{cha:cores}
\fi
Chapter)
\item Some people have experienced niggling issues with the SD card pathway, such as:
\begin{itemize}
\item System unable to reboot from on-boarding screen
\item System unable to reboot from freeze-menu after switching between PAL/NTSC
\end{itemize}
\end{itemize}
In time, if this proves to be a more popular pathway, we can revise our documentation here to suit it. Here are some steps in brief.
\subsection{Preparation Steps}
For users that want to try this pathway, you will need to adjust the JP1 jumper setting to use QSPI and then follow the steps in the \nameref{cha:fpgacpldflashing} chapter in relation to \nameref{sec:installvivado} and \nameref{sec:mainfpgaflashing}.
Be forewarned that the installation of Vivado is a lengthy process (both in terms of download time, and installation time).
Once you have flashed Slot0 of your QSPI chip via Vivado, you can then follow the steps
described in
\ifdefined\printmanual
the {\bf MEGA65 Book}
\else
\bookvref{cha:configuringyourmega}
\fi
to perform the custom SD card formatting,
installing of ROM and support files and on-boarding.
\section{Widget Board}
For Nexys board owners (all models), you may be interested in adding a widget board to your nexys device, in order to allow you to connect to:
\begin{itemize}
\item{a genuine C64 or C65 keyboard}
\item{2 DB-9 joysticks}
\item{Paddles or a 1351 Mouse}
\item{Cartridges (not functioning as yet)}
\end{itemize}
The widget board connects to your nexys board via its PMOD connectors.
It presently is only available as an unpopulated PCB, purchasable from here:
\begin{itemize}
\item \url{https://oshpark.com/shared\_projects/Y37xg9N7}
\end{itemize}
The firmware, pcb diagram, schematic diagram and bill of materials can be found within the following github project:
\begin{itemize}
\item \url{https://github.com/sy2002/DM65PIC}
\end{itemize}
You will need to purchases parts from the bill of materials separately and populate the board yourself.
You may find this forum64.de thread of interest, if you would like to read on the experiences of others that undertook this process, or if you have questions of your own to ask:
\begin{itemize}
\item \url{https://www.forum64.de/index.php?thread/90465-mega-65-ports-add-on-card-still-available-if-where}
\end{itemize}
The pcb (c65Keyb.brd) and schematic (c65Keyb.sch) files can be found within the 'eagle/' subfolder of the DM65PIC project, and can be viewed via the free tool 'AutoDesk Eagle', available here:
\begin{itemize}
\item \url{https://www.autodesk.com/products/eagle/free-download}
\end{itemize}
Here are some photos of the widget board in use:
\begin{center}
\includegraphics[width=0.9\linewidth]{images/widget-board-martin.png}
\end{center}
\begin{center}
\includegraphics[width=0.9\linewidth]{images/widget-board-deft1.png}
\end{center}
\begin{center}
\includegraphics[width=0.9\linewidth]{images/widget-board-deft2.png}
\end{center}
For convenience, the pcb and schematics diagrams for the widget board have also been provided in \bookvref{sec:nexyswidgetschematics}.
Some additional backstory notes for the board are:
\begin{itemize}
\item{The widget board is originally meant to sit inside a c65 case}
\item{Expansion port is not usable and a bit needs to be cut out for c64 case}
\item{Would be reasonable to adapt it for c64 case use (which definitely will be the more regular use)}
\end{itemize}
\section{PMOD-to-Joystick Adaptor}
As an alternate (and cheaper) option for those that just want to add a DB9 joystick port via the PMOD connectors, a user from the community, TheChief, has devised a means to do so. More information can be found in the following Discord thread:
\begin{itemize}
\item \url{https://discord.com/channels/719326990221574164/903079038015389716/929369283119685643}
\end{itemize}
\begin{center}
\includegraphics[width=0.9\linewidth]{images/joystick-pmod-thechief.png}
\end{center}
\begin{minipage}{\linewidth}
\begin{center}
\begin{longtable}{|L{3cm}|L{3cm}|p{3cm}|}
\hline
{\textbf{Joystick action}} & {\textbf{PMOD-JA Connections}} & {\textbf{DB9 Connections}} \\
\hline
{Fire} & {jahi(9)} & {pin 6} \\
\hline
{Up} & {jalo(1)} & {pin 1} \\
\hline
{Left} & {jalo(2)} & {pin 3} \\
\hline
{Down} & {jahi(7)} & {pin 2} \\
\hline
{Right} & {jahi(8)} & {pin 4} \\
\hline
\end{longtable}
\end{center}
\end{minipage}
\section{Useful Tips}
The following are some useful tips for getting familiar with the MEGA65:
\begin{itemize}
\item{Press \& hold \megasymbolkey (or the Commodore key if using a Commodore 64 or 65 keyboard) during boot to start up in C64-mode instead of C65-mode}
\item{Press \& hold \specialkey{RUN STOP} during boot to enter the machine language monitor, instead of starting BASIC.}
\item{Press \widekey{RESTORE} for approximately 1/2 - 1 second to enter the MEGA65 Freeze Menu. From this menu
you have convenient tools to change the CPU speed, switch between PAL \& NTSC video mode, change Audio settings, manage freeze-states,
select D81 disk images, examine and modify memory of the frozen program, among other features. This is in many ways the heart of the MEGA65, so it is well worth exploring and getting familiar with.}
\item{Type \screentext{POKE0,65} in C64-mode to switch the CPU to full speed (40MHz). Some software may behave incorrectly in this mode, while other software will work very well, and run many times faster than on a C64.}
\item{Type \screentext{POKE0,64} in C64-mode to switch the CPU to 1MHz.}
\item{Type \screentext{SYS58552} in C64-mode to switch to C65-mode.}
\item{Type \screentext{GO64} in C65-mode and confirm, by pressing \screentext{Y}, to switch to C64-mode, which is the
same as on a C128.}
\item{The C65 ROM makes device 8 the default, so you can normally leave off the \textbf{,8} from the end of LOAD and SAVE commands.}
\item{Pressing \specialkey{SHIFT} + \specialkey{RUN STOP} from either C64 or C65-mode will attempt to boot from disk.}
\end{itemize}
Have fun! The MEGA65 has been lovingly crafted over many years for your enjoyment. We hope you have as much fun using it as we have had creating it!
The MEGA Museum of Electronic Games \& Art welcomes your feedback, suggestions and contributions to this open-source digital heritage preservation project.