6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 11:47 pm

All times are UTC




Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: RAM bus widths?
PostPosted: Tue Oct 08, 2013 9:05 pm 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
Hey guys. So, I am working on designing a CPU for fun, and I am also writing an emulator for it. I am wondering, how many bits would the ram addresses and the actual ram values be? At the moment, I am just using an array of integers (with some size such as 8192) to serve as ram. In a typical system (more modern than older..) how large are these numbers? 32 bits for the address? I assume the actual values would be 32 bit though right? Or am I confused/mistaken/being stupid?


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Tue Oct 08, 2013 9:46 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
For 8-bit processors with an 8-bit data bus like the 6502 and 65816 have, the RAM will be 8 bits wide, unless you get 9-bit-wide memory to have a parity bit for error checking but that won't be necessary for what you want and it takes extra hardware to take advantage of it anyway. Like most other 8-bit processors, the 6502's address bus is 16 bits wide, so unless you do some sort of banking arrangement (as we've been talking about in the 6502 Memory map considerations topic), there's not really any sense in getting RAM with more than 64KB. Next up in memory data bus width is 16 or 18 bits, and 32 or 36 bits; but the easier-to-use SRAM will generally be 8-bit.

Somewhere around the time I made my first computer (1985), 8Kx8 SRAMs were kind of a luxury for hobbyists at $42 each at Jameco, and then the Japanese started dumping and it suddenly came down to something like $8. I don't remember if I bought just before or just after that, but the dollar was a lot bigger back then. Now you can fill the 6502's memory map for pocket change.

SRAM will always be more expensive than DRAM, but is much easier to implement too (especially not requiring special hardware for row/column refresh like DRAM normally does), and is suitable for small systems where you're not going to fill megabytes, let alone gigabytes, of memory. Unless you want a load of data space, the quantity of RAM a 6502 allows you, even without banking, will be plenty for a hobbyist starting to write his own assembly-language routines. Commericial software takes far more, for several reasons. Time-to-market pressures drive programmers to use pre-written program modules even if they need only a very small portion of each module. They can't take the time to optimize for memory usage. Building in a lot of user-friendliness makes a big increase in program size. Multitasking operating systems with graphical user interfaces again take a lot of memory, and the graphics part of any given program may take a lot of memory. Being able to run scores of different programs at once also requires a lot more memory than running just one thing at a time like the hobbyist is likely to do. Then there's the data. Handling photos, music, or even movies is not something you'll be doing anytime soon. You definitely won't be needing a 32-bit address bus.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Tue Oct 08, 2013 9:50 pm 
Offline

Joined: Mon Aug 05, 2013 10:43 pm
Posts: 258
Location: Southampton, UK
This is of course an extremely complicated question....

In terms of "bittage", here are some examples:

4004 : 4 bits(!) of data, 12 bits of address (4 bits external which were multiplexed with the data (yikes))
6502, 6800, 6809, Z80: "the 8 bit era" : 8 bits of data, 16 bits of address
68000: erm this is complex. 32 bits of data, 32 bits of address (but on early editions, this is only the internal representation. Externally the databus was limited to 16bits and the address bus limited to 24bits (giving 16MB useable address space).

The "modern" era continues this with 64bits of data, 64bits of internal address (but less externally usebale, maybe 40 bits, I'm not sure).

Though I haven't got a clue what you're eventual aim is, I suggest you think about 8 bits of data and anywhere from 8 to about 16 bits of address. 8 bits of data will make dealing with your memory array easier, maybe? Depends what you are writing this thing in.

What you are attempting sounds similar to what I did at college (c. 1992 UK A-Level electronics if that means anything to you...). Our exam had some questions on writing simple machine-code programs for a hypothetical, and very trivial, CPU design which had a dozen or so opcodes (output a byte on the output port, read a byte from ram into the accumulator, add a number to the accumulator etc). I was bored one day so wrote a simulator for this hypothetical processor on my Amiga in AMOS basic. Fun days.

Lawrence

_________________
8 bit fun and games: https://www.aslak.net/


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Tue Oct 08, 2013 11:19 pm 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Aslak3 wrote:
What you are attempting sounds similar to what I did at college (c. 1992 UK A-Level electronics if that means anything to you...). Our exam had some questions on writing simple machine-code programs for a hypothetical, and very trivial, CPU design which had a dozen or so opcodes (output a byte on the output port, read a byte from ram into the accumulator, add a number to the accumulator etc). I was bored one day so wrote a simulator for this hypothetical processor on my Amiga in AMOS basic. Fun days.

We had a similar faux CPU for my CS 101 class that we had to write little "machine language" programs for.

One of the assignments, I think, was to write a MOD routine in it.

My friend changed the interpreter and added a new MOD instruction to it instead. :) He didn't get credit as I recall lol.


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 12:02 am 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
whartung wrote:
Aslak3 wrote:
What you are attempting sounds similar to what I did at college (c. 1992 UK A-Level electronics if that means anything to you...). Our exam had some questions on writing simple machine-code programs for a hypothetical, and very trivial, CPU design which had a dozen or so opcodes (output a byte on the output port, read a byte from ram into the accumulator, add a number to the accumulator etc). I was bored one day so wrote a simulator for this hypothetical processor on my Amiga in AMOS basic. Fun days.

We had a similar faux CPU for my CS 101 class that we had to write little "machine language" programs for.

One of the assignments, I think, was to write a MOD routine in it.

My friend changed the interpreter and added a new MOD instruction to it instead. :) He didn't get credit as I recall lol.


Lol thats something I would do..

GARTHWILSON wrote:
For 8-bit processors with an 8-bit data bus like the 6502 and 65816 have, the RAM will be 8 bits wide, unless you get 9-bit-wide memory to have a parity bit for error checking but that won't be necessary for what you want and it takes extra hardware to take advantage of it anyway. Like most other 8-bit processors, the 6502's address bus is 16 bits wide, so unless you do some sort of banking arrangement (as we've been talking about in the 6502 Memory map considerations topic), there's not really any sense in getting RAM with more than 64KB. Next up in memory data bus width is 16 or 18 bits, and 32 or 36 bits; but the easier-to-use SRAM will generally be 8-bit.

Somewhere around the time I made my first computer (1985), 8Kx8 SRAMs were kind of a luxury for hobbyists at $42 each at Jameco, and then the Japanese started dumping and it suddenly came down to something like $8. I don't remember if I bought just before or just after that, but the dollar was a lot bigger back then. Now you can fill the 6502's memory map for pocket change.

SRAM will always be more expensive than DRAM, but is much easier to implement too (especially not requiring special hardware for row/column refresh like DRAM normally does), and is suitable for small systems where you're not going to fill megabytes, let alone gigabytes, of memory. Unless you want a load of data space, the quantity of RAM a 6502 allows you, even without banking, will be plenty for a hobbyist starting to write his own assembly-language routines. Commericial software takes far more, for several reasons. Time-to-market pressures drive programmers to use pre-written program modules even if they need only a very small portion of each module. They can't take the time to optimize for memory usage. Building in a lot of user-friendliness makes a big increase in program size. Multitasking operating systems with graphical user interfaces again take a lot of memory, and the graphics part of any given program may take a lot of memory. Being able to run scores of different programs at once also requires a lot more memory than running just one thing at a time like the hobbyist is likely to do. Then there's the data. Handling photos, music, or even movies is not something you'll be doing anytime soon. You definitely won't be needing a 32-bit address bus.


So, in the emulator, for convenience .. i could just use int's (32 bit) but not actually have that much memory right?

Thank you all for the replies. I am really learning quite a bit very quickly around here :)


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 1:19 am 
Offline

Joined: Sun Jul 28, 2013 12:59 am
Posts: 235
A couple more fun RAM word widths: 36 bits (old-school computers, back when they did fixed-point BCD and wanted to have nine digits to work with), 40 bits (Symbolics Lisp Machines, 32 bits of data, 8 bits of type tag), 56 bits (TI Explorer I Lisp Machine writable microcode storage). Not sure what the address bus width was on most of these, but the TI Explorer microcode store was something like 14 bits of address... Though the microcode return stack was 15 bits wide due to a feature known as POPJ-14, which was fairly horrifying to figure out (two control registers got involved, plus conditionally starting a memory read cycle, plus conditionally altering the target microcode address).

I wish you luck with your emula^H^H^H^H^Hsimulator. It can be a fun path to go down, both for exploring a design space and for working towards simulating real systems.


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 1:23 am 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
nyef wrote:
A couple more fun RAM word widths: 36 bits (old-school computers, back when they did fixed-point BCD and wanted to have nine digits to work with), 40 bits (Symbolics Lisp Machines, 32 bits of data, 8 bits of type tag), 56 bits (TI Explorer I Lisp Machine writable microcode storage). Not sure what the address bus width was on most of these, but the TI Explorer microcode store was something like 14 bits of address... Though the microcode return stack was 15 bits wide due to a feature known as POPJ-14, which was fairly horrifying to figure out (two control registers got involved, plus conditionally starting a memory read cycle, plus conditionally altering the target microcode address).

I wish you luck with your emula^H^H^H^H^Hsimulator. It can be a fun path to go down, both for exploring a design space and for working towards simulating real systems.


Thanks :P I also intend to, if the project works out, create a hardware version on an FPGA. That could be fun... :D


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 1:46 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
sci4me wrote:
So, in the emulator, for convenience .. i could just use int's (32 bit) but not actually have that much memory right?

Your variables (numeric, string, whatever) can be any size; but if it's more than 8 bits, you'll need two or more bytes per variable.

Quote:
I wish you luck with your emula^H^H^H^H^Hsimulator. It can be a fun path to go down, both for exploring a design space and for working towards simulating real systems.

Yes, if we can be allowed to be purists, if it's software only, it's a simulator.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 2:27 am 
Offline

Joined: Tue Oct 08, 2013 5:40 am
Posts: 72
Location: /home/sci4me
GARTHWILSON wrote:
sci4me wrote:
So, in the emulator, for convenience .. i could just use int's (32 bit) but not actually have that much memory right?

Your variables (numeric, string, whatever) can be any size; but if it's more than 8 bits, you'll need two or more bytes per variable.

Quote:
I wish you luck with your emula^H^H^H^H^Hsimulator. It can be a fun path to go down, both for exploring a design space and for working towards simulating real systems.

Yes, if we can be allowed to be purists, if it's software only, it's a simulator.


So, an emulator would make use of the actual hardware its running on AS WELL AS simulating some of it? But a simulator is just complete software .. "simulation"


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 2:35 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8513
Location: Midwestern USA
sci4me wrote:
So, an emulator would make use of the actual hardware its running on AS WELL AS simulating some of it? But a simulator is just complete software .. "simulation"

An emulator is hardware that substantially (if not completely) performs the functions of a different piece of hardware. An example of emulation that isn't directly related to the 6502 is the WYSE 60 data terminal running in VT-100 emulation. It looks like a VT-100 to both the user and the system to which it is attached, but is actually a WYSE 60.

A simulator is software that substantially (if not completely) performs the functions of a piece of hardware. For example, a number of programs have been written to run under Microsoft Windows that produce an accurate simulation of the 6502. The x86 hardware running the simulation has no 6502 hardware, of course. It is the execution of the simulator's machine code that produces the illusory 6502.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 2:40 am 
Offline

Joined: Sun Jul 28, 2013 12:59 am
Posts: 235
To stretch these boundaries to a rather silly extent, if I wired up an NES controller and a cartridge connector salvaged off of a Game Genie to my Raspberry Pi somehow, and patched my old NES "emulator" to take input from the controller and use the cartridge port instead of ROM images, and used the composite video output on the Pi, do I have an emulator, a simulator, or merely a frightening hack?


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 3:44 am 
Offline

Joined: Sat Dec 13, 2003 3:37 pm
Posts: 1004
Oh, what the heck, I'll toss this on the fire...

So, if I download code to ATmega, and it operates as a 6502, it's a simulator. If I download code to an FPGA, it's an emulator?


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 4:01 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
whartung wrote:
Oh, what the heck, I'll toss this on the fire...

So, if I download code to ATmega, and it operates as a 6502, it's a simulator. If I download code to an FPGA, it's an emulator?

Can you connect hardware to it? It's an emulator. If it's like on the PC screen to simulate processor execution but you can't connect stuff, it's a simulator. A C64 emulator for example would let you plug in C64 cartridges, disc drives, etc., and test their hardware, even if it were a big wire-wrapped breadboard connected to a PC. An in-circuit emulator of a microprocessor has a pod that plugs into the microprocessor socket on a PCB and runs the processor functions but gives you a window into the processor's registers and so on that you wouldn't otherwise have. It is useful for debugging the actual hardware.

The term "emulator" has been abused so much that it is commonly accepted to mean "simulator" also, which is why I started out by saying, "If we can be allowed to be purists..." since only purists insist on the difference. We tend to be the older ones who remember processor emulators that cost $10,000 and plugged into your µP socket. American Automation is one manufacturer I remember.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 6:03 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
These definitions of "emulator" are old school and misguided. The difference is in whether something merely acts like something or whether it also goes to the trouble to work like something. Visual6502 is a simulator; 6502asm is an emulator.
An in-circuit emulator is a piece of hardware which is a specific example of an emulator.
If it's all you've worked with, you might think it's the very definition of an emulator. But you'd be wrong!
Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM bus widths?
PostPosted: Wed Oct 09, 2013 6:38 pm 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8546
Location: Southern California
Quote:
The difference is in whether something merely acts like something or whether it also goes to the trouble to work like something.

I can agree with that part or your post. On the HP calculator forum, sometimes calculator emulators are discussed, like using an iPhone to emulate a calculator that is no longer in production. If the calculator's only input and output was the keyboard and display, then there is no difference between a simulator and an emulator. But if the calculator it had ports (like the HP-41) that allow modules to be plugged in which can interrupt the system, provide I/O to several workbench instruments at once (using the original interface, not USB for example), provide extra memory, and so on, then an emulator must go beyond pretending about the external interrupts and I/O like the simulator does. The emulator, in your words, also goes to the trouble to work like the real thing, allowing such modules to be plugged in and do their job. If it cannot connect to those things, but rather those things exist only in the imagination of a stimulus file, then it's a simulator.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 83 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: