Inspired by the Next Project

Like the title says above this section is for general chat about anything else. (within reason)
dave18
Posts: 186
Joined: Tue May 30, 2017 1:06 am
Location: Bristol, UK

Inspired by the Next Project

Postby dave18 » Mon Jan 13, 2020 6:40 pm

Hi all

I just wanted to share how the Spectrum Next project has inspired me to do something I've always dreamed of which is to build my own computer. This project got me interested in FPGA programming so I got myself a cheap EP2C5 mini board and started working out how to generate video signal. Over the time I've been waiting for my Next I've learned enough about FPGA programming to create a fully functioning computer using a mix of FPGA and other hardware. During the process I also learnt about circuit design and board layout as well as some soldering skills. Here is the finished article.

https://drive.google.com/file/d/1gCalNc ... sp=sharing

and some screenshots of it in action

https://drive.google.com/open?id=133ujw ... _DWfWzofC6
https://drive.google.com/open?id=1Oe2F2 ... 19gwshu0XT

It has the following capabilities

It's based on a CMOD-A& FPGA board which uses an Artix-7 15T and has

Z80 CPU running at 12mhz (uses T80 core), with dedicated 512k memory, bankable in 8k slots.

4 display modes
80 column text
320 x 240 256 colour bitmap mode (scrollable)
512 x 512 scrollable tilemap mode - 320 x 240 visible - 256 colour (8 bit) tiles
512 x 512 scrollable tilemap mode - 320 x 240 visible - 256 colour (4 bit) tiles with palette offset

Each tilemap mode has 2 independantly scrollable tilemaps, background and foreground with the foreground being maskable.
Foreground and background can be independantly disabled

128k gfx memory so total of 2,048 8 bit tiles or 4,096 4 bit tiles
Dedicated tilemap memory 2 x 8k

128 hardware 16x16 sprites - can operate in either 8 bit or 4 bit mode with palette offset.
Can display all 128 sprites on screen at once and approx 90 per scanline
Hardware mirroring and linking.
Can prioritise sprites either in front or behind a foreground tilemap
Independant palette tables for background and foreground sprites
16k dedicated sprite RAM - total of 64 8 bit or 128 4 bit sprite patterns.
Sprite DMA can copy patterns and attribute data at 50mhz

512 colours on screen at once selectable from a palette of 4,096
12 bit colour (R4G4B4)
Separate palettes for Tilemap and Sprites
Separate selectable colour masks for foreground tilemap and sprites
VGA output running at 60hz

SID 8580 sound chip (core taken from MiSTer)
4 x 8 bit PCM channels - selectable frequency 3.9khz, 7.9khz, 15.8khz, 31.5khz (driven off hblank)
Samples share 128k gfx memory space

2 x 16 bit timers - can run between .75hz and 50khz

Maskable interrupts generated for vblank, hblank, defined raster line, keyboard, GPIOA, GPIOB, Timer 1 and Timer 2
Button driven NMI

2 programmable GPIO ports - physical MCP23017 via I2C - connect to 9 pin D-Sub joystick connector
GPIO address pulled down to zero but can be overridden via pin header

2 x analogue inputs (via pin header)

2 x user LED
1 x user RGB LED

SD Card interface via SPI interface

PS2 keyboard

I've even managed to create a functioning operating system for it.

It's been great fun to develop, and the reason I've decided to share my efforts here is simply because without the Next project I would never have had the drive to do this, and trust me, if I can do it anyone can.

Alcoholics Anonymous
Posts: 733
Joined: Mon May 29, 2017 7:00 pm

Re: Inspired by the Next Project

Postby Alcoholics Anonymous » Tue Jan 14, 2020 4:43 am

Way to go. Is there a reason you limited the cpu to 12MHz? The Artix-7 should be a beefy part to play with.

dave18
Posts: 186
Joined: Tue May 30, 2017 1:06 am
Location: Bristol, UK

Re: Inspired by the Next Project

Postby dave18 » Tue Jan 14, 2020 7:36 am

It is mainly due to memory contention issues. The tilemap, palette and sprite RAM are all on dual port memory on the FPGA, however the main graphics memory that holds the tile patterns, bitmaps and samples is in a physical SRAM IC which also needs to be continually accessed by video generation. The video is run from a 25mhz clock and once I clock the CPU to over half that I get gfx corruption which I think is due to my simple contention model not stopping the CPU quickly enough. Basically to make it faster I would need to rethink how I handle memory contention. I think I would need to revisit IO too as with the main system running at 50mhz it assumes it can respond to all IO requests without needing to Wait the CPU. I guess I might be able to double all the clocks, but when I started the project an 8 bit computer with a 12mhz Z80 already seemed a decent target.

Alcoholics Anonymous
Posts: 733
Joined: Mon May 29, 2017 7:00 pm

Re: Inspired by the Next Project

Postby Alcoholics Anonymous » Tue Jan 14, 2020 7:55 am

How are you stopping the cpu? Are you stopping its clock or asserting wait? I ask because the T80 has several bugs and one of them is wait is not handled correctly.

dave18
Posts: 186
Joined: Tue May 30, 2017 1:06 am
Location: Bristol, UK

Re: Inspired by the Next Project

Postby dave18 » Tue Jan 14, 2020 8:18 am

I'm stopping the clock, found out about the wait bug the hard way!

Stefan123
Posts: 119
Joined: Mon Jun 05, 2017 9:38 pm

Re: Inspired by the Next Project

Postby Stefan123 » Tue Jan 14, 2020 12:08 pm

Impressive work! I'm a bit envious of your 12-bit colour palette, that would have been nice to have in the Next too :)

dave18
Posts: 186
Joined: Tue May 30, 2017 1:06 am
Location: Bristol, UK

Re: Inspired by the Next Project

Postby dave18 » Tue Jan 14, 2020 12:20 pm

Thanks. 12 bit colour was the best compromise between available IO pins and colour depth. I wanted to go 16 bit (in fact the palette memory is 16 bit wide, the top 4 bits are just ignored) but I ran out of pins.

User avatar
SevenFFF
Posts: 565
Joined: Mon Jun 05, 2017 5:30 pm
Location: USA

Re: Inspired by the Next Project

Postby SevenFFF » Tue Jan 14, 2020 12:43 pm

Thanks, sounds great! The Next will support about thirty additional cores in the flash, with BiOS loader menus for them as well as the machine personalities in the main core.

It would be cool if you would look into porting your project to Spartan-6 SLX16 in the future, so everyone can check out your work. When the multicore support gets finalised there will be an example empty project with the Next pinout that you should be able to plug your implementation into.
Robin Verhagen-Guest
SevenFFF / Threetwosevensixseven / colonel32
NXtel NXTP ESP Update ESP Reset CSpect Plugins

dave18
Posts: 186
Joined: Tue May 30, 2017 1:06 am
Location: Bristol, UK

Re: Inspired by the Next Project

Postby dave18 » Tue Jan 14, 2020 1:17 pm

I will definitely look to port the core to the Next, it has always been my ambition. I think there might be some challenges, eg I currently have 2 separate SRAMs on their own buses, effectively the CPU can see 512k of dedicated 'fast RAM' and 128k of gfx 'slow RAM' so if the Next RAM is on a single bus I'll need to work around it

I do want to get to a position where I can develop software in parallel to run on my core and the Next.

Alcoholics Anonymous
Posts: 733
Joined: Mon May 29, 2017 7:00 pm

Re: Inspired by the Next Project

Postby Alcoholics Anonymous » Tue Jan 14, 2020 4:00 pm

The ram is 16-bit so organized as 512K x 16 or 1MB x 16 on the next. That might be a bit of an obstacle. If worse comes to worse you could ignore half of it I suppose. The memory expanded model would still be 1MB x 8. In the next itself, the sram operates on 28MHz cycles (so potentially a new request on each 28MHz period) and these cycles are shared between the cpu, layer 2 and possibly a dma operation in the future.
Last edited by Alcoholics Anonymous on Wed Jan 15, 2020 12:09 am, edited 1 time in total.


Who is online

Users browsing this forum: No registered users and 3 guests