element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs MOS 6526 CIA as a FPGA
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: ajkatz83
  • Date Created: 11 Jul 2018 5:26 PM Date Created
  • Views 2766 views
  • Likes 5 likes
  • Comments 8 comments
  • mos
  • 8-bit
  • xilinx
  • c64
  • fpga
  • 6526
  • commodore_64
  • fpga developement
  • altera
  • logic gate
  • mos technologies
Related
Recommended

MOS 6526 CIA as a FPGA

ajkatz83
ajkatz83
11 Jul 2018

Hello all! It's been awhile since perhaps I have posted anything interesting. There are many projects and such I have on back burns that I eventually want to catch up on, but naturally, when i do want to, something that I use frequently and is of great use to me breaks down, an a diversion begins.

 

Lately I have been doing for 8-bit computing, mainly with the C64 and SX-64 that I have and refurbished to the best of my abilities. I had recently started up making a Tapuino, which the filesystem and and components work fully thanks to the plans from Peter Edwards! Unfortunately, the one component that I didn't consider carefully was the edge-board connector; not because of the pitch, which was fine at 3.96mm, but that there was a separation in the connector pin from supply voltage and ground that were together, and then all the control pins for red, write, motor and sense. A short occurred for which is that best way to describe it and messed up the CIA #2 chip on the C64 Reloaded I have. I had two spares on hand and that did fix the garbage on-screen when I did power up again. Of course, seeing these are old volatile chips, the replacement spare blew out and I had to use my last spare, aside from spending $50 dollars on ebay for another or a fake one from China.   

Block diagram

 

 

 

 

 

 

 

 

 

So that is where this block diagram comes into play. In my studies thus far I am getting into digital logic and I had been curious can a so-called "replacement" chip with FPGA development can happen? So far I had got good feedback from a question I did ask and found out that Xilnix Spartan II or Altera Max 10 would be good candidates to make this happen. The issue isn't so much with the FPGA but more so that this block diagram doesn't make as much sense as I would have hoped for. Schematic symbols are relatively easy for me to interpret, however, I am not certain if this here are block logic symbols, or block gate logic symbols--not sure what I am looking at which makes it rather difficult. I assume the squares are registers, the lines in the center are buses? The access control symbols don't mean  much either.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

image

 

 

 

The only thing out of the interfacing section are RS0-RS3 which basically address the register that is being accessed; the truth table that was on one of the other pages made sense as to what those pins did.

 

I guess mainly how I see all this is not so much in code but rather in a schematic format, meaning, that there should be flip-flops and gates of some kind explaining how this chip functions. I get that it talks about its operation throughout and even on this page, however, seeing it in logic gates interconnected as such just would make more sense to me. Again traditionally, from above, I imagine that the squares are flip-flips and somehow interlinked with NAND gates? I suppose I am confused some may be because there are other devices like the processor and SID that this all interfaces to as well and not knowing how it operates in the entire system has me rather overwhelmed to think how one small piece has its place.

 

 

image

 

I am by no means looking to be spoon fed this, I simply am trying to make sense of this so perhaps I could make some relative replacement and so when this, now 36 y/o technology disappears, some 8 bit machines and still carry on. Just by these two sheets here, I am imagining that I need to concentrate on one pin, as to it's function and find the gate equivalent? Still I am in that schematic design mindset, but that's kind of how I am seeing this all work out.

  • Sign in to reply

Top Comments

  • genebren
    genebren over 7 years ago +2
    Great project. I had to do a similar thing many years ago when a product that our company built relied on an old IEEE controller chip from Intel. We ran out of good choices to procure these chips so we…
  • ajkatz83
    ajkatz83 over 7 years ago in reply to jc2048 +2
    Sorry I didn't get back to you sooner, fell into a funk here, not because of the engineering, just other worldly things. I like what you're saying here. So from the datasheet I have sectioned it out like…
  • jc2048
    jc2048 over 7 years ago in reply to ajkatz83 +2
    When you're developing it, you can do it piece by piece rather than doing the whole design and then trying to make it all work. Indeed it will be better like that. Get a simple bit going first and then…
  • ajkatz83
    ajkatz83 over 7 years ago in reply to jc2048

    jc2048  wrote:

    When you're developing it, you can do it piece by piece rather than doing the whole design and then trying to make it all work. Indeed it will be better like that. Get a simple bit going first and then build on it. The bus interface has to be first because its shared by everything. After that, the simplest output is the I/O port since it's only some latches (the tri-stating happens at the FPGA's I/O pins and is very simple to do). Get that working so that you can write to it and see the data appear and read from it and get correct data back, then move on to each of the other parts in turn. That makes the testing more manageable as you focus on one part at a time.

     

    At the present time, from the datasheet and the research from Wolfgang Lorenz, I have been doing just that as you've suggested. I have gone function by function and simply mapped it out and drawn to which I believe in this journal that I keep of all my projects. The system data bus, as you're saying, has been the easiest to track thus far and just seems like connections to the 6510 in the system. I had also thought if I can make a test verification board with an actual 6526, I could extrapolate a bit with the readings I would be getting off a scope so I would how things are being edge-triggered. I imagine all that would be is the 6526 broken out by its pins, ports and buses and tested for signalling in one of two states from the other gates that are related to them.  

     

    Timing might cause you a few problems. The FPGA will be much faster than the old device, so by comparison things happen almost instantly. The most obvious problem on the bus side is the data hold time when reading from the device. The FPGA will tristate in a few nanoseconds after the phase two edge, so you're going to have to contrive some way to extend that to the original minimum time otherwise other chips in the system won't have time to latch the data. (One way you might consider would be to lock an internal clock to 16x the phase two clock and then use that to time the extra delay that you need.)

     

    So far in the 6526 datasheet I have seen the timing and it is in means of nanoseconds. I have never messed with a FPGA before, so I cannot believe how much more faster these gate arrays can go. Though if they are going faster and the chips wouldn't be able to latch properly, and needing to to 16x fast then the phi2 clock, perhaps something like a PLL would be able to do that? That's the only device that coming to mind being here in a radio shop. 

     

     

    The FPGA has flip-flops as part of the fabric - you don't have to build them from logic gates. They have asynchronous set and reset, but can also be used as clocked D-types or JK or T (you get to choose - the FPGA is designed so that they can be individually configured as any of the standard types). If you use VHDL, the synthesis will do that for you and pick whatever is appropriate (and most efficient) to suit what you describe as the behaviour. If you're saying that some of the original is asynchronous and depends on natural delays in the chip, you're going to have to move away from that and go for a properly clocked design. You'd find an asynchronous design very, very difficult to manage in the FPGA because you don't know how the timing will fall for a particular synthesis and mapping run and trying to constrain the timing gets complicated very quickly.

     

    In the Wolfgang Lorenz research, I was finding out most of the flip flops are edge triggered. Which edge I am not certain yet, but the ^ on the flip flops was a dead give away and something new that I learned last night lol. I was thinking of S/R but thinking of it more, I think either D-type or J/K might be more appropriate to accommodate the clock, and it might be set up in a Master-Slave kind of configuration that's going into a specific bit decrement counter; sometimes it's been two or three that I believe I am reading here with a tri-state buffer in between the flip-flop. I do hope a synchronous operation will prevail, though then again I have never done anything like this, even though whatever it turns out I do have some references to either/or, so in relation to the FPGA hopefully I'll have some of my hair left if attempting to do so. 

     

     

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jc2048
    jc2048 over 7 years ago in reply to ajkatz83

    When you're developing it, you can do it piece by piece rather than doing the whole design and then trying to make it all work. Indeed it will be better like that. Get a simple bit going first and then build on it. The bus interface has to be first because its shared by everything. After that, the simplest output is the I/O port since it's only some latches (the tri-stating happens at the FPGA's I/O pins and is very simple to do). Get that working so that you can write to it and see the data appear and read from it and get correct data back, then move on to each of the other parts in turn. That makes the testing more manageable as you focus on one part at a time.

     

    Timing might cause you a few problems. The FPGA will be much faster than the old device, so by comparison things happen almost instantly. The most obvious problem on the bus side is the data hold time when reading from the device. The FPGA will tristate in a few nanoseconds after the phase two edge, so you're going to have to contrive some way to extend that to the original minimum time otherwise other chips in the system won't have time to latch the data. (One way you might consider would be to lock an internal clock to 16x the phase two clock and then use that to time the extra delay that you need.)

     

    The FPGA has flip-flops as part of the fabric - you don't have to build them from logic gates. They have asynchronous set and reset, but can also be used as clocked D-types or JK or T (you get to choose - the FPGA is designed so that they can be individually configured as any of the standard types). If you use VHDL, the synthesis will do that for you and pick whatever is appropriate (and most efficient) to suit what you describe as the behaviour. If you're saying that some of the original is asynchronous and depends on natural delays in the chip, you're going to have to move away from that and go for a properly clocked design. You'd find an asynchrounous design very, very difficult to manage in the FPGA because you don't know how the timing will fall for a particular synthesis and mapping run and trying to constrain the timing gets complicated very quickly.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ajkatz83
    ajkatz83 over 7 years ago in reply to jc2048

    Sorry I didn't get back to you sooner, fell into a funk here, not because of the engineering, just other worldly things.

     

    I like what you're saying here. So from the datasheet I have sectioned it out like puzzle pieces and included what pins do what and how they all work. So far the only confusing part was the handshaking with /PC and /FLAG and that all seems to be triggered on negative edges and the /PC just runs for one clock cycle making data ready or accepting it, so I believe.

     

    Been reading the Write and Reading timing diagrams and there is a lot going on with pulses and such and how fast this is all happening. If I know how to simulate this it would be helpful, seeing I am more visual than comprehending this all abstractly. WIth Xilinx I was watching some videos where it was using their ISE and Webpack was involved where schematics were being created. I have this research from Wolfgang Lorenz which shows the 6526 purely software, except the serial port and TOD. I'm waiting for my FPGA now so I can get my hands on the software and see what I have here in a simulation sense. I believe mostly I am working with S/R flip-flips and something about a decrement counter and some tri-state buffers from the looks of things.

     

    If I do figure this out I think I should get my engineering badge too LOL. Thanks for your help!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jc2048
    jc2048 over 7 years ago in reply to ajkatz83

    The block diagram is high-level and conceptual, it's not meant to tell you how it's implemented. Back then, it was meant to be an aid to understanding for a design engineer using the chip or a programmer understanding what they were doing setting the registers.

     

    You're in the situation where you're reverse engineering the device. The different blocks will function differently from each other. The ports will  be latches. The serial port will be a shift register, with parallel load and store for the data-bus side and the serial in and out connected to rx and tx. The counters will be, er, counters (carry on like this and I'll earn my engineer's badge).

     

    You'll need to work in from both sides, on the one hand the register access from the processor buses and on the other back from the IO pins, and try and make it all match up. You've got a reasonably good spec to work with - the datasheet will do a reasonable job of showing you what the chip should do if you get it right. The trickiest bit may well be some of the details of the timer circuits and how they trigger other parts.

     

    It always used to be the case that you could do a design using purely schematic-capture in Xilinx Webpack, if you wanted, but I'm not familiar with the latest design suites, nor what their competitors allow, so don't quote me on that. If you have the confidence to do this as hardware design with logic, you probably wouldn't find it too difficult to master VHDL.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • ajkatz83
    ajkatz83 over 7 years ago in reply to genebren

    O h yes, I do have it all printed out and in front of me. That's presently what I have, ports A and B plus the timers. That's where I am going to make a schematic of some sort.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube