6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 5:13 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Sat Jul 01, 2023 4:02 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
Hello everyone!

I've been working on my new Xilinx CPLD project, but wanting to go a different route than normal. Introducing the mess o' wires that somehow is running 6502 assembly code on an Arduino!

First, the memory map is:

$0000-$03FF = 1K of direct access RAM on Arduino, duplicated from $0000-$7FFF
and
$F000-$F7FF = 2K of display RAM for text characters through VGA
$F800-$FFFF = 2K of code RAM loaded from the SD Card, both of these are duplicated from $8000-$FFFF

The Arduino loads the first 2K from the SD Card, puts it in $F800. It assumes this is 6502 assembly code, and (currently) runs it immediately. My testing code is small:

Code:
   .65C02

   .ORG $F800

   LDY #$00
   LDX #$02
loop
   LDA #'T'
   STA $F000,Y
   INY
   LDA #'e'
   STA $F000,Y
   INY
   LDA #'s'
   STA $F000,Y
   INY
   LDA #'t'
   STA $F000,Y
   INY
   DEX
   BNE loop
   LDA #'!'
   STA $F020
   STP

   .ORG $FFFC
   
   .BYTE $00,$F8
   .BYTE $00,$F8


After that, it goes into "scratchpad" mode, where I can just type whatever I want from the PS/2 keyboard onto the screen. I plan to creating a little menu where it will run the assembly code on command, instead of simply being a bootloader only.

I completely despise using this breadboard, it has failed me multiple times and has been more of a problem than a solution. Yet, it works *right now* and that's good enough. I plan on making an SMT style board for this very soon.

More updates when I have them. Thanks everyone!

Chad


Attachments:
20230701_104209.jpg
20230701_104209.jpg [ 2.27 MiB | Viewed 852 times ]
20230701_104122.jpg
20230701_104122.jpg [ 2.05 MiB | Viewed 852 times ]
Top
 Profile  
Reply with quote  
PostPosted: Sat Jul 01, 2023 9:58 pm 
Offline

Joined: Tue Jul 05, 2005 7:08 pm
Posts: 1043
Location: near Heidelberg, Germany
Do you have an architectural overview or schematics diagram?
I'm somewhat lost on your description and the picture

_________________
Author of the GeckOS multitasking operating system, the usb65 stack, designer of the Micro-PET and many more 6502 content: http://6502.org/users/andre/


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2023 2:03 am 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
Here is the schematic.

Sorry for the confusion. The idea is that I am using an Arduino to run 6502 assembly code. I've seen others do this, but what's different here is that it is also more "stand alone", using VGA display and PS/2 Keyboard. I could use the serial connection with the Arduino but am choosing not to.

The code on the Arduino has all of the inner workings of the 6502 processor. Well, it has all of the instructions except for zero-page, which I haven't gotten to yet. The 6502 code is stored on the SD card. On boot, the Arduino loads the 6502 assembly code (in binary form) into RAM, and then executes it, acting just like a 6502 processor. So, I guess that counts as simulation/emulation.

The memory map is very strange, because the Arduino's direct access RAM is very small, and the extra RAM I put on it is mainly for video display. Thus, the only effective places in memory available are $0000-$03FF for quick RAM, $F000-$F7FF for slow display RAM, and $F800-$FFFF for slow general RAM. Still 2KB of 6502 code can go a long way. A game or a system monitor program would be some options.

The reason I put it in the "hardware" section on the forum is because it's very much in the hardware phase. As you can see, the breadboard mess is still a work in progress. But, as of now, it seems to work 99% of the time, which is all I can ask for at this point :)

I don't know how fast it's effectively running the 6502 simulation/emulation, I haven't benchmarked it yet. Though the Arduino is at 16 MHz this will be FAR SLOWER due to slow RAM access and other internal workings.

I hope that clarifies. Thank you!

Chad


Attachments:
Schematics.pdf [141.36 KiB]
Downloaded 51 times
Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2023 5:54 am 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
It's an interesting concept - not new though - but have you seen the recent port by Ed? ie. how good is your 6502 emulator ;-)

viewtopic.php?f=1&t=7640

You might want to look at the ATmega1280p (or similar) - 16KB internal RAM. I use one in my Ruby board - plan A was to use it to generate composite video directly (with external 65c02) and that worked, but it used 9KB for the video RAM and stole too many cycles to be usable enough...

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2023 7:59 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
I like to call this kind of project embedded emulation - it's emulation on a microcontroller, rather than on a personal computer. It's a single application which starts at power-on. From a certain perspective, it acts like a 6502 computer, and that's great. From other perspectives, it doesn't, and there are other kinds of projects to address that.

On the subject of correctness, or validation, the Dormann test suite is very good, although it takes a while to run. I wouldn't worry too much about my test on obscure JSR behaviour! It's not uncommon for people to work towards getting a Basic (perhaps a tiny Basic) up and running - but VTL02, or Forth, would be interesting alternatives. Of course, just getting a blinking LED working is a milestone.

Nice project, anyway!


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2023 8:50 pm 
Offline
User avatar

Joined: Wed Feb 14, 2018 2:33 pm
Posts: 1488
Location: Scotland
BigEd wrote:
but VTL02, or Forth, would be interesting alternatives. Of course, just getting a blinking LED working is a milestone.

Nice project, anyway!


Never underestimate the power of a blinking LED!

-Gordon

_________________
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/


Top
 Profile  
Reply with quote  
PostPosted: Sun Jul 02, 2023 10:15 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
drogon wrote:
BigEd wrote:
but VTL02, or Forth, would be interesting alternatives. Of course, just getting a blinking LED working is a milestone.

Nice project, anyway!


Never underestimate the power of a blinking LED!

-Gordon


You mentioned it, so I have a mini-story. While I've been breadboarding (which is not regular for me), I have had a lot of wires and other components all over my desk area. My 5yo daughter was wanting to put wires into components like I was, so I gave her her own breadboard with some wires and other things like capacitors, an LCD thing, some random chips, and all that. She's been connecting things together for a few days now, but of course when she plugs it in, nothing happens. So today I got some LED's out, and told her to put them here, put this resistor there, connect these together, bring this to the power rail, etc. And she made mistakes of course and so I said, "Oh, it's not lighting up, did you really put that where it should be?" She adjusted things and it lit up! She then connected a button, then a switch, then an inverter chip with my assistance.

Who knows, maybe the next great electronics genius just make a blinking LED? Or, maybe it was just a fun project with daddy :)

Thank you both, Ed and Gordon.

Chad


Top
 Profile  
Reply with quote  
PostPosted: Thu Jul 13, 2023 12:40 pm 
Offline

Joined: Sat Oct 09, 2021 11:21 am
Posts: 718
Location: Texas
Coming from my SMD soldering topic, here:

viewtopic.php?f=1&t=7629&start=30#p101467

It works! And the first time! :)

I've done some modifying to the code and structure since the last posts, so here is a refresher/update:

This is an Arduino "shield" that displays characters through VGA, has access to a PS/2 Keyboard, and uses an SD card module for storage. I have a fully populated W65C02 assembly code emulator/simulator inside of the Arduino's ROM (well, minus the RMB, BBR, TSB, and TRB codes). I also put a line editor in there, so that I can eventually run BASIC or some such on it.

Right now it has a flavor of Wozmon inside the line editor. That means you can type out, modify, run, save, and reload a number of monitor commands. Or you can directly access the monitor commands with the $ symbol.

The memory map has changed a bit. $0000-$01FF (duplicated to $0FFF) uses the Arduino's internal RAM which is very fast. $1000-$1FFF (duplicated to $FFFF) uses the display RAM which is very very very slow in comparison since I'm accessing it serially. The 512 bytes on the Arduino's RAM can be saved and reloaded from it's own internal EEPROM, while the rest of the memory gets sent to the SD card for storage.

This module can also be used as a 'dumb terminal', connected serially to a different 6502 unit, or even the PC. You type on the PS/2 keyboard and it sends ASCII commands. You send it ASCII commands, and it displays the results on the screen. The vertical scrolling is software based, but because it also uses the internal RAM, it is quite fast and responsive.

I plan on adding BASIC to this, as well as Tetris.

And that's it for now! Thanks everyone!

Chad


Attachments:
20230712_181101.jpg
20230712_181101.jpg [ 2.38 MiB | Viewed 635 times ]
20230713_071015.jpg
20230713_071015.jpg [ 2.02 MiB | Viewed 635 times ]
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 31 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: