6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Wed May 15, 2024 3:45 am

All times are UTC




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: 6502 wide stack
PostPosted: Wed Nov 29, 2017 12:54 pm 
Offline

Joined: Wed Nov 29, 2017 10:43 am
Posts: 7
Location: Riva del Garda (38066 TN) Italy
Hello

I put a my old VHDL project of a wide (16 bit) stack 6502 CPU, also I added some useful opcodes for fast contest switch, zero page relocation etc.
The CPU has binary/decimal ALU for full compatibility, I tested this CPU on several projects (on Altera Cyclone IV) as intelligent I/O coprocessor for industrial automation projects for my company.
The clock cycles needed for opcodes are almost identical to original 6502 project, some opcode need less clock cycle than original CPU.

Best Regards
Valerio Venturi
Italy


Attachments:
6502 wide stack.zip [31.68 KiB]
Downloaded 181 times
Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Wed Nov 29, 2017 3:38 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3354
Location: Ontario, Canada
Welcome, Valerio :)

This is a nice selection of improvements. For example the exchange instructions appeal to me -- something so simple, but so worthwhile. It's almost like having new address modes. For example, if you want (ind),X mode then just use XYZ -- ie; exchange X with Y -- and follow up by using (ind),Y mode.

Maybe you can tell us more about that I/O coprocessor, please.

-- Jeff


Code:
; new V6502 opcodes macros
phr:                .macro             ;AXY->SP: push A,X,Y to stack (useful for fast context switch)
                    .byte        $8b
                    .endm
                   
plr:                .macro             ;SP->YXA: pull A,X,Y from stack (useful for fast context switch)
                    .byte        $ab
                    .endm

taz:                .macro             ;A->Z: copy A to zero page register (MSB base address)
                    .byte        $1b
                    .endm
                   
tza:                .macro             ;Z->A: copy zero page register to A
                    .byte        $3b
                    .endm

txy:                .macro             ;X->Y: copy X to Y
                    .byte        $9b
                    .endm
                   
tyx:                .macro             ;Y->X: copy Y to X
                    .byte        $bb
                    .endm

xyx:                .macro             ;X<->Y: exchange X with Y
                    .byte        $eb
                    .endm

xax:                .macro             ;A<->X: exchange A with X
                    .byte        $0b
                    .endm

xay:                .macro             ;A<->Y: exchange A with Y
                    .byte        $2b
                    .endm

isp:                .macro             ;X -> S (lsb); A -> S msb: copy X and A to S (16 bit stack pointer)
                    .byte        $4b
                    .endm

tsp:                .macro             ;S lsb -> X; S msb -> A: copy S to X and A
                    .byte        $5b
                    .endm

                   
jsrx:               .macro       arg1  ;JSR ($XXXX,X) jump vector table indexed by X
                    .byte        $fc
                    .word        arg1
                    .endm

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Mon Dec 04, 2017 10:55 am 
Offline

Joined: Wed Nov 29, 2017 10:43 am
Posts: 7
Location: Riva del Garda (38066 TN) Italy
Hello Jeff

I am sorry for delay to answer you but I was very busy, I used the V6502 as I/O coprocessor (or slave CPU) to help main CPU (PowerPC MPC5200) to execute several high speed tasks such intelligent DMA controller, several I2C and SPI interfaces, one CAN bus, incremental encoders, and some discrete I/Os, all of these devices was included in a large FPGA project. Also the ROM and SRAM for the V6502 was included in the FPGA and the main CPU could update "on fly" the software via a simple I2C bus. The main board project was a real time controller for robotic systems.
I choosed the 6502 due to his high deterministic architecture, and also for his speed to execute simple tasks, (the CPU clock was 50 MHZ and the preemptive multitasking interrupt ran at 10 KHZ, 100 microseconds per task).
Today the project is almost obsolete and we moved to a new ARM architecture.

-- Valerio


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Mon Dec 04, 2017 2:56 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1929
Location: Sacramento, CA, USA
valerio63 wrote:
Today the project is almost obsolete and we moved to a new ARM architecture.

Thankfully, your robot didn't have an ego, because it would have taken a serious hit.

Mike B.


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Mon Dec 04, 2017 4:43 pm 
Offline

Joined: Wed Nov 29, 2017 10:43 am
Posts: 7
Location: Riva del Garda (38066 TN) Italy
.....the destiny of everyone (even the robots) is to become obsolete....:)


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Tue Dec 05, 2017 8:36 am 
Offline

Joined: Wed Nov 29, 2017 10:43 am
Posts: 7
Location: Riva del Garda (38066 TN) Italy
Hello

i posted an example of multitasking source code for V6502


Attachments:
v6502_multitasking.asm [12.72 KiB]
Downloaded 167 times
Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Tue Dec 05, 2017 10:19 am 
Offline

Joined: Wed Nov 29, 2017 10:43 am
Posts: 7
Location: Riva del Garda (38066 TN) Italy
I added a PDF file that shows the improvements of V6502


Attachments:
V6502WS.pdf [58.19 KiB]
Downloaded 183 times
Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Tue Dec 05, 2017 10:31 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10800
Location: England
Thanks!

As an aside, this note is interesting:
Quote:
Unlike 65C02 the RES input cannot be used as additional interrupt request signal...

We did discuss that here - it seems the early 'C02s did write to stack during reset, but the later 'C02s from WDC do not...

Having RTI pull the Z register could break some existing software, but I see why it's useful. A tradeoff!


Top
 Profile  
Reply with quote  
 Post subject: Re: 6502 wide stack
PostPosted: Fri Dec 29, 2017 8:48 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1929
Location: Sacramento, CA, USA
Updated version here:

viewtopic.php?f=10&t=5026

Mike B.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 guests


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: