FPGA Spectrum Project

For experts to discuss very technical stuff and newbies to ask why the Spectrum they bought off ebay doesn't work.
User avatar
ketmar
Manic Miner
Posts: 697
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: FPGA Spectrum Project

Post by ketmar »

eh. "release often, release early!" ;-)

just dump it as it is. everybody had to start somewhere, and we aren't here to make fun of your first attemps. in the worst case you'll get no feedback, which doesn't change the situation much from the current one, i guess. ;-) and in the best case you'll get some valuable hints and maybe some help. it is understandable that you're still learning, and i guess nobody expects the perfectly written and documented code from the beginner. ;-)

tl;dr: if the only thing that worries you is bad code quality, then go on, share the code! there is nothing to be ashamed of.

p.s.: i'm not trying to push you, of course. it is up to you to decide anyway, and whatever you decide will not be wrong.
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

https://photos.app.goo.gl/UJf4Aw2q3bGpkF1K6

Some photos of the board - I'm using delta-sigma audio dacs, one single flash device for file system / roms, and one single SDRAM, which already comes on the Altera Cyclone IV eval board. Result is a very simple daughter board. VGA is done by simple resistor DAC, and of course PS2 keyboard. I wanted to have something that a complete novice could throw together. The ZX Spectrum core is nearing it's MVP (48k, 128k, turbo, hyper loading, opus discovery disk, multiface). SDcard has to be <= 2GB for now. File system is simple and proprietary for now. ROMs stored on same device as games / disks.
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

Thankyou, [mention]ketmar[/mention]. I've decided on the strength of these conversations to do a full disclosure. I'll share on gitlab in the next few days. Also I'm creating a electronic form of the schematic - currently it's scribbled on a few sheets of A4 with a few coffee stains on. I had not expected to get anywhere with it - it was just a handy distraction from the lockdown, the empty shelves, the empty streets and the empty schools. The trajectory it took is a equal and opposite reaction to the way I was feeling at the time. Now it's just fun, and to share it will be even better.

Watch this space :)
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

I'm working and making good progress on the cleanup. Of course, some horrid things will remain.

Circuit diagram here: hope it is allowed: https://drive.google.com/file/d/1QMU1GS ... sp=sharing.
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

And as promised, I'm sharing the source here. I've borrowed bits from other projects from people kind enough to share.

https://gitlab.com/zxmicrojack/fpga-spec

All comments are welcome - try to keep it constructive. All modifications are allowed, but please contribute back to me if you find a bug. If you want to build the hardware yourself, then drop me a line I'll include more step by step info. Really, this board can be put together by people of limited soldering ability, and no fancy equipment other than a soldering iron, a craft knife and a glue gun.

Enjoy, and please get in touch. Also I've added a couple of extra photos showing the new menu screens. Nothing major, just made a bit more neat, and added a spectrum style rainbow in the corner.
User avatar
ketmar
Manic Miner
Posts: 697
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: FPGA Spectrum Project

Post by ketmar »

by the way, could you recommend some free textbooks for those who knows almost nothing about fpgas? or, let me be more specific: i can program in asm for various architectures, so i know what bits, registers and such are, and have some rough understanding of how CPUs are working on a lower level. what should i read to proceed to design my own fpga devices? ;-)
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

Not sure if I can recommend. My degree was in computer systems engineering, 26 years ago - a mix of electronics and software, so lots of digital electronics and software, and I wrote some tiny amount of VHDL, but dreamed of picking this up in my career. This never happened due to lack of demand in this area at the time, so I went pure software, but with a good understanding of electronics, the hardware guys passed me schematics so I could write bring up code initially, moving onto bigger projects later on. I programmed embedded in many languages with 6-7 different assembly languages ranging from 32 bit down to 8 bit, and recently moved to Java web services 5 years ago. This is my attempt to fill the gap that was never filled in my career.

So, I'm not sure how much of my limited knowledge of HDLs is by osmosis and how much by self teaching. As a first jump - I read this free ebook:
https://www.amiq.com/consulting/misc/fr ... _ebook.pdf

After that I just tried and failed to do simple things for 2-3 months until I got the "hang" of it. Trial and error, but mostly error I would say is your greatest training tool for any thing. However, I'm more than happy to share what I've learned, please just DM, or even build my board, build my code and mess about with it. It's based on this board:

https://www.ebay.co.uk/itm/ALTERA-Cyclo ... SwpBdd5s3s

And if you are able to hold a soldering iron, the daughter board is simplicity itself. As for verilog, things started to go much better for me when I stopped thinking about this as a sequential program, and thought about it as an expression of the digital hardware. In summary, still very much a beginner, but happy to share.
User avatar
ketmar
Manic Miner
Posts: 697
Joined: Tue Jun 16, 2020 5:25 pm
Location: Ukraine

Re: FPGA Spectrum Project

Post by ketmar »

thank you alot! i know how hard it may be to give a proper list of things to start with when you collected various random knowledge over the years. ;-) i did various embedded programming too, but never touched the hardware side. i know some theory, and know which side of soldering iron is hot, but that's basically it. but i'm not scared to learn new things. ;-)

so thank you for the book! i'll prolly start (slowly) reading it, and we'll see how it will go from here.
User avatar
cmal
Manic Miner
Posts: 629
Joined: Fri Jun 05, 2020 1:05 am
Location: California

Re: FPGA Spectrum Project

Post by cmal »

Very interesting project, although I know almost nothing about hardware and especially fpga. Thanks for posting. I've downloaded the book and will dig into it.
azesmbog
Manic Miner
Posts: 307
Joined: Sat May 16, 2020 8:43 am

Re: FPGA Spectrum Project

Post by azesmbog »

zxmicrojack wrote: Thu Aug 13, 2020 9:54 pm
https://gitlab.com/zxmicrojack/fpga-spec

All comments are welcome - try to keep it constructive.
I would like to be constructive, but I don't see the project itself ??
Does he already exist or will he only someday ??

Well, about the scheme, constructively)
The keyboard, of course, will work in this version, but it will still be correct to install protective diodes.
Desirable.
but this is a personal matter for everyone.
FPGA inputs are not very tolerant to 5 volts.
Image
Last edited by azesmbog on Fri Aug 14, 2020 9:39 am, edited 1 time in total.
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

Thats great information, thanks. As for the repo - I thought I had made it public - Now fixed :)
azesmbog
Manic Miner
Posts: 307
Joined: Sat May 16, 2020 8:43 am

Re: FPGA Spectrum Project

Post by azesmbog »

and what, ready-made hex files can not be laid out ??
Sources are great, but not all Linux systems, and of course you can run the Makefile under Windows, but it's very, very difficult :)
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

I wouldn't expect anyone to want to view the hex files at all, but yes I can format them more neatly, just I had some initial difficulties importing srecords into verilog compiler, and this kind of worked, so I left it. Until speaking to yourself and [mention]ketmar[/mention], I had not imagined I would share quite so quickly, so yes there is probably more cleanup work needed. This had fallen into a - it works, so no need to fix it yet - tech debt :)

Thanks for the comments so far.
azesmbog
Manic Miner
Posts: 307
Joined: Sat May 16, 2020 8:43 am

Re: FPGA Spectrum Project

Post by azesmbog »

zxmicrojack wrote: Fri Aug 14, 2020 10:17 am I wouldn't expect anyone to want to view the hex files at all
i only need 2 files:
hyperloader.hex & bios.hex
to check if the assembly is correct
Spoiler
Image
Legendary DE1 !!!
Image
Is this the menu ??
I compiled in a completely different assembly language. There are too many differences with yours, perhaps I was mistaken somewhere and did not overlook :(
And of course, you need an archive of files that must be written to the SD card
Last edited by azesmbog on Fri Aug 14, 2020 8:16 pm, edited 2 times in total.
User avatar
DouglasReynholm
Manic Miner
Posts: 349
Joined: Wed Feb 20, 2019 8:38 pm

Re: FPGA Spectrum Project

Post by DouglasReynholm »

Older members of this site will know I've gone on about this before, so I hope they can forgive me for mentioning it one last time..

But I find it so bloody frustrating that I worked for Altera for 7 years, and tried to get the retro computing/gaming sceners interested in FPGA for so long, only to be met with blank stares..

"What's an FPGA!?"..

Now I'm well out of touch with the technology (worked for a couple other FPGA manufacturers, finally left the electronic industry behind in 2011 completely) and everyone has finally embraced the tech. And I can't really help like I could have back then.

I still have some 'insider' insight if anyone newer to the tech needs any clarity on anything (feel free to ask/pm) but I'm disappointed that I could have been much more useful to the community had things taken off a bit earlier - dev kits, tools, advice etc, all of which I had in my power to give away!

There, I've finally said it. Ghost can be laid to rest.

(Altera are now Intel FPGA, and I suspect due to Intel struggling with node tech, are now suffering)

Edit: just seen post above. Had 10 DE1's to give away at one point, no questions asked!
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

That's amazing - yes thats the menu - for some reason it's not importing the font...

I shared my hex files, and the rom binaries. Place them in the data directory and ./mkcard.sh. Write this to the SD card and go. will work to get more assemblers working, out of interest, which one are you using?

https://drive.google.com/drive/folders/ ... sp=sharing

I wrote some small readme last night. Really happy you're trying out my code! :D

https://gitlab.com/zxmicrojack/fpga-spe ... README.txt

Some keys:
'`' (button to left of 1 on my uk keyboard) switches to a debug screen, pressing F10 will dump out the registers - no clues as to which is which but its the REGset to T80pa.
F11 will start/stop tape playing with which ever tape you selected - not needed with hyperloading.
F9 will bring up main menu.
F8 and F7 are for single stepping through ROMs for debugging problems - has to be activated in code as yet - messy, but works.
F6 is mutiface 128 nmi button
F5 is multiface 1 nmi button.

number keys (normally cursors on zx keyboard) will move up and down and page up and down on menus. 0 selects.
hexdump mode 'x' exits, I think 1/2 moves through page memories.
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

[mention]DouglasReynholm[/mention] I always knew what FPGA was even back at uni - their usefulness was never lost on me, and we used them on some early PVR STBs in my former life. This is the first time I've been able to play with them, and is fulfilling a 25+ year ambition to do something meaningful with them. My problem is when I tell my colleagues at work - all technical, all developers with years of experience, they just don't understand... So what CPU is it? Is FPGA the CPU? Oh yes, I did some assembler at uni - x86.

So I showed them pictures of the thing working with their favourite spectrum games.... they said.... so it's an emulator. (facepalm). Its a logical replica running on an actual z80 IP core.... Frustrating that few people understand what I've been doing... but I think I'm in good company here.
FPGAs are the future, and it will explode in all directions I think due to this market.

PS - any FPGA board you have no longer use for I would gladly take off your hands :D
azesmbog
Manic Miner
Posts: 307
Joined: Sat May 16, 2020 8:43 am

Re: FPGA Spectrum Project

Post by azesmbog »

zxmicrojack wrote: Sat Aug 15, 2020 3:21 pm will work to get more assemblers working, out of interest, which one are you using?
I always use SJAsm + assembler under Windows.
hyperloader.hex was compiled correctly for me, but bios.hex already started to diverge from about 300 addresses (unless, of course, the versions coincide. I compiled the first version, could you send the last one?)
That's what I did
https://drive.google.com/file/d/16261nu ... sp=sharing

With your hex files, the menu is normal.
But there are still many problems. Firstly, if I upload a file to the devboard, then after each upload, I get 4 options in succession:
1 - Screen with Dan Dare
2 - Screen without menu, but with an inscription at the top - Loading roms from sdcard
3 - Sometimes full menu screen - Main Menu (rare)
4- Vertical red stripes (after pressing F5 / F6 - turn blue) - this is most often.
And so in a circle, twice in a row it was not the same thing.
On DE1, SDRAM memory is 12-bit, only 8 MB, I hope this is not enough?))
Yes, the LED always blinks, about 1 time per second.
Now on SDcard.
Will it be enough to simply format in FAT / FAT12 - and write files with ROM to it, or should there be some kind of file system of its own?

Uploaded 50 more times. Understood a little.
If Dan Dar is loaded - then by F9 you can go to the main menu.

When starting a memory test of all pages, it hangs on testing the 8th page.
This is normal?
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

The board I am using has 32MB of SDRAM, so it's probably from the high bit addresses I set in main.v.

`define PAGEMEM24_23 2'b11
`define PAGEMEM24_22 3'b110

These set the bit 24-23 of the address bus. With the DE1 with 8MB of SDRAM, then it should ignore the top bits. I set it to the top 8MB because there seemed to be some bit faults on the SDRAM on the board I bought. Page 8 would be 32Kb * 8 = 256Kb, which makes no sense. Though I suspect it may be that your board uses a different SDRAM device, then it will not be properly driven using the controller of my device. Mine is a W9825G6KH-6, which is a 16Mx16 part, whereas DE1 says it's 1Mx16x4banks - seems like there should be some different config for this device. Maybe one of the pins is misconnected? What happens if you hit F12? Stupidly I forgot to mention most importantly that the power on reset seems to be quite flaky since I corrected the timings. F12 will reset the board as normal, and jump into 48k spectrum mode.

For SD card, lazily I've not implemented a fat filesystem yet, so I have a proprietary one. In tools directory there should be a *mkfs* tool, if you build this directory, change to data directory, unpack the roms from the zip file on the link I supplied, then ./mkcard.sh you should be able to make an image which you would then just write to an SDcard. I use *dd* on linux, but I expect you could use windd on your side.

Just tried it now, and I noticed a bug with the script - it's using the wrong file reference for mkfs, I corrected it, so pull the repo it should be fixed now. I also uploaded an SDcard image to the above link. I also noticed that I shipped a few TAPs and OPDs along with the target ROMs in the repo by accident. I'll leave them for now.

I'll download your assembler and try to correct the faults - for now just use the hex file I supplied.

Just checked and seems to be a lot of incompatible changes between the two, would be difficult to keep compatibility for both. Could you try to use the windows version of z88dk ?

https://sourceforge.net/projects/z88dk/files/z88dk/2.0/
zxmicrojack
Drutt
Posts: 36
Joined: Tue Aug 04, 2020 7:29 pm

Re: FPGA Spectrum Project

Post by zxmicrojack »

Just wondering - 8 pages of 32kb, would make 256kb - totally out for the 8mb SDRAM, but about the right ballpark for the 512kb SRAM. This has a 16 bit databus, if you are using only 8 bits of that, that would make total sense. Few of the designs for the DE1 I've seen use the SDRAM.
Post Reply