6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Jul 05, 2024 6:58 am

All times are UTC




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: Thu Oct 13, 2016 5:43 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1696
Location: Sacramento, CA
I bought an Atmel ARM Cortex M7 development board a few weeks ago. Cost was ~$40. Here's a link to the board on Mouser:
http://www.mouser.com/search/ProductDet ... AME70-XPLD

Attachment:
ATSAME70XPLD_SPL.jpg
ATSAME70XPLD_SPL.jpg [ 36.14 KiB | Viewed 4612 times ]


Anyway, after a week of getting to know how the built in tools worked, I was able to port some of my old 65C02 Simulator for Windows C code and have a working emulator running. It is using a virtual COM port over USB set at 115200 baud and running my SBC2OS. Tonight, I built in a cycle counter and tomorrow I plan to play with onboard timer interrupts to calculate the emulated processor speed. With a 300MHz Fmax, it should be pretty darn fast - even with 0 optimizations.

From there, I will start playing with all of the built-in IO on the dev board. It has USB support (in addition to the debug USB port), 2MB of SDRAM, Ethernet, SD card, SPI, TWI, multiple USARTS, and many other features. I may even play around with some sort of video output and/or 65816 Emulation.

Its the big brother to my other Atmel 65C02 Emulator -> http://sbc.rictor.org/avr65c02.html

I'll share more as I go.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 13, 2016 8:07 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10838
Location: England
Should be interesting - looking forward to updates.


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 15, 2016 12:36 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1696
Location: Sacramento, CA
Well, first go around was disappointing. It measured 7.7MHz while waiting in a loop to receive a character on the serial port. When I did a multi page dump of memory, it dropped as low as 5.9MHz. I'm using the built-in library supplied with the Atmel Studio 7 GCC. Apparently, the learning curve on ARM assembly is pretty steep and most developers stick with C.

I've been reading some "bare metal" applications papers which got me interested in this in the first place. I think I'll work on some optimizations concerning system IO and then work on the Simulator code.

I was hoping for 20-40 MHz target clock while still supporting the advanced IO available - SD card, USB, Ethernet. I think low res video still might be an option if I can utilize the DMA resources and dual-ported SRAM without too much of a performance penalty.

The good news is I'm in no hurry and plan on exploring one thing at a time.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 15, 2016 5:47 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10838
Location: England
ARM assembly is not at all bad if you're already a 6502 expert - main difference is you have to consider how to use all the registers, because if you only use three you'll have a lot more loads and stores than you need. Although I see now that this core speaks only the Thumb variant of ARM code, which means the register set is split into two halves and things are a bit more awkward.

For a 300MHz device, 30MHz should be achievable but probably not using C. Maybe Chris Baird's stm6502 would manage 15MHz though, on previous experience. Maybe you could try that, or the lib6502 core? (There are two assembly language 6502 cores which should go faster, but 65tubeasm in PiTubeDirect is full ARM and a6502 is Thumb-2, so either would need some effort to port.)


Last edited by BigEd on Tue Oct 25, 2016 6:11 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 15, 2016 3:49 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1696
Location: Sacramento, CA
Thanks for the references Ed. I figured out why the cycle count drops when I send through the serial port, now the cycle count is more consistent a 7.4 -7.7 MHz. When waiting for the TX buffer to empty, the ARM code was looping, essentially pausing the 6502 clock. Now the 6502 code loops.

I have my AVR emulator code in assembly and I had though I might be able to use that a reference point. I will do some tweaking of the C code first. I had actually looked at Samuel's lib65816 as a possible next step as well. It would be a better match for the 2MB SDRAM the ARM board has too.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 15, 2016 3:50 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10838
Location: England
Ah - a 65816 emulation - even better!


Top
 Profile  
Reply with quote  
PostPosted: Mon Oct 17, 2016 4:29 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1696
Location: Sacramento, CA
Yes, I have downloaded lib65816 and your run65816.c and will give it a more detailed look.

Yesterday I played with running the "Execute" routine for several cycles before returning to the main loop. I found extending the Execute loop for 24 cycles worth of instructions increased the overall speed to 10MHz. Going beyond that did not yield any significant performance increase.

Trying to optimize the Execute code would be my next step, but I'm itching to give lib65816 a try first. I'll start with just a 64k system first.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Thu Oct 20, 2016 3:41 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1696
Location: Sacramento, CA
Tonight I finally got the lib65816 code running. I had a lot of trouble with the CPU Event system so I eventually gave up and am using the old E_UPDATE method, which will serve my purpose just fine. The bad news is that it is running at 4 MHz.

It looks like I'll be digging out the ARM assembly language reference manual.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 22, 2016 10:38 am 
Offline
User avatar

Joined: Sun Oct 13, 2013 2:58 pm
Posts: 485
Location: Switzerland
Hi Daryl,

this is cool, I'll need to order one of those as well. I think 4MHz for a first run with a library that is not necessarily speed optimized is not too bad for a 65816 emulation. Although compared to the performance of the 8-bit AVR based emulation it is poor. However I think porting the speed relevant parts to assembler will accelerate the emulation quite a bit. And it has lots of IO, Ethernet, USB, SPI, .. and as you said using DMA a video interface should be feasible.

Cheers

Peter


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 22, 2016 3:58 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1696
Location: Sacramento, CA
Hi Peter,

Yes, this board does have a lot to offer considering the relatively low price. I actually started looking at the 32 bit AVR's and found a few that offered similar features but their Fmax was 60MHz. Also, from what I read, they are being overtaken by the ARM in a majority of the industry and may not be around much longer. So, I switched my focus to ARM and when I found this board, it fit my needs almost perfectly. One of the best things about it is that it has a built-in download/debug interface so all I needed was to install Atmel Studio 7 and away I went.

I have downloaded a few assembly examples for ARM using Studio 7 and am reading over the programming manual. I plan to keep the C wrapper and some of the initialization code and will try to port the CPU_Execute routines to assembly. My hope is to bring the speed up to 20MHz, which would make them at least equivalent to the actual 65C02/65816's.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 22, 2016 5:25 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
I timed my C/C++ 65c816 emulator on my Chipkit wifire 200 MHz PIC32MZ for comparison and its a little faster at around a 6.2 MHz emulated clock.

The Chipkit works like an arduino and currently I'm only doing one instruction execution per call to loop (). Doing more steps per call might increase it a bit.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 22, 2016 6:07 pm 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
BitWise wrote:
I timed my C/C++ 65c816 emulator on my Chipkit wifire 200 MHz PIC32MZ for comparison and its a little faster at around a 6.2 MHz emulated clock.

The Chipkit works like an arduino and currently I'm only doing one instruction execution per call to loop (). Doing more steps per call might increase it a bit.


Indeed, more steps per loop definitely helps:
Code:
EM65C816 [16.10]
FCPU = 200000000
PCLK = 100000000

76799994 cycles in 7824744 uSecs = 9.82 MHz
153599989 cycles in 15652592 uSecs = 9.81 MHz
230399982 cycles in 23480612 uSecs = 9.81 MHz
307199976 cycles in 31308633 uSecs = 9.81 MHz
383999971 cycles in 39136653 uSecs = 9.81 MHz
460799964 cycles in 46964673 uSecs = 9.81 MHz
537599958 cycles in 54792693 uSecs = 9.81 MHz


The code is currently configured for 384K of RAM (with a 4K boot image copied to $00:F000) and 128K of ROM.

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 22, 2016 6:42 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10838
Location: England
We can call that 10MHz - excellent!


Top
 Profile  
Reply with quote  
PostPosted: Sat Oct 22, 2016 8:06 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 9:02 pm
Posts: 1696
Location: Sacramento, CA
Yes, very nice results! Especially for C code.

Daryl

_________________
Please visit my website -> https://sbc.rictor.org/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: