Public
Edited
Jan 19, 2024
2 forks
4 stars
Insert cell
Insert cell
radix2 = grender(g => { // empty circuit provided as an argument

const i32 = {width: 32}; // edge types
const i32r = {width: 32, capacity: 1};

const a = g('a'); // create target socket nodes (a, b)
const b = g('b');

const aEdge = a(i32); // create edges from target sockets (type i32)
const bEdge = b(i32);
const add = g('+'); // create (adder, subtractor) nodes
const sub = g('-');
aEdge(add)(sub); // connect target edges to the operation node
bEdge(add)(sub);
const xEdge = add(i32r); // create edges for the initiator sockets
const yEdge = sub(i32r);
const x = g('x'); // create initiator socket nodes
const y = g('y');
xEdge(x); // connect initiator edges to the initiator sockets
yEdge(y);
})
Insert cell
Insert cell
Insert cell
flip_flop = grender(g => {
const target = g(); // target socket node
const edge = target({width: 8, capacity: 1}); // create edge (flip-flop) from target socket
const initiator = g(); // initiator socket node
edge(initiator); // connect edge to the initiator socket
})
Insert cell
piper = grender(g => {
[0, 1, 2, 3, 4].reduce((res, e) => {
const cur = g();
cur({width: 8, capacity: 1})(res);
return cur;
}, g())
})
Insert cell
Insert cell
grender(g => {
const edges = [0, 1, 2, 3].map(() => g()()); // create target edges
const node = g('+', edges); // create node and link target edges
node()(g()); // create output edge and link to the ctarget node
// set width for all edges
g.edges.map(perEdgeSet(16));
})
Insert cell
grender(g => {
const e1 = g()({width: 512});
[0, 1, 2].map(() => {
const n = g();
const e = n({width: 512, capacity: 1});
e1(n);
[0, 1, 3, 4].map(() => e(g()));
});
})
Insert cell
adder12 = grender(g => {
g('+', [0, 1, 2].map(_ =>
g('+', [0, 1].map(_ =>
g('+', [0, 1].map(_ =>
g()()
))()
))()
))()
(g());
// set width for all edges
// g.edges.map(perEdgeSet(16, 1));
})
Insert cell
chainXor = grender(g => {
[0, 1, 2].reduce(e =>
g('^', [g()(), e])(),
g()()
)(g());
})
Insert cell
deconcat = grender(g => {
const w = (width, capacity) => ({width, capacity});
const deconcat = g('{ }');

g()(w(32))(deconcat);
deconcat(w(4))(g());
deconcat(w(4))(g());
deconcat(w(8))(g());
deconcat(w(16))(g());

return {'{ }': reqack.macros.deconcat};
})
Insert cell
FIReducer = g => (prev, tap, i) => {
const b = g(tap);
if (i == 0) {
prev[0](b);
return [prev[0], b()];
}
const [z, s] = [g(), g('+')];
prev[0](z);
const zl = z({capacity: 1});
zl(b);
b()(s);
prev[1](s);
return [zl, s()];
}
Insert cell
fir = grender(g => {
const taps = [0.09, 0.31, 0.44, 0.31, 0.09];
const [x, y] = 'x y'.split(' ').map(name => g(name));
const xl = x();

taps.reduce(FIReducer(g), [xl, xl])[1](y);
// set width for all edges
g.edges.map(perEdgeSet(16));
// add custom node types
return taps.reduce((res, tap) => {
res[tap] = {data: p => `assign ${p.i[0].wire} = (${p.t[0].wire} * ${(tap * (1 << 14))|0}) >> 14;`}
return res;
}, {});
})
Insert cell
_radix2 = grender(g => {
const [i32, i32r] = [{width: 32}, {width: 32, capacity: 1}];
const [in0, in1, ou0, ou1, add, sub] = 'a b c d + -'.split(' ').map(name => g(name));
in0(i32)(add)(sub);
in1(i32)(add)(sub);
add(i32r)(ou0);
sub(i32r)(ou1);
})
Insert cell
grender(g => {
const edges = [0, 1].map(() => g()({capacity: 1})); // create target edges
const node = g('+', edges); // create node and link target edges
node({capacity: 1.5})(g()); // create output edge and link to the ctarget node
// set width for all edges
g.edges.map(perEdgeSet(32));
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more