My questions are:
- How is ROM Memory designed (with hardware design)?
- How RAM Memory is designed and How they divided the RAM Memory?
ROM is Read Only Memory, and is typically written once (or written rarely) as in the case of EPROM and its variants, or mask programmed at the semiconductor manufacturer with a custom chip design containing the correct ROM data. ROM is available in discrete chips, as well as part of some processors. For instance, a lot of consumer devices sold in large quantites, such as digital watches, thermometers, so forth contain processors with ROM to reduce cost, as ROM is cheaper than flash memory. When ordered in very large quantities they are mask programmed when the silicon dice are fabricated, but smaller quantities include ROM that is programmable once.
ROM retains the data even if there's no power.
A simple ROM might consist of a single fuse and a diode per bit. The diode allows addressing circuitry at the edges to select rows and columns and interrogate the fuse to find out if it's present or broken. When writing data to the ROM it's called burning because you are literally burning out fuses, and often requires a higher voltage be present on a programming pin. Since the fuses cannot be burnt at lower (normal) operating voltages there is little risk of data change during normal chip operation.
Modern microcontrollers use more advanced ROM, and today Flash is quite common, though it's still more expensive and less dense than mask programming, and not suited for cost constrained applications where tens of thousands of chips will be used.
RAM is memory that can be read from and written to multiple times with no degradation of the memory cells. This is used to store active program data and code.
RAM generally loses the data once it loses power.
In simple devices a single bit of RAM can consume as many as five transisters making a flip flop as well as row/column activation lines. This large footprint makes static RAM very expensive to produce in large quantities on silicon. More dense RAM can be made by removing several of the transistors and adding a capacitor. Since the capacitor loses charge over time each bit has to be read and re-written frequently to make sure charged capacitors stay charged, and discharged capacitors don't gather charge. This type of RAM is referred to as DRAM, Dynamic Random Access Memory. While it requires more work to keep refreshed, you can fit 2-5 times as much memory on the same area of silicon as you can with static RAM.
Using multiple types of memory
While I've only discussed ROM and RAM here, there are many types of memory. Each has attributes that are useful, and they often complement one another. Most microcontrollers include a memory type that is fast, and loses data when the power goes out - often a form of RAM which is referred to as volatile, and they generally include a memory type that is dense and doesn't lose its data when it loses power - often a form of ROM, or Flash memory which is referred to as non-volatile.
There are memories that try to meet all the requirements - fast, dense, and non-volatile, but they are still relatively specialized and are still not as cost effective as maintaining two different types of memory, especially on the same silicon as the processor die.
When you have to manage two or more types of memory with one processor you usually put them in the same address space but at different addresses. Thus the processor can access them with the same instructions, but the programmer has to be aware of which they access so they don't inadvertently attempt to write memory that can't normally be written.
Some processors, such as the PIC 8 and 16 bit processors, have two fully separate address spaces for the RAM and Flash. The architecture of the processor supports a code space and a data space, and so the memories aren't simply at different addresses int he same memory space - they are in logically separate memory spaces and different instructions are used to access them.
Processors with external memory, such as common computer and mobile device processors used to run Linux, Windows, iOS and other operating systems, can have the different memory types at any address - it's up to the hardware designer to decide where in the address space their memory is, with some constraints, such as making sure ROM exists at the boot-up location for the processor, and the slower memory is at addresses where wait states can be used.