Category: Sci/Tech

Processor architecture (by )

The current state of the art in processor design seems to be a reasonably complex instruction set, which is interpreted by a thing that translates it into a series of more primitive instructions which are then fed into some kind of multiple-issue pipelined thingy with speculative execution. You know, the kind of stuff x86 has been since the 386. 64-bit instructions, vector SIMD instructions, lots of cores and all that are just variations on the theme.

I'm sure this is a local maximum in the space of processor designs. So few of the transistors on each chip seem to be actual ALU doing something useful. All this translation and pipeline control seems to be a lot of logic that's just adapting to the impedance mismatch between the ALUs and instruction set...

So, I'm always interested in more exotic processor architectures, and there's two different threads I'd love to explore (as in, design and simulate in an FPGA) if I had time. The common theme is simple control logic; this means you can fit in more ALUs, or wide ALUs and registers, in the same space - or just fit more cores and more cache on the same die.

Zero-operand stack machines

The idea here is to use a stack instead of a register file. This means that instructions just need an operator (eg, "add") as the operands are implicit - the stack always provides the inputs and outputs. This means that the instructions can be very small due to the lack of operands; generally, much smaller than a machine word, so each word loaded can have several instructions in. This can mean that the memory bandwidth required to feed the chip with instructions is reduced; and since the decode and control logic becomes very simple, you can sustain a high clock rate with minimal pipelining, so reducing the memory bandwidth consumed by instruction loads is handy.

That means you can't fit literals or static addresses inside instructions, though, so you need something like a "load immediate" instruction that fetches the next word from the instruction stream and pushes it, rather than treating it as instructions. If an instruction word contains several "load immediate" instructions, then that many subsequent words of instruction stream could be literals!

One example of this approach is a Minimal Instruction Set Computer, but the concept is broader than that. Large instruction sets can be easily supported.

The control logic boils down to loading an instruction word, then treating it as a FIFO of smaller instructions to execute while the next instruction word is loading. Most instructions just engage an ALU circuit hardwired to the top element or two of the stack, whose output becomes the new top of stack. A few might transfer data to/from a memory access unit or a register, including the instruction pointer to change the flow of control. Not many gates are needed to decode an instruction, leading to the short cycle time.

Instructions that can't complete in a single cycle present a problem, though. The use of a stack tends to mean that an instruction depends on the result of the previous instruction, so it's tricky to execute several instructions in parallel and thus make progress in the presence of weighty multiply/divide instructions or memory reads.

I can think of three ways of overcoming that, and you can combine all three:

Multiple stacks

The approach taken by the 4stack processor is to have four stacks, each with its own independent ALU. Each instruction word has an instruction for each ALU in, and they execute in parallel on each clock tick. Presumably, there's some means to transfer results between the stacks - I imagine a bus joining them, an instruction to pop a value from the stack onto the bus, and an instruction to push from the bus. The timings of the bus reads and writes are such that it's possible to have an instruction word with a pop->bus from one stack and push->bus for one or more stacks that do such a transfer in a single cycle.

Due to the synchrony of instructions feeding into each ALU, we can't "stall" an ALU. If one of them executes a weighty instruction or has a cache miss on a memory read, we either stall ALL the ALUs at once, or we mandate that certain instructions are followed by a fixed number of NOPs before another instruction can execute, to allow time for it to complete.

This puts the onus on the compiler to schedule instruction-level parallelism, and means that the compiler needs to know the precise timings (and number of ALUs) of the target CPU - we can't use the same instruction set for a broad range of implementations!

Result registers

Weighty instructions might not put their results straight on the stack; instead, the instruction might cause the inputs to be pulled from the stack and the instruction starts executing. When it completes, the result is latched into a result register, and a later instruction pushes the contents of the result register (stalling if it's not ready yet). This means that the instruction stream can get on with other stuff while the lengthy instructions run. However, it requires such multi-cycle instructions to inherently work differently; and it puts some onus on the compiler to know how many instructions to wait between starting these instructions and trying to access their results for best performance.

Virtual stack

Finally, we can virtualise the values on the stack. A division instruction, for example, might read two actual values from the stack and then push a token that means "Wait for the result coming from division unit 7". If the next instruction is an addition, then it would read that token and (say) a literal value from the next stack position; since one of the inputs is a token it can't execute yet, but it still assigns an addition ALU and loads the literal value. But it tells division unit 7 to, when it completes, push the result into port 1 of addition ALU 3; and it pushes a token that means "Wait for the result coming from addition ALU 3", and so on. Basically, rather than waiting for operations to complete so you can push a value to the stack, you can instead push a reference to an operation in progress; a cluster of ALUs and memory access units connected by suitable buses then becomes a kind of dataflow machine which is fed connections from the instruction stream, in effect taking the condensed zero-operand instruction stream and using it to assign dependencies between instructions, rather than using virtual registers to assign dependencies as in current CPU designs. But this requires the kind of complex control logic that I feel current CPU designs are drowning in.

Transport-triggered architecture

Another way to simplify control logic is to build your CPU as a bunch of modules with input and output ports. Arithmetic and logic operation modules have one or two inputs and a single output; a memory reader has an address input and a data output; a memory writer has address and data inputs and no outputs; registers have an input and an output; and so on.

Each instruction contains a few bits to control whether the instruction executes conditionally on bits from a flag register, then an output port to read from, and an input port to write the result to. The decoding consists of checking the conditional execution flags then either doing nothing, or pushing the input and output port IDs onto two address busses and toggling a strobe line that causes the output port to write its contents to a data bus, and the input port to load from it.

As with the zero-operand stack machines, the instructions are small, so can probably cram several into a machine word - maybe split into groups that share a single set of conditional execution bits, for even more compactness. These instructions are all operand and no operator!

To insert literal values in the instruction stream, one can again have an output port on the instruction fetch module, that when read pulls a literal value from the instruction stream and stops it from being interpreted as instructions.

The output of each module is a register, where a value appears as soon as it's ready and waits until it's read - so there's no need to explicitly store it in a general purpose register. However, the CPU might have a few general-purpose registers anyway to store stuff in, as well as the usual instruction pointer, flags, and machine control registers.

This makes it easy to exploit parallelism; the instruction stream can trigger lots of modules and then come back later to read their output registers. The compiler might need to know the cycles required to do various things and not read the outputs until they're ready, or there might be handshaking on the internal bus so that instructions stall until an output is ready, which makes it easier to deal with things like memory reads that can take widely varying numbers of cycles to complete. Even then, the compiler can still benefit from knowing cycle timings in order to schedule stuff better.

Modules could be pipelined. Rather than having four multipliers, you might have one that you can feed (say) four sets of inputs into and then, later, read the output register four times to get the results. The compiler might need to know how deep the pipeline is to avoid overflowing it with results; or the hardware spec might mandate that up to sixteen multiplies can be pipelined, and put a FIFO on the output register to make up the extra capacity needed beyond the number of pipeline stages it has.

The downside is that the compiler needs to know how many modules there are and what port numbers are wired up to what. This, again, makes it hard to have a single executable that can run on a wide range of implementations of the design.

However, this looks rather like the execution model behind the virtual-stack machine discussed above - so perhaps we could have a generic stack-based instruction set that is executed by a virtual stack to generate instructions for an underlying transport-triggered machine...

Modules could be quite complex; for instance, an index register module might comprise a register coupled directly to a memory access system. By accessing different input or output registers, it could update the contents of the register, or write to the memory address stored in the register, or read from the memory address in the register; and different input/output ports could be accessed that cause it to pre- or post-increment or -decrement the index register at the same time, allowing for efficient operations on contiguous blocks of memory. Also, the internal data bus might be arbitrarily wide, allowing ALUs to operate on, and registers to store, vectors of several machine words; modules that only operate on a single word at a time might sacrifice a few input-port-select bits in their instructions to select which word from the vector on the data bus to read into their input port.

To save on space taken up by literals, we can have a simple module with output ports that produce some useful constants (0, 1, -1); or dedicate a single bit of the instruction to selecting whether the input port number field specifies an input port, or is a literal to just load onto the data bus. An input port number will be much smaller than a machine word, so this will only cater for small literals, but most literals are small and we can fall back onto fetching an entire word from the instruction module for larger literals. We might want to sign-extend a small literal, however.

The data bus might become a bottleneck, but that's OK - we can have several of them, and make the instructions specify an input and output port number for each bus; we then trigger multiple transfers in each instruction cycle. This is very similar to having several instructions in a machine word, except that they execute in parallel rather than serial. We just now need to specify what happens if the same port is read or written by two parallel transfers!

Conclusions

A general theme with many of the above approaches is that the compiler ends up needing to know more about the details of the chip implementation, because the compiler is responsible for more scheduling.

Perhaps this is no bad thing - runtime code generation is becoming the norm anyway, and it would be possible to bootstrap the system by having an initial "minimal instruction set" which is standardised, and allows access to a description of the current chip architecture; the runtime code generator can then be compiled (using a compiler written in the minimal instruction set), and then the processor switched into normal mode. This might even be implemented by having a simple version of the stack architecture as a front-end processor that starts executing code while the main CPU is dormant; it then has an instruction that hands an initial instruction pointer value to the dormant main CPU and starts it up. Multicore systems would need only one front-end processor to bring the whole system up!

Another approach might be to have a transport-triggered architecture with a small set of guaranteed modules available at well-known port numbers in every implementation, with variation occurring in the rest of the port-number space. But this requires the instruction format to have enough bits for the port numbers to allow for the largest imaginable processor, leading to unnecessarily wide instructions for smaller devices. Perhaps this can be handled by having the instruction decoder support both standard narrow instructions and implementation-specific wider instructions, again starting off in standard mode and allowing switching to wide mode once the processor definition has been read and used to compile the compiler that can exploit the full capabilities.

Either way, I think that future processor architectures might be more tightly coupled to the compilers than we're used to.

Florence Nightingale The Puppet (by )

Florence Nightingale having a shocking read of Mr Greys Anatomy

Florence Nightingale the puppet is getting about over excited about Mr Gray's Anatomy. Like Ada Lovelace Florence is a Victorian icon famous for developing graphical representations of data and for being one of the founders of modern medicine.

Though she was made with the other four puppets that we developed after Ada she sadly has not had that many outings but now is her time to shine. The brain hat I knitted for the Science Showoff event will be one of her props along with the brain - she may have to share with some of the other puppets at times 🙂

Other works to go with her are scripts, research into her life, her manga self and a series of other textiles and papier mache props, possibly with some 3D printing.

She is very excited to be out and about and is currently relaxing after what has already been a hectic British Science Week - she will be at Cheltenham Hackspace on Sunday 19th of March (yes this Sunday as of time of posting), for the Science Cafe!

Cuddly Science is on the Loose! (by )

The Cuddly Science Massive

Cuddly Science is on the loose - cuddly science whoo hoo!

For those of you who don't know these are the Cuddly Science puppets - they are historical scientists, engineers, medics and technologists. They talk, sing, tell you things, answer questions. They can be used with all age groups including grown ups only!

They were hiding for a bit with the head injury mainly as it takes quiet abit of thinking to talk science. I think I did two events with them in the first year after the head injury and they were short little cameos not full on.

In the summer I managed to get them out to couple of festivals - but it was a whole year on by then! But I did still had to stick to my subject areas so we mainly did space!

Cuddly Science Space Craft workshop at Wychwood Music Festival

However this doesn't mean I had stopped developing the idea and by the autumn we were back at Maker Faires and making papier mache fossils!

Having just taken the puppet Ada to International Womens Day and been part in amazing show where Ada had quiet a complex and new role, I am feeling confident that it is time for Cuddly Science to be doing more things 🙂

Being British Science Week (I often keep calling it National Science and Engineering Week which is what it used to be called), the puppets have been going into school for show and tell and of course we have the Science Cafe!

We now have a good variety of workshops from DNA extraction, to Light including smoke chamber, lasers and lenses! We have robot board games that show the basics of programming, and a universe in a box (this was an educational kit which I bought sponsering another identical kit to be sent to poorer regions).

Not to mention knitted brain hats and papier mache props, lab glass ware, and sand pits!

I'm even making a photo gallery of all the Cuddly Science stuff - it is taking me a long time as I still have to ration thinking time but it is getting there 🙂

Ada Out and About (by )

AdaLovelace the puppet getting ready for school show and tell

This week is British Science Week so Ada and the other puppets are out and about, Mary was so exstatic to find out that she could take them in to her school for show and tell 🙂

Of course she now has her own wish list of puppets she wants making!

The puppets are for our Science Outreach, Communication, Education stuff which goes by the name of Cuddly Science and will be appearing at the end of the week at Cheltenham Hackspace for a Science Cafe!

Ripples… (by )

Ada Lovelace the puppet reading Equal Rites by Terry Pratchett

It's the anniversary of the author Sir Terry Pratchett's death, I have been working my way through the Discworld books, it is taking time as I still struggle with reading since the head injury. I've started with what I think of as the Rincewind Books.

The Colour of Magic The Light Fantastic Sourcery Eric Interesting Times The Last Continent Science of the Discworld The Globe

I've probably missed some out - I'm currently reading The Last Continet 🙂

Rincewind is one of my favourite characters, he reminds me a lot of my dad, being an accidental hero - thinking he's a coward etc... being a nice person, having issues with inanimate household objects that refuse to actually be inanimate (in dad's case it's coathangers).

Then I plan on reading the Death Books as I think of them. Death and Susan are again characters I love, especially when Susan has wild hair she can not control!

Reaper Man Mort Soul Music The Hogfather The Thief of Time

Again I am probably missing titles! If you see a glaring omission please comment!

Then The Witches Books (including the Tiffany Books as a subset - this is slightly unfair as Rincewind should count as one of the Wizards but the character sets are all so over lapped that there are many different ways you could divid it all up ie Hogswatch could be seen as a Wizard book as well as Death), followed by Vimes, The Services Books (De Word and Moist), Maurice and then Pyramids, Small Gods and another other miscellany I have missed!

Alaric bought me the graphic novel of Small Gods and I want to work my way through the graphic novels as well, I know there was a copy of The Last Hero that I gave to my brother but I'm not really sure where it ended up!

After that it is time for non-Discworld Terry Pratchett including the Long Wars books.

As you can see from the photo, Ada Lovelace the Puppet is relaxing with one of her favourite book - Equal Rites. This is most apt for the Victorian Maths genius who made the fist computer programme (or would have been if there'd been a computer to actually run it on!). She was educated but that was unusual for a women in her era, especially with maths and science but she excelled at it and this bought (and still does amazingly) a lot of hate.

She had to fight to be accepted academically, Equal Rites is about a young girl who ends up being a Wizard but is initially denied entry to the Unseen University. It seemed apt.

I actually took the photo for International Women's Day but I have included it in this post because apart from the issue of gender equality etc... it represents something else...

Ripples - "No one is finally dead until the ripples they cause in the world die away" - this is a quote from the Discworld series.

And Ada in many respects represents a ripple and the on going legacy of Terry Pratchett. Of course it is only one element of how she came to be but it is none the less still an element.

The story begins with me at school - my Chemistry Teacher Miss Scudder tries to explain the Discworld books to me and writes it down in my leavers book. It was given as an example of Sci-Fantasy that I would love - she was right.

So my science teacher introduced me to Terry Pratchett's work, again she was not the only one but she was the most authoritive? If that's the right word.

The books sustained me through my A'levels and stupid amounts of stress that we poor on our young adults in education. Then to university where again the mirrors and parrelles with various books helped me.

And finally the point at which I really felt like jacking the whole science thing in... Science of the Discworld appeared where they look at the geology/formation of our planet (our universe is accidently created by the Wizards). This book reminded me why I was damn well studying rocks!

Then of course things went catastrophic health wise but JK, Pullman and Pratchett where there as my comfort reads (along with the three Annes and "coughs" the point horrors). Reading them took on a slightly more abstract purpose, they showed twisty corkscrews of lives, not the nice neat progressions that is expected.

In short they helped me reform to new paths and to climb around, under and sometimes into the obsticals that got in my way. They showed me that other routes are not wrong routs just different.

In many ways the books helped me think outside the box as it were - Cuddly Science, the art, the craft, the writing etc... all of that and how I use it and fuse it... is a little bit off centre as it were. Terry Pratchett showed me with his mirror worlds that that was great, that was how the world gets changed for the better... little by little by little.

So my science teacher introduced me to the Discworld, the Discworld, sustained my and kept me interested in science, taught me to think squiggly, squiggly thinking lead to me making puppets to teach kids science.

These are RIPPLES.

GNUTerryPratchett.

WordPress Themes

Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales