Published
Edited
Apr 26, 2021
2 stars
Insert cell
Insert cell
fir(() => {
const $ = {
A0: input('A0'),
A1: input('A1'),
B0: input('B0'),
B1: input('B1'),
};
$.a0b1 = wire('a0b1', and($.A0, $.B1));
$.a1b0 = wire('a1b0', and($.A1, $.B0));
$.X0 = output('X0', and($.B0, $.A0));
$.X1 = output('X1', xor($.a0b1, $.a1b0));
$.X3 = output('X3', and($.a0b1, $.a1b0));
$.X2 = output('X2', xor($.X3, and($.A1, $.B1)));
return [{
type: 'module', name: 'top',
inputs: [$.A0, $.A1],
body: [$.X1, $.X3, $.X2, $.X0]
}];
})
Insert cell
noder = op => function () {
return {type: op, arguments: [...arguments]};
}
Insert cell
and = noder('and')
Insert cell
xor = noder('xor')
Insert cell
wire = (name, arg) => ({type: 'wire', name, arguments: [arg]})
Insert cell
output = (name, arg) => ({type: 'output', name, arguments: [arg]})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more