[HN Gopher] Virtualizing the 6502 on a 6502 with 6o6
       ___________________________________________________________________
        
       Virtualizing the 6502 on a 6502 with 6o6
        
       Author : goldenskye
       Score  : 176 points
       Date   : 2024-05-12 02:00 UTC (21 hours ago)
        
 (HTM) web link (oldvcr.blogspot.com)
 (TXT) w3m dump (oldvcr.blogspot.com)
        
       | userbinator wrote:
       | Despite how simple and limited the 6502 is, it's always
       | interesting to see this almost 50-year-old architecture being
       | stretched to new limits. 6502 cores are still found in some SoCs
       | aimed at the ultra-low-cost high-volume market.
        
         | dailykoder wrote:
         | > 6502 cores are still found in some SoCs aimed at the ultra-
         | low-cost high-volume market.
         | 
         | What's the reason behind that? Probably just keeping existing,
         | working designs and thus saving R&D costs? Sounds like beating
         | a 10 cent risc-v core would be hard.
         | 
         | Edit: When I first read your comment I had to chuckle a bit,
         | because I got the image of a multicore SoC with 6502 6502
         | cores. That would be a fun project for my FPGA hmmmmmmmm ...
        
           | themoonisachees wrote:
           | 10c per part is incredibly high depending on how low-cost
           | we're talking.
           | 
           | If your chip needs very basic processing, and you're going to
           | sell it for less than a cent per chip, you need your core to
           | be basically free.
           | 
           | Sure RISC-V is very inexpensive, but for parts like these
           | risc is massive overkill and as a modern core, you'll be
           | spending a lot of die area on a core that should really be an
           | ASIC, but designing an ASIC is expensive so you can just slap
           | a 6502 in that bad boy and call it a day.
           | 
           | On the other end of the scale, you'd be surprised to learn
           | that many chips you don't ever interface with as a user
           | contain even ARM cores. These are usually ASICs in high-end
           | products.
        
             | jeffgreco wrote:
             | Go on!
        
             | snvzz wrote:
             | >but for parts like these risc is massive overkill
             | 
             | You seem to underestimate how small a RISC-V core can be.
             | 
             | Take a look at SERV.
        
               | irdc wrote:
               | There's also the cost of rewriting (yes, from assembler)
               | all the existing code. And don't forget QA.
        
               | monocasa wrote:
               | The area of just the register file (even for rv32e) is
               | higher area than the survivors of the 8 bit ucontrollers.
        
               | userbinator wrote:
               | 16 registers * 32 bits * 4 transistors / cell = 2k
               | transistors just for storing the bits alone, and that's
               | not including the decoding and read/write circuitry.
        
           | utensil4778 wrote:
           | A _lot_ of cheap USB1 /2 widgets are actually a 6800 core.
           | It's crazy how these old CPUs have stuck around for so long
        
         | ddingus wrote:
         | There is a ton of code out there for pretty much any task you
         | want.
         | 
         | I have the 16 bit successor, the 65816, on a variable speed
         | expansion card in my Apple 2. I run it in 8 bit mode most of
         | the time mostly because it works and most library code is 8
         | bit.
         | 
         | At those speeds, the chip is fast! Especially when one
         | considers the simple model: ram clocked 1:1 with the cpu. In my
         | case, I can run code over the 1Mhz bus, essentially turning
         | most multi cycle ops into a single bus cycle per memory fetch.
         | 
         | Or, the card has a megabyte of RAM and that runs at CPU speed.
         | (0.15 to 16 Mhz) When doing that, it is fast enough to run
         | large programs, written in higher level languages, at a useful
         | speed. Of course Assembly language is crazy fast.
         | 
         | It is a pretty fun environment to hack around in.
        
       | sitkack wrote:
       | This post has been hanging out with no comments for ages. I was
       | like, I'll skim it later.
       | 
       | > It's almost burying the lede to announce that, though, because
       | the real meat in this entry is how the Commodore 64 manages to
       | emulate a very different 6502-based system. That piece is "6o6,"
       | for "6502-on-6502," and is a full virtualized software NMOS 6502
       | CPU that runs on a 6502 CPU -- which I've open-sourced too. It
       | has full control of guest code execution, including trapping
       | undocumented and jam opcodes, and completely abstracts all memory
       | access, making it possible to remap addresses, intercept illegal
       | reads or writes, or even run entirely from virtual memory. On top
       | of that, it's complete enough to not only pass a full functional
       | test but also virtualize itself virtualizing itself:
       | 
       | This is incredible! Not just from a 6502 perspective, but from an
       | everything perspective! Amazing work.
       | 
       | Also, it reminded me of this "The Zilog Z80 has a Protected Mode"
       | https://www.youtube.com/watch?v=DLSUAVPKeYk posted to hn, but got
       | no discussion.
        
         | FLT8 wrote:
         | Also related: C64 booting Linux by emulating a RISC-V
         | processor:
         | 
         | https://hackaday.com/2023/08/27/linux-on-a-commodore-64/
        
           | sitkack wrote:
           | Wow!
           | 
           | > There is a catch (rather: a couple) of course: It runs
           | extremely slowly and it needs a RAM Expansion Unit (REU), as
           | there is no chance to fit it all into just 64KiB.
           | 
           | > It even emulates virtual memory with an MMU.
           | 
           | https://github.com/onnokort/semu-c64
        
           | userbinator wrote:
           | That reminds me of this similar project using an ARM emulator
           | instead: https://news.ycombinator.com/item?id=5581851
        
         | elvis70 wrote:
         | > Also, it reminded me of this "The Zilog Z80 has a Protected
         | Mode" https://www.youtube.com/watch?v=DLSUAVPKeYk posted to hn,
         | but got no discussion.
         | 
         | Here is a thread with 138 comments:
         | https://news.ycombinator.com/item?id=33229526
        
       | drpossum wrote:
       | https://archive.fo/2u3Y8
        
         | aspenmayer wrote:
         | https://web.archive.org/web/20240512030623/http://oldvcr.blo...
        
       | andrea76 wrote:
       | Can it run GEOS in a GEOS window?
        
       | varispeed wrote:
       | I had goosebumps reading it. I will have to read again and
       | again... Amazing!
        
       | vertnerd wrote:
       | > Here's the first of my bucket list projects I'm completing
       | which I've intermittently worked on for literally two decades.
       | 
       | This one hell of a bucket list you must have. Respect.
        
       | cobbzilla wrote:
       | This is amazing. It brings back memories of the first time I
       | taught myself 6502 assembly, there was a book called "The Visual
       | Computer" that came with an emulator on a floppy disk. It was
       | very eye opening! I found a PDF of the book [1] but not sure if
       | the software on the floppy survives anywhere.
       | 
       | [1] https://files.commodore.software/reference-
       | material/books/c6...
        
         | pvg wrote:
         | Not sure about the C64 one but I've seen the Apple ][ one on
         | the software archive sites before sites before. It's _The
         | Visible Computer_ , a reference to these educational models:
         | 
         | https://americanhistory.si.edu/collections/nmah_214319
         | 
         | 'Visual 6502' is the name of the modern gate and transistor
         | level 6502 simulators:
         | 
         | http://visual6502.org/JSSim/index.html
        
           | cobbzilla wrote:
           | Thank you, you're right, I remembered the name wrong. It was
           | The Visible Computer. I was learning on an Apple //c
        
       ___________________________________________________________________
       (page generated 2024-05-12 23:00 UTC)