Add description to constants

This commit is contained in:
prescientmoon 2024-11-27 10:44:23 +01:00
parent 96e2184a24
commit 932490ec18
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -1,7 +1,7 @@
const carryExplanation = (half = true) => `
The carry out is necessary to preserve the bit count
(the maximum sum of 2 n-bit integers ${
half ? '' : 'and a carry'
half ? '' : 'and a carry'
} beeing 1 << (n + 1) - ${half ? 2 : 1})
`
@ -11,40 +11,40 @@ const delay = `
`
export const descriptions: Record<string, string> = {
not: `
not: `
The not gate is one of the most basic logic gates.
It outputs the inverse of the input
`,
and: `
and: `
The and gate outputs true only if both inputs are true.
The and gate is the logic equivalent of f(x, y) = x * y
`,
or: `
or: `
The or gate outputs true if any of the inputs is true.
The or gate is the logic equivalent of f(x, y) = x + y - x * y
`,
nand: `
nand: `
The nand gate only outputs true if none or one of the inputs is true.
The nand gate is the logic equivalent of f(x, y) = 1 - x * y
`,
nor: `
nor: `
The nor gate only outputs true if none of the inputs is true.
The nor gate is the logic equivalent of f(x, y) = 1 + x * y - (x + y)
`,
xor: `
xor: `
The xor gate (also known as the 'exclusive or' gate) only outputs true if one and only one of the inputs is true.
The xor gate is the logic equivalent of f(x, y) = x + y - 2 * x * y
`,
xnor: `
xnor: `
The xnor gate (also known as the 'not exlusive or' gate) only outputs true if none or both the inputs are true.
The xnor gate is the logic equivalent of f(x, y) = 1 - |x - y|
`,
'half adder': `
'half adder': `
The half adder is used to add 2 numbers. It outputs a result and a carry.
${carryExplanation()}
The half adder is the logic equivalent of f(x, y) = { x + y - 2 * x * y, x * y }
`,
'full adder': `
'full adder': `
The full adder is the building block for almos all math related circuit.
The full adder is used to add 2 number and a carry. It outputs a result and a carry.
${carryExplanation(false)}
@ -53,38 +53,41 @@ export const descriptions: Record<string, string> = {
x * y + y * z + z * x - 2 * x * y * z
}
`,
comparator: `
comparator: `
Compares the 2 inputs. The first input is only true if a > b, the second input is
only true if a === b and the 3rd input is only true if a < b.
`,
'parallel delayer': `
'parallel delayer': `
Delays the inputs by a amount of time. ${delay}
`,
'sequential delayer': `
'sequential delayer': `
Delays the input by a certain amount of time relative to the last change. ${delay}
`,
'4 bit encoder': `
'4 bit encoder': `
Encodes the 4 inputs into a single output
`,
'4 bit decoder': `
'4 bit decoder': `
Splits the input into 4 outputs
`,
'bit merger': `
'bit merger': `
Merges the bits of both inputs into 1 output
`,
'bit splitter': `
'bit splitter': `
Splits the bits from the input into 2 chunks of the same length
`,
button: `
button: `
Outputs either 0 or 1. Has no inputs. You can change its value by left clicking on it.
`,
'light bulb': `
'light bulb': `
${output} The color changes based on the input.
`,
'rgb light': `
'rgb light': `
${output} The color is a based on the 3 inputs. The first input means red, the second green and the third blue.
`,
incrementor: `
incrementor: `
Outputs the input + 1
`,
constant: `
Outputs a numeric constant configured (like any other property) by right-clicking the component
`
}