Fix comparator pin order
This commit is contained in:
parent
932490ec18
commit
bb1a29a61b
|
@ -5,7 +5,7 @@ const _2i1oColumns = ['Input A', 'Input B', 'Output']
|
|||
const delayerCols = ['Time', 'Input', 'Output']
|
||||
|
||||
const adderData = (half = true) => {
|
||||
return recursiveCombinations([0, 1], half ? 2 : 3).map(combination => {
|
||||
return recursiveCombinations([0, 1], half ? 2 : 3).map((combination) => {
|
||||
const a = combination[0] + combination[1] + (half ? 0 : combination[2])
|
||||
|
||||
return [...combination, Number(a % 2 === 1), Number(a >= 2)]
|
||||
|
@ -13,7 +13,7 @@ const adderData = (half = true) => {
|
|||
}
|
||||
|
||||
const coderData = (encode = true, depth = 4) => {
|
||||
return recursiveCombinations([0, 1], depth).map(combination => {
|
||||
return recursiveCombinations([0, 1], depth).map((combination) => {
|
||||
const final = combination.join('')
|
||||
|
||||
if (encode) {
|
||||
|
@ -33,31 +33,64 @@ export const ioTables: Record<
|
|||
> = {
|
||||
not: {
|
||||
columns: ['Input', 'Output'],
|
||||
data: [[0, 1], [1, 0]]
|
||||
data: [
|
||||
[0, 1],
|
||||
[1, 0]
|
||||
]
|
||||
},
|
||||
and: {
|
||||
columns: _2i1oColumns,
|
||||
data: [[0, 0, 0], [0, 1, 0], [1, 0, 0], [1, 1, 1]]
|
||||
data: [
|
||||
[0, 0, 0],
|
||||
[0, 1, 0],
|
||||
[1, 0, 0],
|
||||
[1, 1, 1]
|
||||
]
|
||||
},
|
||||
or: {
|
||||
columns: _2i1oColumns,
|
||||
data: [[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]]
|
||||
data: [
|
||||
[0, 0, 0],
|
||||
[0, 1, 1],
|
||||
[1, 0, 1],
|
||||
[1, 1, 1]
|
||||
]
|
||||
},
|
||||
nor: {
|
||||
columns: _2i1oColumns,
|
||||
data: [[0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 0]]
|
||||
data: [
|
||||
[0, 0, 1],
|
||||
[0, 1, 0],
|
||||
[1, 0, 0],
|
||||
[1, 1, 0]
|
||||
]
|
||||
},
|
||||
nand: {
|
||||
columns: _2i1oColumns,
|
||||
data: [[0, 0, 1], [0, 1, 1], [1, 0, 1], [1, 1, 0]]
|
||||
data: [
|
||||
[0, 0, 1],
|
||||
[0, 1, 1],
|
||||
[1, 0, 1],
|
||||
[1, 1, 0]
|
||||
]
|
||||
},
|
||||
xor: {
|
||||
columns: _2i1oColumns,
|
||||
data: [[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 0]]
|
||||
data: [
|
||||
[0, 0, 0],
|
||||
[0, 1, 1],
|
||||
[1, 0, 1],
|
||||
[1, 1, 0]
|
||||
]
|
||||
},
|
||||
xnor: {
|
||||
columns: _2i1oColumns,
|
||||
data: [[0, 0, 1], [0, 1, 0], [1, 0, 0], [1, 1, 1]]
|
||||
data: [
|
||||
[0, 0, 1],
|
||||
[0, 1, 0],
|
||||
[1, 0, 0],
|
||||
[1, 1, 1]
|
||||
]
|
||||
},
|
||||
'half adder': {
|
||||
columns: ['x', 'y', 'sum', 'carry out'],
|
||||
|
@ -69,24 +102,30 @@ export const ioTables: Record<
|
|||
},
|
||||
comparator: {
|
||||
columns: ['Input A', `Input B`, `A > b`, `A = b`, `A < B`],
|
||||
data: recursiveCombinations([0, 1], 2).map(combination => {
|
||||
data: recursiveCombinations([0, 1], 2).map((combination) => {
|
||||
const [a, b] = combination
|
||||
|
||||
return [
|
||||
...combination,
|
||||
Number(a > b),
|
||||
Number(a === b),
|
||||
Number(a < b)
|
||||
]
|
||||
return [...combination, Number(a < b), Number(a === b), Number(a > b)]
|
||||
})
|
||||
},
|
||||
'parallel delayer': {
|
||||
columns: delayerCols,
|
||||
data: [[0, 1, 0], [500, 0, 0], [1000, 0, 1], [1500, 0, 0]]
|
||||
data: [
|
||||
[0, 1, 0],
|
||||
[500, 0, 0],
|
||||
[1000, 0, 1],
|
||||
[1500, 0, 0]
|
||||
]
|
||||
},
|
||||
'sequential delayer': {
|
||||
columns: delayerCols,
|
||||
data: [[0, 1, 0], [500, 0, 0], [1000, 0, 1], [1500, 0, 1], [2000, 0, 0]]
|
||||
data: [
|
||||
[0, 1, 0],
|
||||
[500, 0, 0],
|
||||
[1000, 0, 1],
|
||||
[1500, 0, 1],
|
||||
[2000, 0, 0]
|
||||
]
|
||||
},
|
||||
'4 bit encoder': {
|
||||
columns: ['Input A', 'Input B', 'Input C', 'Input D', `Output`],
|
||||
|
@ -106,24 +145,24 @@ export const ioTables: Record<
|
|||
},
|
||||
button: {
|
||||
columns: ['Previous', 'Output'],
|
||||
data: [0, 1].map(x => [x, Number(!x)])
|
||||
data: [0, 1].map((x) => [x, Number(!x)])
|
||||
},
|
||||
'light bulb': {
|
||||
columns: ['Input', 'State'],
|
||||
data: [0, 1].map(x => [x, x ? 'on' : 'off'])
|
||||
data: [0, 1].map((x) => [x, x ? 'on' : 'off'])
|
||||
},
|
||||
'rgb light': {
|
||||
columns: ['Red', 'Green', 'Blue', 'Color'],
|
||||
data: recursiveCombinations([0, 1], 3).map(combination => {
|
||||
data: recursiveCombinations([0, 1], 3).map((combination) => {
|
||||
return [
|
||||
...combination,
|
||||
fromChunks(combination.map(value => (value ? 255 : 0)))
|
||||
fromChunks(combination.map((value) => (value ? 255 : 0)))
|
||||
]
|
||||
})
|
||||
},
|
||||
incrementor: {
|
||||
columns: ['x', 'x + 1'],
|
||||
data: recursiveCombinations([0, 1], 2).map(combination => {
|
||||
data: recursiveCombinations([0, 1], 2).map((combination) => {
|
||||
const input = combination.join('')
|
||||
const output = (parseInt(input, 2) + 1).toString(2)
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ const comparatorTemplate: PartialTemplate = {
|
|||
const a = context.getBinary(0)
|
||||
const b = context.getBinary(1)
|
||||
|
||||
context.setBinary(0, Number(a > b), 1)
|
||||
context.setBinary(0, Number(a < b), 1)
|
||||
context.setBinary(1, Number(a === b), 1)
|
||||
context.setBinary(2, Number(a < b), 1)
|
||||
context.setBinary(2, Number(a > b), 1)
|
||||
`
|
||||
},
|
||||
pins: {
|
||||
|
|
Loading…
Reference in a new issue