Most used unary and binary functions in demo coding
category: code [glöplog]
Hi!
I'm creating an 8bit retro computer from scratch using TTL, SRAM and GAL ICs. My hope is to get to the end of the project and give some boards for free to interested coders over here, to see if it can carve it's niche as a demo/game platform.
The architecture allows for fast read -> modify -> write loops, applying a unary function to each copied byte, has a fast "fill" mode and optimized parallel memory access, with relatively fast 8bit*8bit multiplication (30 cycles). The target clock freq is 18Mhz.
Now I'm wondering: if you could add an operation to a CPU ALU to speed it up, or add a new fast instruction, what would it be? scaling? filtering? min/max? clipped (saturated) add/sub? abs(a-b)? bit masking? hardware sin() LUT?
Thanks for any shared insight
I'm creating an 8bit retro computer from scratch using TTL, SRAM and GAL ICs. My hope is to get to the end of the project and give some boards for free to interested coders over here, to see if it can carve it's niche as a demo/game platform.
The architecture allows for fast read -> modify -> write loops, applying a unary function to each copied byte, has a fast "fill" mode and optimized parallel memory access, with relatively fast 8bit*8bit multiplication (30 cycles). The target clock freq is 18Mhz.
Now I'm wondering: if you could add an operation to a CPU ALU to speed it up, or add a new fast instruction, what would it be? scaling? filtering? min/max? clipped (saturated) add/sub? abs(a-b)? bit masking? hardware sin() LUT?
Thanks for any shared insight
This might be a shot in the dark, but could you implement a binary LogSumExp or an approximation of it? For log values with a great enough difference it can be approximated with a simple Max. This operation would be great for computations in log space, which avoid multiplication and division so they tend to be good for 3D transformations and projection.
With my limited experience on programming old hardware, the things I'm missing most are multiply and fast divide. A hardware LUT for sin sounds fun but if the memory access is fast enough, it's probably not that useful. Saturated add and sub sound useful but kind of fringe for most effects.
Fixed point in hardware?
Fixed point in hardware?
SIMD muladd. :-)
My vote goes to saturated add for those particle effects and and a fast multiplier to avoid having to create a lot of multables.
I vote for bringing back conditional execution flags like thumb had... https://support.arm.com/documentation/dui0473/m/condition-codes/conditional-execution-in-thumb-state
Quote:
I vote for bringing back conditional execution flags like thumb had...
Flip8 (the name of the machine) already has it! It's the SKIP opcode. Skips next instruction on carry,zero,negative or overflow clear/set, almost for free (no jump overhead).
Quote:
This might be a shot in the dark, but could you implement a binary LogSumExp or an approximation of it? For log values with a great enough difference it can be approximated with a simple Max. This operation would be great for computations in log space, which avoid multiplication and division so they tend to be good for 3D transformations and projection.
I could implement it with something like this: RES=Ra; RES-=Rb; Ra max= Rb; RES=LSE0(RES); RES+=Ra (12 cycles). in 4.4 fixed point. LSE0() would be a fast LUT integrated in the ALU, together with LSD0(), LOG2() and EXP2().
Quote:
Fixed point in hardware?
I could implement 18 cycles fixed point (4.4x4.4 or 4.4x1.7) multiplication and 21 cycles division (thru reciprocal + multiplication). That's the best the machine can do. Max resolution is 640x360 so precision should be just enough.
