Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming Hardware

Building a 32-Bit, One-Instruction Computer 269

Hugh Pickens writes "The advantages of RISC are well known — simplifying the CPU core by reducing the complexity of the instruction set allows faster speeds, more registers, and pipelining to provide the appearance of single-cycle execution. Al Williams writes in Dr Dobbs about taking RISC to its logical conclusion by designing a functional computer called One-Der with only a single simple instruction — a 32-bit Transfer Triggered Architecture (TTA) CPU that operates at roughly 10 MIPS. 'When I tell this story in person, people are usually squirming with the inevitable question: What's the one instruction?' writes Williams. 'It turns out there's several ways to construct a single instruction CPU, but the method I had stumbled on does everything via a move instruction (hence the name, "Transfer Triggered Architecture").' The CPU is implemented on a Field Programmable Gate Array (FPGA) device and the prototype works on a 'Spartan 3 Starter Board' with an XS3C1000 device available from Digilent that has the equivalent of about 1,000,000 logic gates, costing between $100 and $200. 'Applications that can benefit from custom instruction in hardware — things like digital signal processing, for example — are ideal for One-Der since you can implement parts of your algorithm in hardware and then easily integrate those parts with the CPU.'"
This discussion has been archived. No new comments can be posted.

Building a 32-Bit, One-Instruction Computer

Comments Filter:
  • by nokiator ( 781573 ) on Thursday November 19, 2009 @03:23PM (#30161468) Journal
    I built a single instruction microprocessor at grad school. The only instruction was to move a 32-bit data from one address to another address. All the ALU and I/O functions were memory mapped. For example, you could have an adder where address A was operand #1, address B was operand #2 and address C was the result. Branches were handled through ALU units where the result of the operation changed the instruction pointer for some future instruction. It was very easy to implement and notoriously difficult to program.
  • Re:Cheating? (Score:2, Interesting)

    by Anonymous Coward on Thursday November 19, 2009 @03:26PM (#30161522)

    Erm, no. The canonical single instruction machine uses "subtract and branch if negative" and that's not considered to be three instructions (subtract, test, branch) but one.
    Using memory-mapped facilities to perform operations like addition...now THAT is cheating.

  • by Animats ( 122034 ) on Thursday November 19, 2009 @03:39PM (#30161782) Homepage

    That's an old idea. [wikipedia.org] The classic "one instruction" is "subtract, store, and branch if negative". This works, but the instructions are rather big, since each has both an operand address and a branch address.

    Once you have your one instruction, you need a macroassembler, because you're going to be generating long code sequences for simple operations like "call". Then you write the subroutine library, for shifting, multiplication, division, etc.

    It's a lose on performance. It's a lose on code density. And the guy needed a 1,000,000 gate FPGA to implement it, which is huge for what he's doing. Chuck Moore's original Forth chip, from 1985 [ultratechnology.com] had less than 4,000 gates, and delivered good performance, with one Forth word executed per clock.

  • by purpledinoz ( 573045 ) on Thursday November 19, 2009 @03:48PM (#30161942)
    For a few seconds there, I thought you said grade school. Made me feel very inferior :) Wouldn't the complexities of programming it be handled by a compiler? If someone managed to write one for a 1 instruction processor?
  • One command? (Score:3, Interesting)

    by HockeyPuck ( 141947 ) on Thursday November 19, 2009 @03:56PM (#30162090)

    Reminds me of this old saying,

    "Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work."

    I just wish I knew who came up with it.

  • by mwvdlee ( 775178 ) on Thursday November 19, 2009 @03:57PM (#30162106) Homepage

    It's got only one instruction. ...and the first parameter to that instruction controls what the instruction does with the rest of the parameters.

    (p.s. I wish this was just a joke, but this is pretty much what it seems to be doing)

  • by pz ( 113803 ) on Thursday November 19, 2009 @04:07PM (#30162256) Journal

    ... whose first operand is the task to perform. Followed by the necessary operands for that task.

    Exactly. It isn't a single instruction computer.

    And the idea isn't new.

    If a single instruction architecture is designed, then there is only one instruction (duh), and there's no reason to encode that instruction in the instructions themselves. All that will be left is encoding for operands. There's a tempting but brief foray into semantics where you can argue that the first handful of bits in TFA's instruction set are operands to the execution control unit, but that is, in fact, what most would consider defining a set of instructions where each distinct value in that first handful of bits describes more-or-less a distinct instruction. One quickly realizes, however, that there is a fundamental difference between data operands and instruction operands, and, by stating that it is a single instruction architecture, the implication is that there are no instruction operands. Therefore, TFA's architecture is not single instruction.

    It's well known that there are universal logic elements (like the two-input NOR gate), and, by extension, you can create single instruction architectures that compute the universal logic element operation on two arguments, writing the results to a third. Instructions in such architectures are just memory locations -- source A, source B and destination. While incredibly simple, such a machine is going to have a very, very low instruction set density. It's an interesting project for intellectual curiosity (like in an introductory graduate level machine architecture course) but hardly worthy of a Slashdot front page mention.

  • by Bakkster ( 1529253 ) <Bakkster@man.gmail@com> on Thursday November 19, 2009 @04:21PM (#30162514)

    But most FPGAs utilize a CPU core, which is often hard-wired and has ports to access the programable elements. Assuming the single-instruction MIPS runs faster than the common 'standard' CPUs such as PowerPC, then there would be a benefit. The CPU could be smaller (leaving more space for programmable elements) and more easily expanded upon (run additional functions by address rather than by OPCODE).

    That's a big 'if', but there's merit in exploring it. The biggest barrier I can think of right now is with programming time, and that's the most expensive part of most FPGA projects already.

  • by multipartmixed ( 163409 ) on Thursday November 19, 2009 @04:43PM (#30162892) Homepage

    Interesting.

    First off, your one-instruction CPU, I guess you didn't need to express the instruction in machine code, just the arguments.

    Here's the funny question, why not develop an assembler with synthetic instructions, like SPARC v9? It would certainly make it easier to program.

  • Re:Cheating? (Score:5, Interesting)

    by maxwell demon ( 590494 ) on Thursday November 19, 2009 @05:08PM (#30163432) Journal

    I'd also consider it cheating. I can also invent a one-instruction computer, where the one instruction is a move immediate instruction. The move instruction moves a byte-sized value into a "command register" which does different things depending on the value of the byte you load into it and the current state of the machine. Indeed, since there's just one instruction, and it always has a single one-byte operand, I just don't encode the instruction itself, I just put all the operands into memory, one after another. And I define the state machine so that the actions are exactly the same as the actions of an x86 interpreting those bytes as separate instructions. Therefore I can avoid doing an implementation myself; I can just use a stock x86 processor as proof of concept.

  • by psYchotic87 ( 1455927 ) <stefanhetzwaantj ... m minus caffeine> on Thursday November 19, 2009 @05:41PM (#30164146)

    What you describe is pretty much how the linux kernel handles system calls. See this: How system calls work on linux/i86 [tldp.org]

    For an example of what a single instruction CPU might look like, take a look at this: Building the Turing complete coffee machine: an adequate assembly langauge [tldp.org]

  • by stonewolf ( 234392 ) on Thursday November 19, 2009 @06:27PM (#30164910) Homepage

    A cousin of mine (Howdy Rusty!) described this concept to me in the '70s while I was taking classes toward my CS degree.

    A little background: I went to the good old University of Utah which had a Boroughs 1700 with user writable microcode and so a lot of project centered around writing microcode and designing micro architectures. A friend was trying to code up a single instruction machine based on Curry Combinators. I thought he was nuts, but I liked the idea of a single instruction machine. So, I was talking to my cousin and he described an architecture that had one instruction that was a source and a destination address. Any address could be either memory or a register in a functional unit, an FU for short. No kidding, that is how he described it.

    The only trouble was trying to figure out how to do a conditional branch.

    A few years later while I was in gradual school I solved that problem and wrote paper about it. Being a gradual student I could not publish without permission from my adviser. Well, he got a good laugh out of the idea and told me not to show it to anyone. So, of course I sent it to everyone I knew. They all had a good laugh to. Said it was the funniest thing I had ever written. You see, I was into writing humorous stories at the time and people thought this was another one. Oh well, I have a print out of the thing around here somewhere.

    What I really liked about the architecture is that if you started modifying it to make it more economical, doing things like making the addresses have different lengths and adding a bit to tell you if the long address is the source or the destination, the move architecture starts looking more and more like a classic instruction set architecture. I thought that was very cool. When you look at micro coded architectures and think about a pure move based processor it really does look like all traditional architectures are attempts to make the one instruction machine make more economical use of instruction bits.

    So, how did I solve the conditional branch problem? Pretty much the way this fellow did. Every FU may, or may not, cause condition flags to be set. I added registers where you could read and write the condition bits and read and write the program counter. I also added a mask register that was anded with the condition register so you could enable and disable conditions. Then I just made the current instruction conditional on the values of the flags register anded with the mask register. If the result was non-zero the current instruction was skipped. Of course, the machine had to clear the condition register after each instruction was executed. (Hmm, it would make more sense to only make moves to the program counter conditional and it would make more sense to only clear the flags after a move to the instructions counter... Hey was a gradual student back then! :) That approach allowed you to select say the sign bit from one ALU, do an subtraction by moving values to two registers in the ALU, then jump if the sign bit is set. It also let you directly make any instruction conditional so you could implement something like the ABS() function without any jumps. Or, at least that was the idea.

    I called my one instruction: The Conditional Move From Here To There And Clear Flags, or TCMFHTTACF insturction. The assembly for it was really dull, it just always had the same op code down the left hand edge of the screen... Ok, really, I just never listed anything but addresses when I wrote code for it.

    Nice to see that someone actually built one of these. BTW, this kind of architecture makes it easy to add multiple execution units. With parallel execution and careful use of shared and private FUs and memories you can build a pretty damn powerful special purpose processor without a lot of hardware complexity.

    This just to damn cool... someone finally built it!

    Stonewolf

  • Re:Cheating? (Score:2, Interesting)

    by wd5gnr ( 1682238 ) on Thursday November 19, 2009 @07:37PM (#30165886)
    Well with bias, I don't think that's exactly the point. In fact, it is more like exposing the microcode engine directly to the programmer. The advantage is that you can readily add function blocks and therefore instructions without having to know about how the CPU works internally. So regardless of if it is really "one instruction" or not, it could be useful for quickly building application-specific CPUs, or even building CPUs on the fly to best suit certain programs (which could be interesting for "big iron" running lots of CPUs to solve a big problem, for example).
  • by SharpFang ( 651121 ) on Thursday November 19, 2009 @07:54PM (#30166136) Homepage Journal

    FPGA is usually the prototype phase.

    Actually, this could be implemented as a really small handful of transistors for the actual processor and a ton of various memory-mapped peripherials. Some of them being really simple old basic logic chips for ALU.

    It would mean a simple version for cheap microcontrollers would be really cheap to make, a family of compatible devices of different scale would be possible, and extending/upgrading existing instruction set would be easy too.

    The above is not a conflicting statement with the 1-instruction set idea. The MOV would not be really THE instruction set. The real instructions would be "place data in register A, read result from register B" and the memory map would be the real instruction set.

    But I just can't see it for anything bigger. It might be used for massively multicore processors if the address and data bus could be shared somehow. But I think it would be the bottleneck really fast.

  • by epine ( 68316 ) on Thursday November 19, 2009 @07:57PM (#30166170)

    x86 is with us because of backwards compatibility. even Intel were unable to shrug it off with Itanium and various other things.

    x86 is still with us because is-gross turned out to be 20% is-gross and 80% with-gross. The 20% that actually is-gross has been a minor cross to bear, the other 80% was relegated to traps, microcode, and emulation. The most ridiculous CISC instruction from 1980 is a pimple on a bedbug in silicon area thirty years later. Moore's law: the amazing zit shrinking cream.

    you almost need a different compiler for each generation of CPUs

    If your compiler doesn't work well on a 486, it's badly broken. Since then, there have been two different approaches by Intel which annoy the compiler gods: the Pentium and Pentium IV which place a premium on low level instruction scheduling, and everything else, starting with the Pentium Pro and including the Core Duo, all non-deterministic data-flow architectures at heart.

    The main differences in a good Pentium Pro compiler was a few hazard-aware instruction order tweaks, mostly focused on the complex/simple/simple instruction decode architecture. Hand tweaking for the Pentium Pro did not offer as much as with other architectures. It was hard to gain complete control for cycle precise scheduling, and the OOO logic did a good job of mitigating dependency chains on the fly: you neither had a large problem to solve, nor much control in solving it.

    There's a rumour the trace cache is making a reappearance in Sandy Bridge, so perhaps the pendulum is swinging back to the Pentium/Pentium IV side of the fence.

    A long time ago I read some long papers on TTA, around the time Intel went the wrong direction with Itanium (defining bundles as a unit of independent instructions, rather than bundles as units of dependent instructions).

    What makes TTA interesting is having many buses, with as many buses utilized on each clock cycle as possible. This guy has not invented an instruction set. He has invented a microcode engine. In doing so, he's muddied the notion of processor state, so there's no abstraction for handling interrupts. The great thing on an FPGA is that you can program around the need for interrupts, if you can devote a small core to each concurrent task.

    Real microcode instructions tend to have very long bit vectors, so that multiple buses can be coordinated on the same clock cycles. If you aren't trying to throw maximal resources at a single, dominant task, you can instead have many concurrent execution engines, each with a single function unit bus. This works for some applications.

    My feeling about Itanium is that it should have allowed instruction clusters such as complex multiply in a single bundle.

    r = ac - bd
    i = ad + bc

    This requires four inputs from the register file, two outputs to the register file, four multiplications, and two additions. You can find many examples in TAOCP V4F1 of small instructions clusters of this nature. A single eight byte bundle will be hard pressed to encode six arbitrary registers from a 256 register set, but I would argue that you don't need to. Compilers are extremely clever at register colouring, so a clever subset of full generality would prove more than adequate. Hint: invent the compiler and prove this, before committing the design to silicon.

    From a TTA perspective, such a bundle achieves six operations at the expense of just four reads and two writes to the shared register file, with some intermediate results briefly shunted on local sidings. Managing the local sidings introduces some non-determinism from the perspective of the compiler, but nowhere near the scope of OOO shunting overhead in the Pentium Pro.

    I think the Itanium design fell victim to ATM logic: determinism at the expense of higher aggregate throughput in the common case. That bet rarely pays off. They tricked themselves into believing they could bet against the grain by shuffling the downside of this fictio

  • Re:Cheating? (Score:3, Interesting)

    by Nazlfrag ( 1035012 ) on Thursday November 19, 2009 @09:09PM (#30166932) Journal

    I suppose it's cheating. I think it's useful though simply as a backbone for a custom processor, then patch in what you need. You might need an ALU and DSP for a complex project, and an accumulator & bit shifter for a simpler one. This lets you link them to a common bus architecture which could make for easy prototyping.

He has not acquired a fortune; the fortune has acquired him. -- Bion

Working...