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

Third version of make-layer-stack to use add-symmetric on a tuple of LayerSpec #92

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated after merging in main branch
Liang Chao committed Jul 23, 2024
commit e6237f6e50f08bf439c1458c704699b4b987b9c2
53 changes: 27 additions & 26 deletions src/layerstack.stanza
Original file line number Diff line number Diff line change
@@ -553,11 +553,11 @@ public defn create-pcb-stackup (stack:LayerStack) :
doc:\<DOC>
Construct a LayerStack with a series of outer layers.

@snippet Stackup with Soldermask
@snippet 4-Layer Stackup with Soldermask
```
val copper-35um = Copper(0.035)
val copper-17_5um = Copper(0.0175)
val stack = make-layer-stack("4-Layer Stack with Soldermask", top-layers,
val stack = make-layer-stack("4-Layer Stackup with Soldermask", top-layers,
soldermask = soldermask) where :
val soldermask = Soldermask(0.019, SoldermaskMaterial)
val prepreg = FR4(0.1, FR4-Material)
@@ -570,16 +570,16 @@ doc:\<DOC>
The LayerStack created has these layers:
[ soldermask
copper-35um
prepreg-2313
prepreg
copper-17_5um
core ; single dielectric layer in the center
copper-17_5um
prepreg-2313
prepreg
copper-35um
soldermask
]

@snippet Stackup with Three Dielectric Layers Below the Outer Copper Layer
@snippet 4-Layer Stackup with Three Dielectric Layers Below the Outer Copper Layer
```
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
@@ -607,9 +607,9 @@ doc:\<DOC>
]
```

@snippet Stackup with an Even Number of Layers
@snippet 4-Layer Stackup with an Even Number of Layers
```
make-layer-stack("4-layer stack with an even number of layers", top-layers, even-layers? = true) where :
make-layer-stack("4-layer stackup with an even number of layers", top-layers, even-layers? = true) where :
val top-layers =
[
[copper-35um prepreg]
@@ -632,7 +632,7 @@ doc:\<DOC>
@param name The name of the LayerStack
@param series-of-top-layers A tuple of tuples of LayerSpec's, from outer to inner layers.
@param description (optional) The description of the LayerStack
@param soldermask (optional) The soldermask layer to be added as the outermost layer
@param soldermask (optional) The soldermask layer to be added as the outer-most layer
@param even-layers? (optional) Whether there are an even number of layers. The default is `false`.
@return The created LayerStack object
<DOC>
@@ -644,7 +644,7 @@ public defn make-layer-stack (name:String,
val stack = #LayerStack(One(name), description)
;Access pairs of outer-layers in reverse order
for top-layers in in-reverse(series-of-top-layers) do :
add-symmetric(top-layers, stack, even-layers? = even-layers?)
add-symmetric-layers(top-layers, stack, even-layers? = even-layers?)
;Add soldermask
if value?(soldermask) is LayerSpec :
add-soldermask(value!(soldermask), stack)
@@ -654,15 +654,17 @@ public defn make-layer-stack (name:String,
doc: \<DOC>
Symmetrically add a series of layers to the stack.

Given a stack, this function adds a series of layers, ordered from outer-most to inner most, to the stack on the top side
and on the bottom side to construct a symmetric stackup.
This function takes the current stack and adds a series of layers, from outer-most to inner-most, to the stack on the top side
and to the bottom side.
This constructs a symmetric stackup.

@param top-layers a series of LayerSpec's to add to the top and the bottom, from outer-most to inner-most
@param top-layers a series of LayerSpec's to add to the top and the bottom
@param stack The LayerStack object
@param even-layers? (optional) Whether there are an even number of layers. The default is `false`.
@param

@return The LayerStack object that was passed in.

@snippet Stackup with Three Adjacent Dielectric Layers
@snippet 4-Layer Stackup with Adjacent Dielectric Layers

```stanza
val copper-35um = Copper(0.035)
@@ -671,30 +673,28 @@ and on the bottom side to construct a symmetric stackup.
val prepreg2 = FR4(0.2, FR4-Material)
val prepreg3 = FR4(0.3, FR4-Material)
val core = FR4(1.265, FR4-Material)
val stack = LayerStack(name = "4-layer stack with adjacent dielectric layers")
add-symmetric([copper-35um prepreg prepreg2 prepreg3],
add-symmetric([copper-17_5um core], stack)
val stack = LayerStack(name = "4-layer stackup with adjacent dielectric layers")
add-symmetric-layers([copper-35um prepreg prepreg2 prepreg3],
add-symmetric-layers([copper-17_5um core], stack)
)
```
@snippet 6 Add adjacent dielectric layers below the outer copper layer

@snippet Stackup with an Even Number of Layers
@snippet 6-Layer Stackup with an Even Number of Layers
```
val stack = LayerStack(name = "4-layer stack with an even number of layers")
add-symmetric([copper-35um prepreg],
add-symmetric([copper-17_5um prepreg2], stack, even-layers? = true)
val stack = LayerStack(name = "6-layer stackup with an even number of layers")
add-symmetric-layers([copper-35um prepreg],
add-symmetric-layers([copper-17_5um core],
add-symmetric-layers([copper-17_5um prepreg2], stack, even-layers? = true)
)
)
```
@snippet-note 6 In the center of the stack, the `prepreg2` layer is added to the top and the bottom.

<DOC>
public defn add-symmetric (top-layers:Tuple<LayerSpec>, stack:LayerStack
public defn add-symmetric-layers (top-layers:Tuple<LayerSpec>, stack:LayerStack
-- even-layers?:True|False = false) -> LayerStack :
;Verify input
if length(top-layers) <= 1 :
throw(Exception("Invalid argument: Expect two or more layers in the tuple. Found %_" % [top-layers]))
;Get layers from outermost to innermost layers
;Get layers from outer-most to inner-most layers
val layers-vec = to-vector<LayerSpec> $ top-layers
;Add innermost layer
if length(layers(stack)) == 0 and not even-layers? :
@@ -706,3 +706,4 @@ public defn add-symmetric (top-layers:Tuple<LayerSpec>, stack:LayerStack
add-top(reversed-layers, stack)
add-bottom(reversed-layers, stack)
stack

75 changes: 38 additions & 37 deletions tests/layerstack.stanza
Original file line number Diff line number Diff line change
@@ -140,6 +140,7 @@ My Crazy Stack - each layer is different for testing
10 - copper-105um
;<note>
val test-stack = LayerStack(name = "My Crazy Stack")
val copper-17_5um = Copper(0.0175, name = "cu1")
val copper-35um = Copper(0.035, name = "cu1")
val copper-70um = Copper(0.070, name = "cu2")
val copper-105um = Copper(0.105, name = "cu3")
@@ -208,9 +209,9 @@ doc:\<DOC>
val top-layers = [
soldermask
copper-35um
prepreg-2313
prepreg
copper-17_5um
core-2313
core
]
verify-layers(stack, top-layers)
```
@@ -219,11 +220,11 @@ doc:\<DOC>
[
soldermask
copper-35um
prepreg-2313
prepreg
copper-17_5um
core-2313 ; the middle layer
core ; the middle layer
copper-17_5um
prepreg-2313
prepreg
copper-35um
soldermask
]
@@ -233,7 +234,7 @@ doc:\<DOC>
```
val top-layers = [
copper-35um
prepreg-2313
prepreg
copper-17_5um
core
]
@@ -269,7 +270,7 @@ public defn verify-layers (stack:LayerStack, top-layers:Tuple<LayerSpec>
#EXPECT(stack[total-layers - 1 - idx] == top-layers[idx])

doc:\<DOC>
Verify a typical 4-layers stack used in this package
Verify a typical 4-layers stack used in this test package

@param soldermask? When true, add the soldermask layer
@param add-prepreg-layers When the tuple is not empty, insert the multiple `add-prepreg-layers` right below the outer [copper prepreg] layers
@@ -288,10 +289,9 @@ defn verify-4-layer-stack (stack:LayerStack
[copper-17_5um core]
]
verify-layers(stack, top-layers)
if soldermask? :
#EXPECT(length(conductors(stack)) == length(top-layers) - 1)
else :
#EXPECT(length(conductors(stack)) == length(top-layers))
val n-soldermask = 1 when soldermask? else 0
val n-additional-prepreg-layers = length(add-prepreg-layers)
#EXPECT(length(conductors(stack)) + n-additional-prepreg-layers + n-soldermask == length(top-layers))

;Use the function make-layer-stack to create a LayerStack from a tuple of LayerSpect
deftest(layerstack) make-4-layer-stack-with-soldermask :
@@ -300,8 +300,8 @@ deftest(layerstack) make-4-layer-stack-with-soldermask :
val core = FR4(1.265, FR4-Material)
val stack = make-layer-stack("4-Layer Stack with Soldermask", top-layers, soldermask = soldermask) where :
val top-layers = [
[copper-35um prepreg-2313]
[copper-17_5um core-2313]
[copper-35um prepreg]
[copper-17_5um core]
]
verify-4-layer-stack(stack, soldermask? = true)

@@ -311,14 +311,14 @@ deftest(layerstack) make-4-layer-layer-stack-without-soldermask :
val core = FR4(1.265, FR4-Material)
val stack = make-layer-stack("4-Layer Stack without Soldermask", top-layers) where :
val top-layers = [
[copper-35um prepreg-2313]
[copper-17_5um core-2313]
[copper-35um prepreg]
[copper-17_5um core]
]
verify-4-layer-stack(stack)

; Two adjacent dielectric layers, right below the outer copper layer
; Example: "JLC04161H-7628A"
deftest(layerstack) make-layer-stack-two-dielectric-prepreg-layers-below-outer-copper :
deftest(layerstack) make-4-layer-stack-two-adjacent-dielectric-layers-below-outer-copper :
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
val core = FR4(1.265, FR4-Material)
@@ -331,7 +331,7 @@ deftest(layerstack) make-layer-stack-two-dielectric-prepreg-layers-below-outer-c

; Three adjacent dielectric layers, right below the outer copper layer
; Example: "JLC04161H-7628A"
deftest(layerstack) make-layer-stack-three-adjacent-dielectric-layers-below-outer-copper :
deftest(layerstack) make-4-layer-stack-three-adjacent-dielectric-layers-below-outer-copper :
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
val prepreg3 = FR4(0.3, FR4-Material)
@@ -343,18 +343,32 @@ deftest(layerstack) make-layer-stack-three-adjacent-dielectric-layers-below-oute
]
verify-4-layer-stack(stack, add-prepreg-layers = [prepreg2 prepreg3])

; Three adjacent dielectric layers, right below the outer copper layer
; Example: "JLC04161H-7628A"
deftest(layerstack) test-add-symmetric-layers-with-three-adjacent-dielectric-layers :
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
val prepreg3 = FR4(0.3, FR4-Material)
val core = FR4(1.265, FR4-Material)
val stack = LayerStack(name = "4-layer symmetric stack with three adjacent dielectric layers")
add-symmetric-layers([copper-35um prepreg prepreg2 prepreg3],
add-symmetric-layers([copper-17_5um core], stack)
)
verify-4-layer-stack(stack, add-prepreg-layers = [prepreg2 prepreg3])


; Two adjacent dielectric layers in the middle, , right below the inner copper layer
; Example: JLC06161H-1080B"
deftest(layerstack) make-layer-stack-with-two-adjacent-dielectric-layers-in-center :
deftest(layerstack) make-6-layer-stack-with-two-adjacent-dielectric-layers-below-inner-copper :
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
val prepreg3 = FR4(0.3, FR4-Material)
val core = FR4(1.265, FR4-Material)
val stack = make-layer-stack("6-layer stack with two adjacent dielectric layers in the center", top-layers) where :
val stack = make-layer-stack("6-layer stack with two adjacent dielectric layers in the middle", top-layers) where :
val top-layers = [
[copper-35um prepreg]
[copper-17_5um core]
[copper-17_5um prepreg2 prepreg3] ; => The center of the stack has [copper-17_5um prepreg2 prepreg3 prepreg2 copper-17_5um]
[copper-17_5um prepreg2 prepreg3]
]
verify-layers(stack, top-layers) where :
val top-layers = [
@@ -364,7 +378,7 @@ deftest(layerstack) make-layer-stack-with-two-adjacent-dielectric-layers-in-cent

; Even number of layers
; Example: "JLC06201H-3313A"
deftest(layerstack) make-layer-stack-with-even-number-of-layers :
deftest(layerstack) make-6-layer-stack-with-even-number-of-layers :
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
val core = FR4(1.265, FR4-Material)
@@ -383,27 +397,14 @@ deftest(layerstack) make-layer-stack-with-even-number-of-layers :
copper-17_5um core
copper-17_5um prepreg2]

; Three adjacent dielectric layers, right below the outer copper layer
; Example: "JLC04161H-7628A"
deftest(layerstack) test-add-symmetric-layers-with-three-adjacent-dielectric-layers-below-outer-copper :
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
val prepreg3 = FR4(0.3, FR4-Material)
val core = FR4(1.265, FR4-Material)
val stack = LayerStack(name = "4-layer symmetric stack with three adjacent dielectric layers")
add-symmetric([copper-35um prepreg prepreg2 prepreg3],
add-symmetric([copper-17_5um core], stack)
)
verify-4-layer-stack(stack, add-prepreg-layers = [prepreg2 prepreg3])

deftest(layerstack) test-add-symmetric-layers-with-even-number-of-layers :
val prepreg = FR4(0.1, FR4-Material)
val prepreg2 = FR4(0.2, FR4-Material)
val core = FR4(1.265, FR4-Material)
val stack = LayerStack(name = "6-layer stack with even number of layers")
add-symmetric([copper-35um prepreg],
add-symmetric([copper-17_5um core],
add-symmetric([copper-17_5um prepreg2], stack, even-layers? = true) ; => The center of the stack has [copper-17_5um prepreg2 prepreg2 copper-17_5um]
add-symmetric-layers([copper-35um prepreg],
add-symmetric-layers([copper-17_5um core],
add-symmetric-layers([copper-17_5um prepreg2], stack, even-layers? = true)
)
)
;Verify the layer stack with even number of layers