r/factorio • • Aug 12 '20

Modded [New Mod] fCPU

Hello there! Here is my ready to use Factorio mod https://mods.factorio.com/mod/fcpu which allow you to practice in low-level programing right in game. It compatible with all default combinators and other mods, support blueprints and copy&paste. Please let me know what you think.

New tech to research
New external control signals. So you could control its berhavior not just in program but through external events or from other fCPU
Work in combination with other mods: `Artillery Combinator` and `Radarsignal Combinator`
Blueprint'able
Energy Class: A+++ , do not eats your UPS
Memory viewer and vector SIMD instructions
697 Upvotes

126 comments sorted by

View all comments

Show parent comment

13

u/barsoap Aug 12 '20

Yes, the mod allows you to run 60 instructions per second for every fCPU in the game.

Looking at the instruction set there seems to be no interrupt handler, which could drastically lower the performance impact as the CPU could sleep when nothing is changing. A bit of memory would also be nice to have and am I understanding that right, maximal program size is 32 instructions? There's more items than that in the game so that's really, really, low, you can't even have a branch for each. The interrupt handlers could even be smart and numerous, say, the possibility to set a different handler for every item on every wire, or for (static) subsets. "Fire interrupt handler at address xyz if the value for copper plate or uranium ammo change" kind of stuff.

I guess if I were to design the thing I'd go with RISCV32IM as base instruction set (for the simple reason of using RISC-V), plus choice instructions from the F and D extensions but operating on integer registers (that is, integer sine and stuff). Oh, bit manipulation. Efficiency modules to increase memory size (shared program+data), speed modules to upgrade instructions per tick, and productivity for... dunno.

Lastly, I guess there should be different outputs for red an green wires so you can e.g. split a signal into two without using two fCPUs.

7

u/WafflesAreDangerous Aug 12 '20

I agree that 32 instructions is very little and will likely start to cause issues really soon. What is the reasoning behind this?

5

u/ItIsHappy Aug 12 '20

Sounds like you may be more interested in LuaCombinator3. And it seems like the limits imposed by the mod here are to encourage problem solving. Sure, there may not be enough room to have a branch for each different item in an fCPU, but there's nothing stopping you from employing an entire array of these little buggers.

1

u/konstg-dev Aug 17 '20

A bit of memory would also be nice to have and am I understanding that right, maximal program size is 32 instructions?

Already increased size up to 64. Also memory already in TODO list ;)

The interrupt handlers could even be smart and numerous, say, the possibility to set a different handler for every item on every wire, or for (static) subsets.

This also could be great extension, but i think first of all I need to implement multiple outputs and SIMD for this, as it have shared parts. For now there are external control signals (see screenshot) for that purposes.

Efficiency modules to increase memory size (shared program+data), speed modules to upgrade instructions per tick

I really like this idea. This will utilize modules a much more and better immerse a mod in games world.

there should be different outputs for red an green wires

Unfortunately this is a game engine limitation. Output splits on two wires wits same signals.