3 ms·
I found these Ben Eater YouTube videos very useful to understanding what microcode is and how it works: 8-bit CPU control logic https://youtu.be/dXdoim96v5A ht
by dkersten 4y ago
I found these Ben Eater YouTube videos very useful to understanding what microcode is and how it works:
8-bit CPU control logic https://youtu.be/dXdoim96v5A https://youtu.be/dXdoim96v5A
8-bit CPU reprogramming microcode https://youtu.be/JUVt_KYAp-I https://youtu.be/JUVt_KYAp-I
In short, the microcode instructions are a bunch of flags that enable different parts of the processor during that clock cycle (eg is data being loaded off the bus into a register? Is the adder active? Etc), so to implement an instruction that says add value from memory a to value from memory b and store in memory c, the microcode might be: copy memory a onto bus, store bus to register, copy memory b to bus, store b to register, add both register and put result online bus, store value on bus to memory c. (In a hypothetical simple cpu like the one Ben built, a real one is obviously much more sophisticated). So in Ben’s toy CPU, the instructions are just indices nto an EEPROM that stored the control logic but pattern “microcode” for each instruction, and IIRC each instruction takes however many cycles the longest instruction requires (in real life that would be optimised of course).
This is also how some processors like the 6502 have “undocumented” instructions: they’re just bit patterns enabling parts of the processor that weren’t planned or intended.
So you can see that it may be possible to fix a bug in instructions by changing the control logic in this way, even though the actual units being controlled are hard wired. I guess it very much depends on what the bug is. Of course I only know how Ben’s microcode works and not how an advanced processor like the one in question does it, but I imagine the general theme is similar.