Compare commits
4 Commits
3e9272255c
...
0a108fdc73
Author | SHA1 | Date | |
---|---|---|---|
0a108fdc73 | |||
cd8784fcee | |||
4733f69b51 | |||
33d79f35fa |
Binary file not shown.
@ -2,6 +2,7 @@
|
|||||||
#import "@preview/cetz:0.3.4": draw
|
#import "@preview/cetz:0.3.4": draw
|
||||||
|
|
||||||
#set text(font: "Source Sans 3")
|
#set text(font: "Source Sans 3")
|
||||||
|
#set page(width: auto, height: auto, margin: .5cm)
|
||||||
|
|
||||||
#circuit({
|
#circuit({
|
||||||
element.block(
|
element.block(
|
||||||
@ -37,7 +38,6 @@
|
|||||||
)
|
)
|
||||||
wire.stub("AdrSrc-MP.north", side: "north", name: "AdrSrc")
|
wire.stub("AdrSrc-MP.north", side: "north", name: "AdrSrc")
|
||||||
|
|
||||||
/*
|
|
||||||
element.block(
|
element.block(
|
||||||
pos: (
|
pos: (
|
||||||
6, (align: "A", with: "AdrSrc-MP.out")
|
6, (align: "A", with: "AdrSrc-MP.out")
|
||||||
@ -126,11 +126,12 @@
|
|||||||
bus: true
|
bus: true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
let mid = ("InstDataMgr.east", 50%, "RegFile.west")
|
let mid = ("InstDataMgr.east", 50%, "RegFile.west")
|
||||||
wire.wire(
|
wire.wire(
|
||||||
"InstDataMgr.Instr",
|
"InstDataMgr.Instr",
|
||||||
(vertical: (), horizontal: mid),
|
(vertical: (), horizontal: mid),
|
||||||
id: "wInstDataMgr-Bus"
|
id: "wInstDataMgr-Bus",
|
||||||
name: ("Instr", none),
|
name: ("Instr", none),
|
||||||
bus: true
|
bus: true
|
||||||
)
|
)
|
||||||
@ -143,7 +144,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"RegFile.A1",
|
"RegFile.A1",
|
||||||
(horizontal: mid, vertical: ()),
|
(horizontal: mid, vertical: ()),
|
||||||
id: "wBus-RegFile-A1"
|
id: "wBus-RegFile-A1",
|
||||||
name: (none, "RS1"),
|
name: (none, "RS1"),
|
||||||
slice: (19, 15),
|
slice: (19, 15),
|
||||||
reverse: true,
|
reverse: true,
|
||||||
@ -152,7 +153,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"RegFile.A3",
|
"RegFile.A3",
|
||||||
(horizontal: mid, vertical: ()),
|
(horizontal: mid, vertical: ()),
|
||||||
id: "wBus-RegFile-A3"
|
id: "wBus-RegFile-A3",
|
||||||
name: (none, "RD"),
|
name: (none, "RD"),
|
||||||
slice: (11, 7),
|
slice: (11, 7),
|
||||||
reverse: true,
|
reverse: true,
|
||||||
@ -161,12 +162,12 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"Extender.in",
|
"Extender.in",
|
||||||
(horizontal: mid, vertical: ()),
|
(horizontal: mid, vertical: ()),
|
||||||
id: "wBus-Extender"
|
id: "wBus-Extender",
|
||||||
slice: (31, 7),
|
slice: (31, 7),
|
||||||
reverse: true,
|
reverse: true,
|
||||||
bus: true
|
bus: true
|
||||||
)
|
)
|
||||||
|
|
||||||
element.alu(
|
element.alu(
|
||||||
pos: (
|
pos: (
|
||||||
22, (align: "in1", with: "RegFile.RD1")
|
22, (align: "in1", with: "RegFile.RD1")
|
||||||
@ -178,10 +179,11 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"RegFile.RD1",
|
"RegFile.RD1",
|
||||||
"ALU.in1",
|
"ALU.in1",
|
||||||
id: "wRegFile-ALU"
|
id: "wRegFile-ALU",
|
||||||
name: ("A", "SrcA"),
|
name: ("A", "SrcA"),
|
||||||
bus: true
|
bus: true
|
||||||
)
|
)
|
||||||
|
wire.stub("ALU.north", side: "north")
|
||||||
|
|
||||||
element.block(
|
element.block(
|
||||||
pos: (
|
pos: (
|
||||||
@ -200,7 +202,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"ALU.out",
|
"ALU.out",
|
||||||
"OutBuf.in",
|
"OutBuf.in",
|
||||||
id: "wALU-OutBuf"
|
id: "wALU-OutBuf",
|
||||||
name: "ALUResult",
|
name: "ALUResult",
|
||||||
bus: true
|
bus: true
|
||||||
)
|
)
|
||||||
@ -214,12 +216,12 @@
|
|||||||
fill: util.colors.orange,
|
fill: util.colors.orange,
|
||||||
entries: 3
|
entries: 3
|
||||||
)
|
)
|
||||||
wire.stub("Res-MP.north", name: "ResultSrc")
|
wire.stub("Res-MP.north", side: "north", name: "ResultSrc")
|
||||||
wire.stub("Res-MP.in2")
|
wire.stub("Res-MP.in2")
|
||||||
wire.wire(
|
wire.wire(
|
||||||
"OutBuf.out",
|
"OutBuf.out",
|
||||||
"Res-MP.in0",
|
"Res-MP.in0",
|
||||||
id: "wOutBuf-ResMP"
|
id: "wOutBuf-ResMP",
|
||||||
name: "ALUOut",
|
name: "ALUOut",
|
||||||
bus: true
|
bus: true
|
||||||
)
|
)
|
||||||
@ -227,7 +229,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"Extender.out",
|
"Extender.out",
|
||||||
"ALU.in2",
|
"ALU.in2",
|
||||||
id: "wExt-ALU"
|
id: "wExt-ALU",
|
||||||
name: ("ImmExt", "SrcB"),
|
name: ("ImmExt", "SrcB"),
|
||||||
bus: true,
|
bus: true,
|
||||||
style: "zigzag",
|
style: "zigzag",
|
||||||
@ -237,7 +239,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"InstDataMgr.RD",
|
"InstDataMgr.RD",
|
||||||
"Res-MP.in1",
|
"Res-MP.in1",
|
||||||
id: "wInstDataMgr-ResMP"
|
id: "wInstDataMgr-ResMP",
|
||||||
style: "dodge",
|
style: "dodge",
|
||||||
dodge-y: -4,
|
dodge-y: -4,
|
||||||
dodge-sides: ("east", "west"),
|
dodge-sides: ("east", "west"),
|
||||||
@ -248,7 +250,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"Res-MP.out",
|
"Res-MP.out",
|
||||||
"AdrSrc-MP.in1",
|
"AdrSrc-MP.in1",
|
||||||
id: "wResMP-AdrSrc"
|
id: "wResMP-AdrSrc",
|
||||||
style: "dodge",
|
style: "dodge",
|
||||||
dodge-y: -5,
|
dodge-y: -5,
|
||||||
dodge-sides: ("east", "west"),
|
dodge-sides: ("east", "west"),
|
||||||
@ -259,7 +261,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"Res-MP.out",
|
"Res-MP.out",
|
||||||
"RegFile.WD3",
|
"RegFile.WD3",
|
||||||
id: "wResMP-RegFile"
|
id: "wResMP-RegFile",
|
||||||
style: "dodge",
|
style: "dodge",
|
||||||
dodge-y: -5,
|
dodge-y: -5,
|
||||||
dodge-sides: ("east", "west"),
|
dodge-sides: ("east", "west"),
|
||||||
@ -270,7 +272,7 @@
|
|||||||
wire.wire(
|
wire.wire(
|
||||||
"Res-MP.out",
|
"Res-MP.out",
|
||||||
"PCBuf.PCNext",
|
"PCBuf.PCNext",
|
||||||
id: "wResMP-PCBuf"
|
id: "wResMP-PCBuf",
|
||||||
style: "dodge",
|
style: "dodge",
|
||||||
dodge-y: -5,
|
dodge-y: -5,
|
||||||
dodge-sides: ("east", "west"),
|
dodge-sides: ("east", "west"),
|
||||||
@ -281,5 +283,4 @@
|
|||||||
|
|
||||||
wire.intersection("wResMP-RegFile.dodge-end", radius: .2)
|
wire.intersection("wResMP-RegFile.dodge-end", radius: .2)
|
||||||
wire.intersection("wResMP-AdrSrc.dodge-end", radius: .2)
|
wire.intersection("wResMP-AdrSrc.dodge-end", radius: .2)
|
||||||
*/
|
|
||||||
})
|
})
|
@ -1,45 +1,40 @@
|
|||||||
#import "@preview/cetz:0.3.2": draw
|
#import "@preview/cetz:0.3.2": draw
|
||||||
#import "element.typ"
|
#import "element.typ"
|
||||||
#import "ports.typ": add-port
|
#import "ports.typ": add-port
|
||||||
|
#import "../util.typ"
|
||||||
|
|
||||||
|
#let draw-shape(elmt, bounds) = {
|
||||||
|
let tl = bounds.tl
|
||||||
|
let tr = bounds.tr
|
||||||
|
let bl = bounds.bl
|
||||||
|
let br = bounds.br
|
||||||
|
|
||||||
#let draw-shape(id, tl, tr, br, bl, fill, stroke) = {
|
|
||||||
let p0 = tl
|
let p0 = tl
|
||||||
let p1 = (tr, 10%, br)
|
let p1 = util.lerp(tr, 10%, br)
|
||||||
let p2 = (tr, 90%, br)
|
let p2 = util.lerp(tr, 90%, br)
|
||||||
let p3 = bl
|
let p3 = bl
|
||||||
let p4 = (tl, 55%, bl)
|
let p4 = util.lerp(tl, 55%, bl)
|
||||||
let p5 = (tl, 50%, br)
|
let p5 = util.lerp(tl, 50%, br)
|
||||||
let p6 = (tl, 45%, bl)
|
let p6 = util.lerp(tl, 45%, bl)
|
||||||
|
|
||||||
|
let bounds2 = element.complete-bounds(elmt, (
|
||||||
|
tl: p0,
|
||||||
|
tr: p1,
|
||||||
|
br: p2,
|
||||||
|
bl: p3
|
||||||
|
))
|
||||||
|
|
||||||
let f1 = draw.group(name: id, {
|
|
||||||
|
|
||||||
draw.merge-path(
|
|
||||||
inset: 0.5em,
|
|
||||||
fill: fill,
|
|
||||||
stroke: stroke,
|
|
||||||
close: true,
|
|
||||||
draw.line(p0, p1, p2, p3, p4, p5, p6)
|
|
||||||
)
|
|
||||||
draw.anchor("north", (p0, 50%, p1))
|
|
||||||
draw.anchor("south", (p2, 50%, p3))
|
|
||||||
draw.anchor("west", (p0, 50%, p3))
|
|
||||||
draw.anchor("east", (p1, 50%, p2))
|
|
||||||
draw.anchor("north-west", p0)
|
|
||||||
draw.anchor("north-east", p1)
|
|
||||||
draw.anchor("south-east", p2)
|
|
||||||
draw.anchor("south-west", p3)
|
|
||||||
draw.anchor("name", (p5, 50%, (p1, 50%, p2)))
|
|
||||||
})
|
|
||||||
|
|
||||||
let f2 = add-port(id, "west", (id: "in1"), (p0, 50%, p6))
|
|
||||||
let f3 = add-port(id, "west", (id: "in2"), (p3, 50%, p4))
|
|
||||||
let f4 = add-port(id, "east", (id: "out"), (p1, 50%, p2))
|
|
||||||
|
|
||||||
let f = {
|
let f = {
|
||||||
f1; f2; f3; f4
|
draw.line(
|
||||||
|
p0, p1, p2, p3, p4, p5, p6,
|
||||||
|
fill: elmt.fill,
|
||||||
|
stroke: elmt.stroke,
|
||||||
|
close: true
|
||||||
|
)
|
||||||
|
draw.anchor("name", (p5, 50%, (p1, 50%, p2)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return (f, tl, tr, br, bl)
|
return (f, bounds2)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draws an ALU with two inputs
|
/// Draws an ALU with two inputs
|
||||||
@ -47,18 +42,7 @@
|
|||||||
/// #examples.alu
|
/// #examples.alu
|
||||||
/// For parameters description, see #doc-ref("element.elmt")
|
/// For parameters description, see #doc-ref("element.elmt")
|
||||||
#let alu(
|
#let alu(
|
||||||
x: none,
|
..args
|
||||||
y: none,
|
|
||||||
w: none,
|
|
||||||
h: none,
|
|
||||||
name: none,
|
|
||||||
name-anchor: "center",
|
|
||||||
fill: none,
|
|
||||||
stroke: black + 1pt,
|
|
||||||
id: "",
|
|
||||||
debug: (
|
|
||||||
ports: false
|
|
||||||
)
|
|
||||||
) = {
|
) = {
|
||||||
let ports = (
|
let ports = (
|
||||||
west: (
|
west: (
|
||||||
@ -70,24 +54,18 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
element.elmt(
|
return element.elmt(
|
||||||
draw-shape: draw-shape,
|
draw-shape: draw-shape,
|
||||||
x: x,
|
|
||||||
y: y,
|
|
||||||
w: w,
|
|
||||||
h: h,
|
|
||||||
name: name,
|
|
||||||
name-anchor: name-anchor,
|
|
||||||
ports: ports,
|
ports: ports,
|
||||||
fill: fill,
|
ports-pos: (
|
||||||
stroke: stroke,
|
west: (
|
||||||
id: id,
|
in1: l => l * 0.225,
|
||||||
auto-ports: false,
|
in2: l => l * 0.775,
|
||||||
ports-y: (
|
),
|
||||||
in1: (h) => {h * 0.225},
|
east: (
|
||||||
in2: (h) => {h * 0.775},
|
out: l => l * 0.5
|
||||||
out: (h) => {h * 0.5}
|
)
|
||||||
),
|
),
|
||||||
debug: debug
|
..args
|
||||||
)
|
)
|
||||||
}
|
}
|
@ -10,7 +10,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panic("Could not find port with id '" + str(id) + "'")
|
panic("Could not find port with id '" + str(id) + "' in ports " + repr(ports))
|
||||||
}
|
}
|
||||||
|
|
||||||
#let local-to-global(origin, u, v, points) = {
|
#let local-to-global(origin, u, v, points) = {
|
||||||
@ -157,9 +157,9 @@
|
|||||||
let props2 = props
|
let props2 = props
|
||||||
if side in elmt.ports-margins {
|
if side in elmt.ports-margins {
|
||||||
let (pt0, pt1) = props
|
let (pt0, pt1) = props
|
||||||
let margins = ports-margins.at(side)
|
let margins = elmt.ports-margins.at(side)
|
||||||
a = (pt0, margins.at(0), pt1)
|
let a = util.lerp(pt0, margins.at(0), pt1)
|
||||||
b = (pt0, 100% - margins.at(1), pt1)
|
let b = util.lerp(pt0, 100% - margins.at(1), pt1)
|
||||||
props2 = (a, b)
|
props2 = (a, b)
|
||||||
}
|
}
|
||||||
bounds.ports.insert(side, props2)
|
bounds.ports.insert(side, props2)
|
||||||
@ -209,6 +209,15 @@
|
|||||||
)
|
)
|
||||||
func
|
func
|
||||||
|
|
||||||
|
draw.anchor("north", bounds.t)
|
||||||
|
draw.anchor("south", bounds.b)
|
||||||
|
draw.anchor("west", bounds.l)
|
||||||
|
draw.anchor("east", bounds.r)
|
||||||
|
draw.anchor("north-west", bounds.tl)
|
||||||
|
draw.anchor("north-east", bounds.tr)
|
||||||
|
draw.anchor("south-east", bounds.br)
|
||||||
|
draw.anchor("south-west", bounds.bl)
|
||||||
|
|
||||||
if elmt.name != none {
|
if elmt.name != none {
|
||||||
draw.content(
|
draw.content(
|
||||||
(name: elmt.id, anchor: elmt.name-anchor),
|
(name: elmt.id, anchor: elmt.name-anchor),
|
||||||
@ -219,6 +228,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
add-ports(elmt, bounds)
|
add-ports(elmt, bounds)
|
||||||
|
|
||||||
|
if elmt.debug.bounds {
|
||||||
|
draw.line(
|
||||||
|
bounds.tl, bounds.tr, bounds.br, bounds.bl,
|
||||||
|
stroke: red,
|
||||||
|
close: true
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/// Draws an element
|
/// Draws an element
|
||||||
@ -263,6 +280,7 @@
|
|||||||
id: auto,
|
id: auto,
|
||||||
ports-pos: auto,
|
ports-pos: auto,
|
||||||
debug: (
|
debug: (
|
||||||
|
bounds: false,
|
||||||
ports: false
|
ports: false
|
||||||
),
|
),
|
||||||
extra: (:)
|
extra: (:)
|
||||||
@ -287,7 +305,6 @@
|
|||||||
ports.at(key) = side-ports
|
ports.at(key) = side-ports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ((
|
return ((
|
||||||
cls: cls,
|
cls: cls,
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -1,41 +1,25 @@
|
|||||||
#import "@preview/cetz:0.3.2": draw
|
#import "@preview/cetz:0.3.2": draw
|
||||||
#import "element.typ"
|
#import "element.typ"
|
||||||
#import "ports.typ": add-port
|
#import "ports.typ": add-port
|
||||||
|
#import "../util.typ"
|
||||||
|
|
||||||
#let draw-shape(id, tl, tr, br, bl, fill, stroke, h-ratio: 75%, align-out: true) = {
|
#let draw-shape(elmt, bounds) = {
|
||||||
let (x, y) = bl
|
let ratio = elmt.l-ratio / 100%
|
||||||
let (width, height) = (tr.at(0) - x, tr.at(1) - y)
|
let tl2 = util.lerp(bounds.bl, elmt.l-ratio, bounds.tl)
|
||||||
|
let bounds2 = element.complete-bounds(elmt, (
|
||||||
|
tl: tl2,
|
||||||
|
tr: bounds.tr,
|
||||||
|
br: bounds.br,
|
||||||
|
bl: bounds.bl,
|
||||||
|
))
|
||||||
|
|
||||||
let ratio = h-ratio / 100%
|
let f = draw.line(
|
||||||
|
bounds2.tl, bounds2.tr, bounds2.br, bounds2.bl,
|
||||||
tl = (x, y + height * ratio)
|
fill: elmt.fill,
|
||||||
let tr2 = (x + width, y + height * ratio)
|
stroke: elmt.stroke,
|
||||||
let br = (x + width, y)
|
close: true
|
||||||
|
)
|
||||||
if align-out {
|
return (f, bounds2)
|
||||||
(tr, tr2) = (tr2, tr)
|
|
||||||
} else {
|
|
||||||
(tr, tr2) = (tr, tr)
|
|
||||||
}
|
|
||||||
|
|
||||||
let f = draw.group(name: id, {
|
|
||||||
draw.merge-path(
|
|
||||||
inset: 0.5em,
|
|
||||||
fill: fill,
|
|
||||||
stroke: stroke,
|
|
||||||
close: true,
|
|
||||||
draw.line(tl, tr2, br, bl)
|
|
||||||
)
|
|
||||||
draw.anchor("north", (tl, 50%, tr2))
|
|
||||||
draw.anchor("south", (bl, 50%, br))
|
|
||||||
draw.anchor("west", (tl, 50%, bl))
|
|
||||||
draw.anchor("east", (tr2, 50%, br))
|
|
||||||
draw.anchor("north-west", tl)
|
|
||||||
draw.anchor("north-east", tr2)
|
|
||||||
draw.anchor("south-east", br)
|
|
||||||
draw.anchor("south-west", bl)
|
|
||||||
})
|
|
||||||
return (f, tl, tr, br, bl)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draws a bit extender
|
/// Draws a bit extender
|
||||||
@ -45,54 +29,28 @@
|
|||||||
/// - h-ratio (ratio): The height ratio of the left side relative to the full height
|
/// - h-ratio (ratio): The height ratio of the left side relative to the full height
|
||||||
/// - align-out (bool): If true, the output and input ports are aligned, otherwise, the output port is centered on the right side
|
/// - align-out (bool): If true, the output and input ports are aligned, otherwise, the output port is centered on the right side
|
||||||
#let extender(
|
#let extender(
|
||||||
x: none,
|
l-ratio: 75%,
|
||||||
y: none,
|
|
||||||
w: none,
|
|
||||||
h: none,
|
|
||||||
name: none,
|
|
||||||
name-anchor: "center",
|
|
||||||
fill: none,
|
|
||||||
stroke: black + 1pt,
|
|
||||||
id: "",
|
|
||||||
h-ratio: 75%,
|
|
||||||
align-out: true,
|
align-out: true,
|
||||||
debug: (
|
..args
|
||||||
ports: false
|
|
||||||
)
|
|
||||||
) = {
|
) = {
|
||||||
let ports = (
|
let ports = (
|
||||||
west: (
|
west: ((id: "in"),),
|
||||||
(id: "in"),
|
east: ((id: "out"),)
|
||||||
),
|
|
||||||
east: (
|
|
||||||
(id: "out"),
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
let out-pct = if align-out {h-ratio / 2} else {50%}
|
let out-pct = if align-out {l-ratio / 2} else {50%}
|
||||||
let ports-y = (
|
let ports-pos = (
|
||||||
"in": (h) => {h - h * (h-ratio / 200%)},
|
"east": (l, i) => {l - l * (out-pct / 100%)}
|
||||||
"out": (h) => {h - h * (out-pct / 100%)}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
element.elmt(
|
return element.elmt(
|
||||||
draw-shape: draw-shape.with(h-ratio: h-ratio, align-out: align-out),
|
cls: "extender",
|
||||||
x: x,
|
draw-shape: draw-shape,
|
||||||
y: y,
|
|
||||||
w: w,
|
|
||||||
h: h,
|
|
||||||
name: name,
|
|
||||||
name-anchor: name-anchor,
|
|
||||||
ports: ports,
|
ports: ports,
|
||||||
auto-ports: false,
|
ports-pos: ports-pos,
|
||||||
ports-y: ports-y,
|
extra: (
|
||||||
fill: fill,
|
l-ratio: l-ratio,
|
||||||
stroke: stroke,
|
align-out: align-out
|
||||||
id: id,
|
),
|
||||||
debug: debug
|
..args
|
||||||
)
|
)
|
||||||
|
|
||||||
let in-pos = (rel: (0, h * (h-ratio / 200%)), to: id+".south-west")
|
|
||||||
let out-pos = (id+".south-east", out-pct, id+".north-east")
|
|
||||||
add-port(id, "west", ports.west.first(), in-pos)
|
|
||||||
add-port(id, "east", ports.east.first(), out-pos)
|
|
||||||
}
|
}
|
@ -13,23 +13,12 @@
|
|||||||
tr: tr2,
|
tr: tr2,
|
||||||
br: br2,
|
br: br2,
|
||||||
))
|
))
|
||||||
let f = {
|
let f = draw.line(
|
||||||
draw.merge-path(
|
bounds2.tl, bounds2.tr, bounds2.br, bounds2.bl,
|
||||||
inset: 0.5em,
|
close: true,
|
||||||
fill: elmt.fill,
|
fill: elmt.fill,
|
||||||
stroke: elmt.stroke,
|
stroke: elmt.stroke
|
||||||
close: true,
|
)
|
||||||
draw.line(bounds2.tl, bounds2.tr, bounds2.br, bounds2.bl)
|
|
||||||
)
|
|
||||||
draw.anchor("north", bounds2.t)
|
|
||||||
draw.anchor("south", bounds2.b)
|
|
||||||
draw.anchor("west", bounds2.l)
|
|
||||||
draw.anchor("east", bounds2.r)
|
|
||||||
draw.anchor("north-west", bounds2.tl)
|
|
||||||
draw.anchor("north-east", bounds2.tr)
|
|
||||||
draw.anchor("south-east", bounds2.br)
|
|
||||||
draw.anchor("south-west", bounds2.bl)
|
|
||||||
}
|
|
||||||
|
|
||||||
return (f, bounds2)
|
return (f, bounds2)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
panic("Unknown port " + port + " on element " + elmt.id)
|
panic(
|
||||||
|
"Unknown port '" + port + "' on element '" + elmt.id + "', could not automatically determine side"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#let get-port-idx(elmt, port, side: auto) = {
|
#let get-port-idx(elmt, port, side: auto) = {
|
||||||
@ -125,7 +127,7 @@
|
|||||||
elmt,
|
elmt,
|
||||||
bounds
|
bounds
|
||||||
) = {
|
) = {
|
||||||
let debug = elmt.debug.ports
|
let debug = elmt.debug.at("ports", default: false)
|
||||||
|
|
||||||
if type(elmt.ports) != dictionary {
|
if type(elmt.ports) != dictionary {
|
||||||
return
|
return
|
||||||
@ -142,7 +144,7 @@
|
|||||||
pt0.at(1) - pt1.at(1)
|
pt0.at(1) - pt1.at(1)
|
||||||
}
|
}
|
||||||
for (i, port) in side-ports.enumerate() {
|
for (i, port) in side-ports.enumerate() {
|
||||||
let offset = get-port-pos(elmt, bounds, side, port, i)
|
let offset = get-port-pos(elmt, bounds, side, port.id, i)
|
||||||
|
|
||||||
let pos = (pt0, offset, pt1)
|
let pos = (pt0, offset, pt1)
|
||||||
let offset-prev = if type(offset) == ratio {
|
let offset-prev = if type(offset) == ratio {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user