FPGAs and 65816's

for bbc micro/electron hardware, peripherals & programming issues (NOT emulators!)
dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

FPGAs and 65816's

Post by dominicbeesley » Tue Mar 04, 2014 12:24 am

Hello,

I've been away from the board for a while. I got a bit cheesed off with my 65816 project last year. First I broke my BBC (or it died itself, still not sure which), that took a lot of tracking down but in the end turned out to be a dead ROM. Next I ordered a whole lot of Xilinx 9536 CPLDs not realising that I'd bought the 3.3V parts instead of the 5V parts and then I kind of lost my rag. I will get back on it though, I've just ordered a (hopefully 5V XC9572) which I'll be working with soon.

In the meantime I've been trying to better my VHDL skills and I've been playing with a DE0 nano. So far I've knocked up a few mini projects including a 50MHz 6502 computer, next up I'm going to try and stitch together a BBC Micro running on the DE0 nano. I'd be interested to know what existing VHDL projects there are out there to crib / mercilessly plagiarise. My VHDL skill are pretty poor so far.

I've been looking at Mike Stirling's version for the DE1 which looks pretty cool. I'd like to get this working then extend it out to a prototype 65816 system to try my re-written MOS out on.

However I have managed to get HDMI and something resembling Mode 0 on a BBC direct out of the DE0 nano to my monitor

Dom

User avatar
roland
Posts: 3636
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: FPGAs and 65816's

Post by roland » Tue Mar 04, 2014 12:46 am

Hi Dom,

One of the best VHDL projects here is the Atom GODIL video adapter. That is a very extended replacement for the 6847 that is used in the Atom. Besides the video part it also provides SID audio, mouse interface, vga connection and 80 column text mode.

Parts of this work is based on the Atom FPGA project that is also mentioned several times in different posts.

Regard,
Roland
FPGAtom: 512 KB RAM, Real Time Clock and 64 colours
MAN WOMAN :shock:

User avatar
hoglet
Posts: 8947
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: FPGAs and 65816's

Post by hoglet » Tue Mar 04, 2014 7:23 am

Hi Dom,

Here's a couple of links to FPGA things I have been involved with:

Atom FPGA
https://github.com/hoglet67/AtomFpga
http://www.stardot.org.uk/forums/viewto ... =44&t=6313

Atom GODIL
https://github.com/hoglet67/AtomGodilVideo/wiki
http://www.stardot.org.uk/forums/viewto ... =44&t=7320

Atom FPGA is based on Alan D's work. I added a SID (from https://code.google.com/p/netsid-papilio) and upgraded to the latest T65 core. It's also now running later SDDOS software and can run a SDDOS version of the Atom Software Archive. It works on the Papilio One and on the Olimex MOD VGA boards (both Xilinx).

Dave

PhilYoung
Posts: 203
Joined: Sun Jun 12, 2011 4:55 pm
Contact:

Re: FPGAs and 65816's

Post by PhilYoung » Tue Mar 04, 2014 9:06 am

Hi,

At a slight tangent, but in the same ball-park, there is this Tube ULA replacement (in Verilog, not VHDL) which might be of some use:

https://sites.google.com/site/beeb816/p ... memis32768

Good luck !

Cheers,

Phil Young

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Tue Mar 04, 2014 9:55 am

Thanks both,

Plenty to look at there. I like the look of those GODIL things....I might have to get hold of one of those!

D

User avatar
pstnotpd
Posts: 396
Joined: Wed Jan 20, 2010 11:05 am
Contact:

Re: FPGAs and 65816's

Post by pstnotpd » Tue Mar 04, 2014 2:01 pm

You could try to convince John Kortink to share his 6502 Second Processor for De0-nano sources.

User avatar
flynnjs
Posts: 831
Joined: Tue Jul 06, 2010 9:33 pm
Contact:

Re: FPGAs and 65816's

Post by flynnjs » Tue Mar 04, 2014 11:41 pm

I did make some fairly unsubtle hints at John and I got some fairly unsubtle responses back :-(

I have done a fair few modifications to Ed's FPGA Verilog Tube as I found a number of bugs and there are timing issues which vary depending on how your parasite side processor are clocked.

I have a 6502 which boots, copies the BASIC ROM across and gives a prompt but crashes when parsing the first command line input. Will sort this out after I get the USB Econet finished and then I'll open source it all. For the DE0 (with a level shiter) of course.

BTW, those of you that are using a DE0 with a third party Tube level shifter might want to double check how the 5v IRQ line (which is actually generally unused) is attached to the FPGA.
I've cut the track to avoid any possibility of aggravating the FPGA although I hadn't experienced any immediate problems.

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Wed Mar 05, 2014 10:48 am

Aye, John's doesn't like giving his sources away, which is his choice. I am going to order a tube silencer at some point...might do it now!

I'm hoping to have a full HDMI system running soon, but likely to get sidetracked by my 16bit beeb project as I've now got hold of a 5V CPLD. I will at some point concentrate on the FPGA thing. Unfortunately, we need to sell this house and that will involve tidying up my growing collection of dead and dying beebs, TVs and radios and other electro-junk that is scattered around the house and stick to the DE0 which takes up considerably less space!

You'll probably get away with that IRQ setup in terms of blowing the FPGA. I've accidentally fed all sorts of dodgy voltages into mine and it seems to have survived! The IRQ is held high with a fairly high value (3k3) resistor so will pull about -0.5mA out of a 3.3V pin. You may find that the FPGA drags the IRQ down a bit possibly causing false IRQs at the host chip, but unlikely.

D

User avatar
BigEd
Posts: 2857
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: FPGAs and 65816's

Post by BigEd » Sat Mar 08, 2014 5:57 pm

Ooh, flynnjs, if you've managed any improvements to the Tube code, please share them! We can update our version, surely.

Cheers
Ed

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Sun Mar 09, 2014 7:34 pm

Got it up and running with a 6502 core now and got simple characters printing on the screen...

I've used the r6502_tc core so far but I'd really like to get something that will do both CMOS and 65816 stuff - is the T65 core still the best for this (in terms of completeness of implementation). Where's the best version to download - I no longer seem to be able to find anything on FPGAarade

Cheers

D

User avatar
BigEd
Posts: 2857
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: FPGAs and 65816's

Post by BigEd » Sun Mar 09, 2014 7:58 pm

There is the M65C02 core, but I'm not aware of any core which does much of the '816 instructions - the T65 has the intention, but I'm not sure if it has the substance.
See http://forum.6502.org/viewtopic.php?p=31959#p31959
Cheers
Ed

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Sun Mar 09, 2014 9:00 pm

Ah, that's disappointing! Looks like I might have to roll my own, though that might be a bit of a leap too far...

I can't find any info and how much is missing from the T65 in terms of the 65816's instructions/behaviour. I probably don't need it 100% but I _do_ need to know what works/doesn't. I really just want to have something to write and test an operating system against on vhdl so I can do software / hardware development in parallel....

Thanks

D

User avatar
hoglet
Posts: 8947
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: FPGAs and 65816's

Post by hoglet » Sun Mar 09, 2014 9:12 pm

In the AtomFPGA I updated to Mike Stirling's version of the T65 core, as he had made some bug fixes. Before I updated to this version, the 6522 interrupts handler was getting called twice, which made SID music quite interesting.

I can dig around for the link if you like.

Dave


User avatar
BigEd
Posts: 2857
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: FPGAs and 65816's

Post by BigEd » Sun Mar 09, 2014 9:26 pm

I believe the FPGAArcade version of T65 is found at
https://svn.pacedev.net/repos/pace/sw/s ... t/cpu/t65/
(Comments in the file call this version 302, but I'm not sure if it has all the final fixes which are floating around)

There are many 6502 HDL cores: see
http://forum.6502.org/viewtopic.php?t=1673
and
http://6502.org/homebuilt#HDL
for a subset.

Cheers
Ed

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Mon Mar 10, 2014 12:25 pm

Thanks lads,

Plenty to look at there...

D

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Tue Mar 11, 2014 6:15 pm

Right, I downloaded all the t65 versions and it looks like the one on pacedev is the same as Mike Stirling's and is the most up to date.

That dropped into my project with the minimum of fuss, just a bit of signal renaming. I've not tried the 65c02 or 65816 modes yet.

I have got it to boot into BBC BASIC by committing a bit of brutality against the MOS ROM and recompiling it (basically skip the initial bits that talk to the VIAs). This is just a flat 32k RAM (dual port to screen) and a 32k ROM with page &FE talking to some non-standard peripherals (LCD/LEDs).

Pictures here

Not sure where to go with this now? The problems on the DE0 nano really are a lack of non-volatile memory so maybe the way to go is a simple SDCard interface and download ROMS into SDRAM with a little bootloader?

Do you think other people would be interested in being able to reproduce this...if so it might be worth pursuing. If not I'll probably just hack something simple together for my own purposes?

Cheers

D

PhilYoung
Posts: 203
Joined: Sun Jun 12, 2011 4:55 pm
Contact:

Re: FPGAs and 65816's

Post by PhilYoung » Tue Mar 11, 2014 6:59 pm

dominicbeesley wrote:
Do you think other people would be interested in being able to reproduce this...if so it might be worth pursuing. If not I'll probably just hack something simple together for my own purposes?

Cheers

D
I'm sure they would, please go ahead and post when you're ready.

BTW the URL for the pictures didn't show up....

Cheers,

Phil Young

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Tue Mar 11, 2014 11:49 pm

Cheers Phil,

Ooops url...here

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Sat Mar 29, 2014 1:07 am

I got it to boot to BASIC and I can now type in test programs and run them!

There were quite a couple of bugs in my code which were stopping it from working before (mainly bits I'd commented out and forgot to put back!).

But I found a real stumper with the T65 core which had me going for a long while until I got it figured.

It seems that during a PLP (pull flags from stack) instruction the P flag is unstable during the execution of the instruction and the I bit was sometimes getting set to 0 even when the value _before_ and _after_ the PLP had it set.

After a lot of head scratching and RTL simulations I made a quick hack to the T65 core:

Code: Select all

if NMIAct = '1' then
    NMICycle <= '1';
-- DOM HACK : PLP causes Flag_I to follow ALU_Q during LDP, ignore until
-- LDP is low, otherwise get spurious irq cycles during PLP even if
-- I is set before and after PLP!
elsif IRQ_n_o = '0' and P(Flag_I) = '0' and LDP = '0' then
    IRQCycle <= '1';
end if;
It's just the LPD = '0' bit that I added.

This seems to work (by not allowing an interrupt cycle to start while the P flag is changing) which seems sensible to me. The thing is, I've no idea whether this is intentional behaviour that would have occurred in a real 6502 and my RAM or timing implementation or something is causing the problem or whether I've spotted a real bug?!?

Any ideas?

There's a quick video of it drawing some triangles on my blog...I don't know how to put videos on the forum
D

User avatar
hoglet
Posts: 8947
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: FPGAs and 65816's

Post by hoglet » Sat Mar 29, 2014 6:34 am

Hi Dominic,

Can you post a link to your blog? Sounds interesting.

The T65 core is being used in Alan D's Atom FPGA, and I'm wondering why I've not hit this problem. It could be because the Atom makes little use of interrupts, but I was able to get some interrupt driven SID music to play.

Under what circumstances were you seeing this problem? I'd like to try to induce it if possible.

Also, if you could post your latest T65 core, I'd like to compare it with what we are using to see if any other differences have crept in.

Thanks,

Dave

User avatar
hoglet
Posts: 8947
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: FPGAs and 65816's

Post by hoglet » Sat Mar 29, 2014 6:35 am

Question for the Atom folk....

Are there any Atom games that rely on 6522 interrupts?

I'd like to do a bit more testing of this side of Atom FPGA.

Dave

User avatar
richardtoohey
Posts: 3741
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand
Contact:

Re: FPGAs and 65816's

Post by richardtoohey » Sat Mar 29, 2014 7:38 am

hoglet wrote:Can you post a link to your blog?
I'm guessing (with the help of a search engine beginning with G!)

http://dossytronics.blogspot.co.nz/

But could be wrong!

User avatar
1024MAK
Posts: 9728
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: FPGAs and 65816's

Post by 1024MAK » Sat Mar 29, 2014 8:19 am

hoglet wrote:Can you post a link to your blog? Sounds interesting.
Err, he did, a couple of his posts up... viewtopic.php?f=3&t=7877#p82183

Mark

User avatar
hoglet
Posts: 8947
Joined: Sat Oct 13, 2012 6:21 pm
Location: Bristol
Contact:

Re: FPGAs and 65816's

Post by hoglet » Sat Mar 29, 2014 8:23 am

In my defence, I did search the thread for the word blog, and didn't find it earlier on. :D

Dave

User avatar
oss003
Posts: 3186
Joined: Tue Jul 14, 2009 11:57 am
Location: Netherlands
Contact:

Re: FPGAs and 65816's

Post by oss003 » Sat Mar 29, 2014 9:25 am

hoglet wrote:Question for the Atom folk....

Are there any Atom games that rely on 6522 interrupts?

I'd like to do a bit more testing of this side of Atom FPGA.

Dave
Hi Dave,

The only ones I can think of are Joe Blade, Jungle Journey (SID version) and the AtomSID progam.

Greetings
Kees

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Sat Mar 29, 2014 10:37 am

Hi all,

Thanks for posting the "blog" link up, its not really much of a blog, I've just uploaded a zip of the VHDL and assembler sourcecodes.

You may have found that the IRQ problem didn't occur or didn't cause problems in the Atom. The IRQs themselves seem to work ok (I'm not sure about the timings though). It's just the edge case where there is something in the ALU with bit 2 unset during a PLP that has bit 2 set before and after it gets unset long enough for an IRQ to get flagged.

I've bodged this by not allowing IRQs to latch during the time when the P register is being updated. This might not be the best method, I probably ought to change the state machine logic to only set the LDP flag during the right machine cycle. (With my botch there's a chance that a short interrupt "blip" could get missed).

I'll be studying the T65 source in more detail soon to try and work out which 65816 instructions look to be correctly implemented and which aren't.

I also intend to change the code to use generics for the processor mode (instead of signals) hopefully that should reduce the number of slices.

Thing is I'm still feeling my way with all this VHDL stuff so spend quite a lot of time chasing my tail...

My test program was:

Code: Select all

mos_handle_res:
        ldx     #$FF
        txs

        lda     #$FF
        pha
        
        lda     #0
        adc     #1
        
        plp
        jmp     mos_handle_res
I stepped through this and forced the IRQ_n line low in the RTL simulator and found that the processor was jumping to the irq handler straight after the plp, which it shouldn't have as SEI was in effect.

D

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Sat Mar 29, 2014 10:41 am

Oops forgot to mention. The version of T65 is the latest one I could find (from Mike Stirling's BBC on a DE1 project. Much of the VHDL in this project is lifted from this project.

At some point I'll see about posting these "fixes" to Opencores

Cheers

D

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Fri May 02, 2014 6:13 pm

I've been a bit quiet on this recently - I've been in for an operation and once again I've also taken my car to pieces so need to spend a lot of free time on that.

I've made a few improvements - it now has the RAM working from DE0's on board SDRAM chip - I wrote my own SDRAM controller which is a bit simplistic but seems to work. This also allowed me to make a bit more on-chip space for ROMS.

The next thing I've tried is adding in a user via and connecting this up to an SDCARD and loading the MMBEEB rom. So far no joy - just get image not found though it looks to be talking to the SDCARD. Just get card? if no card inserted.

Before I spend a lot of time delving - is it likely to be my SDCARD? The one I've got is a 2Gb "integral" brand one I've had in a GP2X for years. It does look to be formatted as FAT16 and is not fragmented....

D

dominicbeesley
Posts: 960
Joined: Tue Apr 30, 2013 11:16 am
Contact:

Re: FPGAs and 65816's

Post by dominicbeesley » Sat May 03, 2014 12:16 pm

Got a bit further this morning - the BEEB.MMB file wasn't in the first eight directory entries on the card so I moved it with a sector editor. It now recognises the card and image but I just get garbage when I do a *DCAT or *DIN/*.

Any ideas?

Post Reply