An FPGA that you can play Zork on - Page 1
Forum section: electronics / projects

author: robertbaruch
author_rank: Regular Contributor
timestamp: December 14, 2016, 05:32:10 pm
content: Zorkwas the first commercial text adventure game. The game was originally implemented on a mainframe with a luxurious 1MB of memory! But it couldn't be played on the new home machines of the time, which usually had only 48k, so the programmers developed a virtual machine that executed bytecode called Z-code.My project is to implement a CPU that can execute Z-code natively on an FPGA. You hook it up via USB to a terminal emulator, load the bytecode for the game, and play! It's my first FPGA project. It will use an Artix-7 onDigilent's Cmod A7 board, which conveniently has SRAM for the computer's RAM.Why Artix-7 and not the more popular Spartan-6? Because I like SystemVerilog more than Verilog and theAlteraXilinx IDE that supports SystemVerilog only supports the 7-series chips. One possibility that I thought of was, Xilinx's other IDE that supports the 6-series can import netlists. If there were a program (a free one, not Mentor Graphics or Synoptix) that could convert SystemVerilog to netlists, you could use that. But really, the difference between, say, the Papilio and the Cmod A7 is not much anyway.I've starteda video blogabout the project, since it's a learning experience for me, and I hope it can help others!

author: rstofer
author_rank: Super Contributor
timestamp: December 14, 2016, 07:06:40 pm
content: That sounds like a fun project. Retrocomputing always is!You might want to edit the name of the toolchain. If you are using Artix, I don't think Altera plays with it.

author: Pjotr
author_rank: Frequent Contributor
timestamp: December 14, 2016, 09:08:34 pm
content: Jeezzz..... Played Cave on a PDP10 (the university mainframe those days). I think it was the predecessor of Zork. I remember it locked the university computer and playing time was limited before nine in the morning and after five o'clock in the afternoon. The makers must be completely stoned when they programmed itWe kept track of the cave on a large sheet of paper and kept adding new sheets over and over. Implementing a PDP10 on a FPGA must be fun!

author: robertbaruch
author_rank: Regular Contributor
timestamp: December 14, 2016, 10:12:11 pm
content: Quote from: rstofer on December 14, 2016, 07:06:40 pmOooops, right you are!

author: robertbaruch
author_rank: Regular Contributor
timestamp: December 14, 2016, 10:19:10 pm
content: Quote from: Pjotr on December 14, 2016, 09:08:34 pmDid you use a terminal that went "feep"?

author: Macbeth
author_rank: Super Contributor
timestamp: December 14, 2016, 10:29:22 pm
content: Quote from: Pjotr on December 14, 2016, 09:08:34 pmThere is always the original Essex MUD - utterly amazing at the time. Ran on a DEC-10 and written in BCPL.Unfortunately there was a distinct advantage to the "internals" (Essex Uni students) with their 9600 baud terminals and the "externals" running at 1200 baud, or even 300 baud using a crappy telephone modem (acoustic coupler) via PDP-8 dial in "gateways" into the JANET network. There was also PSS from British Telecom.Essex restricted MUD1 to the midnight hours IIRC.ETA: Blimey it's still alive athttp://www.british-legends.com/CMS/

author: boffin
author_rank: Unknown
timestamp: December 14, 2016, 10:40:00 pm
content: Quote from: robertbaruch on December 14, 2016, 10:19:10 pmVT52 w/ the relay BRRRAP;I remember when the 1st VT100s arrived

author: NivagSwerdna
author_rank: Super Contributor
timestamp: December 15, 2016, 11:03:50 pm
content: Happy memories thread... I remember playing something involving a grate and a stream[think the house and letterbox might not be in that version]on the PDP something whatever at University of Exeter Chemistry department where the Exeter Homebrew computer club met... happy memories... and BCPL... the first language we were taught at University (maybe 2nd... I seem to remember some Waterloo Pascal)... wow now I feel old.Looking forward to seeing how the z-machine comes along!

author: bson
author_rank: Unknown
timestamp: December 15, 2016, 11:31:00 pm
content: The original Dungeon was written in MDL and then ported to Fortran. I played the Fortran-IV version on pdp-11's (found on the then popular DECUS tapes if memory serves) and spent quite a bit of time dissecting the source code. It was a little slimmed down from the full version on pdp-10, if I remember correctly the latter had a bunch of "end game" stuff including a Rose Room with a big compass in it, that was missing from the pdp-11 version, presumably due to code size (I-space) limitations. But it was mostly the same. A friend and I spent many nights completely mapping it out and solving all the puzzles (prior to laying our hands on the F4 source code). Later on it became commercialized as Zork I and reimplemented using the virtual Z-machine.The hostname for my NAS is bankofzork and the volumes are exported as /Vault1, /Vault2, etc...

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: December 16, 2016, 04:39:23 pm
content: Ive implemented ZMachine in C. what a nightmare. A very organic spec, if you want to play things from zmachine v0 up through v5 or even v6/v8.. Id probably target v3 + v5 only.do you plan on implementing the virtual memory and everything? the zmachine spec is pretty deep.

author: robertbaruch
author_rank: Regular Contributor
timestamp: December 18, 2016, 12:54:59 am
content: I plan on implementing v3 first, then moving up one version at a time until v8.Virtual memory is not implemented in the virtual machine, it's in the implementation on whatever CPU you're running. My CPU *is* the virtual machine, so there is no need for virtual memory.

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: December 18, 2016, 04:30:55 pm
content: since zmachine 6/7/8 are graphical enhancements, sound and mouse support, I'd say its not worth implementing (very few games utilise the 6/7/8 modifications)are you going to implement Quetzal and Blorb?6/7/8 also go down the rabbit hole of PNG, JPEG, WAV, OGG, MP3, MOD.fonts in beyond zork. ugh. realtime keyboard input for border zone..version 3 still has sound effects too but I think only Lurking Horror had it and only on either atari st or amiga so most people never new/heard them.are you going to (I assume) decouple the ui from the cpu? and have some pc side app interface with the fpga running the cpu? I cant imagine dealing with the streams and ui text/snd/gfx junk in the fpga.

author: robertbaruch
author_rank: Regular Contributor
timestamp: December 20, 2016, 02:58:08 am
content: I'm not sure about sound and so on. I definitely want to include text, even if at a basic VT100 terminal level. We'll see how far I get!

author: Marty Geist
author_rank: Newbie
timestamp: March 09, 2017, 02:31:47 pm
content: Hi All;Robert, I just stumbled on Your Project, Very good..I am up to part 4, of Your project..My Question is "Can I put Your project on a different Digilent Board, as I Don't have the money for the Boards that You are using ??"I have a Digilent Spartan 3E Starter Board and a NEXYS 2 Board, which I got from a friend who I have done some work for in the Past..And these would have Switches and Led's that I could use for Input and Output, with out getting an Arduino Board, something else that I don't have..THANK YOU Marty

author: james_s
author_rank: Super Contributor
timestamp: March 10, 2017, 07:24:39 pm
content: I have Zork running on a EP2C5T144 FPGA, the dev board cost me $13 and there is an external SRAM, PS/2 keyboard and micro SD card with a CP/M disk image. The entire system can be built for under $20, I found an old 9" green monochrome CRT monitor that gives it a very authentic look.I got the basic design from here and made some improvements.http://searle.hostei.com/grant/Multicomp/

author: asmi
author_rank: Super Contributor
timestamp: March 11, 2017, 01:22:52 am
content: Quote from: james_s on March 10, 2017, 07:24:39 pmThat chip isancient(it's Cyclone 2 if my memory serves me). It's not even supported with current version of Quartus.

author: asmi
author_rank: Super Contributor
timestamp: March 11, 2017, 01:25:49 am
content: Quote from: robertbaruch on December 20, 2016, 02:58:08 amYou can add I2S output pmod module (http://store.digilentinc.com/pmod-i2s-stereo-audio-output/) which would allow you to output sound.P.S. Can't wait to see new episodes!

author: amspire
author_rank: Super Contributor
timestamp: March 11, 2017, 01:48:21 am
content: Quote from: asmi on March 11, 2017, 01:22:52 amIt is also a very capable chip and a really great price. Cheap enough to use directly in projects. I am pretty amazed it is powerful enough to run Zork under CP/M- I wouldn't have guessed that. I will definitely take a look at that project to see how it was done. The latest Quartus that can be used is 13.0Sp1.

author: asmi
author_rank: Super Contributor
timestamp: March 11, 2017, 03:21:24 am
content: Quote from: amspire on March 11, 2017, 01:48:21 amI've just checked the price out of curiosity - and it turned out to be not that cheap at almost $15 at Digikey. For that money (or less) you can buy Spartan-6, Cyclone 4 or MAX10 chip (all in the same TQFP-144 package) which will run circles around Cyclone 2 (not to mention that fabric in any of these chips will be waaay faster).Personally I like Lattice ICE40 Ultra FPGAs as they are cheap and very easy to use in your own boards, and it's available in easy to solder QFN-48 package. The only trouble is that they are kinda hard to find for sale, but I've bought ten 4K chips few months ago which will last for some time. Recently Lattice announced even more capable UltraPlus devices (which contain 1Mbit SRAM memory on-chip!), but I don't know when they will become available (as in "Digikey-Mouser kind of available").For heavy lifting though Artix-7 (and Zynq SoC based on the same fabric) is simply the best balance of capabilities and price. The only problem is that they are only available in BGAs. I held a lot of hope when Xilinx announced that Spartan-7 will be shipped in TQFP package, but looks like they've quietly dropped this

author: amspire
author_rank: Super Contributor
timestamp: March 11, 2017, 03:32:32 am
content: Quote from: asmi on March 11, 2017, 03:21:24 amThe point is the development board is $13 including shipping. Instead of buying the chips, buy the board and use it in projects. You cannot get a development board for any of the chips you mentioned for double the price. I seem to remember there is a Cyclone 4 board for about 3 times the price. The EP2C5T144 board is perfect for starting in FPGAs but definitely, if you are designing a product, move to something better.

author: asmi
author_rank: Super Contributor
timestamp: March 11, 2017, 03:39:38 am
content: Quote from: amspire on March 11, 2017, 03:32:32 amThat board is waaay too big for my projects. Besides I like designing my own custom boards for every project - just like I 3D print all cases for them as well. I love making as much stuff myself as I can manage - I see no fun in cobbling together a ton of weird boards with tons of stuff that is useless of any specific project. I just can't imagine making a permanent device using devboard (Cmod boards, which are used in the topic at hand, might be exception here as it's small enough and there are almost no extra chips except of what's absolutely required to run the FPGA).As for the price - well if my goal would be to be as cheapo as possible I wouldn't go into FPGAs at all. Most of projects I'm working on could be done much cheaper using MCUs instead of FPGAs. It's a hobby after all - so it going to be net loss no matter what.As for development boards - just make your own with whatever nooks and crannies you want! It's not really that complicated, and you will definitely learn a lot designing it!

author: james_s
author_rank: Super Contributor
timestamp: March 11, 2017, 08:06:54 am
content: Way too big? It's about the size of a credit card. It's actually a bit of a stretch to even call it a dev board, really it's more of a breakout board for the FPGA. I've got a whole pile of them, several are retro computers, another runs Asteroids and Asteroids Deluxe driving a vector monitor I made out of a 5" B&W TV. I've got Space Invaders, PacMan and Galaxian running on one with external ROM. On another one I've implemented a bunch of different sound boards used in 80s pinball machines and arcade games. For one-offs it's a real time saver, and the whole board costs less than the bare parts to get any other FPGA I'm aware of up and running.Yeah it's an ancient chip, but who cares? It's way more than enough for what I'm doing with it. Asteroids for example consumes only 29%, the complete 64K 10MHz Z80 CP/M system with VGA, PS/2 keyboard, serial port and SD card interface fills 91% so even that has room to spare. What's wrong with using an older chip if the design fits and it works? Anything bigger would be wasted. I have a DE2-115 also but most of the time I end up using the little Cyclone II boards because they're tiny and cheap enough that if I ever manage to kill one it's no big deal, and I make daughterboards that plug right onto them to expand the capabilities. The Z80 system at 10MHz is way faster than the real Z80 computers that were around when CP/M was contemporary. It's actually the SRAM that is the bottleneck there, I've clocked the related 6502 computer at 25MHz on that same board using only the paltry internal RAM. 25MHz is ridiculously fast for an 8 bit retro computer.

author: james_s
author_rank: Super Contributor
timestamp: March 11, 2017, 08:22:53 am
content: Here's my implementation of Grant's Multicomp on the left and Asteroids Deluxe on the right. For Asteroids I started with the code from fpgaarcade, ripped out the rasterizer and added a DAC and amps and DC-DC converter for the deflection signals. There's also an audio amplifier, and an I2C eeprom that I intend to use for high score save if I ever get around to coding that part. The board stack for either project is about the size of a deck of cards and operates on 5V.

author: amspire
author_rank: Super Contributor
timestamp: March 11, 2017, 11:18:23 am
content: Very neat James. I have a couple on order for an idea I want to experiment with, and I will need a plug in board.Is there any 5V available on the headers? As far as I can see, it is only the 3.3V.

author: asmi
author_rank: Super Contributor
timestamp: March 11, 2017, 12:01:25 pm
content: Quote from: james_s on March 11, 2017, 08:06:54 amI doFor me the biggest problem is the fact that you gotta use very old version of Quartus to design anything for that. FPGA design software is buggy even in current version, so dealing with old unsupported software is too much of a hassle. Just look at ISE which doesn't work out of box in Win10. And in general new things are better because they are new and shinyAnyway, enough off-topic here.

author: deebee
author_rank: Newbie
timestamp: March 11, 2017, 02:12:00 pm
content: I am with James on this one, I like the cheapo cyclone ii boards. They work well enough for exactly this kind of retro computing project. I think it also kind of fits really, bit of a retro looking board in itselfA couple of plus points, they are cheap and can be left in the finished project. I don't want to tie up my >£100 cyclone V soc development board in a Z80 project only to have to dismantle it when I have a more demanding project that actually needs it. As for the software, there is something to be said for using the older version, it may well have some bugs or quirks that won't get fixed, but they are stable bugs that you can learn to work with. The latest and greatest always has the possibility of new unseen bugs that can frustrate. And keeping an older piece of software working has never been a problem, big fan of keeping a couple of older linux VM builds around that I know work with the software. Software doesn't stop working just because it's old, it doesn't wear out (ignoring any potential licensing issues but thats another story). Anyone considering FPGA projects should try these low cost boards to test the waters, it can be tricky and not everyone will stick with it so please don't blow large sums of money for your first project.

author: james_s
author_rank: Super Contributor
timestamp: March 11, 2017, 06:45:00 pm
content: I'm running Quartus II v13.0 under Win7x64 and have not had any issues with it whatsoever that I recall. It's rock solid stable, it does what it's supposed to do, it works just as well now as it did when it was the newest thing around. It's not a problem to have multiple versions installed although I do find it annoying that newer versions drop support for older parts. I'll never understand the obsession some people seem to have with new, must have the latest and greatest, everything older sucks because it's old, I'm forced to use Win10 at work and I absolutely despise it, horrible turd of an operating system that I feel like is constantly fighting with me and pushing MS "apps" and services, uhg! Well whatever, the whole point of this thread is to play with old retro stuff and even the lowly Cyclone II is still a very powerful part. I have a couple of much higher end FPGA boards and feel that I'm generally wasting them because I've barely scratched the surface of what they can do. I'm just not that great of an FPGA developer and most of my interest is in replicating retro hardware. I've had a lot of fun pushing these little Cyclone II boards as far as I can.There is no 5V on the headers for some reason, but there is a pair of pads next to the power input jack that are connected to that. I have a board in the works that needs 5V and for that I'm just placing a small DC-DC converter on the daughterboard like I did to get the +/-15V for the vector output.

author: amspire
author_rank: Super Contributor
timestamp: March 11, 2017, 10:30:14 pm
content: Quote from: james_s on March 11, 2017, 06:45:00 pmThat is probably the way I will go, since I need to have some analog, and using a DC-DC converter needs I can power everything from 5V. Just had a look at the one you used - ISA0315, 33mA output current and costs $4.75. Looks good - I might get the same one.

author: james_s
author_rank: Super Contributor
timestamp: March 11, 2017, 10:59:59 pm
content: Quote from: amspire on March 11, 2017, 10:30:14 pmIt works well, they have a whole range of different voltages available, same footprint. You're welcome to the KiCad designs for either of these boards if you want them, I made a component that is the set of headers that plugs into the FPGA board with all the pins named. Beware that there are a few pins that are input-only that feed the global clock network, I got bit by those on the first run of a board I did. Also there are some pins that are tied to Vcc and Gnd with zero ohm resistors, remove those resistors from the bottom and you can use those pins. I think it was done for the larger FPGA in that series which requires more power and ground pins. Then there's an RC network to ground on one of the pins, I removed that to free up another pin for the Asteroids board. It's completely unnecessary to have.

author: brooks
author_rank: Newbie
timestamp: March 18, 2017, 01:12:14 am
content: Hi Robert,Thanks a lot for doing this! Lots of fun since I work with FPGAs now but played Zork back in the day. I also saw something like this originally on a PDP11. It was on a "terminal" which had no screen but just used a dot matrix printout instead!I'm on part 5 of the video series. Would you mind providing a link to the spreadsheet you show, or adding it to the git repo?Thanks

author: cerkit
author_rank: Newbie
timestamp: May 01, 2017, 06:23:59 pm
content: Thanks for the great videos. I own a Mojo FPGA, so I'm not able to use System Verilog. I'm also new to FPGA's, so I'm learning Verilog slowly. I come from a software development background, so this has been a fun challenge.I'd like to implement your zmachine idea on the Mojo. I may not ever get it working, but I'm really enjoying your videos.Is this the same engine that ran Planetfall? I loved that game. I don't think I played much Zork.

author: helius
author_rank: Super Contributor
timestamp: May 01, 2017, 11:00:25 pm
content: Quote from: cerkit on May 01, 2017, 06:23:59 pmThe Z-Machine is a specification of a simple virtual machine, the one most text adventures used. It was created by Infocom and all their titles used it.Since the Inform compiler was released publicly, hundreds more titles have been written for it. Seehttp://www.ifarchive.org/Using a portable virtual machine was an important enabling technology for text adventures, since you could author M titles, write N interpreters for the computer architectures people used (and in the '80s there were a lot of them), and then sell M*N products while only spending the effort to develop M+N actual software programs. The authors of the titles also could use a high-level language (object oriented and memory safe) even though the products were delivered for 8-bit micros with a more primitive developer experience.Frankly, the whole concept of implementing it in Verilog is odd. Since FPGA cores (like for the MiST) that implement the Amiga, C64, ZX Spectrum, etc, already exist, and these platforms already have Z-Machine interpreters, it is logically entailed that any of these are "An FPGA that you can play Zork on".

author: james_s
author_rank: Super Contributor
timestamp: May 01, 2017, 11:03:02 pm
content: Quote from: wilfred on May 01, 2017, 10:44:18 pmI'm horrible at documenting stuff like that. A guy named Fred Kono designed the deflection board, I made a Z amplifier based on a modified version of the Electrohome G05 Z amp, we've been working on a better more integrated design. There have been a few different versions of the deflection board, the latest uses ordinary 2N3904 and 2N3906 transistors to form a differential amplifier and then TIP41 and TIP42 output transistors, I have the schematic at home I can post. One of these days I'll finish my version of the PCB layout which combines deflection and the Z amp, HV will be on a separate board using the flyback from the TV the tube came from.

author: Makkowitch
author_rank: Newbie
timestamp: December 26, 2017, 10:31:58 am
content: Hi y'allI watched some of the videos on building the z-machine on an FPGA. It's a little bit out of my depth, I'm just beginning to look into hardware and FPGA's. I wonder why the whole VM is implemented on the FPGA (CPU). What's the reason for that decision?I would have thought that implementing machine code in the CPU, and implementing the VM in software, would be the way to go.Btw - It seems like the series ends at part 6. So I guess the project has been obandoned?

author: helius
author_rank: Super Contributor
timestamp: December 26, 2017, 09:39:23 pm
content: Quote from: Makkowitch on December 26, 2017, 10:31:58 amI would tend to agree with you, because the Z-Machine VM is rather high-level and object-oriented, and depends on supporting infrastructure that is almost impossible to implement without software (including file and printer I/O). Seemy previous comment.Here is the official specification of the Z-Machine. You can see that many of its features are not easily implemented in pure hardware.