From 21b5d1cbfe98ac6bb38b9af62009f5f6aeb93318 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Fri, 17 May 2024 14:18:33 +0200 Subject: [PATCH] fixed multiplexers with named ports + minor changes --- src/circuit.typ | 2 ++ src/elements/alu.typ | 1 - src/elements/block.typ | 1 - src/elements/element.typ | 1 - src/elements/extender.typ | 1 - src/elements/multiplexer.typ | 5 ++++- src/util.typ | 6 +++--- src/wire.typ | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/circuit.typ b/src/circuit.typ index 84fb819..13c0f80 100644 --- a/src/circuit.typ +++ b/src/circuit.typ @@ -3,6 +3,8 @@ /// Draws a block circuit diagram /// +/// This function is also available as `circuiteria.circuit()` +/// /// - body (none, array, element): A code block in which draw functions have been called /// - length (length, ratio): Optional base unit /// -> none diff --git a/src/elements/alu.typ b/src/elements/alu.typ index 5191c83..3954851 100644 --- a/src/elements/alu.typ +++ b/src/elements/alu.typ @@ -48,7 +48,6 @@ stroke: black + 1pt, id: "", debug: ( - grid: false, ports: false ) ) = { diff --git a/src/elements/block.typ b/src/elements/block.typ index 6f1d9ef..27151b7 100644 --- a/src/elements/block.typ +++ b/src/elements/block.typ @@ -26,7 +26,6 @@ stroke: black + 1pt, id: "", debug: ( - grid: false, ports: false ) ) = element.elmt( diff --git a/src/elements/element.typ b/src/elements/element.typ index ee76a3b..98170b3 100644 --- a/src/elements/element.typ +++ b/src/elements/element.typ @@ -32,7 +32,6 @@ auto-ports: true, ports-y: (), debug: ( - grid: false, ports: false ) ) = draw.get-ctx(ctx => { diff --git a/src/elements/extender.typ b/src/elements/extender.typ index 1a7294c..d2e1fc5 100644 --- a/src/elements/extender.typ +++ b/src/elements/extender.typ @@ -36,7 +36,6 @@ stroke: black + 1pt, id: "", debug: ( - grid: false, ports: false ) ) = { diff --git a/src/elements/multiplexer.typ b/src/elements/multiplexer.typ index d2eccb5..0288199 100644 --- a/src/elements/multiplexer.typ +++ b/src/elements/multiplexer.typ @@ -33,7 +33,6 @@ stroke: black + 1pt, id: "", debug: ( - grid: false, ports: false ) ) = { @@ -45,6 +44,10 @@ let bits = util.lpad(str(i, base: 2), nbits) ports.push((id: "in" + str(i), name: bits)) } + } else { + for (i, port) in entries.enumerate() { + ports.push((id: "in" + str(i), name: port)) + } } element.elmt( diff --git a/src/util.typ b/src/util.typ index 62da0f5..ae128d8 100644 --- a/src/util.typ +++ b/src/util.typ @@ -11,11 +11,11 @@ /// /// #example(`#util.lpad("0100", 8)`, mode: "markup") /// -/// - s (str): The string to pad +/// - string (str): The string to pad /// - len (int): The target length /// -> str -#let lpad(s, len) = { - let res = "0" * len + s +#let lpad(string, len) = { + let res = "0" * len + string return res.slice(-len) } diff --git a/src/wire.typ b/src/wire.typ index 3e3ff82..4b7ed9c 100644 --- a/src/wire.typ +++ b/src/wire.typ @@ -118,7 +118,7 @@ /// - style (str): The wire's style (see `wire-styles` for possible values) /// - reverse (bool): If true, the start and end points will be swapped (useful in cases where the start point depends on the end point, for example with perpendiculars) /// - zigzag-ratio (ratio): Position of the zigzag vertical relative to the horizontal span (only with style "zigzag") -/// - dodge-y (int, float, length, ratio): Y position to dodge the wire to (only with style "dodge") +/// - dodge-y (number): Y position to dodge the wire to (only with style "dodge") /// - dodge-sides (array): The start and end sides (going out of the connected element) of the wire (only with style "dodge") /// - dodge-margins (array): The start and end margins (i.e. space before dodging) of the wire (only with style "dodge") #let wire(