Page 2 of 3

Re: PIC Modules for Emulation

Posted: Sun Apr 14, 2013 11:34 am
by BigEd
Very nice!

Re: PIC Modules for Emulation

Posted: Mon Apr 15, 2013 10:31 am
by BigEd
Hi Andrew - this is a 5V tolerant part, I think? That's handy. My a5602 project (inspired by cjb's stm6502[1]) runs on a cheap ARM SoC board, which has many 5V tolerant I/Os, but is rather bulky.

It might be interesting to run your benchmark - it looks like it's this one: http://mdfs.net/Docs/Comp/BBCBasic/BenchMrks2 - is that so?

Cheers
Ed

[1] viewtopic.php?f=8&t=2177

Re: PIC Modules for Emulation

Posted: Mon Apr 15, 2013 10:41 am
by BitWise
BigEd wrote:
Hi Andrew - this is a 5V tolerant part, I think? That's handy. My a5602 project (inspired by cjb's stm6502[1]) runs on a cheap ARM SoC board, which has many 5V tolerant I/Os, but is rather bulky.

It might be interesting to run your benchmark - it looks like it's this one: http://mdfs.net/Docs/Comp/BBCBasic/BenchMrks2 - is that so?

Cheers
Ed

[1] viewtopic.php?f=8&t=2177
Its a 3V3 device but some of the I/Os are 5V tolerant. How many do you need?

Yes thats the bench mark I'm using. I can't do the recursive part with 8K of RAM but I think the device may be able to support 16K of emulation memory - There is a discrepency between the data sheet (16K) and the memory I can see in the debugger (18K). I need to change a couple of macros and rebuild to test it out.

And I think I might try a little overclocking as well - See how far I can push it.

Re: PIC Modules for Emulation

Posted: Mon Apr 22, 2013 8:42 pm
by BitWise
I've made all the code available as a SourceForge project

https://sourceforge.net/projects/em-65c02/

Re: PIC Modules for Emulation

Posted: Mon Apr 22, 2013 9:28 pm
by BigEd
That's great, thanks!

Re: PIC Modules for Emulation

Posted: Fri Jul 05, 2013 9:14 pm
by BitWise
A short video showing my VT220 shield and 65C02 emulation working together to run a simple BBC BASIC program.

https://plus.google.com/u/0/11755257763 ... cbhb7P7w6a

Re: PIC Modules for Emulation

Posted: Sat Jul 06, 2013 3:57 pm
by BitWise
I've increased the RAM available to the emulation to 15K on the same device (wrapped at the 16K boundary). The area above the 15K ($3C00-$3FFF) is shared with the CPU stack.

Re: PIC Modules for Emulation

Posted: Sat Jul 06, 2013 4:21 pm
by BigEd
Does that offer the amusing possibility of escaping the emulation by smashing the stack?

Re: PIC Modules for Emulation

Posted: Sat Jul 06, 2013 4:32 pm
by BitWise
BigEd wrote:
Does that offer the amusing possibility of escaping the emulation by smashing the stack?
It does at the moment but I think I'll move the stack below the RAM in the next build then it the end area will map onto ROM which will put a stop to that.

I think I can also squeeze another 3/4 of a K into the RAM area so only a single 256 byte page is reserved for the host device.

Re: PIC Modules for Emulation

Posted: Sun Jul 07, 2013 6:19 pm
by Michael
Very nice demo', Andrew. Keep up the good work...

Cheerful regards, Mike

Re: PIC Modules for Emulation

Posted: Wed Aug 07, 2013 7:51 am
by BitWise
Having reached the limits of the Microchip 24F/33F chips (for the time being). I've been porting my emulation to a PIC32MX device and expanding the range of devices handled. I now have a 65C816 emulation with 128K of RAM and an 8080 with 64K.

I'm using a uJet32+ module http://www.ebay.co.uk/itm/PIC32MX795F51 ... 5278wt_981 which has a micro SD socket.

I'm working towards being able to boot CP/M 2.2 in the 8080 emulator and considering designing my own surface mount board combining a PIC32 and a PIC24 running my terminal software to make a 'CP/M on a credit card' system.

Later this year Microchip are releasing a new range of PIC32MZ devices with 1M of flash ROM and 512K of RAM operating at 200MIPS (the MX is only 80MIPS) which will give my code a 2.5x speed boost. I should be able to emulate a 65C816 at ~10-12MIPS (maybe more).

Re: PIC Modules for Emulation

Posted: Mon Sep 30, 2013 11:56 am
by BitWise
Microchip appear to have finally released the PIC24EP512GP202-I/SP devices I have been waiting for and some are due to be delivered this week so I can test the latest version of my emulator with a full 32K of RAM, 32K ROM and an improved execution loop/interrupt handler that should be a little faster than the old code.

All you need is one 10K resistor, 2x 100nF cap, a 10uF tant. cap, a single chip (for £3.23) and 3.3 volts for a 6Mhz+ 65C02 system that can use the PICs peripherals (I/O, SPI, I2C, UART, etc.) with support for IRQs and NMIs. A cheap PL2303 module (from eBay) can be used to connect using RS232 and power the circuit.

I've moved the code to the new MPLABX IDE and will be restructuring the public SVN archive (to support trunks for MPLAB and MPLABX) before I upload the new code.

*Edit: Missed a cap off the component list.

Re: PIC Modules for Emulation

Posted: Mon Sep 30, 2013 12:07 pm
by BigEd
Sounds great!
How does the emulated CPU see the peripherals - escaped opcodes such as WDM, or emulated memory-mapped I/O, or something else?

Re: PIC Modules for Emulation

Posted: Mon Sep 30, 2013 2:20 pm
by BitWise
BigEd wrote:
Sounds great!
How does the emulated CPU see the peripherals - escaped opcodes such as WDM, or emulated memory-mapped I/O, or something else?
I use the 65C816 coprocessor instruction COP ($02) to access a small number of native code functions that do things like read/write memory and set/clear/toggle bits - much like the BBC's OSBYTE/OSWORD calls.

The simple implemention of OSRDCH in my MOS emulation is:

Code: Select all

		PHX
		PHY

		REPEAT			; Wait for character to be available
		 LDX #<(U1STA+URXDA/8)
		 LDY #>(U1STA+URXDA/8)
		 IO_READ
		 AND #1<<(URXDA%8)
		UNTIL NE

		LDX #<U1RXREG		; Then read it
		LDY #>U1RXREG
		IO_READ

		PLY
		PLX
		RTS
Where IO_READ is defined as:

Code: Select all

IO_READ		.MACRO
		.BYTE	$02,$01
		.ENDM

Re: PIC Modules for Emulation

Posted: Mon Sep 30, 2013 3:19 pm
by BigEd
Thanks for explaining - seems like a fine idea to me. Modelling memory-mapped I/O can only slow things down. (I hope I hadn't missed a previous explanation)