zamuel_a wrote:
I have built some smaller 6502 based projects in the past...
Firstly, welcome to our 6502 world. Be sure to stop by the "
introduce yourself" topic and tell everyone about yourself.
Quote:
...but want to create something more advanced, like a "real" computer and thought about using the 65c816 since it would be easier to handle a lot of memory (and it's faster to). I would like to create a simple multitasking OS, so it had been nice to have an MMU and I was thinking about how advanced it should be...
An admonishment I often give to anyone wishing to build a homebrew computer as you wish to do is to first learn how to make a single-engine plane fly before building that four-engine jumbo jet. Memory management and protection can be complicated to implement and depending on the degree of functionality you desire, may entail the need for considerable hardware resources. Other than the
ABORT input and
MLB and
VPB outputs, the 65C816 offers nothing that facilitates memory management and protection—you will have to provide the missing functionality using programmable logic. So before you launch into your project, you should develop a realistic set of features and goals for your new system, keeping in mind that the more complicated it gets the greater the likelihood that it will not get to an operational state.
barrym95838 wrote:
If I was attempting something similar, I would start with an existing (well-documented) design (like a IIgs or BDD's POC1 and POC2), study it, decide what I liked and disliked about it, and go from there. Your options are wide open ... you just need a place from which to start, IMO.
That's what I did: I looked at what others had done and then went to work concocting a design.
When I designed my
POC V1 unit I stayed intentionally simple but did make it possible to add on to it. My goal at the time was to fully understand what it would take to make the 65C816 work with non-65xx peripheral hardware and to refine my design to where the unit would run at relatively high clock speeds—I had set a goal of 8 MHz operation, which was achieved. What I was going to some lengths to avoid was a complicated design that would be difficult to debug should it not work. That strategy paid off, as POC V1.0 worked on the first attempt—after I fixed an assembly error.
If you do want to set up a protected environment with the 65C816 you will have to get complex logic involved. One of the circuit features that will be required will be that of handling the A16-A23 address component (the "bank" address), which can be done with discrete logic or with a CPLD, the latter being recommended. Using a sufficiently large CPLD, you can also incorporate the elements needed to implement memory protection as well as possibly trapping for illegal instructions (where "illegal" means whatever you want it to mean).
Linux and UNIX systems have long used a 4KB page size for allocating and protecting memory, which could be implemented with the 65C816. The problem will be in figuring out where to set up the necessary page tables, which could potentially have as many as 4096 entries for a maximally-sized system with 16 MB of RAM. You will also need to develop the logic required to implement an abort function should a process violate the memory boundaries assigned to it. In other words, you will be developing the functions that are built into modern x86 and 68K MPUs to manage system resources.
The other issue with which you will have to contend is the fact that the 65C816 directs all direct page and stack activity to bank $00, which can lead to contention between processes. In my POC V2 design, I am working toward an architecture that redirects direct page and stack accesses back to the bank in which the process is running. It's not a simple matter though, but entirely doable.
What I would suggest you do is start out with a basic design to get familiar with the 65C816, especially its 16 bit capabilities. Build it around a CPLD but initially only program enough into the CPLD to get the A16-A23 address component working, as well as such things as qualified read/write signals—in other words, the basic glue logic. Once that is up and running you can add code to the CPLD to handle I/O wait-stating, which will be necessary to be able to operate the 65C816 at maximum speed (20 MHz). Only after those items have addressed would I then work on the memory management and protection.
Succinctly stated, work in stages so you don't have to grapple with too many debugging problems at the same time. Once a stage is operating in a satisfactory manner then go on to a new feature. Before you know it, you will have a full featured unit that can compute.
Also, don't hesitate to ask lots of questions. We have more than a few very knowledgeable members and while no one individual is likely to be an expert on all facets of computer design, the combined expertise around here can be frightening at times.
Please don't be shy about tapping into it.