Skip to content

Commit 429b48c

Browse files
authored
Merge pull request #3499 from llysdal/wire-fpga
Add Wire FPGA to main branch wire
2 parents 00add36 + c34d4e5 commit 429b48c

File tree

21 files changed

+6351
-1
lines changed

21 files changed

+6351
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
~'ExecutionInterval":n0.1;'Position":{n2.6361454580615;6.2933851740375}'ExecuteOn":{~'Timed":b1'Trigger":b0'Inputs":b1}'Name":'Hello World!"'Nodes":{{~'ioName":'A"'gate":'normal-input"'connections":{}'type":'fpga"'y":n-20;'x":n-45}{~'ioName":'B"'gate":'normal-input"'connections":{}'type":'fpga"'y":n-5;'x":n-45}{~'gate":'+"'connections":{{n1;1}{n2;1}}'type":'wire"'y":n-20;'x":n-5}{~'ioName":'Add"'gate":'normal-output"'connections":{{n3;1}}'type":'fpga"'y":n-20;'x":n35}{~'ioName":'RotatedBy"'gate":'angle-input"'connections":{}'type":'fpga"'y":n40;'x":n-45}{~'ioName":'Vector"'gate":'vector-input"'connections":{}'type":'fpga"'y":n25;'x":n-45}{~'gate":'vector_rotate"'connections":{{n6;1}{n5;1}}'type":'wire"'y":n30;'x":n-5}{~'ioName":'Rotated"'gate":'string-output"'connections":{{n9;1}}'type":'fpga"'y":n30;'x":n35}{~'gate":'vector_tostr"'connections":{{n7;1}}'type":'wire"'y":n30;'x":n15}{~'ioName":'Text"'gate":'string-output"'connections":{{n11;1}}'type":'fpga"'y":n55;'x":n35}{~'gate":'string-constant"'connections":{}'value":'Hello World!"'type":'fpga"'y":n55;'x":n-5}{~'x":n20;'connections":{}'value":'Hello world!"'type":'editor"'y":n0;'visual":'label"}@{~'x":n20;'connections":{}'value":'Here's a comment"'type":'editor"'visual":'comment"'y":n5}}'Zoom":n6.6919658530683;

data_static/fpgahelp.txt

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<style>
5+
body {background-color: white; margin-right: 30px;}
6+
h1 {font-family: Verdana, sans-serif;}
7+
h2, h3, h4 {margin-bottom: 0; font-family: Verdana, sans-serif;}
8+
p {margin-top: 0; font-family: Verdana, sans-serif;}
9+
th, td {font-family: Verdana, sans-serif;}
10+
</style>
11+
</head>
12+
<body>
13+
<h1>FPGA Help</h1>
14+
15+
<h2>Types</h2>
16+
<div class="col" style="margin-left: 20px;">
17+
<table>
18+
<tr>
19+
<th style="width: 60px;">Type</th>
20+
<th style="width: 80px;">Color</th>
21+
</tr>
22+
<tr>
23+
<td>Normal</td>
24+
<td style="background-color: rgb(190, 190, 255)"></td>
25+
</tr>
26+
<tr>
27+
<td>Vector</td>
28+
<td style="background-color: rgb(70, 160, 255)"></td>
29+
</tr>
30+
<tr>
31+
<td>Angle</td>
32+
<td style="background-color: rgb(100, 200, 100)"></td>
33+
</tr>
34+
<tr>
35+
<td>String</td>
36+
<td style="background-color: rgb(250, 160, 90)"></td>
37+
</tr>
38+
<tr>
39+
<td>Array</td>
40+
<td style="background-color: rgb(20, 110, 20)"></td>
41+
</tr>
42+
<tr>
43+
<td>Entity</td>
44+
<td style="background-color: rgb(255, 100, 100)"></td>
45+
</tr>
46+
<tr>
47+
<td>Ranger</td>
48+
<td style="background-color: rgb(130, 100, 60)"></td>
49+
</tr>
50+
<tr>
51+
<td>Wirelink</td>
52+
<td style="background-color: rgb(200, 80, 200)"></td>
53+
</tr>
54+
</table>
55+
</div>
56+
57+
<h2>Controls</h2>
58+
<div class="col" style="margin-left: 20px;">
59+
<table>
60+
<tr>
61+
<th style="width: 180px;">Key</th>
62+
<th>Effect</th>
63+
</tr>
64+
<tr>
65+
<td>Left mouse button</td>
66+
<td>Used to move gates, draw connections, and draw selections</td>
67+
</tr>
68+
<tr>
69+
<td>Double click</td>
70+
<td>Draw connection from all the gates inputs / outputs</td>
71+
</tr>
72+
<tr>
73+
<td>Right mouse button</td>
74+
<td>Hold and drag mouse around to move around the internals of the FPGA</td>
75+
</tr>
76+
<tr>
77+
<td>C</td>
78+
<td>Creates a gate at the cursor position. Select which gate in the gate selector on the right</td>
79+
</tr>
80+
<tr>
81+
<td>X</td>
82+
<td>Removes the gate under the cursor. If a selection has been made, it will delete all selected gates</td>
83+
</tr>
84+
<tr>
85+
<td>E</td>
86+
<td>Edits a property of the gate under the cursor. Applicable for Input, Output and Constant gates</td>
87+
</tr>
88+
<tr>
89+
<td>G</td>
90+
<td>Toggles align to grid</td>
91+
</tr>
92+
<tr>
93+
<td>Ctrl C</td>
94+
<td>Copies the selected gates</td>
95+
</tr>
96+
<tr>
97+
<td>Ctrl V</td>
98+
<td>Pastes the previously copied gates, and marks the pasted gates as selected</td>
99+
</tr>
100+
</table>
101+
</div>
102+
103+
<h2>Execution</h2>
104+
<div class="col" style="margin-left: 20px;">
105+
<p>The FPGA can be made to execute on different conditions.
106+
As default, it will execute if one of the inputs changes, or if it has a <i>timed</i> gate (as marked by red) inside it.
107+
It should be noted that if 2 different inputs change the same tick, the FPGA will execute twice,
108+
where the first execution will be with an old value for one of the inputs. This is due to how Wiremod works, where only one input is triggered at a time.
109+
</p>
110+
<p>
111+
To further customize chip execution, there are 3 different ways a chip can trigger an execution.
112+
</p>
113+
<h4>Inputs</h4>
114+
<div class="col" style="margin-left: 20px;">
115+
<p>
116+
The chip executes when an input is changed, and propagates the changes inside it, updating the gates affected by the input change.
117+
Gates that aren't affected by the input change, will not execute.
118+
</p>
119+
</div>
120+
<h4>Timed</h4>
121+
<div class="col" style="margin-left: 20px;">
122+
<p>
123+
Timed execution only affects gates which are timed (marked by red).
124+
This includes gates such as 'OS Time' and 'Entity Position', which share the property that their output is time dependant.
125+
For these gates to always have the correct output, timed execution needs to be on.
126+
The frequency that these timed gates are updated with can be controlled with the <b>Execution Interval</b> setting.
127+
</p>
128+
</div>
129+
<h4>Trigger In</h4>
130+
<div class="col" style="margin-left: 20px;">
131+
<p>
132+
For the greatest control over executions, the other options can be turned off and this one turned on.
133+
The gate will get a "Trigger" input, which when set to something other than 0, will cause the chip to execute everything necessary.
134+
The FPGA keeps a "lazy queue", such that it knows which gates will need to execute when the "Trigger" input is triggered.
135+
This includes all timed gates, and input gates which have had their value changed since last trigger.
136+
</p>
137+
</div>
138+
<br>
139+
<h3>Special execution gates</h3>
140+
<div class="col" style="margin-left: 20px;">
141+
<p>
142+
To further customize how a chip executes, some special execution gates have been included.
143+
They can be found under FPGA/Execution
144+
<h4>Execution Delta</h4>
145+
<div class="col" style="margin-left: 20px;">
146+
<p>
147+
This chip will return the time between the current execution and the last one.
148+
Useful for time critical circuitry - such as levitating - or calculations where the time difference is required.
149+
</p>
150+
</div>
151+
<h4>Execution Count</h4>
152+
<div class="col" style="margin-left: 20px;">
153+
<p>
154+
Increments by one each time the chip executes
155+
</p>
156+
</div>
157+
<h4>Last (Normal/Vector/Angle/String)</h4>
158+
<div class="col" style="margin-left: 20px;">
159+
<p>
160+
Mainly designed to allow looping circuitry. For example, a memory gate feeding it's own value + 1 into itself will produce an infinite loop.
161+
If a Last gate is put somewhere in the loop, it will allow it to be executed. It does this by using the value the gate connected to it's input had last execution,
162+
'disengaging' the infinite loop.
163+
</p>
164+
</div>
165+
<h4>Previous (Normal/Vector/Angle/String)</h4>
166+
<div class="col" style="margin-left: 20px;">
167+
<p>
168+
An alternative to the Last gate, that functions a bit differently. This gate will output the value the connected gate had the previous tick,
169+
which differs from the Last gate behaviour both because multiple executions can happen each tick, which will cause the Last gate to change, but not the Previous gate.
170+
The most important difference, is that the Previous gate will trigger a new execution during next tick, with the updated value.
171+
This can cause a chain reaction, if this execution changes the Previous gate, causing it to trigger next tick again.
172+
To avoid such chain reactions, the value should somehow stabilize - but the internal circuitry decides that.
173+
</p>
174+
</div>
175+
<h4>Last Timed (Normal/Vector/Angle/String)</h4>
176+
<div class="col" style="margin-left: 20px;">
177+
<p>
178+
Alternative form of the Last gate, this one can trigger an execute if the FPGA is set to trigger on Timed.
179+
This is useful for loops that are meant to execute every Execution Interval, where you don't care if the value has actually changed or not.
180+
</p>
181+
</div>
182+
</p>
183+
</div>
184+
</div>
185+
186+
</body>
187+
</html>

lua/autorun/wire_load.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ if SERVER then
3030
AddCSLuaFile("wire/wireshared.lua")
3131
AddCSLuaFile("wire/wirenet.lua")
3232
AddCSLuaFile("wire/wiregates.lua")
33+
AddCSLuaFile("wire/fpgagates.lua")
34+
AddCSLuaFile("wire/cpugates.lua")
3335
AddCSLuaFile("wire/wiremonitors.lua")
3436
AddCSLuaFile("wire/gpulib.lua")
3537
AddCSLuaFile("wire/timedpairs.lua")
@@ -63,6 +65,10 @@ if SERVER then
6365
AddCSLuaFile("wire/client/text_editor/texteditor.lua")
6466
AddCSLuaFile("wire/client/text_editor/wire_expression2_editor.lua")
6567

68+
-- node editor
69+
AddCSLuaFile("wire/client/node_editor/nodeeditor.lua")
70+
AddCSLuaFile("wire/client/node_editor/wire_fpga_editor.lua")
71+
6672
for _, filename in ipairs(file.Find("wire/client/text_editor/modes/*.lua","LUA")) do
6773
AddCSLuaFile("wire/client/text_editor/modes/" .. filename)
6874
end
@@ -74,6 +80,8 @@ include("wire/wireshared.lua")
7480
include("wire/wirenet.lua")
7581
include("wire/wire_paths.lua")
7682
include("wire/wiregates.lua")
83+
include("wire/fpgagates.lua")
84+
include("wire/cpugates.lua")
7785
include("wire/wiremonitors.lua")
7886
include("wire/gpulib.lua")
7987
include("wire/timedpairs.lua")
@@ -120,6 +128,8 @@ if CLIENT then
120128
include("wire/client/thrusterlib.lua")
121129
include("wire/client/rendertarget_fix.lua")
122130
include("wire/client/customspawnmenu.lua")
131+
include("wire/client/node_editor/nodeeditor.lua")
132+
include("wire/client/node_editor/wire_fpga_editor.lua")
123133
end
124134

125135
if SERVER then print("Wiremod " .. select(2, WireLib.GetVersion()) .. " loaded") end

0 commit comments

Comments
 (0)