forked from HEL/circuiteria
improved doc + moved examples to separate file
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
|
||||
/// Draws a block circuit diagram
|
||||
///
|
||||
/// This function is also available as `circuiteria.circuit()`
|
||||
/// This function is also available at the package root
|
||||
///
|
||||
/// - body (none, array, element): A code block in which draw functions have been called
|
||||
/// - length (length, ratio): Optional base unit
|
||||
|
@ -39,14 +39,7 @@
|
||||
|
||||
/// Draws an ALU with two inputs
|
||||
///
|
||||
/// #box(width: 100%, align(center)[
|
||||
/// #circuit({
|
||||
/// element.alu(x: 0, y: 0, w: 1, h: 2, id: "alu")
|
||||
/// wire.stub("alu-port-in1", "west")
|
||||
/// wire.stub("alu-port-in2", "west")
|
||||
/// wire.stub("alu-port-out", "east")
|
||||
/// })
|
||||
/// ])
|
||||
/// #examples.alu
|
||||
/// - x (number, dictionary): see `elmt()`
|
||||
/// - y (number, dictionary): see `elmt()`
|
||||
/// - w (number): see `elmt()`
|
||||
|
@ -15,37 +15,15 @@
|
||||
|
||||
/// Draws a block element
|
||||
///
|
||||
/// #box(width: 100%, align(center)[
|
||||
/// #circuit({
|
||||
/// element.block(
|
||||
/// x: 0, y: 0,
|
||||
/// w: 2, h: 2,
|
||||
/// id: "block",
|
||||
/// ports: (
|
||||
/// north: ((id: "clk", clock: true),),
|
||||
/// west: (
|
||||
/// (id: "in1", name: "A"),
|
||||
/// (id: "in2", name: "B"),
|
||||
/// ),
|
||||
/// east: (
|
||||
/// (id: "out", name: "C"),
|
||||
/// )
|
||||
/// )
|
||||
/// )
|
||||
/// wire.stub("block-port-clk", "north")
|
||||
/// wire.stub("block-port-in1", "west")
|
||||
/// wire.stub("block-port-in2", "west")
|
||||
/// wire.stub("block-port-out", "east")
|
||||
/// })
|
||||
/// ])
|
||||
/// #examples.block
|
||||
/// - x (number, dictionary): see `elmt()`
|
||||
/// - y (number, dictionary): see `elmt()`
|
||||
/// - w (number): see `elmt()`
|
||||
/// - h (number): see `elmt()`
|
||||
/// - name (none, str): see `elmt()`
|
||||
/// - name-anchor (str): see `elmt()`
|
||||
/// - ports: (dictionary): see `elmt()`
|
||||
/// - ports-margins: (dictionary): see `elmt()`
|
||||
/// - ports (dictionary): see `elmt()`
|
||||
/// - ports-margins (dictionary): see `elmt()`
|
||||
/// - fill (none, color): see `elmt()`
|
||||
/// - stroke (stroke): see `elmt()`
|
||||
/// - id (str): see `elmt()`
|
||||
|
@ -27,17 +27,7 @@
|
||||
|
||||
/// Draws a bit extender
|
||||
///
|
||||
/// #box(width: 100%, align(center)[
|
||||
/// #circuit({
|
||||
/// element.extender(
|
||||
/// x: 0, y: 0,
|
||||
/// w: 3, h: 1,
|
||||
/// id: "extender"
|
||||
/// )
|
||||
/// wire.stub("extender-port-in", "west")
|
||||
/// wire.stub("extender-port-out", "east")
|
||||
/// })
|
||||
/// ])
|
||||
/// #examples.extender
|
||||
/// - x (number, dictionary): see `elmt()`
|
||||
/// - y (number, dictionary): see `elmt()`
|
||||
/// - w (number): see `elmt()`
|
||||
|
@ -23,32 +23,7 @@
|
||||
|
||||
/// Draws a multiplexer
|
||||
///
|
||||
/// #box(width: 100%, align(center)[
|
||||
/// #circuit({
|
||||
/// element.multiplexer(
|
||||
/// x: 0, y: 0,
|
||||
/// w: 1, h: 3,
|
||||
/// id: "multiplexer",
|
||||
/// entries: 3
|
||||
/// )
|
||||
/// wire.stub("multiplexer-port-in0", "west")
|
||||
/// wire.stub("multiplexer-port-in1", "west")
|
||||
/// wire.stub("multiplexer-port-in2", "west")
|
||||
/// wire.stub("multiplexer.north", "north")
|
||||
/// wire.stub("multiplexer-port-out", "east")
|
||||
/// element.multiplexer(
|
||||
/// x: 3, y: 0,
|
||||
/// w: 1, h: 3,
|
||||
/// id: "multiplexer2",
|
||||
/// entries: ("A", "B", "C")
|
||||
/// )
|
||||
/// wire.stub("multiplexer2-port-in0", "west")
|
||||
/// wire.stub("multiplexer2-port-in1", "west")
|
||||
/// wire.stub("multiplexer2-port-in2", "west")
|
||||
/// wire.stub("multiplexer2.south", "south")
|
||||
/// wire.stub("multiplexer2-port-out", "east")
|
||||
/// })
|
||||
/// ])
|
||||
/// #examples.multiplexer
|
||||
/// - x (number, dictionary): see `elmt()`
|
||||
/// - y (number, dictionary): see `elmt()`
|
||||
/// - w (number): see `elmt()`
|
||||
|
25
src/wire.typ
25
src/wire.typ
@ -2,22 +2,7 @@
|
||||
#import "util.typ": opposite-anchor
|
||||
|
||||
/// List of valid wire styles
|
||||
/// #box(width: 100%, align(center)[
|
||||
/// #circuit({
|
||||
/// draw.circle((0, 0), radius: .1, name: "p1")
|
||||
/// draw.circle((2, 1), radius: .1, name: "p2")
|
||||
/// draw.circle((3, 0), radius: .1, name: "p3")
|
||||
/// draw.circle((5, 1), radius: .1, name: "p4")
|
||||
/// draw.circle((6, 0), radius: .1, name: "p5")
|
||||
/// draw.circle((8, 1), radius: .1, name: "p6")
|
||||
/// wire.wire("w1", ("p1", "p2"), style: "direct")
|
||||
/// wire.wire("w2", ("p3", "p4"), style: "zigzag")
|
||||
/// wire.wire("w3", ("p5", "p6"), style: "dodge", dodge-y: -0.5, dodge-margins: (0.5, 0.5))
|
||||
/// draw.content((1, -1), [`direct`])
|
||||
/// draw.content((4, -1), [`zigzag`])
|
||||
/// draw.content((7, -1), [`dodge`])
|
||||
/// })
|
||||
/// ])
|
||||
/// #examples.wires
|
||||
#let wire-styles = ("direct", "zigzag", "dodge")
|
||||
#let signal-width = 1pt
|
||||
#let bus-width = 1.5pt
|
||||
@ -233,13 +218,7 @@
|
||||
|
||||
/// Draws a wire stub (useful for unlinked ports)
|
||||
///
|
||||
/// #box(width: 100%, align(center)[
|
||||
/// #circuit({
|
||||
/// draw.circle((0, 0), radius: .1, name: "p")
|
||||
/// wire.stub("p", "east", name: "port")
|
||||
/// })
|
||||
/// ])
|
||||
///
|
||||
/// #examples.stub
|
||||
/// - port-id (str): The port anchor
|
||||
/// - side (str): The side on which the port is (one of "north", "east", "south", "west")
|
||||
/// - name (none, str): Optional name displayed at the end of the stub
|
||||
|
Reference in New Issue
Block a user