3 ms·
Should be "32-ish architectural registers". Real processors have a lot more registers but they are not directly visible. This is the whole reason why x86-64 i
by rwmj 4y ago
Should be "32-ish architectural registers". Real processors have a lot more registers but they are not directly visible. This is the whole reason why x86-64 is usable despite having only 16 architectural integer registers (or actually a little less than that).
The article doesn't get RISC-V instruction encoding right. It mentions compressed instructions, but instructions can also be longer than 32 bits. The important thing about RISC-V is that the instruction stream can easily be divided at instruction boundaries (unlike, say, x86 which is horrific to decode). This gives you most of the benefits of fixed size instructions and the benefits of extensibility when you need it.
- weinzierl 4y ago> "This is the whole reason why x86-64 is usable despite having only 16 architectural integer registers [..]" Who'd have thought thirty year ago we'd all be sittin' here talking tens of registers, eh? In them days we was glad to have two or three. If we were lucky. My first computer had 1 (one). One with less bits than fingers on our hands. It was so dear to us we even gave it a name. "Accu" it was called. If you tell that to the young people today, they won't believe you.
- speed_spread 4y agoSounds as comfortable as living with two teenagers in a house with single bathroom. You have to optimize around it and use clever tricks that shouldn't be documented.
- _joel 4y agoLuxury
- kstrauser 4y agoMy first (usable) computer was a Commodore 64, with 3 registers but a special addressing mode for RAM in the 0x00-0xFF range. It was largely used as 256 bytes of “kinda like a register but not exactly” storage.
- weinzierl 4y agoBrilliant little machine, the good old 64. You are absolutely right about the zeropage (0x00-0xFF) and the three registers. Two of those three were pretty special and limited however. So, I'd say the C64 (and all 6502 or 6510 based systems) had really only one general purpose register.
- Dylan16807 4y agoThe 68k was quite a popular chip, with almost 20 registers and a clear trend towards more, and it came out over 40 years ago.
- adwn 4y ago> Should be "32-ish architectural registers". The entire article is about instruction sets, not about their physical implementation, so I don't think this clarification is necessary.
- ajross 4y agox86 isn't that difficult to decode. Instructions all fall on byte boundaries, so if you want to decode 16 bytes of instructions in a cycle you need 16 parallel decode engines. That sounds awful by the standards of 1987 RISC transistor budgets, but for modern CPUs it's mostly noise.
- avianes 4y agoThe difficulty is not to decode a single instruction, the difficulty is to decode multiple instructions in parallel (let's say from 5 to 8 instructions in parallel). In a modern high performance processor instructions are decoded in batches: Decoding the first instruction is straightforward. But x86 instructions range from 1 to 15 bytes, therefore the second instruction can start from byte-offset 1 up to 15. 3rd instruction has a byte-offset ranging from 2 to 30, ans so on. Furthermore, figuring out an x86 instruction length requires reading several byte from the instruction. In the end, the 8th instruction has 99 possible byte-offset, and assuming that we put, as you suggest, a decoder for each position and length, we need about 1590 decoders and many multiplexer to decode 8 full instructions per cycle. Of course we don't do that, it would consume a lot of energy for nothing. To handle that, modern x86 processor instruction decoding involves a instruction length decode before the instruction decode. The instruction length decode is responsible for identifying the instruction positions and boundaries, and this instruction length decode is a challenging part of the x86 processor to design. We don't know how Intel or AMD exactly do instruction length decode, but we know that some published techniques include a length predictor. That's why, for simplicity and energy efficiency, instruction boundaries must be easily identified and the number of instruction lengths must be kept low.
- ajross 4y ago> In the end, the 8th instruction has 99 possible byte-offset, and assuming that we put, as you suggest, a decoder for each position and length, we need about 1590 decoders and many multiplexer to decode 8 full instructions per cycle. Um... wat? No CPU tries to decode 99 bytes of memory in a cycle. ADL is at 32 currently, I believe. And the instruction starting at byte 12 doesn't change depending on anything but it's own data. It either exists (because the previous instruction ended on byte 11) or it doesn't. So you decode 32 instructions starting at each byte you've fetched (the last ones can be smaller subset engines because they don't need to decode longer instruction forms), and then mask them on or off based on earlier instruction state. Then feed your 1-32 decoded instructions through a mux tree to pack them and you're done. Surely there's more complexity, since this is going to have to be pipelined in practice, and a depth of 32 is going to require something akin to a carry-lookahead adder instead of being chained. But the combinatorics you're citing seem ridiculous, I don't understand that at all.