NOTE: UPDATE (16/09/2018) The IC system has evolved significantly since this news post. For a more recent description of the programmable circuit implementation available now on the stable branch check out the full patch notes post here.
The next evolution of logic circuits is now available for testing on the beta branch. This will continue to be worked on in the weeks to come based on your feedback, so please give them a try and let us know how you get on!
These will be a late-game optional replacement for the existing logic circuits, allowing you to make far more intricate circuits using a programming language based on MIPS and best of all, all housed in a single chip!
A computer program is written on a computer with a ProgrammableChipMotherboard
inserted. Once written the code can be exported to whichever ProgrammableChip
is selected from the drop down. Code can also be imported from selected
devices for editing.
When sent to the device execution will begin at line 0 (the first line) and
stop when it reaches the end of the code. To have code recur jump and branching statements need to be used. In those cases execution will run either
- 128 lines of code, or
- until a yield statement is reached, execution will begin on the following line
the next power tick.
The chip can take up to three inputs from other Logic Readers referred to by the values i0, i1, and i2 corresponding to the input screws on the chip. It also has five registers referred to by the values r0, r1, r2, r3, and r4. The output value, referred to as o, can then be read by a Logic Writer on the same network and used as you wish.
In the following list
- d is a register or output
- s and t are registers, inputs, or floats
- a is a non-negative integer value
All calculations, except for the address to jump to, are done as floats.
As a final note before listing the commands, there may well be ways of combining commands to get results you want that use behaviour not specified here. That behaviour may change at some point in the future.
We also plan on making the loaded commands persist with the device when it is deconstructed, so you can configure them with a computer then reinstall them at another location on a separate device network. This will likely come next week.
// Text after a // will be ignored to the end of the line. The amount of white
// space between arguments isn't important, but new lines start a new command.
move d s // stores the value of s in d
add d s t // calculates s + t and stores the result in d
sub d s t // calculates s - t and stores the result in d
mul d s t // calculates s * t and stores the result in d
div d s t // calculates s / t and stores the result in d
mod d s t // calculates s mod t and stores the result in d. Note this
// doesn't behave like the % operator - the result will be
// positive even if the either of the operands are negative
slt d s t // stores 1 in d if s < t, 0 otherwise
sqrt d s // calculates sqrt(s) and stores the result in d
round d s // finds the rounded value of s and stores the result in d
trunc d s // finds the truncated value of s and stores the result in d
ceil d s // calculates the ceiling of s and stores the result in d
floor d s // calculates the floor of s and stores the result in d
max d s t // calculates the maximum of s and t and stores the result in d
min d s t // calculates the minimum of s and t and stores the result in d
abs d s // calculates the absolute value of s and stores the result in d
log d s // calculates the natural logarithm of s and stores the result
// in d
exp d s // calculates the exponential of s and stores the result in d
rand d // selects a random number uniformly at random between 0 and 1
// inclusive and stores the result in d
// boolean arithmetic uses the C convention that 0 is false and any non-zero
// value is true.
and d s t // stores 1 in d if both s and t have non-zero values,
// 0 otherwise
or d s t // stores 1 in d if either s or t have non-zero values,
// 0 otherwise
xor d s t // stores 1 in d if exactly one of s and t are non-zero,
// 0 otherwise
nor d s t // stores 1 in d if both s and t equal zero, 0 otherwise
// Lines are numbered starting at zero
j a // jumps to line a.
bltz s a // jumps to line a if s < 0
blez s a // jumps to line a if s <= 0
bgez s a // jumps to line a if s >= 0
bgtz s a // jumps to line a if s > 0
beq s t a // jumps to line a if s == t
bne s t a // jumps to line a if s != t
yield // ceases code execution for this power tick
This is a sample timer command set, alternating between 1 for 1 tick (0.5s), then off for 2 ticks (1s).
move r0 0 // Line 0: move the value 0 to register0
sub r1 r0 3 // Line 1: subtract 3 from the value in r0 and write it to r1
bltz r1 4 // Line 2: jump to line 4 if r1 < 0 (skip the next line)
move r0 0 // Line 3: move the value 0 to register0
slt o r0 1 // Line 4: if r0 < 1 write 1 to the output, otherwise 0.
add r0 r0 1 // Line 5: increment r0 by 1
yield // Line 6: wait until next power tick (0.5s)
j 1 // Line 7: jump back to line 1
As always, we would love to hear about what you're making with the new programmable chip and devs will be keeping an eye on the #logic-discussions channel in Stationeers Discord next week, so bring all your comments and suggestions!