Compare commits
No commits in common. "047c3b8893a78096e5fc79659c6e6fba5e580efa" and "8ec245f36efad3b358a73fcfeb46a3e16d652ae6" have entirely different histories.
047c3b8893
...
8ec245f36e
@ -74,43 +74,3 @@ wire.stub("p", "east", name: "east", vertical: true)
|
||||
wire.stub("p", "south", name: "south", length: 15pt)
|
||||
wire.stub("p", "west", name: "west", length: 3em)
|
||||
```)
|
||||
|
||||
#let gate-and = example(```
|
||||
gates.gate-and(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-and(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
||||
|
||||
#let gate-nand = example(```
|
||||
gates.gate-nand(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-nand(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
||||
|
||||
#let gate-buf = example(```
|
||||
gates.gate-buf(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-buf(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
||||
|
||||
#let gate-not = example(```
|
||||
gates.gate-not(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-not(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
||||
|
||||
#let gate-or = example(```
|
||||
gates.gate-or(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-or(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
||||
|
||||
#let gate-nor = example(```
|
||||
gates.gate-nor(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-nor(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
||||
|
||||
#let gate-xor = example(```
|
||||
gates.gate-xor(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-xor(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
||||
|
||||
#let gate-xnor = example(```
|
||||
gates.gate-xnor(x: 0, y: 0, w: 1.5, h: 1.5)
|
||||
gates.gate-xnor(x: 3, y: 0, w: 1.5, h: 1.5, inverted: "all")
|
||||
```, vertical: true)
|
Binary file not shown.
BIN
manual.pdf
BIN
manual.pdf
Binary file not shown.
65
manual.typ
65
manual.typ
@ -4,7 +4,6 @@
|
||||
#import "doc/examples.typ"
|
||||
#import "src/circuit.typ": circuit
|
||||
#import "src/element.typ"
|
||||
#import "src/gates.typ"
|
||||
#import "src/util.typ"
|
||||
#import "src/wire.typ"
|
||||
|
||||
@ -14,7 +13,7 @@
|
||||
#{
|
||||
outline(indent: true, depth: 3)
|
||||
}
|
||||
|
||||
#set page(numbering: "1/1", header: align(right)[circuiteria #sym.dash.em v#lib.version])
|
||||
#show link: set text(blue)
|
||||
#show heading.where(level: 3): it => context {
|
||||
let cnt = counter(heading)
|
||||
@ -45,44 +44,6 @@
|
||||
]
|
||||
}
|
||||
|
||||
#set page(numbering: "1/1", header: align(right)[circuiteria #sym.dash.em v#lib.version])
|
||||
#set page(
|
||||
header: locate(loc => {
|
||||
let txt = [circuiteria #sym.dash.em v#lib.version]
|
||||
let cnt = counter(heading)
|
||||
let cnt-val = cnt.get()
|
||||
if cnt-val.len() < 2 {
|
||||
align(left, txt)
|
||||
return
|
||||
}
|
||||
let i = cnt-val.at(1) - 1
|
||||
grid(
|
||||
columns: (auto, 1fr),
|
||||
column-gutter: 1em,
|
||||
align: horizon,
|
||||
txt,
|
||||
place(horizon + left)[
|
||||
#rect(width: 100%, height: .5em, radius: .25em, stroke: none, fill: util.colors.values().at(i))
|
||||
]
|
||||
)
|
||||
}),
|
||||
footer: locate(loc => {
|
||||
let cnt = counter(heading)
|
||||
let cnt-val = cnt.get()
|
||||
if cnt-val.len() < 2 { return }
|
||||
let i = cnt-val.at(1) - 1
|
||||
grid(
|
||||
columns: (1fr, auto),
|
||||
column-gutter: 1em,
|
||||
align: horizon,
|
||||
place(horizon + left)[
|
||||
#rect(width: 100%, height: .5em, radius: .25em, stroke: none, fill: util.colors.values().at(i))
|
||||
],
|
||||
counter(page).display("1/1", both: true)
|
||||
)
|
||||
})
|
||||
)
|
||||
|
||||
#let doc-ref(target, full: false, var: false) = {
|
||||
let (module, func) = target.split(".")
|
||||
let label-name = module + func
|
||||
@ -160,6 +121,7 @@ Simply import #link("src/lib.typ") and call the `circuit` function:
|
||||
read("src/elements/extender.typ") + "\n" +
|
||||
read("src/elements/multiplexer.typ"),
|
||||
name: "element",
|
||||
require-all-parameters: true,
|
||||
scope: (
|
||||
element: element,
|
||||
circuit: circuit,
|
||||
@ -173,25 +135,4 @@ Simply import #link("src/lib.typ") and call the `circuit` function:
|
||||
|
||||
#tidy.show-module(element-docs, sort-functions: false)
|
||||
|
||||
#pagebreak()
|
||||
|
||||
#let gates-docs = tidy.parse-module(
|
||||
read("src/elements/logic/gate.typ") + "\n" +
|
||||
read("src/elements/logic/and.typ") + "\n" +
|
||||
read("src/elements/logic/buf.typ") + "\n" +
|
||||
read("src/elements/logic/or.typ") + "\n" +
|
||||
read("src/elements/logic/xor.typ"),
|
||||
name: "gates",
|
||||
scope: (
|
||||
element: element,
|
||||
circuit: circuit,
|
||||
gates: gates,
|
||||
draw: draw,
|
||||
wire: wire,
|
||||
tidy: tidy,
|
||||
examples: examples,
|
||||
doc-ref: doc-ref
|
||||
)
|
||||
)
|
||||
|
||||
#tidy.show-module(gates-docs, sort-functions: false)
|
||||
#(tidy.utilities.get-style-functions(tidy.styles.default).show-reference)(label("wirewire()"), "test")
|
@ -11,3 +11,5 @@
|
||||
#import "elements/logic/or.typ": gate-or, gate-nor
|
||||
#import "elements/logic/xor.typ": gate-xor, gate-xnor
|
||||
#import "elements/logic/buf.typ": gate-buf, gate-not
|
||||
/*
|
||||
*/
|
@ -40,7 +40,16 @@
|
||||
/// Draws an ALU with two inputs
|
||||
///
|
||||
/// #examples.alu
|
||||
/// For parameters description, see #doc-ref("element.elmt")
|
||||
/// - x (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - y (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - w (number): see #doc-ref("element.elmt")
|
||||
/// - h (number): see #doc-ref("element.elmt")
|
||||
/// - name (none, str): see #doc-ref("element.elmt")
|
||||
/// - name-anchor (str): see #doc-ref("element.elmt")
|
||||
/// - fill (none, color): see #doc-ref("element.elmt")
|
||||
/// - stroke (stroke): see #doc-ref("element.elmt")
|
||||
/// - id (str): see #doc-ref("element.elmt")
|
||||
/// - debug (dictionary): see #doc-ref("element.elmt")
|
||||
#let alu(
|
||||
x: none,
|
||||
y: none,
|
||||
|
@ -16,7 +16,18 @@
|
||||
/// Draws a block element
|
||||
///
|
||||
/// #examples.block
|
||||
/// For parameters description, see #doc-ref("element.elmt")
|
||||
/// - x (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - y (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - w (number): see #doc-ref("element.elmt")
|
||||
/// - h (number): see #doc-ref("element.elmt")
|
||||
/// - name (none, str): see #doc-ref("element.elmt")
|
||||
/// - name-anchor (str): see #doc-ref("element.elmt")
|
||||
/// - ports (dictionary): see #doc-ref("element.elmt")
|
||||
/// - ports-margins (dictionary): see #doc-ref("element.elmt")
|
||||
/// - fill (none, color): see #doc-ref("element.elmt")
|
||||
/// - stroke (stroke): see #doc-ref("element.elmt")
|
||||
/// - id (str): see #doc-ref("element.elmt")
|
||||
/// - debug (dictionary): see #doc-ref("element.elmt")
|
||||
#let block(
|
||||
x: none,
|
||||
y: none,
|
||||
|
@ -28,7 +28,16 @@
|
||||
/// Draws a bit extender
|
||||
///
|
||||
/// #examples.extender
|
||||
/// For parameters description, see #doc-ref("element.elmt")
|
||||
/// - x (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - y (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - w (number): see #doc-ref("element.elmt")
|
||||
/// - h (number): see #doc-ref("element.elmt")
|
||||
/// - name (none, str): see #doc-ref("element.elmt")
|
||||
/// - name-anchor (str): see #doc-ref("element.elmt")
|
||||
/// - fill (none, color): see #doc-ref("element.elmt")
|
||||
/// - stroke (stroke): see #doc-ref("element.elmt")
|
||||
/// - id (str): see #doc-ref("element.elmt")
|
||||
/// - debug (dictionary): see #doc-ref("element.elmt")
|
||||
#let extender(
|
||||
x: none,
|
||||
y: none,
|
||||
|
@ -27,10 +27,6 @@
|
||||
return (f, tl, tr, br, bl)
|
||||
}
|
||||
|
||||
/// Draws an AND gate. This function is also available as `element.gate-and()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-and
|
||||
#let gate-and(
|
||||
x: none,
|
||||
y: none,
|
||||
@ -60,10 +56,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
/// Draws an NAND gate. This function is also available as `element.gate-nand()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-nand
|
||||
#let gate-nand(
|
||||
x: none,
|
||||
y: none,
|
||||
@ -87,7 +79,7 @@
|
||||
fill: fill,
|
||||
stroke: stroke,
|
||||
id: id,
|
||||
inverted: if inverted != "all" {inverted + ("out",)} else {inverted},
|
||||
inverted: inverted + ("out",),
|
||||
debug: debug
|
||||
)
|
||||
}
|
@ -24,10 +24,6 @@
|
||||
return (f, tl, tr, br, bl)
|
||||
}
|
||||
|
||||
/// Draws a buffer gate. This function is also available as `element.gate-buf()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-buf
|
||||
#let gate-buf(
|
||||
x: none,
|
||||
y: none,
|
||||
@ -57,10 +53,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
/// Draws a NOT gate. This function is also available as `element.gate-not()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-not
|
||||
#let gate-not(x: none,
|
||||
y: none,
|
||||
w: none,
|
||||
@ -83,7 +75,7 @@
|
||||
fill: fill,
|
||||
stroke: stroke,
|
||||
id: id,
|
||||
inverted: if inverted != "all" {inverted + ("out",)} else {inverted},
|
||||
inverted: inverted + ("out",),
|
||||
debug: debug
|
||||
)
|
||||
}
|
@ -7,21 +7,6 @@
|
||||
return (f, tl, tr, br, bl)
|
||||
}
|
||||
|
||||
|
||||
/// Draws a logic gate. This function is also available as `element.gate()`
|
||||
///
|
||||
/// - draw-shape (function): see #doc-ref("element.elmt")
|
||||
/// - x (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - y (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - w (number): see #doc-ref("element.elmt")
|
||||
/// - h (number): see #doc-ref("element.elmt")
|
||||
/// - inputs (int): The number of inputs
|
||||
/// - fill (none, color): see #doc-ref("element.elmt")
|
||||
/// - stroke (stroke): see #doc-ref("element.elmt")
|
||||
/// - id (str): see #doc-ref("element.elmt")
|
||||
/// - inverted (str, array): Either "all" or an array of port ids to display as inverted
|
||||
/// - inverted-radius (number): The radius of inverted ports dot
|
||||
/// - debug (dictionary): see #doc-ref("element.elmt")
|
||||
#let gate(
|
||||
draw-shape: default-draw-shape,
|
||||
x: none,
|
||||
@ -33,7 +18,6 @@
|
||||
stroke: black + 1pt,
|
||||
id: "",
|
||||
inverted: (),
|
||||
inverted-radius: 0.2,
|
||||
debug: (
|
||||
ports: false
|
||||
)
|
||||
@ -81,11 +65,14 @@
|
||||
// Workaround because CeTZ needs to have all draw functions in the body
|
||||
let func = {}
|
||||
(func, tl, tr, br, bl) = draw-shape(id, tl, tr, br, bl, fill, stroke)
|
||||
func
|
||||
{
|
||||
//draw.rect(tl, br)
|
||||
func
|
||||
}
|
||||
|
||||
let space = 100% / inputs
|
||||
let space = 100% / (inputs + 1)
|
||||
for i in range(inputs) {
|
||||
let pct = (i + 0.5) * space
|
||||
let pct = (i + 1) * space
|
||||
let a = (tl, pct, bl)
|
||||
let b = (tr, pct, br)
|
||||
let int-name = id + "i" + str(i)
|
||||
@ -97,8 +84,8 @@
|
||||
let port-name = "in" + str(i)
|
||||
let port-pos = int-name + ".0"
|
||||
if inverted == "all" or port-name in inverted {
|
||||
draw.circle(port-pos, radius: inverted-radius, anchor: "east", stroke: stroke)
|
||||
port-pos = (rel: (-2 * inverted-radius, 0), to: port-pos)
|
||||
draw.circle(port-pos, radius: .2, anchor: "east", stroke: stroke)
|
||||
port-pos = (rel: (-.4, 0), to: port-pos)
|
||||
}
|
||||
add-port(
|
||||
id, "west",
|
||||
@ -109,8 +96,8 @@
|
||||
|
||||
let out-pos = id + ".east"
|
||||
if inverted == "all" or "out" in inverted {
|
||||
draw.circle(out-pos, radius: inverted-radius, anchor: "west", stroke: stroke)
|
||||
out-pos = (rel: (2 * inverted-radius, 0), to: out-pos)
|
||||
draw.circle(out-pos, radius: .2, anchor: "west", stroke: stroke)
|
||||
out-pos = (rel: (.4, 0), to: out-pos)
|
||||
}
|
||||
add-port(
|
||||
id, "east",
|
||||
@ -118,3 +105,23 @@
|
||||
debug: debug.ports
|
||||
)
|
||||
})
|
||||
/* {
|
||||
let ports = (west: (), east: ((id: "out"),))
|
||||
for i in range(inputs) {
|
||||
ports.west.push((id: "in"+str(i)))
|
||||
}
|
||||
|
||||
element.elmt(
|
||||
draw-shape: draw-shape,
|
||||
x: x,
|
||||
y: y,
|
||||
w: w,
|
||||
h: h,
|
||||
ports: ports,
|
||||
fill: fill,
|
||||
stroke: stroke,
|
||||
id: id,
|
||||
auto-ports: true,
|
||||
debug: debug
|
||||
)
|
||||
}
|
@ -38,10 +38,6 @@
|
||||
return (f, tl, tr, br, bl)
|
||||
}
|
||||
|
||||
/// Draws an OR gate. This function is also available as `element.gate-or()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-or
|
||||
#let gate-or(
|
||||
x: none,
|
||||
y: none,
|
||||
@ -71,10 +67,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
/// Draws a NOR gate. This function is also available as `element.gate-nor()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-nor
|
||||
#let gate-nor(
|
||||
x: none,
|
||||
y: none,
|
||||
@ -98,7 +90,7 @@
|
||||
fill: fill,
|
||||
stroke: stroke,
|
||||
id: id,
|
||||
inverted: if inverted != "all" {inverted + ("out",)} else {inverted},
|
||||
inverted: inverted + ("out",),
|
||||
debug: debug
|
||||
)
|
||||
}
|
@ -45,10 +45,6 @@
|
||||
return (f, tl, tr, br, bl)
|
||||
}
|
||||
|
||||
/// Draws a XOR gate. This function is also available as `element.gate-xor()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-xor
|
||||
#let gate-xor(
|
||||
x: none,
|
||||
y: none,
|
||||
@ -78,10 +74,6 @@
|
||||
)
|
||||
}
|
||||
|
||||
/// Draws a XNOR gate. This function is also available as `element.gate-xnor()`
|
||||
///
|
||||
/// For parameters, see #doc-ref("gates.gate")
|
||||
/// #examples.gate-xnor
|
||||
#let gate-xnor(
|
||||
x: none,
|
||||
y: none,
|
||||
@ -105,7 +97,7 @@
|
||||
fill: fill,
|
||||
stroke: stroke,
|
||||
id: id,
|
||||
inverted: if inverted != "all" {inverted + ("out",)} else {inverted},
|
||||
inverted: inverted + ("out",),
|
||||
debug: debug
|
||||
)
|
||||
}
|
@ -24,8 +24,17 @@
|
||||
/// Draws a multiplexer
|
||||
///
|
||||
/// #examples.multiplexer
|
||||
/// For other parameters description, see #doc-ref("element.elmt")
|
||||
/// - x (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - y (number, dictionary): see #doc-ref("element.elmt")
|
||||
/// - w (number): see #doc-ref("element.elmt")
|
||||
/// - h (number): see #doc-ref("element.elmt")
|
||||
/// - name (none, str): see #doc-ref("element.elmt")
|
||||
/// - name-anchor (str): see #doc-ref("element.elmt")
|
||||
/// - entries (int, array): If it is an integer, it defines the number of input ports (automatically named with their binary index). If it is an array of strings, it defines the name of each input.
|
||||
/// - fill (none, color): see #doc-ref("element.elmt")
|
||||
/// - stroke (stroke): see #doc-ref("element.elmt")
|
||||
/// - id (str): see #doc-ref("element.elmt")
|
||||
/// - debug (dictionary): see #doc-ref("element.elmt")
|
||||
#let multiplexer(
|
||||
x: none,
|
||||
y: none,
|
||||
|
@ -1,5 +0,0 @@
|
||||
#import "elements/logic/gate.typ": gate
|
||||
#import "elements/logic/and.typ": gate-and, gate-nand
|
||||
#import "elements/logic/or.typ": gate-or, gate-nor
|
||||
#import "elements/logic/xor.typ": gate-xor, gate-xnor
|
||||
#import "elements/logic/buf.typ": gate-buf, gate-not
|
@ -2,6 +2,5 @@
|
||||
|
||||
#import "circuit.typ": circuit
|
||||
#import "element.typ"
|
||||
#import "gates.typ"
|
||||
#import "util.typ"
|
||||
#import "wire.typ"
|
Loading…
Reference in New Issue
Block a user