Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support vias in topologies #175

Merged
merged 10 commits into from
Oct 17, 2024
Merged
3 changes: 0 additions & 3 deletions examples/via-structures/diff-via-structure.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,3 @@ set-main-module(top-level)

; View the results
view-board()



1 change: 0 additions & 1 deletion examples/via-structures/se-via-structure.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ defpackage jsl/examples/via-structures/se-via-structures:

import jsl
import jsl/examples/protocols/common/example-board
import jsl/examples/protocols/common/example-components


pcb-module top-level :
Expand Down
81 changes: 62 additions & 19 deletions src/via-structures.stanza
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ defpackage jsl/via-structures:
import jsl/ensure
import jsl/bundles
import jsl/symbols/arrows
import jsl/symbols
import jsl/si

var debug-mode = false
val debug-layer = CustomLayer("vs-debug", Top)
Expand Down Expand Up @@ -425,10 +427,15 @@ defmethod make-via-structure (v:SingleViaStructure -- pose:Pose = DEF_VS_LOC) ->

port COMMON

; Wrapper instance
inst via-pin : topo-via-pin(`p)
place(via-pin) at pose * loc(0.0, 0.0) on Top
geom(via-pin.p) :
via(via-def(v)) at pose * Point(0.0, 0.0)

net cage (COMMON)

net via-net (sig-in, sig-out)
topology-segment(sig-in, sig-out)
topo-net(sig-in => via-pin.p => sig-out)

supports pass-through:
pass-through.A => sig-in
Expand All @@ -437,9 +444,6 @@ defmethod make-via-structure (v:SingleViaStructure -- pose:Pose = DEF_VS_LOC) ->
for cv in ground-cages(v) do:
make-ground-cage(cv, cage, pose = pose)

geom(via-net):
via(via-def(v)) at pose * Point(0.0, 0.0)

make-anti-pads(v, pose = pose)
make-insertion-points(v, pose = pose)

Expand Down Expand Up @@ -549,10 +553,28 @@ defmethod make-via-structure (v:DifferentialViaStructure -- pose:Pose = DEF_VS_L

port COMMON

net via-net-P (sig-in.P, sig-out.P)
topology-segment(sig-in.P, sig-out.P)
net via-net-N (sig-in.N, sig-out.N)
topology-segment(sig-in.N, sig-out.N)
val [via-def-P, via-def-N] = match(via-def(v)):
(obj1:Via): [obj1, obj1]
(obj2:[Via, Via]): obj2
val via-pitch = pitch(v) / 2.0

; First wrapper instance
inst via-pin-P : topo-via-pin(`p)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only concern I have here is the symbol for the diff-pair via structures being two separate schematic symbols in this approach. I think that will make the schematic harder to read. Assuming the user uses the create-via-structure function - then at least these two symbols will be in the same sch group so they will be group together a bit.
I think this is fine for now until we can integrate via structures more directly in the JITX runtime.

place(via-pin-P) at pose * loc(via-pitch, 0.0) on Top
geom(via-pin-P.p) :
via(via-def-P) at pose * Point(via-pitch, 0.0)

; Second wrapper instance
inst via-pin-N : topo-via-pin(`n)
place(via-pin-N) at pose * loc((- via-pitch), 0.0) on Top
geom(via-pin-N.n) :
via(via-def-N) at pose * Point((- via-pitch), 0.0)

; Connect first wrapper instance
topo-net(sig-in.P => via-pin-P.p => sig-out.P)

; Connect second wrapper instance
topo-net(sig-in.N => via-pin-N.n => sig-out.N)

net cage (COMMON)

Expand All @@ -565,20 +587,41 @@ defmethod make-via-structure (v:DifferentialViaStructure -- pose:Pose = DEF_VS_L
for cv in ground-cages(v) do:
make-ground-cage(cv, cage, pose = pose)

val vp = pitch(v) / 2.0
make-anti-pads(v, pose = pose)
make-insertion-points(v, pose = pose)

val [vd-P, vd-N] = match(via-def(v)):
(obj1:Via): [obj1, obj1]
(obj2:[Via, Via]): obj2

geom(via-net-P):
via(vd-P) at pose * Point(vp, 0.0)
; Private topology helpers:
; In order for vias to be used in topologies we need to instantiate phantom pins

defn topo-via-sym (name:Symbol) :
new SymbolDefn :
defmethod name (this) : "Via Pin"
defmethod build-pins (this, sn:SymbolNode) :
add-pin(sn, Ref(name), Point(0.0, 0.0), name = "pin-1")
defmethod build-artwork (this, sn:SymbolNode) :
add-glyph(sn, Circle(-0.5, 0., 0.25))
defmethod build-params (this, sn:SymbolNode) :
false

pcb-pad topo-via-pad :
type = SMD
name = "'Empty' Pad"
shape = EmptyShape()

pcb-landpattern topo-via-landpattern :
pad p : topo-via-pad at loc(0.0, 0.0)

; The wrapper component
public pcb-component topo-via-pin (name:Symbol) :
description = "Wrapper object for injecting via in topology"
reference-prefix = "V"
val p = make-port(name)
val lp = topo-via-landpattern
landpattern = lp(p => lp.p)
assign-symbol(create-symbol(topo-via-sym(name)))

geom(via-net-N):
via(vd-N) at pose * Point((- vp), 0.0)

make-anti-pads(v, pose = pose)
make-insertion-points(v, pose = pose)


doc: \<DOC>
Expand Down