Build Your Own Computer - Emulate RAM/ROM For A 6502 Using a Raspberry Pi Pico

Поделиться
HTML-код
  • Опубликовано: 19 июн 2022
  • Any CPU needs RAM and ROM. If you are building a retro computer using a processor like the 8-bit 6502, you could use a RAM chip and an EEPROM chip, or you could use a Raspberry Pi Pico to emulate RAM and ROM for you!
    My Clock Module: • I Built a Computer Clo...
    Ben Eater - Build a 6502-based computer from scratch: • Build a 65c02-based co...
    Let Me Explain T-shirt: teespring.com/gary-explains-l...
    Twitter: / garyexplains
    Instagram: / garyexplains
    #garyexplains

Комментарии • 180

  • @keithduffield5239
    @keithduffield5239 2 года назад +63

    40 years ago 6502 was my bread and butter. Last program I did was in assembler that was assembled by a cross assembler on a VAX. Program was a real time range estimator for a SONAR system on a Daphne Class submarine using passive ranging. It was paired with a Motorola Maths Co-Processor. What took me a year and resulted in a few kilograms of paper source code could probably be done today with a Pico in a week.

    • @Barnaclebeard
      @Barnaclebeard Год назад +1

      Don't know why you'd casually mention that you are responsible for weapons of war or why that's acceptable to say. Not what 6502s are for, dude.

    • @keithduffield5239
      @keithduffield5239 Год назад +13

      @@Barnaclebeard If you can't make or understand the distinction between an offensive weapon and a defensive system, then that is your problem, not mine.

    • @null7936
      @null7936 Год назад

      Next life I will do such awesome stuff too :D

    • @FlyBy2507
      @FlyBy2507 Год назад +2

      @@Barnaclebeard Si vis pacem, para bellum.

    • @RealDevastatia
      @RealDevastatia 11 месяцев назад +2

      @@Barnaclebeard Are you for real? It's a general purpose CPU. It's "for" whatever someone wants to use it for.

  • @ftorresgamez
    @ftorresgamez 2 года назад +23

    The two most important CPUs that started the 8-bit revolution, the Z80 and the 6502, are still made today, almost 50 years after they were introduced to the world. You have to hand it to the great talents that designed, created and marketed these wonders. Sure, there was the 6809 and the 8080 but none were as loved and as important to the microcomputer era as the 6502 and the Z80.

    • @mikiex
      @mikiex 2 года назад +1

      But there would be no Z80 without the 8080 and no 6502 without the 6800, they are both evolutions on those chips.

    • @hermannseib
      @hermannseib Год назад +2

      Actually, I preferred the 6809 for its much more comprehensive instruction set (and the 16 bit arithmetics). The 6502 love back then was mostly based on the price tag, I think.

    • @petedavis7970
      @petedavis7970 Год назад +2

      @@hermannseib The Atari and it's 6502 was affordable-ish (I got mine for x-mas as a combined present from mother, father and step-mother and I paid half of the $600+ price tag) and at age 12, allowed me to finally start putting into practice the programming I had already learned from reading the book More Basic Computer Games. 41 years later I'm still doing my hobby, except it's been doing a fantastic job of paying my bills for about 35 years,

    • @hermannseib
      @hermannseib Год назад +2

      @@petedavis7970 Precisely. The emerging homecomputer market was created around the chips that allowed to build systems that hobbyists could afford. And, if memory serves right, the 6502 cost about half as much as the 6800 and its successors back then, so it was the better choice ... and thus conquered the market and the hearts of many.

    • @ColonelTux
      @ColonelTux Год назад

      My first computer was an Apple //e. I quickly graduated to programming in assembler and the 6502 was an absolute joy to program.

  • @timsanders9111
    @timsanders9111 Год назад +1

    I’m so glad I found this video. Thank you. I’ve been fascinated with the 6502 since it is the processor used in my first computer in 1983 - an Atari 400. My interest in computers started then and that’s when I knew I wanted to study engineering. This sounds like a great was to learn 6502 assembly. I’ll order a Raspberry Pi this weekend to get started!

  • @avejst
    @avejst 2 года назад +7

    Great solution with the rasp pico!
    Thanks for sharing your experience with all of us 👍 😀

  • @JoeBurnett
    @JoeBurnett Год назад +1

    This is an amazing tutorial! Thank you for making this!

  • @steventaylor6294
    @steventaylor6294 7 месяцев назад

    Beautifully delivered, Gary, thank you.

  • @nimrodlevy
    @nimrodlevy 2 года назад

    Loved it!!! Many thanks! I going to build one! It will be good learning for me!!

  • @martinfinch5011
    @martinfinch5011 2 года назад +4

    Awesome set of videos :)
    The one about how to build and assembler was very interesting. I'd like to see a similar video about building a simple compiler. I get the concept of assembly to machine code but the bridge from a higher level language down to machine code it a bit more complex I believe.
    Only small feedback. For series like these I think add a video number and a common main title so they are easy to find and follow. When searching on RUclips we don't always come across the play list but instead just the individual video. With a title like #1 How To Build A CPU: Assembly language, we will better know its part of a series.
    Looking forward to more :)

    • @GaryExplains
      @GaryExplains  2 года назад +4

      I am glad you like them. There is a playlist: How Does a CPU Work: ruclips.net/p/PLxLxbi4e2mYGvzNw2RzIsM_rxnNC8m2Kz

  • @saiyamjain772
    @saiyamjain772 Год назад

    Thank you for restarting this series🤝

  • @coding_and_things
    @coding_and_things 11 месяцев назад +1

    I got re-inspired recently to try this out (because of your video) and just got it working today. Started at 1Hz and worked my way up. I haven't implemented any form of write yet, so it's acting as a ROM right now just doing a simple loop, starting from $8000 and just looping back by a JMP $8000 command. But I'm pleased to say, it has been stable for the past hour running at 2MHz!! I had to jump through a lot of hoops to get to that level, but am extremely pleased at the result.
    The concept is very similar to yours, but the code is vastly different. Hoping to add write functionality tomorrow.
    Love you channel and keep up the great work!!

    • @GaryExplains
      @GaryExplains  11 месяцев назад +1

      Great job! 👍

    • @crazor01
      @crazor01 8 месяцев назад +1

      @coding_and_things I'd be very much interested in what you had to do to get this running at 2MHz! Did you post about your efforts anywhere? If not, would you be willing to have a chat on like Discord or anything else?

    • @coding_and_things
      @coding_and_things 7 месяцев назад +2

      @@crazor01 Hey there! I did it using the PIO and passing values from a char array (which is just really a 6502 prg file), using pio_sm_put_blocking(). Unfortunately, I don’t have a blog or anything like that, that I can refer you to. But look in to the PIO, at the standard clock rate of the Pico, the PIO executes code at 8nS per instruction. It’s extremely fast!

  • @andyshaw2800
    @andyshaw2800 Год назад +2

    Hi Gary
    Over lockdown I built the Ben Eater 6502 system on breadboard and thoroughly enjoyed making it. It was amazing and fascinating to go through. I was a massive 6502 fan back in the day, so it was great to re-visit the 6502.
    Having discovered your RUclips video by accident I will now be definitely be building this 6502 system with a raspberry pi pico. I am really curious as to how you get the pico to emulate RAM and ROM for the 6502.

  • @dabunnisher29
    @dabunnisher29 5 дней назад

    This looks AWESOME!!!! Cant wait to try. Thank you.

  • @tonyrobinson1349
    @tonyrobinson1349 Год назад +2

    If, like me, you want to do this yourself, you need a W65C02S (as shown in the video) not an old MOS 6502 (like was in my BBC micro). They are largely the same, the difference is that the S is for Static, it can be clocked when you like, whereas the MOS 6502 needs at least 50kHz (or so I'm told). Specifically '
    The W65C02S is a fully static core and the PHI2 clock can be stopped when it is in the high (logic 1) or low (logic 0) state.'. I've got 10 coming from Aliexpress, if they work I'm happy to distribute the surplus.

  • @DaveRepairs
    @DaveRepairs 2 года назад +3

    I often worndered if a PICO can be used to emulate hard to get hold of RAM (and processors) in Arcade board circuits as we entered into revolution of retro gaming, the problems we face in findng replacement parts and also diagnosing faulty boards has lead me here. It's been on my mind a while - Watched a few videos so far, quite a lot covered but very impressed with the 6502 vCPU project

  • @muddyexport5639
    @muddyexport5639 2 года назад +1

    Thanks Prof! Good show!

  • @turbinegraphics16
    @turbinegraphics16 Год назад

    This is pretty amazing, should be able to do some very interesting ways of loading data on old computers with this.

  • @pauldusa
    @pauldusa Год назад

    I did all of this back in 1988, I used the 6502F, that's the Rockwell FORTH chip, With EEprom, Ram & Latch chips, made my own Rs232 serial input interface board with a DB9 connector on a Com port as a piggyback for programming the 6502. All as a hobby project, when I working for Ampex Corp in Redwood City Ca., Long before Embedded Arduino or Pico times. Now were the old timer's presently. Living on a Farm in NE penn. usa.

  • @krtirtho
    @krtirtho 2 года назад +3

    I was thinking of making my own programming language. Thanks to you Gary, now I've to create my own computer, create a micro-kernel & an abstraction layer too😤

    • @GaryExplains
      @GaryExplains  2 года назад +1

      😜 Glad I could help!!

    • @jyvben1520
      @jyvben1520 2 года назад

      maybe look at the Risc 5 instruction set for a base or to see what a modern cpu does ...

  • @MarkEmeryPhotography
    @MarkEmeryPhotography 2 года назад +1

    Nice! I look forwards to seeing how high you can take the clock speed.

    • @coding_and_things
      @coding_and_things 11 месяцев назад +2

      I just cracked the 2MHz mark with a project heavily inspired by Gary's video.

  • @electron7373
    @electron7373 Год назад +2

    Great stuff. Would be nice to see a C version going as fast as possible.

  • @marklewus5468
    @marklewus5468 Год назад +5

    Hi Gary, Great proof of concept! It would be interesting if you extended this into a PIO block that could keep up with the 6502 at its full supported clock rate. That would allow a simple and cheap implementation of a full function 6502 RAM/ROM block, and you could squeeze in a debugging terminal over USB. Also, a link to your code in the dooblydoo under the video would be appreciated.

    • @paulspark7287
      @paulspark7287 Год назад +1

      I'm waiting to see the same thing. Rumbledethumps did something similar with his Pico computer videos.. but I found he went over it way too fast for me. Even with the source I'm struggling to get my head around it. Would be great if somebody could do a video about using Pico PIO to emulate a ROM with C/DMA or whatever - I tried a C program and found it wasn't fast enough for my 8MHz 6502 system.. and boy am I sick of taking my EPROM out and loading it every time I want to change software.

    • @daviddavies3637
      @daviddavies3637 Год назад

      @@paulspark7287 What I took away from this is that it's easy to interface anything to anything - more or less. I have a Raspberry Pi 3 lying around I've done not much with and ordered an ESP32. What I want to do is hook them up to an Atari 800XL. 6502 on those only run at around 1.7Mhz so I'd think something like that would be doable. I'm surprised that the Pico can't do the job you want as I'd have thought it should be possible with the big speed increase you get with these devices. Remember that the 6502 itself often takes several cycles to run a single instruction - usually an extra one or two if the instruction crosses a page boundary. The ARM in the Pico, on the other hand is not only clocked much faster, it's capable of running more than one instruction per clock cycle (I think).

    • @someguy4915
      @someguy4915 Год назад

      @@daviddavies3637 The 6502 only really accesses the bus on the PHI2 HIGH state, so a 1Mhz clock requires the Pi to perform as if the bus is 2Mhz for example.
      And while the 6502 does usually take multiple clock cycles per instruction, it also takes multiple bus-reads per instruction to load the opcode, LSB and MSB address and optionally a further bus read/write, requiring the Pi to be ready at any moment.
      At the W65C02's max speed (according to the datasheet that is) of 14Mhz you'd need to have the Pi ready to serve and read data at 28Mhz. Not to forget that the Pi will require several instructions just to read the data, process it, recall from its memory the proper response and set its output to that, making 28Mhz parallel bus ops most likely impossible.
      Besides that, the W65C02 (at 5VDC) can usually function quite well at 20Mhz without further requirements (other than logic level translators for the Pi's 3.3VDC).
      It would probably be far easier (and faster) to have the Pi attached to the bus but still have a dedicated SRAM IC which is programmed by the Pi which then hands over bus control to the 6502 at full speed.

  • @IanHaver
    @IanHaver Год назад

    Hi, Im sure my 64 had a 6510 in it. Brilliant video :)

  • @DavidAlsh
    @DavidAlsh 2 года назад +1

    Would love to see some RAM visualisation in the terminal, too. Would pair nicely with a performant language like Golang or perhaps Rust, though I don't have a 6502 to mess around with.

  • @TomMitchellNiftyEgg
    @TomMitchellNiftyEgg 7 месяцев назад

    Nice, one could steal a couple address lines at the expense of emulated ram. Other tricks are possible.
    I do love the simplicity of this.

  • @adilsongoliveira
    @adilsongoliveira Год назад

    During my internship (looooong time ago) I learned Z80 assembly. Good timers... I mean, times :)

  • @petedavis7970
    @petedavis7970 Год назад +1

    I had actually considered doing this with a Pi or Arduino, but I wasn't sure about the clock speed, which is what I came to find out 😞. But that's cool. I'll keep watching. Fun stuff.

    • @SpeccyMan
      @SpeccyMan Год назад

      It can be done with Arduino for sure. A good example is the Z80-MBC2 board which uses an ATmega32 to control the onboard Z80 providing it with ROM and control. The Z80 clock can be switched between 4 and 8 MHz and it also controls paging of the onboard 128Kb of static RAM. No reason it cannot be done with a 6502 and I am surprised they don't also do a board for that CPU.

    • @someguy4915
      @someguy4915 Год назад +1

      @@SpeccyMan Looking at the Z80-MBC2 it still has its own SRAM and ROM, meaning the ATMega32 is just used for programming those, then setting the Z80 loose on the bus to run at its own (far higher) speed.
      The ATMega32 in that design runs from a standard 16Mhz crystal, at best it might squeeze out 50-75kHz of bus speed, nowhere near the 4-8Mhz the Z80 would usually run at.
      Considering that a modern day W65C02 can easily run at 14Mhz or be overclocked reliably to at least 20Mhz, no AVR chip would be close to reaching any of those speeds.

    • @coding_and_things
      @coding_and_things 10 месяцев назад +2

      I did this myself and got a stable 2MHz from the Pico.

  • @paulspark7287
    @paulspark7287 Год назад +1

    @Gary Explains Would be great if you're able to do a video on this with PIO/DMA/C etc - something that will give us the required speed to work with an actual 6502 system running at 8MHz or so.

  • @RPG_ash
    @RPG_ash 2 года назад +2

    Nice vid Gary 👍🏻
    If you want a video idea and you want to educate us n00bs about breadboards, you could make a video about the basics of breadboards and how they work 🤪

    • @paulturner5769
      @paulturner5769 2 года назад +1

      Here you go - ruclips.net/user/results?search_query=breadboards+explained .

  • @humanbagel
    @humanbagel Год назад

    "Let me explain" *bass drops*

  • @1MarkKeller
    @1MarkKeller 2 года назад +1

    GARY!!!
    Good morning Professor!
    Good morning fellow classmates!
    Stay safe out there everyone!

  • @TimothyChapman
    @TimothyChapman Год назад +4

    Where's the update video to this one?

  • @jonathanstein6056
    @jonathanstein6056 Год назад

    This would be a good PIO application. That will get you the speed you want.

  • @etmax1
    @etmax1 Год назад +1

    Really need to have some ~100nF bypass caps for the supply

  • @ftorresgamez
    @ftorresgamez 2 года назад +1

    Yes, it was in the Apple 2, and the Apple 1.

  • @petermuller608
    @petermuller608 2 года назад

    Great work! I was considering doing something similar but got hung up on bus timings. Your implementation seems to disregard all bus timings and just assume the clock is low enough and the pico is slow enough for hold timings?

  • @eliotmansfield
    @eliotmansfield 2 года назад +2

    clever.

  • @tub8r
    @tub8r Год назад

    Interesting project and a nice walk-through. One part that isn't very clear, if how this project is connected and works with the Clock module.
    And a related question: does it need an external Clock module, if the clock pin is already connected to the memory emulating Pico? The debugging mode (run, single-step, next step) could be controlled from the serial terminal. Any reasons it won't work?

    • @GaryExplains
      @GaryExplains  Год назад

      Yes, combining all the functions into one Pico should work.

  • @simonmartin4267
    @simonmartin4267 Год назад

    Great video Gary! I'm new to the Pico and Thonny, and cannot for the life of me work out how you got the compiled assembler code (a.out) onto the Pico's flash memory. Is there a particular Thonny plugin you are using? I normally use VSCode for compiling 6502, but could not transfer the a.out file, which left me feeling a bit dumb...

    • @GaryExplains
      @GaryExplains  Год назад

      Right-click on a file in the "Files" section and click "Upload to /"

    • @simonmartin4267
      @simonmartin4267 Год назад

      @@GaryExplains thank you so much!

  • @pubdigitalix
    @pubdigitalix 2 года назад +3

    One question Gary? When execute BNE L0002 always read 0x8e if condition are true what indicates the 6502 load part of next instruction and as Gary previous explains STX take two cycles but after BNE dont jump we only see one read of 0x8e and not two. If these because BNE always load the next instruction like a pipeline of two stages and take the decision in the second stage and then STX don't use an extra cycle because one was providing for the BNE instruction? If not, why STX have two read cycles above and one read cycle at the end? Thanks.

    • @GaryExplains
      @GaryExplains  2 года назад +4

      I wondered if anyone would spot that. I think it is about the pipeline. According to the datasheet BNE takes 2 cycles and you need to add 1 cycle if branch is taken.

  • @GalacticStudios
    @GalacticStudios 2 года назад +2

    Line 46 should not be indented into the for loop.
    I realize that the Pi Pico is a lot faster than a 6502. Even so, I'm surprised it can interpret microPython code, deal with data and address pins one bit at a time, and still keep up with a memory access.

    • @GaryExplains
      @GaryExplains  2 года назад

      Yes, I spotted that bug after I made the video but before I uploaded the code to GitHub!

    • @someguy4915
      @someguy4915 Год назад

      It can only do that at 1Hz though, at the 6502's full speed (14Mhz) the Pi, or even a Raspberry Pi 4 for that matter, would be far too slow.

  • @gaborbabusa6384
    @gaborbabusa6384 2 года назад

    Hi there! Will it work with 6510 too? Will it worth to try, or it wouldn't give as more plus, than bring more difficulties?
    I'm thinking on building a C64 emulator with a real 6502 (or 6510) cpu.

  • @rudy5360
    @rudy5360 7 месяцев назад

    If it were fast enough I would love to see a hardware SID player 😊

  • @JavaJack59
    @JavaJack59 2 года назад +1

    Would be neat to try this with a 68000 as well.

    • @GeorgeStyles
      @GeorgeStyles 2 года назад +2

      Dont think we have enough GPIO on the pico for that - it would need 16 for address bus, 16 for data bus + IO select + clock = 34, and pico only has 28 :( maybe with some kind of latch

  • @tijuthomas6793
    @tijuthomas6793 2 года назад +1

    sir great video i ever seen on youtube , can you make a 16bit computer from scratch ur explanations were awesome if you have time please consider my request plz

    • @YateyTileEditor
      @YateyTileEditor Год назад +1

      If you want to see a computer built from scratch I'd recommend James Sharman's videos. If you want to see 16bit version of the 6502 I'd suggest Adrian Kohlbecker's videos.

    • @johnm2012
      @johnm2012 Год назад +1

      @@YateyTileEditor Adrien's treatment of the timing requirements for the 65816 are rigorous. Looking at his timing diagrams made my head hurt but I learned a lot. Another RUclipsr worth watching is George Foot. He's built a 6502 breadboard computer and also one based on the ARM2, which is a step up even from 16-bit.

  • @chuckbenedict7235
    @chuckbenedict7235 Год назад

    Thanks for the project and ideas. One question...when I replicate this using an Arduino Mega, my base case was to just put 0 in for the start vector, and then 0xEA in for nop. Then I should see the PC increment. And this does happen. However, it takes two clock cycles, which according to the datasheet, is correct, even for nop. But how is it that your single stepping for most instructions seems to take only one clock cycle?

    • @someguy4915
      @someguy4915 Год назад

      Not sure, he also says STX (absolute) takes 2 clock cycles while in reality it takes 4. I'm guessing he is using a software implementation of the 6502 on a Pi which performs the same functionality but has nowhere near the same behavior and timing.

  • @byronwatkins2565
    @byronwatkins2565 2 года назад

    At 13:15, a .word already occupies 16b ($FFFC and $FFFD); the $0000 will be put into $FFFE and $FFFF -- I believe this is the NMI vector that is not used.

    • @GaryExplains
      @GaryExplains  2 года назад

      $FFFA, B is the NMIB vector, FFFE,F is the BRK/IRQB vector. It is all in the datasheet.

    • @byronwatkins2565
      @byronwatkins2565 2 года назад

      @@GaryExplains I knew it had to be one of the two. My point was that there is no need to fill it. I'm considering optimizations to scramble the I/O bits into addresses/data. I'll let you know if anything productive comes from it.

    • @GaryExplains
      @GaryExplains  2 года назад +6

      The reason why I fill it, as I say in the video, is to make a.out the full 64K. Then it can be loaded by the Python program and create a 64K array. If I didn't do that then the memory would be too small in the Python program and an attempt to access FFFE,F would result in a crash.

  • @TheTkiller9999
    @TheTkiller9999 Год назад

    I am wondering if the same can be done for the z80... and how fast a speed I could push the z80 to (20Mhz are available)

  • @johnm2012
    @johnm2012 Год назад

    That would easily fit on a single breadboard and the wires would be shorter too!

    • @GaryExplains
      @GaryExplains  Год назад

      Yes, it would. But the clock module was from another project and is a "reusable" component in that sense.

  • @fabriziocapolini4349
    @fabriziocapolini4349 Год назад

    Very nice! This means we can reboot the 6502/Z80 wars, right? ;-)

    • @GaryExplains
      @GaryExplains  Год назад

      I don't think it was ever a war, more a skirmish as clearly the 6502 was superior... Oh, shots fired 😬🤣

    • @fabriziocapolini4349
      @fabriziocapolini4349 Год назад +1

      @@GaryExplains What, wait, I seem to remember my last Z80 project was a medical timer and it needed no RAM at all because, you know, the Z80 had actual registers... oops... 🤭😉

  • @crynoid2k7
    @crynoid2k7 6 месяцев назад

    The datasheet says that the CPU will drive RDY low when it executes the WAI instruction. Shouldn't you pull it high with a pull up resistor so that you don't create a short if you execute a WAI?

  • @williamtell1477
    @williamtell1477 Год назад

    Hi Gary, I have a rather simple beginner question. Why is the resistor needed for the reset line? Is this something to do with limiting current draw through the chip? If so, why not limit current at the psu?

    • @GaryExplains
      @GaryExplains  Год назад

      So that when the button is NOT pressed it has a state.

    • @RealDevastatia
      @RealDevastatia 11 месяцев назад

      Without the resistor, you'd be shorting the 5V power input to ground when you press the button.

  • @GeorgeStyles
    @GeorgeStyles 2 года назад

    Very nice :) to support actual hardware (6522 VIA for example), wouldnt we need to be able to set the GPIO pins to floating? does the Pico Pi support that? (from memory i think thats tri-state logic), so if it does, I assume it will be something along the lines of if (addr > $FC00) && (addr < $FCFF) set to tristate, else set as usual? edit. or could we get away with setting them as inputs, then we can snoop on the hardware comms

    • @GaryExplains
      @GaryExplains  2 года назад

      Why would you need to set the GPIO pins to analog? I haven't studied the 6522 in detail, but a quick look seems to show that all the pins are digital.

    • @GeorgeStyles
      @GeorgeStyles 2 года назад

      @@GaryExplains I didn't mean analogue. When a bunch of devices share a bus, my understanding is that they have to have a "shut up" pin which disconnected their outputs on the bus to allow other chips to talk. With the current implementation, if you connected a Sid chip to the bus with relevant address decoding, when registers are read, the python script would be serving up the empty parts of its array to the data bus, competing with the genuine outputs of the other chip.

    • @GaryExplains
      @GaryExplains  2 года назад +1

      There just needs to be some logic in the RAM/ROM Python program that ignores requests for certain address ranges.

    • @GeorgeStyles
      @GeorgeStyles 2 года назад +1

      Not ignores, going into write mode even if the R/W line is set to read. I guess we would end up with a snapshot of the (potentially write only) hardware IO in our python array. Would love to see how close you could get to the 1Mhz-4Mhz bus speeds of real computers back in the day. Any chance of a video on how much clock speed the basic python stuff can do???? i know the regular rasp.pi can emulate the whole range of BBC micro tube devices, using a custom RTOS . If i were a betting man, id say that the GHz class of modern microcontrollers could do it.

    • @petermuller608
      @petermuller608 2 года назад +1

      Doing high impedance on the data lines for the address lines to ignore should the the right behavior

  • @daveduke8783
    @daveduke8783 Год назад

    Could you use this as a replacement cpu for a commodore pet ?

  • @garymetheringham4990
    @garymetheringham4990 6 месяцев назад

    did you come up with a solution to free up some gpio pins so you can a# extra hardware? i did try a pcf8574 expander on data pins but no joy.

  • @GrahamToal
    @GrahamToal 2 года назад

    Phi is a Greek letter, not an abbreviation for anything, so is pronounced "Fie!", not "Eff Haitch Eye Two!", so to emulate the BBC weather man, I suppose you could say 'we apologise for the eff'in Phi'. I believe it is used in electronics for clock signals because Phi sounds like "phase".
    The pins that end in 'B' should be read as 'BAR', i.e. an overline that means 'active low' (from the mathematical convention for a negative digit), so RWB is pronounced "R/W-BAR" or "Read/Write-Bar" and would more commonly be typed as R/W̅.

    • @brucemcfarling6594
      @brucemcfarling6594 8 месяцев назад

      Good points - Phi1 is "clock phase 1", and "Phi2" is "clock phase 2", where the 65Co2 only requires Phi2, which is low in the first phase and high in the second. For the "bar" abbreviations, in the old days, when a text editor couldn't do overbards, those were sometimes written /IRQ, etc.. This has an echo in the "R/W" line, which is literally "Both RD and /WR" -- active High for Read, active Low for Write. However, lots of computer software objects to variable names starting in "/", hence the "add a B at the end for the overbar" approach.

  • @GrahamToal
    @GrahamToal Год назад

    The pins which are tied high: do they need something like a 3K pullup? Is it safe to tie them directly to Vcc like this?

    • @johnm2012
      @johnm2012 Год назад +1

      Yes, it's safe to tie CMOS input pins directly to either rail. The absolute max ratings allow a small margin on inputs that exceeds the power rails. You can use a resistor if you want to but the current through it will be negligible. Some pins are bidirectional. In that case you must use a resistor to avoid shorting it when it switches to output mode. 3k seems to be the recommended value by WDC but not all hobbyists have a stock of that value so 3k3 is a valid alternative - in fact anything from about 1k to 10k will be fine. If you're unsure whether a pin might be input only or bidirectional and you want to tie it high or low then put in a resistor anyway and you'll be safe.

    • @GrahamToal
      @GrahamToal Год назад

      @@johnm2012 Thanks! That's the sort of practical advice that lawsuit-shy authors generally don't offer in books :-) Appreciated.

  • @RayMillTN1
    @RayMillTN1 Год назад

    so - how does the 6502 work with 3.3v logic? I looked at the 6809 specs - but its 5v ttl - would I have to wrap the whole processor in level converters?

    • @GaryExplains
      @GaryExplains  Год назад +1

      The current iteration of the 6502, the W65C02S has an operating voltage of 1.8−5V.

  • @mikele101
    @mikele101 2 года назад +2

    No issue with the 5V coming from the 6502 ? The opposite would not be a problem but this way, Pico’s GPIOs could suffer… wouldn’t they ?

    • @GaryExplains
      @GaryExplains  2 года назад +1

      The 6502 is powered from the 3.3v output of the Pico.

    • @mikele101
      @mikele101 2 года назад

      I see… is it a low power version of the 6502 or would a genuine processor from 1976 operate the same under 3.3V ?

    • @GaryExplains
      @GaryExplains  2 года назад

      The W65C02S is a modern day 6502 which runs from 1.8v upwards.

    • @mikele101
      @mikele101 2 года назад +1

      W65C02S ! So it runs between 1.8 and 5V ! And it is fully static so that’s why you can step it ? That’s practical !

    • @mikele101
      @mikele101 2 года назад

      Thanks Gary ! FYI, I’m planning to build a banked rom & ram device to assist a 8080-based machine which could also have changes made through I2C. Cheers

  • @andrewadkins5567
    @andrewadkins5567 2 года назад

    Thank you for the video on the 6502. Just one thing sir, Ben Eater created a video seven months ago and he hasn't been heard from since. He just dropped out of sight.

    • @GaryExplains
      @GaryExplains  2 года назад +2

      I don't know Ben, so I have nothing I can add.

    • @andrewadkins5567
      @andrewadkins5567 2 года назад

      @@GaryExplains Thank you sir.

  • @erikbartmann
    @erikbartmann Год назад +2

    Great stuff! Do you provide the Python-Source-Code?

    • @GaryExplains
      @GaryExplains  Год назад +3

      Yes it is on my GitHub repo. Just Google "garyexplains GitHub" and you will find it.

    • @erikbartmann
      @erikbartmann Год назад

      @@GaryExplains Thanks a lot! Yes, I did it, but what's the filename? Under examples?

    • @GaryExplains
      @GaryExplains  Год назад +6

      Yes, examples/vCPUEMU/PICO_RAMROM/

    • @erikbartmann
      @erikbartmann Год назад

      @@GaryExplains Got it! Thanks!!!

  • @siriokds
    @siriokds Год назад

    Hi! Since the Z80 can run only with 5V on VDD and since RPi Pico gpio is not 5V tolerant, how to interface them?

    • @GaryExplains
      @GaryExplains  Год назад

      Then you need to use a step down convertor. You can buy modules or make your own with resistors. For the signal to be read by the Z80 you will need step up convertor. Alternatively use an Arduino which is 5v.

    • @brucemcfarling6594
      @brucemcfarling6594 8 месяцев назад

      @@GaryExplains For +5v parts that accept TTL levels, +3v CMOS High works as +5v TTL high. So you don't need to step up +3.3v inputs into an, eg Z84C00 (CMOS z80), as they accept high as anything higher than 2.2v as a minimum. So a bus transceiver that is powered at +3.3VCC and has +5v tolerant inputs will work.

  • @md.jannatulnayem4328
    @md.jannatulnayem4328 Год назад

    Can i proceed this tutorial with an 8085 instead of a 6020??? What measures should be taken for this swap?? I couldn't find 6020 in my locality 😴

    • @GaryExplains
      @GaryExplains  Год назад +1

      The thing to watch is if the 8085 is 5v. The Pico is 3.3v tolerant.

  • @johngay8416
    @johngay8416 Год назад

    My two questions are:
    Surely I can swap out the 6502 with a Z-80 with minimal fuss? I just prefer the Z-80.
    Can I use the Pico to clock the processor instead of a separate clock circuit?

    • @GaryExplains
      @GaryExplains  Год назад

      Yes and yes.

    • @johngay8416
      @johngay8416 Год назад

      Great!
      Guess now I gotta try to figure this out myself!
      I’ve got a couple of both. Time to break out the breadboard and start wiring and coding.

    • @GaryExplains
      @GaryExplains  Год назад

      Go for it. Do note that the z80 is probably 5v and the Pico is 3.3v tolerant. The 65c02 works at 3.3v and 5v.

    • @johngay8416
      @johngay8416 Год назад

      After poking around some more, the voltage difference between the Z-80 and the Pico brings this idea to a close.
      But I do have Ben Eater’s 6502 kit, so maybe I’ll give that a go instead?

  • @Noah-is-great
    @Noah-is-great 14 дней назад

    Can you add a link to the code?

  • @neozeed8139
    @neozeed8139 11 месяцев назад

    Wonder how hard for a 68008

  • @HansOtten
    @HansOtten Год назад

    You have a github or website with code and circuit diagram?

    • @GaryExplains
      @GaryExplains  Год назад

      Yes. A quick google search for "garyexplains github" reveals: github.com/garyexplains

    • @HansOtten
      @HansOtten Год назад +1

      @@GaryExplains Yea, found your github, thanks. I went there looking for the RAM/ROM for 6502 Pico example, if you have time to upload that? Much appreciated!

    • @GaryExplains
      @GaryExplains  Год назад +2

      Oh, sorry about that, I thought I had uploaded them. You can now find them here: github.com/garyexplains/examples/tree/master/vCPUEMU/PICO_RAMROM

    • @HansOtten
      @HansOtten Год назад +1

      ​@@GaryExplainsThank you!

  • @happysoulfu
    @happysoulfu 11 месяцев назад

    I try to find some idea to use a chip instead of rom or ram, use on NES/FC game cart as a rom, in my opinion when the NES/FC power on, this PI pico is not ready, loading bin data to ram of PI pico, then unkown data from the data IO of PI pico will be read by NES/FC. Somebody use stm32f407vet6 instead of a rom chip, successfully run game of Mario brother, mybe need a click of reset.

  • @relazingmusictheory8466
    @relazingmusictheory8466 Год назад

    lot during covid.

  • @hermannseib
    @hermannseib Год назад

    Really nice video!
    I was thinking "How the hell is this interpreted Python code going to keep up with normal 6502 clock speeds?" until you resolved that with the 1 Hz clock :-)
    It would be definitely interesting how high you can go. Lacking a 65C02 (other than the one in my Apple IIc, which needs 5V and which I most certainly won't rip out for experiments), I can't help here.
    One little thing, however - at the moment, you're emulating RAM. Nothing in your code prevents writes to any given address.

    • @GaryExplains
      @GaryExplains  Год назад

      True, but a quick "if" statement could make certain sections read-only. Trivial to implement.

  • @md.jannatulnayem4328
    @md.jannatulnayem4328 Год назад

    Unforunately I couldn't find the 6020 in my locality.....😦

    • @GaryExplains
      @GaryExplains  Год назад +1

      You mean 6502, not 6020. I am not saying that to correct your typo, but rather to make sure you were searching for the right component locally.

    • @md.jannatulnayem4328
      @md.jannatulnayem4328 Год назад

      @@GaryExplains Yeah sorry for the typo...I meant to say 6502...it seems only the SMD package is available...I couldn't find the DIP one.

    • @brucemcfarling6594
      @brucemcfarling6594 8 месяцев назад

      @@md.jannatulnayem4328 Search for W65C02S. They are still being produced in DIP, though of course whether local suppliers stock the DIP version (W65C02S6TPG-14) is up to them.

  • @alelondon23
    @alelondon23 Месяц назад

    Such a great video and such a disappointment. The clock limitations of your early unoptimised implementation should have been made clear beforehand, at the presentation. For fastest clocks I see PIO programming in our pico future.

  • @AndrewRoberts11
    @AndrewRoberts11 2 года назад +3

    🤔 the RPi Pico's are $4, while the MOS 6502 are $14 (plus taxes and the usual), so the logical thing would be to substitute a second Pico for the 6502, and emulate it's logic 😉

    • @GaryExplains
      @GaryExplains  2 года назад +3

      That is the long term plan yes...

    • @brucemcfarling6594
      @brucemcfarling6594 8 месяцев назад

      The W65C02S are a little cheaper at $10. -- and that's the relevant price, since an MOS6502 won't work with this single step clock ... you need a fully static CMOS IC for that single-step clock to work.

  • @devcybiko
    @devcybiko Год назад +2

    Why stop at RAM and ROM? Why not just emulate the 6502 on the PICO while you're at it?

  • @semibiotic
    @semibiotic 5 месяцев назад

    There is no sense to emulate RAM. There are ton on SRAM chips available.

    • @GaryExplains
      @GaryExplains  5 месяцев назад

      Ok, thanks for watching anyway.

  • @sleepy9817
    @sleepy9817 2 года назад

    I'm here just for speed test g bye bye

  • @PeterRichardsandYoureNot
    @PeterRichardsandYoureNot 5 месяцев назад

    So, you are not really building your own computer. You are building an emulator that uses the original 6502 as the processor. It’s a bit of a cheat, but it’s original, and I’ll give it to you.

  • @carlosromero4820
    @carlosromero4820 Год назад

    way too confusing

  • @misterhat5823
    @misterhat5823 2 года назад +1

    I just don't see the point. Just because you can... You might as well let the Pico run the 6502 code too.

    • @alankingvideo
      @alankingvideo 2 года назад +5

      Not sure if you are serious, I will answer as though you are. The point is this is all about learning how the 6502 works. Real ram and eproms, and programmers are expensive. The pico can emulate these devices, and in a way that is very flexible, providing real time info as to whars going on on the bus. The real 6502 is like mountain climbing, because it's there, and its being a real processor, working just like it did in the 1970s and 80s, and its great.

    • @misterhat5823
      @misterhat5823 2 года назад

      @@alankingvideo Oh come on. They aren't that expensive.

    • @MarkEmeryPhotography
      @MarkEmeryPhotography 2 года назад +1

      @@misterhat5823 that all depends on how much disposable income you have. Using the Pico like this gives you a debugging ability that standard RAM & ROM wouldn’t give you. Would you learn as much doing it the easy way?

    • @misterhat5823
      @misterhat5823 2 года назад

      @@MarkEmeryPhotography If you can't afford an aliexp programmer, you probably can't afford a 6502 either.

    • @petermuller608
      @petermuller608 2 года назад +4

      This is tool for 6502 development. Extending your argument, why would you use a raspberry pi pico, if you could use the computer you use to program the pico to run the code itself :P

  • @raven4k998
    @raven4k998 Год назад

    cheating he's cheating he might as well be just using the raspberry pi to emulate everything

    • @GaryExplains
      @GaryExplains  Год назад +5

      Eh? Why am I cheating? I don't understand. The idea here is that components like RAM or ROM or even a VIA can be emulated. How is that cheating?

    • @GaryExplains
      @GaryExplains  Год назад +3

      Did you even read the title?

    • @brucemcfarling6594
      @brucemcfarling6594 8 месяцев назад +1

      Any development scaffolding is "cheating" on an imagined rule of "only period appropriate parts", but then again is it cheating to use a cross-assembler? Is it cheating to use CMOS parts?