[Oberon] Commenting code (was: Impartial observation? ...)

Joerg joerg.straube at iaeth.ch
Sat May 14 08:04:03 CEST 2022


> If my employee was producing multi-level ternary operators and refused to write down what the code was doing, then it would impact our progress. We need clear code and good comments to pursue our projects.
> 
Personally, I was not used to read the ternary code. But over time analysing the RISC5 code I got used to it quite easily.
I think the indentation NW used helps a lot.
The only thing that is not clear by just reading it from the start is why the ternarys NW used are nested as they are. eg operation decoding in aluRes.
This is pure time optimization running through log(N) multiplexers  instead of N.
 
Another example is pcmux. Could have been written straightforward as
pcmux = ~rst ? StartAdr :
stall ? PC :
intAck ? 1 :
RTI ? SPC :
BR & cond & u ? nxpc + disp :
BR & cond & ~u ? C0[23:2] :
nxpc;

But these cascading multiplexers generate latency. Knowing that the seventh nxpc case is the most often used, „normal“ case and the other conditions are very rare, NW nested the „IF“s (ternary ?) to reach nxpc the fastest, mainly after 2 multiplexers instead of 6.

Jörg


More information about the Oberon mailing list