Monday, 13 July 2015

Comment: A few observations on memory ...

Time was when a computer had a decent-sized chunk of memory if it had a few kilobytes.

Programming these machines was an exercise in economy.

These days, no self-respecting applications programmer will be seen behind the wheel of a machine will less than gigabytes of memory to shove their programs into. I should know because I have done it, too.

While I agree that having room enough to swing a cat (even if it has to be pretty good natured, and to not mind being concussed on the walls), there is a purity in programming a microcontroller with its limited headroom.

Unfortunately, we live in a world of big data - text, graphics and reference data. That makes things just a little bit more difficult.

I have been learning to use an ATmega328 microcontroller in the form of an Arduino Nano - 32kB of program storage, 1kB of configuration storage and 2kB of program variable and stack space. Now, those are pretty tight constraints, although happily, the Arduino compiler is pretty efficient in its conversion of your programs to machine code.

I would like to be able to run a graphical display off of this tiny computer but, sadly, there is no space in which to keep the font definition data.

Enter External Memory - by connecting a serial memory chip (and a couple of extra components) to the I2C bus, it is possible to access an extra 64kB straight off - and more if you do clever stuff with extra chips, addressing and so on. This takes your computer system into the realms of non-Von Neumann (Wikipedia link) architecture.

By using a bit more ingenuity, it is possible to multiplex the 16-bit address space, and to create paged memory - each page being 64kB of memory (a standard chip size).

What most people forget is that it is perfectly reasonable to multiplex to the the point where a 24-bit or 32-bit address space can be accessed - or even more, though at the combined cost of speed and complexity of memory management.

Using flash memory will give you a reprogrammable, non-volatile data store, and using SRAM (electronically simpler than the ubiquitous DRAM used in PCs) will give you somewhere to store your working data, ephemeris or whatever. Add a battery to SRAM and you have a non-volatile memory space that doesn't wear out in the same way that FLASH memory does.

Back in the 1980's, I was gifted a stack of old SRAM memory boards, each had four 32kB pages of memory. By building some suitable addressing hardware and patching the operating system, my little 6809-based Dragon 32 had access to over a megabyte of RAM (10 boards, two smaller capacity with battery back-up). Okay, it was slow and inefficient, but it was there and ready for use.

By using memory multiplexing, non-Von Neumann architecture, a handful of commonplace chips and a combination of data planning and ingenuity, I will be able to run that graphical display with the font-size I want.

No comments:

Post a Comment

Comments and suggestions are warmly welcomed.