Skip to content

jsl/layerstack

Package name: jsl/layerstack

Summary

Data Types

LayerMaterial

Base class for Defining the Layer Material

Constructors

Function Description
LayerMaterial Constructor for defstruct LayerMaterial

Functions

Function Description
get-type
LayerSpec

DielectricMaterial

Functions

Function Description
FR4 Create a Generic FR4 layer
DielectricMaterial
Soldermask Create a Generic Soldermask layer

LayerSpec

Functions

Function Description
get-name
FR4 Create a Generic FR4 layer
add-top Add one or more layers to the top of the board stackup.
make-stack-statement
add-symmetric Symmetrically add another copper layer with dielectric to the stackup
conductors Get the idx-th conductor layer
LayerSpec
Soldermask Create a Generic Soldermask layer
make-layer-stack Construct a LayerStack with a tuple of outer layers.
is-soldermask
get-conductor Retrieve the conductor LayerSpec and the adjacent dielectric layers if any
get Get a layer by index
set-name
add-bottom Add one or more layers to the bottom of the board stackup.
LayerStack
add-soldermask Add a soldermask layer to both sides of the board.
Copper Create a Copper layer

ConductorMaterial

Functions

Function Description
Copper Create a Copper layer
compute-thickness Compute conductor layer thickness in mm from the layer weight (oz / ft^2)
ConductorMaterial

LayerStack

Functions

Function Description
add-top Add one or more layers to the top of the board stackup.
compare-layer Compare Two LayerIndex given a PCB stackup
in-range? Check if a given copper layer is within a range of layers
layer-num Convert a LayerIndex to a Copper Layer Index
add-symmetric Symmetrically add another copper layer with dielectric to the stackup
conductors Get the idx-th conductor layer
make-layer-stack Construct a LayerStack with a tuple of outer layers.
is-valid-copper-layer? Check if a layer id refers to a valid copper layer in this stackup
get-conductor Retrieve the conductor LayerSpec and the adjacent dielectric layers if any
get-conductor-count Get the total number of conductor layers in the layer stack.
create-pcb-stackup
get Get a layer by index
add-bottom Add one or more layers to the bottom of the board stackup.
LayerStack
add-soldermask Add a soldermask layer to both sides of the board.
conductors-by-index Convert the copper layers into a tuple of LayerIndex objects

General Definitions

Variable Description
CopperMaterial
AluminumMaterial
FR4-Material
SoldermaskMaterial

Definitions

LayerMaterial

Base class for Defining the Layer Material

public defstruct LayerMaterial <: Hashable & Equalable :
    description: Maybe<String>
    material-def: Maybe<JITXDef>
    name: Maybe<String>
    type: MaterialType

  • description: Maybe<String>

  • material-def: Maybe<JITXDef>

  • name: Maybe<String>

  • type: MaterialType

Constructors

LayerMaterial

Constructor for defstruct LayerMaterial

public defn LayerMaterial (name:Maybe<String>, type:MaterialType, description:Maybe<String>, material-def:Maybe<JITXDef>)

Functions

get-type

public defn get-type (x:LayerMaterial) -> MaterialType

  • Returns MaterialType

LayerSpec

public defn LayerSpec ( -- name:String = ?, desc:String = ?, material:LayerMaterial, thickness:Double) -> LayerSpec

  • Returns LayerSpec

DielectricMaterial

public defstruct DielectricMaterial <: LayerMaterial :
    dielectric-coefficient: Maybe<Double>
    is-soldermask: True|False
    loss-tangent: Maybe<Double>

  • dielectric-coefficient: Maybe<Double>

  • is-soldermask: True|False

  • loss-tangent: Maybe<Double>

Functions

FR4

Create a Generic FR4 layer

public defn FR4 (thickness:Double, material:DielectricMaterial = ? -- name:String = ?, description:String = ?) -> LayerSpec

  • thickness: Double - thickness of the layer in mm
  • material: DielectricMaterial - material of the layer. The default is the generic FR4-Material definition.
  • name: String - name of the layer - by default this is None() implying no name.
  • description: String - Descriptive text for this layer. By default this is None() implying no description
  • Returns LayerSpec

Usage: FR4(1.0) : specify thickness in mm FR4(1.2, name = "core-1") : specify thickness and name FR4(0.3, Isola370, name = "prepreg") : specify thickness, material and name

DielectricMaterial

public defn DielectricMaterial ( -- name:String = ?, description:String = ?, dielectric-coefficient:Double = ?, roughness:Double = ?, loss-tangent:Double = ?, material-def:JITXDef = ?, is-soldermask:True|False = ?) -> DielectricMaterial

  • Returns DielectricMaterial

Soldermask

Create a Generic Soldermask layer

public defn Soldermask (thickness:Double, material:DielectricMaterial = ? -- name:String = ?, description:String = ?) -> LayerSpec

  • thickness: Double - thickness of the layer in mm
  • material: DielectricMaterial - material of the layer. The default is the generic SoldermaskMaterial definition.
  • name: String - name of the layer - by default this is None() implying no name.
  • description: String - Descriptive text for this layer. By default this is None() implying no description
  • Returns LayerSpec

LayerSpec

public defstruct LayerSpec <: Equalable :
    description: Maybe<String>
    material: LayerMaterial
    name: Maybe<String>
    thickness: Double

  • description: Maybe<String>

  • material: LayerMaterial

  • name: Maybe<String>

  • thickness: Double

Functions

get-name

public defn get-name (x:LayerSpec) -> Maybe<String>

  • Returns Maybe<String>

FR4

Create a Generic FR4 layer

public defn FR4 (thickness:Double, material:DielectricMaterial = ? -- name:String = ?, description:String = ?) -> LayerSpec

  • thickness: Double - thickness of the layer in mm
  • material: DielectricMaterial - material of the layer. The default is the generic FR4-Material definition.
  • name: String - name of the layer - by default this is None() implying no name.
  • description: String - Descriptive text for this layer. By default this is None() implying no description
  • Returns LayerSpec

Usage: FR4(1.0) : specify thickness in mm FR4(1.2, name = "core-1") : specify thickness and name FR4(0.3, Isola370, name = "prepreg") : specify thickness, material and name

add-top

Add one or more layers to the top of the board stackup.

public defn add-top (l-set:LayerSpec|Collection<LayerSpec>, s:LayerStack) -> LayerStack

  • l-set: LayerSpec|Collection<LayerSpec> - layer or set of layers to add to the top of the stack. Note that if this value is a collection, then the layers will be added to the stack one at a time. For example:
add-top( [dielectric, copper], stack)

This will add the dielectric to the top of the stack, and then the copper on top of that. - s: LayerStack - LayerStack we are adding to. - Returns LayerStack - The modified layer stack object

When used on its own, this function is useful for creating asymmetric pcb stackups. This function is most useful when used on a non-empty layer stack.

make-stack-statement

public defn make-stack-statement (x:LayerSpec)

add-symmetric

Symmetrically add another copper layer with dielectric to the stackup

public defn add-symmetric (copper:LayerSpec, dielectric:LayerSpec, s:LayerStack) -> LayerStack

  • copper: LayerSpec - Copper Layer to add to the top and the bottom
  • dielectric: LayerSpec - Dielectric Layer to add to the top and the bottom.
  • s: LayerStack - The LayerStack object
  • Returns LayerStack - The LayerStack object that was passed in.

This function takes the current stackup and adds the dielectric layer on both sides, followed by the copper layer on both sides.

This results in a board that is built up from the center with 2 more dielectric layers, and 2 more copper layers. This constructs a symmetric stackup.

val stack = LayerStack(name = "6-Layer Symmetric Stackup")

val copper-35um = Copper(0.035, name = "cu")
val core-FR4 = FR4(1.0, name = "core")
val prepreg-FR4 = FR4(0.5, name = "prepreg")

add-symmetric(copper-35um, core-FR4,
  add-symmetric(copper-35um, prepreg-FR4,
    add-symmetric(copper-35um, core-FR4, stack)
  )
)

conductors

Get the idx-th conductor layer

public defn conductors (ls:LayerStack) -> Tuple<LayerSpec>

  • Returns Tuple<LayerSpec>

Usage: conductors(stack)[idx]

LayerSpec

public defn LayerSpec ( -- name:String = ?, desc:String = ?, material:LayerMaterial, thickness:Double) -> LayerSpec

  • Returns LayerSpec

Soldermask

Create a Generic Soldermask layer

public defn Soldermask (thickness:Double, material:DielectricMaterial = ? -- name:String = ?, description:String = ?) -> LayerSpec

  • thickness: Double - thickness of the layer in mm
  • material: DielectricMaterial - material of the layer. The default is the generic SoldermaskMaterial definition.
  • name: String - name of the layer - by default this is None() implying no name.
  • description: String - Descriptive text for this layer. By default this is None() implying no description
  • Returns LayerSpec

make-layer-stack

Construct a LayerStack with a tuple of outer layers.

public defn make-layer-stack (name:String, top-layers:Tuple<[LayerSpec, LayerSpec]> -- description:String = ?, soldermask:LayerSpec = ?) -> LayerStack

  • name: String - The name of the LayerStack
  • top-layers: Tuple<[LayerSpec, LayerSpec]> - The pairs of mechanical and dielectric layers, from outer to inner layers.
  • description: String - The description of the LayerStack
  • Returns LayerStack

Example:

  val copper-35um = Copper(0.035)
  val copper-17_5um = Copper(0.0175)
  val jlcpcb-jlc2313 = make-layer-stack("JLCPCB 4-layer 1.6mm", outer-layers,
    soldermask = soldermask) where :
    val soldermask = Soldermask(0.019, SoldermaskMaterial)
    val prepreg-2313 = FR4(0.1, FR4-Material-2313)
    val core-2313 = FR4(1.265, FR4-Material-Core)
    val outer-layers = [
      [copper-35um prepreg-2313]
      [copper-17_5um core-2313]
    ]
The LayerStack created has these layers: [ soldermask copper-35um prepreg-2313 copper-17_5um core-2313 copper-17_5um prepreg-2313 copper-35um soldermask ]

is-soldermask

public defn is-soldermask (l:LayerSpec) -> True|False

  • Returns True|False

get-conductor

Retrieve the conductor LayerSpec and the adjacent dielectric layers if any

public defn get-conductor (ls:LayerStack, index:Int) -> [Maybe<LayerSpec>, LayerSpec, Maybe<LayerSpec>]

  • ls: LayerStack - LayerStack object to interrogate
  • index: Int - Conductor layer to inspect. This is a zero-based index where the top layer is 0, the first inner layer is 1, etc.
  • Returns [Maybe<LayerSpec>, LayerSpec, Maybe<LayerSpec>]

When calculating trace widths, etc it is often useful to know the features of the copper layers those traces will be placed on. This function helps extract the copper layer data as well as the adjacent dielectric layers if any.

get

Get a layer by index

public defn get (ls:LayerStack, idx:Int) -> LayerSpec

  • Returns LayerSpec

Usage: stack[idx]

set-name

public defn set-name (l:LayerSpec, name:String)

add-bottom

Add one or more layers to the bottom of the board stackup.

public defn add-bottom (l-set:LayerSpec|Collection<LayerSpec>, s:LayerStack) -> LayerStack

  • l-set: LayerSpec|Collection<LayerSpec> - layer or set of layers to add to the top of the stack. Note that if this value is a collection, then the layers will be added to the stack one at a time. For example:
add-bottom( [dielectric, copper], stack)

This will add the dielectric to the bottom of the stack, and then the copper after the dielectric. - s: LayerStack - LayerStack we are adding to. - Returns LayerStack - The modified layer stack object

When used on its own, this function is useful for creating asymmetric pcb stackups. This function is most useful when used on a non-empty layer stack.

LayerStack

public defn LayerStack ( -- name:String = ?, description:String = ?, initial-layers:Seqable<LayerSpec> = ?) -> LayerStack

  • Returns LayerStack

add-soldermask

Add a soldermask layer to both sides of the board.

public defn add-soldermask (sm:LayerSpec, s:LayerStack) -> LayerStack

  • Returns LayerStack

Copper

Create a Copper layer

public defn Copper (thickness:Double, material:ConductorMaterial = ? -- name:String = ?, description:String = ?) -> LayerSpec

  • thickness: Double - thickness of the layer in mm
  • material: ConductorMaterial - material of the layer. The default is the generic CopperMaterial definition.
  • name: String - name of the layer - by default this is None() implying no name.
  • description: String - Descriptive text for this layer. By default this is None() implying no description
  • Returns LayerSpec

Usage: Copper(0.3) : specify thickness Copper(0.3, name = "Cu") : specify thickness and name Copper(0.3, CustomCuMaterial, name = "PWR") : specify thickness, material and name

ConductorMaterial

public defstruct ConductorMaterial <: LayerMaterial :
    density: Double
    roughness: Maybe<Double>

  • density: Double - Density of this Conductor material in g / mm^3

  • roughness: Maybe<Double> - Surface roughness in mm RMS.

Functions

Copper

Create a Copper layer

public defn Copper (thickness:Double, material:ConductorMaterial = ? -- name:String = ?, description:String = ?) -> LayerSpec

  • thickness: Double - thickness of the layer in mm
  • material: ConductorMaterial - material of the layer. The default is the generic CopperMaterial definition.
  • name: String - name of the layer - by default this is None() implying no name.
  • description: String - Descriptive text for this layer. By default this is None() implying no description
  • Returns LayerSpec

Usage: Copper(0.3) : specify thickness Copper(0.3, name = "Cu") : specify thickness and name Copper(0.3, CustomCuMaterial, name = "PWR") : specify thickness, material and name

compute-thickness

Compute conductor layer thickness in mm from the layer weight (oz / ft^2)

public defn compute-thickness (x:ConductorMaterial, weight:Double) -> Double

  • x: ConductorMaterial - Conductor Material type
  • weight: Double - expects a value like 0.5, 1.0, 2.0 etc for the weight of the metal layer in oz / ft^2.
  • Returns Double - Layer thickness in mm

ConductorMaterial

public defn ConductorMaterial ( -- name:String = ?, description:String = ?, density:Double, roughness:Double = ?, material-def:JITXDef = ?) -> ConductorMaterial

  • Returns ConductorMaterial

LayerStack

public defstruct LayerStack :
    description: Maybe<String>
    layers: Vector<LayerSpec>
    name: Maybe<String>

  • description: Maybe<String>

  • layers: Vector<LayerSpec>

  • name: Maybe<String>

Functions

add-top

Add one or more layers to the top of the board stackup.

public defn add-top (l-set:LayerSpec|Collection<LayerSpec>, s:LayerStack) -> LayerStack

  • l-set: LayerSpec|Collection<LayerSpec> - layer or set of layers to add to the top of the stack. Note that if this value is a collection, then the layers will be added to the stack one at a time. For example:
add-top( [dielectric, copper], stack)

This will add the dielectric to the top of the stack, and then the copper on top of that. - s: LayerStack - LayerStack we are adding to. - Returns LayerStack - The modified layer stack object

When used on its own, this function is useful for creating asymmetric pcb stackups. This function is most useful when used on a non-empty layer stack.

compare-layer

Compare Two LayerIndex given a PCB stackup

public defn compare-layer (ls:LayerStack, a:LayerIndex, b:LayerIndex) -> Int

  • ls: LayerStack - PCB Stackup Generator - This provides the number of copper layers in the stackup.
  • Returns Int - This function returns zero if the layer indices match This function returns a value < 0 if a is closer to the Top than b This function returns a value > 0 if a is closer to the Bottom than b

in-range?

Check if a given copper layer is within a range of layers

public defn in-range? (ls:LayerStack, a:LayerIndex, start:LayerIndex, end:LayerIndex) -> True|False

  • ls: LayerStack - PCB Stackup Generator - This provides the number of copper layers in the stackup.
  • a: LayerIndex - Copper Layer to compare against the start and end range.
  • start: LayerIndex - Start of the copper layer range.
  • end: LayerIndex - End of the copper layer range.
  • Returns True|False - True if a is on or between start & end. False if outside that range.

This is an inclusive check - so if a == start or a == end - then this check will return True.

layer-num

Convert a LayerIndex to a Copper Layer Index

public defn layer-num (ls:LayerStack, l:LayerIndex|Int) -> Int

  • ls: LayerStack - PCB Stackup Generator - This provides the number of copper layers in the stackup.
  • l: LayerIndex|Int - Which layer in the stackup we are referring to.
  • Returns Int - A zero-indexed value where Top is 0 and Bottom is N-1 where N is the number of layers in the stackup.
  • Throws ValueError - If l is invalid for this stackup - ie, if the layer is outside of the available copper layers of the design.

add-symmetric

Symmetrically add another copper layer with dielectric to the stackup

public defn add-symmetric (copper:LayerSpec, dielectric:LayerSpec, s:LayerStack) -> LayerStack

  • copper: LayerSpec - Copper Layer to add to the top and the bottom
  • dielectric: LayerSpec - Dielectric Layer to add to the top and the bottom.
  • s: LayerStack - The LayerStack object
  • Returns LayerStack - The LayerStack object that was passed in.

This function takes the current stackup and adds the dielectric layer on both sides, followed by the copper layer on both sides.

This results in a board that is built up from the center with 2 more dielectric layers, and 2 more copper layers. This constructs a symmetric stackup.

val stack = LayerStack(name = "6-Layer Symmetric Stackup")

val copper-35um = Copper(0.035, name = "cu")
val core-FR4 = FR4(1.0, name = "core")
val prepreg-FR4 = FR4(0.5, name = "prepreg")

add-symmetric(copper-35um, core-FR4,
  add-symmetric(copper-35um, prepreg-FR4,
    add-symmetric(copper-35um, core-FR4, stack)
  )
)

conductors

Get the idx-th conductor layer

public defn conductors (ls:LayerStack) -> Tuple<LayerSpec>

  • Returns Tuple<LayerSpec>

Usage: conductors(stack)[idx]

make-layer-stack

Construct a LayerStack with a tuple of outer layers.

public defn make-layer-stack (name:String, top-layers:Tuple<[LayerSpec, LayerSpec]> -- description:String = ?, soldermask:LayerSpec = ?) -> LayerStack

  • name: String - The name of the LayerStack
  • top-layers: Tuple<[LayerSpec, LayerSpec]> - The pairs of mechanical and dielectric layers, from outer to inner layers.
  • description: String - The description of the LayerStack
  • Returns LayerStack

Example:

  val copper-35um = Copper(0.035)
  val copper-17_5um = Copper(0.0175)
  val jlcpcb-jlc2313 = make-layer-stack("JLCPCB 4-layer 1.6mm", outer-layers,
    soldermask = soldermask) where :
    val soldermask = Soldermask(0.019, SoldermaskMaterial)
    val prepreg-2313 = FR4(0.1, FR4-Material-2313)
    val core-2313 = FR4(1.265, FR4-Material-Core)
    val outer-layers = [
      [copper-35um prepreg-2313]
      [copper-17_5um core-2313]
    ]
The LayerStack created has these layers: [ soldermask copper-35um prepreg-2313 copper-17_5um core-2313 copper-17_5um prepreg-2313 copper-35um soldermask ]

is-valid-copper-layer?

Check if a layer id refers to a valid copper layer in this stackup

public defn is-valid-copper-layer? (ls:LayerStack, l:Int|LayerIndex) -> True|False

  • ls: LayerStack - PCB Stackup Generator
  • l: Int|LayerIndex - Index into the copper layers. If Int, this is a simple zero-based index starting from the Top layer and working to the Bottom layer.
  • Returns True|False

get-conductor

Retrieve the conductor LayerSpec and the adjacent dielectric layers if any

public defn get-conductor (ls:LayerStack, index:Int) -> [Maybe<LayerSpec>, LayerSpec, Maybe<LayerSpec>]

  • ls: LayerStack - LayerStack object to interrogate
  • index: Int - Conductor layer to inspect. This is a zero-based index where the top layer is 0, the first inner layer is 1, etc.
  • Returns [Maybe<LayerSpec>, LayerSpec, Maybe<LayerSpec>]

When calculating trace widths, etc it is often useful to know the features of the copper layers those traces will be placed on. This function helps extract the copper layer data as well as the adjacent dielectric layers if any.

get-conductor-count

Get the total number of conductor layers in the layer stack.

public defn get-conductor-count (ls:LayerStack) -> Int

  • Returns Int

This is the number of signal and plane layers that are available in this stackup.

create-pcb-stackup

public defn create-pcb-stackup (ls:LayerStack)

get

Get a layer by index

public defn get (ls:LayerStack, idx:Int) -> LayerSpec

  • Returns LayerSpec

Usage: stack[idx]

add-bottom

Add one or more layers to the bottom of the board stackup.

public defn add-bottom (l-set:LayerSpec|Collection<LayerSpec>, s:LayerStack) -> LayerStack

  • l-set: LayerSpec|Collection<LayerSpec> - layer or set of layers to add to the top of the stack. Note that if this value is a collection, then the layers will be added to the stack one at a time. For example:
add-bottom( [dielectric, copper], stack)

This will add the dielectric to the bottom of the stack, and then the copper after the dielectric. - s: LayerStack - LayerStack we are adding to. - Returns LayerStack - The modified layer stack object

When used on its own, this function is useful for creating asymmetric pcb stackups. This function is most useful when used on a non-empty layer stack.

LayerStack

public defn LayerStack ( -- name:String = ?, description:String = ?, initial-layers:Seqable<LayerSpec> = ?) -> LayerStack

  • Returns LayerStack

add-soldermask

Add a soldermask layer to both sides of the board.

public defn add-soldermask (sm:LayerSpec, s:LayerStack) -> LayerStack

  • Returns LayerStack

conductors-by-index

Convert the copper layers into a tuple of LayerIndex objects

public defn conductors-by-index (ls:LayerStack -- omits:Collection<Int|LayerIndex> = ?) -> Tuple<LayerIndex>

  • ls: LayerStack - Layer Stack Generator
  • omits: Collection<Int|LayerIndex> - A collection of copper layers that we don't want to include in the generated output. Any value in this collection that matches a copper layer will cause that LayerIndex to be skipped. An Int value in this list indicates a simple zero-based index into the copper layers starting at Top and going to Bottom
  • Returns Tuple<LayerIndex>

General Definitions

CopperMaterial

public val CopperMaterial

AluminumMaterial

public val AluminumMaterial

FR4-Material

public val FR4-Material

SoldermaskMaterial

public val SoldermaskMaterial