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

Jsl/make layer stack v2 #79

Closed
wants to merge 6 commits into from
Closed

Jsl/make layer stack v2 #79

wants to merge 6 commits into from

Conversation

lchao-jitx
Copy link
Contributor

@lchao-jitx lchao-jitx commented Jul 12, 2024

  • Revert the last commit for 'Enhance make-layer-stack to handle multiple adjacent prepreg layers'
    and then re-commit it for review.
    • This commit also removes the reference to JLCPCB in the examples/tests for layer-stack so that a generic 4-layer stack is used.
  • Revise verify-layers to handle even number of layers in a stack.

In summary, the make-layer-stack is revised to support these two examples:

    make-layer-stack("4-layer stack with three adjacent prepreg layers", top-layers) where :
      val top-layers =  [
        [copper-35um [prepreg prepreg2 prepreg3]]
        [copper-17_5um core]
      ]

and

    make-layer-stack("6-layer stack with even number of layers", outers, even-layers? = true) where :
      val outers =
        [
          [copper-35um prepreg]
          [copper-17_5um core]
          [copper-17_5um prepreg2] ; => two layers of prepreg2 in the center
        ]

@lchao-jitx lchao-jitx requested review from callendorph and emspin July 12, 2024 17:02
@lchao-jitx
Copy link
Contributor Author

On second thought, maybe a better method to support multiple adjacent prepreg layers is:

    val stack = make-layer-stack("4-layer with two adjacent prepreg layers", top-layers) where :
      val top-layers =  [
        [copper-35um prepreg prepreg]
        [copper-17_5um core]
      ]

rather than what I have in the last commit: 'Enhance make-layer-stack ...'

    val stack = make-layer-stack("4-layer with two adjacent prepreg layers", top-layers) where :
      val top-layers =  [
        [copper-35um prepreg]
        prepreg
        [copper-17_5um core]
      ]

@lchao-jitx lchao-jitx requested a review from bhusang July 12, 2024 17:17
@callendorph
Copy link
Contributor

I would prefer that we consider the following:

    val stack = make-layer-stack("4-layer with two adjacent prepreg layers", top-layers) where :
      val top-layers =  [
        [copper-35um [prepreg prepreg] ]
        [copper-17_5um core]
      ]

Because they we can add a function like:

defn make-multi-ply (m:Material, num-ply:Int ) -> Tuple<Material> : 
  to-tuple $ for i in 0 to num-ply seq:
      m

defn make-double-ply (m:Material) -> Tuple<Material> : 
  make-multi-ply(m, 2)

And this ends up looking more like:

    val prepreg-x2 = make-dual-ply(prepreg)
    val stack = make-layer-stack("4-layer with two adjacent prepreg layers", top-layers) where :
      val top-layers =  [
        [copper-35um prepreg-x2 ]
        [copper-17_5um core]
      ]

This was we can prevent the introduction of touching copper layers by design and we can support multiple pre-preg layers as necessary.

@lchao-jitx
Copy link
Contributor Author

I found that some 6-layer JLCPCB stakcups have an even number of layers, such as "JLC061211-2116", "JLC061211-2116" , "JLC06201H-3313A", "JLC062011-7628", "JLC062011-3313", "JLC062011-1080" etc.
The version in the last commit works for those cases since whenever it is a single LayerSpec, it is added to both the top and the bottom of the stack.
image
For example,

  val test-stack = make-layer-stack("JLC06201H-3313A", outers) where :
  val core = FR4("core", 0.7, "core")
  val prepreg = FR4("2116", 0.1164, "2116*1")
  val prepregA = FR4("3313", 0.0994, "3313*1")
  val outers =
    [
      [copper-35um prepreg]
      [copper-15_2um core]
      copper-15_2um
      prepregA       ; => two layers of prepregA in the center
    ]

@lchao-jitx
Copy link
Contributor Author

lchao-jitx commented Jul 12, 2024

The two adjacent prepreg layers may not be the same though.
Here is an example with three different adjacent prepreg layers:
image
We could support it this way.

protected val stack = make-layer-stack("JLC04161H-2116A", outers) where :
  val core = FR4("core", 0.6, "core")
  val prepreg = FR4("2116", 0.124, "2116*1")
  val prepregA = FR4("7628", 0.218, "7628*1")
  val prepregB = FR4("2116", 0.1164, "2116*1")
  val outers = 
    [ 
      [copper-35um [prepreg prepregA prepregB]]
      [copper-15_2um core]
    ]

@lchao-jitx
Copy link
Contributor Author

lchao-jitx commented Jul 12, 2024

For the case when there are even number of layers (no one center layer), perhaps we can support it this way:

val test-stack = make-layer-stack("JLC06201H-3313A", outers) where :
  val core = FR4("core", 0.7, "core")
  val prepreg = FR4("2116", 0.1164, "2116*1")
  val prepregA = FR4("3313", 0.0994, "3313*1")
  val outers =
    [
      [copper-35um prepreg]
      [copper-15_2um core]
      [copper-15_2um [prepregA]]       ; => two layers of prepregA in the center
    ]

To use [copper-15_2um [prepregA]], rather than [copper-15_2um prepregA].

But then, maybe it is better to just use an optional flag even-layers?, like I used for verify-layers function.
This way it's more explicit for the user.

[Edit] Strike above comment.
I have implemented it with an optional flag even-layers? and committed the code with this change.

@lchao-jitx
Copy link
Contributor Author

The make-layer-stack is revised to support these two examples:

    make-layer-stack("4-layer stack with three adjacent prepreg layers", top-layers) where :
      val top-layers =  [
        [copper-35um [prepreg prepreg2 prepreg3]]
        [copper-17_5um core]
      ]

and

    make-layer-stack("6-layer stack with even number of layers", outers, even-layers? = true) where :
      val outers =
        [
          [copper-35um prepreg]
          [copper-17_5um core]
          [copper-17_5um prepreg2] ; => two layers of prepreg2 in the center
        ]

…], rather than error out. Add test when there are multiple prepreg layers in the middle
]
```

Example 3: 6-layer stack with even number of layers, such as "JLC06201H-3313A"
Copy link
Contributor

Choose a reason for hiding this comment

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

For examples 1, 2, 3 - let's please use the @snippet marker and related @snip-note marker syntax here for the docstrings.

See here for more details:
https://jit-x.slack.com/docs/TKJEB34LS/F05RW135Y0J


Example 3: 6-layer stack with even number of layers, such as "JLC06201H-3313A"
```
make-layer-stack("6-layer stack with even number of layers", outers, even-layers? = true) where :
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would we do this ?
Why would we not just continue using the pattern we have already established?

For example:

     val outers =
        [
          [copper-35um prepreg]
          [copper-17_5um core]
          [copper-17_5um [prepreg2, prepreg2]] ; => two layers of prepreg2 in the center
        ]

I would much prefer this than even-layers? which is difficult to explain and requires additional handling.

add-top(reverse(layers), stack) ; ordered from inner to outer
add-bottom(reverse(layers), stack)
else : ; even-layers? = true
if outer[1] is LayerSpec :
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please use a match statement instead of using if ... is ?

The if ... is is an anti-pattern in stanza and the idiomatic mechanism is the match clause.

Comment on lines +663 to +666
if n-insuls == 1 : ; [copper [dielectric]] => treat it as [copper dielectric]
add-symmetric(metal, insuls[0], stack)
else :
add-symmetric(insuls[n-insuls - 2], insuls[n-insuls - 1], stack)
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't look right. What happens if n-insuls is greater than 3 ?

;Verify input
if outer[1] is Tuple<LayerSpec> and empty?(outer[1] as Tuple<LayerSpec>) :
throw(Exception("Invalid argument: The tuple of dialectric layers is empty. Expect [LayerSpec Tuple<LayerSpec>]. Found %_" % [outer]))
if not even-layers? :
Copy link
Contributor

Choose a reason for hiding this comment

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

The even-layers? parameter here is making this function about 1000x more complicated than this needs to be.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to remove this.

@lchao-jitx
Copy link
Contributor Author

Please see the third version of make-layer-stack in #92 with a much simplified interface and logic.

I have incorporated changes to address the comments in this PR there too.

@lchao-jitx
Copy link
Contributor Author

Dropping this PR since the third version of make-layer-stack in this other PR has a much cleaner interface.

@lchao-jitx lchao-jitx closed this Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants