fCPU


Factorio Customizable Processing Unit. Allow to write any logic on low level machine code. The fCPU acts like a programmable microcontroller with a vector coprocessor that supports many useful instructions.

Content
3 months ago
0.18 - 1.1
8.51K
Logistic network Circuit network

b Space Exploration Compatibility? fcpu hangs

2 years ago

As a developer myself I absolutely love fcpu. However, Is this mode compatible with Space Exploration? I am setting up my rocket logistics and the fcpu I have in orbit seems to just lock up and stop processing at a particular line. I cant get it to restart or halt without re-placing it. I can't either pin it down to anything specific I do. It works for a while but even if I am just in space for a few moments it stops again without travelling between areas. It has plenty of power.

It seems to be related to processing the input signals. If I re-place it then let it run it runs, but after processing input signals for some time the program and the fcpu eventually locks up.

Its a simple program with SIMD instructions but no branching and no waiting opcodes. It should always continue to run. I have a few fcpus which seem to run fine on the homeworld.

Any ideas? Any more info I can give to figure this out? I'm using the latest versions of SE, factorio, and fCPU.

Factorio :1.1.53
fcpu: 0.4.13
SE: 0.5.108

With the power of fCPU and the complexity of SE, Id really hate to have to not use fcpu and go back to regular circuits. I can do in a few lines what would take a lot of error-prone fiddling with many combinators.

2 years ago

fCPU used to work pretty well with SE a few months ago (after crash fixes).

Sadly after WARP all of mem is cleared the registers stay saved tho(r0-r7).
The thing is, as you described, that it crashes randomly(on warp) and stops.

The workaround is simple:
just make a normal combinator that forces (a few ticks after warp) jmp to a specific location in the program (and handle it properly) and start signal.
To do this u have to use the signals provided by fCPU ( run and jmp).
Hope u figure this out despite my cloudy explanation :) HF

1 year, 2 months ago

I trying to use fcpu. But any programm hangs after 50-100 iteration.
Scenario:
1. Place fcpu
2. write code
3. Run
4. Wait something about 2 minutes
5. Open fcpu and see that code evaluation a stoped

I can only replace fcpu to start code again. Reseting with combinator isn`t help

2 months ago
(updated a month ago)

Thanks to the great insight provided by @wisnia20012 above (thx mate), I have the following findings:

  • Sleeping by 'slp' (I think other blocking functions too) seems to hang the fcpu indefinitely
  • Halting and resuming seems to work fine across surfaces

The key takeaway being to have the fcpu in the halted state during the switching of surfaces. Rig a timer with two decider combinators (as the one on display on the Factorio wiki) that outputs a 'Run' signal to the fcpu every 120 ticks or so.

After you give a 'Launch' signal to the console, halt in the next instruction. When in flight, set the Anchor signals only when you read the Distance signal to be smaller than 0, then halt in the next instruction. This way, it is as good as guaranteed that the fcpu will be in the halted state whilst switching between surfaces.

Example of a spaceship between Nauvis' Orbit and an oil planet's orbit:

; INPUT
; M1[1]: ANCHOR
; M1[2]: DISTANCE
; M1[3]: DESTINATION
; M1[4]: DENSITY OF ASTROIDS
; M1[5]: SPEED

; OUTPUT
; M2[1]: DESTINATION
; M2[2]: CLAMP SHIP
; M2[3]: CLAMP SHORE
; M2[4]: LAUNCH

JMP :START

; R1: RETURN ADDRESS
:BLK_BATTERY_CHARGED ; WAIT FOR BATTERIES TO BE CHARGED
CLR R2
FIG R2 [virtual-signal=signal-battery-percent]
TEQ R2 100
JMP R1
HLT
JMP :BLK_BATTERY_CHARGED

; R1: RETURN ADDRESS
; R2: DESTINATION
:SET_DESTINATION ; OUTPUT DESTINATION AND CLAMPS
MOV M2[1] R2
XMOV OUT1 M2
JMP R1 ; END OF SET_DESTINATION

; R1: RETURN ADDRESS
; R2: ANCHOR_SHIP
; R3: ANCHOR_SHORE
:SET_ANCHORS ; SET ANCHORS TO DOCK SHIP
MOV M2[2] R2 ; SET CLAMP ON SHIP
MOV M2[3] R3 ; SET CLAMP ON DESTINATION
XMOV OUT1 M2
JMP R1 ; END OF SET_ANCHORS

:START
HLT
CLR
; READ INPUTS
FIG R1 [virtual-signal=signal-A]
SST R1 [virtual-signal=signal-A]
MOV M1[1] R1 ; if A is not available, set A 0
FIG M1[2] [virtual-signal=signal-distance]
FIG M1[3] [virtual-signal=se-planet-orbit]
TNE M1[3] 0
JMP :FOUND_DESTINATION
FIG M1[3] [virtual-signal=se-moon]
TNE M1[3] 0
JMP :FOUND_DESTINATION
FIG M1[3] [virtual-signal=se-moon-orbit]
TNE M1[3] 0
JMP :FOUND_DESTINATION
FIG M1[3] [virtual-signal=se-planet]
TNE M1[3] 0
JMP :FOUND_DESTINATION
FIG M1[3] [virtual-signal=se-star]
TEQ M1[3] 0
HLT
:FOUND_DESTINATION
FIG M1[4] [virtual-signal=signal-D]
FIG M1[5] [virtual-signal=signal-speed]
TEQ M1[1] 45 ;
JMP :AT_NAUVIS_ORBIT
TEQ M1[1] 1232
JMP :AT_MANNANAN_ORBIT
JMP :IN_SPACE

:AT_NAUVIS_ORBIT ; AT NAUVIS ORBIT, LAUNCH TO MANNANAN
LEA R1 :FUEL_LOADING
MOV R2 1232[virtual-signal=se-moon-orbit]
JMP :SET_DESTINATION

:FUEL_LOADING ; WAIT FOR FUEL TO LOAD
HLT
FIR R1 [fluid=se-ion-stream]
TLE R1 50000
JMP :FUEL_LOADING
:OIL_UNLOADING ; WAIT FOR OIL TO UNLOAD
HLT
FIR R1 [fluid=crude-oil]
TGE R1 500
JMP :OIL_UNLOADING
LEA R1 :LAUNCH ; WAIT FOR BATTERIES TO BE CHARGED
JMP :BLK_BATTERY_CHARGED

:AT_MANNANAN_ORBIT ; AT MANNANAN, LAUNCH TO NAUVIS ORBIT
LEA R1 :OIL_LOADING
MOV R2 45[virtual-signal=se-planet-orbit] ; SET DESTINATION TO NAUVIS ORBIT
JMP :SET_DESTINATION
:OIL_LOADING ; WAIT FOR OIL TO LOAD
FIR R1 [fluid=crude-oil]
TLT R1 399000
JMP :OIL_LOADING
LEA R1 :LAUNCH ; WAIT FOR BATTERIES TO BE CHARGED
JMP :BLK_BATTERY_CHARGED
:LAUNCH ; SEND LAUNCH SIGNAL
MOV M2[4] 1[virtual-signal=se-spaceship-launch]
XMOV OUT1 M2
HLT
HLT
JMP :START


:IN_SPACE
LEA R1 :AUTOPILOT
MOV R2 M1[3] ; FROM INPUT
JMP :SET_DESTINATION

:AUTOPILOT
FIG R1 [virtual-signal=signal-distance]
BLT R1 0 :DOCK ; WHEN ARRIVED, DOCK
HLT
JMP :AUTOPILOT

:DOCK
LEA R1 :START
MOV R2 10[virtual-signal=se-anchor-using-left-clamp]
MOV R3 350[virtual-signal=se-anchor-to-right-clamp]
JMP :SET_ANCHORS

This seems to be working rock solid, so I wanted to share!

New response