2019-06-23 11:20:22 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Jean-Pierre Charras, jp.charras at wanadoo.fr
|
2021-04-16 21:07:06 +00:00
|
|
|
* Copyright (C) 2009-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-06-23 11:20:22 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 3
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2021-04-16 21:07:06 +00:00
|
|
|
* @file board_stackup.h
|
2019-06-23 11:20:22 +00:00
|
|
|
*/
|
|
|
|
|
2021-04-16 21:07:06 +00:00
|
|
|
#ifndef BOARD_STACKUP_H
|
|
|
|
#define BOARD_STACKUP_H
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <wx/string.h>
|
2021-07-29 09:47:43 +00:00
|
|
|
#include <layer_ids.h>
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
class BOARD;
|
2019-06-23 11:20:22 +00:00
|
|
|
class BOARD_DESIGN_SETTINGS;
|
|
|
|
class OUTPUTFORMATTER;
|
|
|
|
|
|
|
|
// A enum to manage the different layers inside the stackup layers.
|
|
|
|
// Note the stackup layers include both dielectric and some layers handled by the board editor
|
2020-09-22 21:50:59 +00:00
|
|
|
// Therefore a stackup layer item is not exactly like a board layer
|
2019-06-23 11:20:22 +00:00
|
|
|
enum BOARD_STACKUP_ITEM_TYPE
|
|
|
|
{
|
|
|
|
BS_ITEM_TYPE_UNDEFINED, // For not yet initialized BOARD_STACKUP_ITEM item
|
|
|
|
BS_ITEM_TYPE_COPPER, // A initialized BOARD_STACKUP_ITEM item for copper layers
|
|
|
|
BS_ITEM_TYPE_DIELECTRIC, // A initialized BOARD_STACKUP_ITEM item for the
|
|
|
|
// dielectric between copper layers
|
|
|
|
BS_ITEM_TYPE_SOLDERPASTE, // A initialized BOARD_STACKUP_ITEM item for solder paste layers
|
|
|
|
BS_ITEM_TYPE_SOLDERMASK, // A initialized BOARD_STACKUP_ITEM item for solder mask layers
|
2019-09-24 12:33:28 +00:00
|
|
|
// note: this is a specialized dielectric material
|
2019-06-23 11:20:22 +00:00
|
|
|
BS_ITEM_TYPE_SILKSCREEN, // A initialized BOARD_STACKUP_ITEM item for silkscreen layers
|
|
|
|
};
|
|
|
|
|
|
|
|
// A enum to manage edge connector fab info
|
|
|
|
enum BS_EDGE_CONNECTOR_CONSTRAINTS
|
|
|
|
{
|
|
|
|
BS_EDGE_CONNECTOR_NONE, // No edge connector in board
|
|
|
|
BS_EDGE_CONNECTOR_IN_USE, // some edge connector in board
|
2020-09-22 21:50:59 +00:00
|
|
|
BS_EDGE_CONNECTOR_BEVELLED // Some connector in board, and the connector must be beveled
|
2019-06-23 11:20:22 +00:00
|
|
|
};
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
/**
|
2019-11-14 15:26:05 +00:00
|
|
|
* A helper class to manage a dielectric layer set of parameters
|
2019-11-11 18:34:48 +00:00
|
|
|
*/
|
|
|
|
class DIELECTRIC_PRMS
|
|
|
|
{
|
2021-04-16 21:07:06 +00:00
|
|
|
public:
|
|
|
|
DIELECTRIC_PRMS() :
|
|
|
|
m_Thickness(0), m_ThicknessLocked( false ),
|
|
|
|
m_EpsilonR( 1.0 ), m_LossTangent( 0.0 )
|
|
|
|
{}
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
private:
|
2021-04-16 21:07:06 +00:00
|
|
|
friend class BOARD_STACKUP_ITEM;
|
|
|
|
|
2019-11-11 18:34:48 +00:00
|
|
|
wxString m_Material; /// type of material (for dielectric and solder mask)
|
|
|
|
int m_Thickness; /// the physical layer thickness in internal units
|
|
|
|
bool m_ThicknessLocked; /// true for dielectric layers with a fixed thickness
|
2020-09-22 21:50:59 +00:00
|
|
|
/// (for impedance controlled purposes), unused for other layers
|
2019-11-11 18:34:48 +00:00
|
|
|
double m_EpsilonR; /// For dielectric (and solder mask) the dielectric constant
|
|
|
|
double m_LossTangent; /// For dielectric (and solder mask) the dielectric loss
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-06-23 11:20:22 +00:00
|
|
|
/**
|
2021-04-16 21:07:06 +00:00
|
|
|
* Manage one layer needed to make a physical board.
|
|
|
|
*
|
|
|
|
* It can be a solder mask, silk screen, copper or a dielectric.
|
2019-06-23 11:20:22 +00:00
|
|
|
*/
|
|
|
|
class BOARD_STACKUP_ITEM
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BOARD_STACKUP_ITEM( BOARD_STACKUP_ITEM_TYPE aType );
|
2020-11-18 19:50:36 +00:00
|
|
|
BOARD_STACKUP_ITEM( const BOARD_STACKUP_ITEM& aOther );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
/**
|
2021-04-16 21:07:06 +00:00
|
|
|
* Add (insert) a DIELECTRIC_PRMS item to m_DielectricPrmsList
|
2019-11-14 15:26:05 +00:00
|
|
|
* all values are set to default
|
|
|
|
* @param aDielectricPrmsIdx is a index in m_DielectricPrmsList
|
|
|
|
* the new item will be inserted at this position
|
|
|
|
*/
|
|
|
|
void AddDielectricPrms( int aDielectricPrmsIdx );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove a DIELECTRIC_PRMS item from m_DielectricPrmsList
|
|
|
|
* @param aDielectricPrmsIdx is the index of the parameters set
|
|
|
|
* to remove in m_DielectricPrmsList
|
|
|
|
*/
|
|
|
|
void RemoveDielectricPrms( int aDielectricPrmsIdx );
|
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
/// @return true if the layer has a meaningful Epsilon R parameter
|
2019-06-23 11:20:22 +00:00
|
|
|
/// namely dielectric layers: dielectric and solder mask
|
2019-11-14 15:26:05 +00:00
|
|
|
bool HasEpsilonRValue() const;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2020-09-22 21:50:59 +00:00
|
|
|
/// @return true if the layer has a meaningfully Dielectric Loss parameter
|
2019-06-23 11:20:22 +00:00
|
|
|
/// namely dielectric layers: dielectric and solder mask
|
2019-11-14 15:26:05 +00:00
|
|
|
bool HasLossTangentValue() const;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
2019-09-24 12:33:28 +00:00
|
|
|
/// @return true if the material is specified
|
2019-11-14 15:26:05 +00:00
|
|
|
bool HasMaterialValue( int aDielectricSubLayer = 0 ) const;
|
2019-09-24 12:33:28 +00:00
|
|
|
|
2019-06-23 11:20:22 +00:00
|
|
|
/// @return true if the material is editable
|
2019-11-14 15:26:05 +00:00
|
|
|
bool IsMaterialEditable() const;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
/// @return true if the color is editable
|
2019-11-14 15:26:05 +00:00
|
|
|
bool IsColorEditable() const;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
/// @return true if Thickness is editable
|
2019-11-14 15:26:05 +00:00
|
|
|
bool IsThicknessEditable() const;
|
2019-07-27 19:09:43 +00:00
|
|
|
|
|
|
|
/// @return a reasonable default value for a copper layer thickness
|
|
|
|
static int GetCopperDefaultThickness();
|
|
|
|
|
|
|
|
/// @return a reasonable default value for a solder mask layer thickness
|
|
|
|
static int GetMaskDefaultThickness();
|
2019-09-09 14:45:21 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
/// @return a the number of sublayers in a dielectric layer.
|
|
|
|
/// the count is >= 1 (there is at least one layer)
|
|
|
|
int GetSublayersCount() const { return m_DielectricPrmsList.size(); }
|
|
|
|
|
2019-09-09 14:45:21 +00:00
|
|
|
/// @return a wxString to print/display Epsilon R
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString FormatEpsilonR( int aDielectricSubLayer = 0 ) const;
|
2019-09-09 14:45:21 +00:00
|
|
|
|
|
|
|
/// @return a wxString to print/display Loss Tangent
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString FormatLossTangent( int aDielectricSubLayer = 0 ) const;
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
/// @return a wxString to print/display a dielectric name
|
2019-11-14 15:26:05 +00:00
|
|
|
wxString FormatDielectricLayerName() const;
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
// Getters:
|
2020-12-20 18:50:45 +00:00
|
|
|
bool IsEnabled() const { return m_enabled; }
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
BOARD_STACKUP_ITEM_TYPE GetType() const { return m_Type; }
|
|
|
|
PCB_LAYER_ID GetBrdLayerId() const { return m_LayerId; }
|
|
|
|
wxString GetColor() const { return m_Color; }
|
|
|
|
wxString GetLayerName() const { return m_LayerName; }
|
|
|
|
wxString GetTypeName() const { return m_TypeName; }
|
|
|
|
int GetDielectricLayerId() const { return m_DielectricLayerId; }
|
2019-11-11 18:34:48 +00:00
|
|
|
|
2019-11-14 15:26:05 +00:00
|
|
|
int GetThickness( int aDielectricSubLayer = 0 ) const;
|
|
|
|
bool IsThicknessLocked( int aDielectricSubLayer = 0 ) const;
|
|
|
|
double GetEpsilonR( int aDielectricSubLayer = 0 ) const;
|
|
|
|
double GetLossTangent( int aDielectricSubLayer = 0 ) const;
|
|
|
|
wxString GetMaterial( int aDielectricSubLayer = 0 ) const;
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
// Setters:
|
|
|
|
void SetEnabled( bool aEnable) { m_enabled = aEnable; }
|
|
|
|
void SetBrdLayerId( PCB_LAYER_ID aBrdLayerId ) { m_LayerId = aBrdLayerId; }
|
|
|
|
void SetColor( const wxString& aColorName ){ m_Color = aColorName; }
|
|
|
|
void SetLayerName( const wxString& aName ) { m_LayerName = aName; }
|
|
|
|
void SetTypeName( const wxString& aName ) { m_TypeName = aName; }
|
2019-11-14 15:26:05 +00:00
|
|
|
void SetDielectricLayerId( int aLayerId ) { m_DielectricLayerId = aLayerId; }
|
2019-11-11 18:34:48 +00:00
|
|
|
|
|
|
|
void SetThickness( int aThickness, int aDielectricSubLayer = 0 );
|
|
|
|
void SetThicknessLocked( bool aLocked, int aDielectricSubLayer = 0 );
|
|
|
|
void SetEpsilonR( double aEpsilon, int aDielectricSubLayer = 0 );
|
|
|
|
void SetLossTangent( double aTg, int aDielectricSubLayer = 0 );
|
|
|
|
void SetMaterial( const wxString& aName, int aDielectricSubLayer = 0 );
|
2021-04-16 21:07:06 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
BOARD_STACKUP_ITEM_TYPE m_Type;
|
|
|
|
wxString m_LayerName; /// name of layer as shown in layer manager. Useful to create reports
|
|
|
|
wxString m_TypeName; /// type name of layer (copper, silk screen, core, prepreg ...)
|
|
|
|
wxString m_Color; /// mainly for silkscreen and solder mask
|
|
|
|
PCB_LAYER_ID m_LayerId; /// the layer id (F.Cu to B.Cu, F.Silk, B.silk, F.Mask, B.Mask)
|
|
|
|
/// and UNDEFINED_LAYER (-1) for dielectric layers that are not
|
|
|
|
/// really layers for the board editor
|
|
|
|
int m_DielectricLayerId;/// the "layer" id for dielectric layers,
|
|
|
|
/// from 1 (top) to 31 (bottom)
|
|
|
|
/// (only 31 dielectric layers for 32 copper layers)
|
|
|
|
/// List of dielectric parameters
|
|
|
|
/// usually only one item, but in complex (microwave) boards, one can have
|
|
|
|
/// more than one dielectric layer between 2 copper layers, and therefore
|
|
|
|
/// more than one item in list
|
|
|
|
std::vector<DIELECTRIC_PRMS> m_DielectricPrmsList;
|
|
|
|
|
|
|
|
bool m_enabled; /// true if this stackup item must be taken in account,
|
|
|
|
/// false to ignore it. Mainly used in dialog stackup editor.
|
2019-06-23 11:20:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2021-04-16 21:07:06 +00:00
|
|
|
* Manage layers needed to make a physical board.
|
|
|
|
*
|
|
|
|
* They are solder mask, silk screen, copper and dielectric. Some other layers, used in
|
|
|
|
* fabrication, are not managed here because they are not used to make a physical board itself.
|
|
|
|
*
|
|
|
|
* @note There are a few other parameters related to the physical stackup like finish type,
|
|
|
|
* impedance control and a few others.
|
2019-06-23 11:20:22 +00:00
|
|
|
*/
|
|
|
|
class BOARD_STACKUP
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
BOARD_STACKUP();
|
2020-11-18 19:50:36 +00:00
|
|
|
BOARD_STACKUP( const BOARD_STACKUP& aOther );
|
2019-06-23 11:20:22 +00:00
|
|
|
BOARD_STACKUP& operator=( const BOARD_STACKUP& aOther );
|
|
|
|
|
|
|
|
~BOARD_STACKUP() { RemoveAll(); }
|
|
|
|
|
2020-11-04 02:49:19 +00:00
|
|
|
const std::vector<BOARD_STACKUP_ITEM*>& GetList() const { return m_list; }
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
/// @return a reference to the layer aIndex, or nullptr if not exists
|
|
|
|
BOARD_STACKUP_ITEM* GetStackupLayer( int aIndex );
|
|
|
|
|
2021-04-16 21:07:06 +00:00
|
|
|
/**
|
|
|
|
* @return the board layers full mask allowed in the stackup list
|
2019-07-27 19:09:43 +00:00
|
|
|
* i.e. the SilkS, Mask, Paste and all copper layers
|
|
|
|
*/
|
|
|
|
static LSET StackupAllowedBrdLayers()
|
|
|
|
{
|
|
|
|
return LSET( 6, F_SilkS, F_Mask, F_Paste, B_SilkS, B_Mask, B_Paste )
|
|
|
|
| LSET::ExternalCuMask() | LSET::InternalCuMask();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-06-23 11:20:22 +00:00
|
|
|
/// Delete all items in list and clear the list
|
|
|
|
void RemoveAll();
|
|
|
|
|
|
|
|
/// @return the number of layers in the stackup
|
2020-11-18 19:50:36 +00:00
|
|
|
int GetCount() const { return (int) m_list.size(); }
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
/// @return the board thickness ( in UI) from the thickness of BOARD_STACKUP_ITEM list
|
2021-02-11 19:25:49 +00:00
|
|
|
int BuildBoardThicknessFromStackup() const;
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
/// Add a new item in stackup layer
|
|
|
|
void Add( BOARD_STACKUP_ITEM* aItem ) { m_list.push_back( aItem ); }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Synchronize the BOARD_STACKUP_ITEM* list with the board.
|
|
|
|
* Not enabled layers are removed
|
|
|
|
* Missing layers are added
|
|
|
|
* @param aSettings, is the current board setting.
|
|
|
|
* @return true if changes are made
|
|
|
|
*/
|
|
|
|
bool SynchronizeWithBoard( BOARD_DESIGN_SETTINGS* aSettings );
|
|
|
|
|
|
|
|
/**
|
2021-04-16 21:07:06 +00:00
|
|
|
* Create a default stackup, according to the current BOARD_DESIGN_SETTINGS settings.
|
2019-06-23 11:20:22 +00:00
|
|
|
* @param aSettings is the current board setting.
|
2019-07-27 19:09:43 +00:00
|
|
|
* if nullptr, build a full stackup (with 32 copper layers)
|
|
|
|
* @param aActiveCopperLayersCount is used only if aSettings == nullptr is the number
|
|
|
|
* of copper layers to use to calculate a default dielectric thickness.
|
|
|
|
* ((<= 0 to use all copper layers)
|
2019-06-23 11:20:22 +00:00
|
|
|
*/
|
2020-12-20 18:44:13 +00:00
|
|
|
void BuildDefaultStackupList( const BOARD_DESIGN_SETTINGS* aSettings,
|
2020-09-22 21:50:59 +00:00
|
|
|
int aActiveCopperLayersCount = 0 );
|
2019-06-23 11:20:22 +00:00
|
|
|
|
|
|
|
/**
|
2021-04-16 21:07:06 +00:00
|
|
|
* Write the stackup info on board file
|
2019-06-23 11:20:22 +00:00
|
|
|
* @param aFormatter is the OUTPUTFORMATTER used to create the file
|
|
|
|
* @param aBoard is the board
|
|
|
|
* @param aNestLevel is the index to nest level to indent the lines in file
|
|
|
|
*/
|
|
|
|
void FormatBoardStackup( OUTPUTFORMATTER* aFormatter,
|
2020-12-20 18:44:13 +00:00
|
|
|
const BOARD* aBoard, int aNestLevel ) const;
|
2021-04-04 17:58:51 +00:00
|
|
|
|
|
|
|
/**
|
2021-04-16 21:07:06 +00:00
|
|
|
* Calculate the distance (height) between the two given copper layers.
|
|
|
|
*
|
|
|
|
* This factors in the thickness of any dielectric and copper layers between the two given
|
2021-05-11 01:48:50 +00:00
|
|
|
* layers, and half the height of the given start and end layers. This half-height calculation
|
|
|
|
* allows this to be used for consistent length measurements when calculating net length through
|
|
|
|
* a series of vias. A more advanced algorithm would be possible once we have a good concept of
|
2021-06-09 19:32:58 +00:00
|
|
|
* the start and end for a length measurement, but for now this will do.
|
2021-05-11 01:48:50 +00:00
|
|
|
* See https://gitlab.com/kicad/code/kicad/-/issues/8384 for more background.
|
|
|
|
*
|
2021-04-04 17:58:51 +00:00
|
|
|
* @param aFirstLayer is a copper layer
|
|
|
|
* @param aSecondLayer is a different copper layer
|
|
|
|
* @return the height (in IU) between the two layers
|
|
|
|
*/
|
|
|
|
int GetLayerDistance( PCB_LAYER_ID aFirstLayer, PCB_LAYER_ID aSecondLayer ) const;
|
2021-04-16 21:07:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of external copper finish
|
|
|
|
*/
|
|
|
|
wxString m_FinishType;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if some layers have impedance controlled tracks or have specific
|
|
|
|
* constrains for micro-wave applications
|
|
|
|
* If the board has dielectric constrains, the .gbrjob will contain
|
|
|
|
* info about dielectric constrains: loss tangent and Epsilon rel.
|
|
|
|
* If not, these values will be not specified in job file.
|
|
|
|
*/
|
|
|
|
bool m_HasDielectricConstrains;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* True if some layers (copper and/or dielectric) have specific thickness
|
|
|
|
*/
|
|
|
|
bool m_HasThicknessConstrains;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the board has edge connector cards, some constrains can be specified
|
|
|
|
* in job file:
|
|
|
|
* BS_EDGE_CONNECTOR_NONE = no edge connector
|
|
|
|
* BS_EDGE_CONNECTOR_IN_USE = board has edge connectors
|
|
|
|
* BS_EDGE_CONNECTOR_BEVELLED = edge connectors are beveled
|
|
|
|
*/
|
|
|
|
BS_EDGE_CONNECTOR_CONSTRAINTS m_EdgeConnectorConstraints;
|
|
|
|
|
|
|
|
bool m_CastellatedPads; ///< True if castellated pads exist
|
|
|
|
bool m_EdgePlating; ///< True if the edge board is plated
|
|
|
|
|
|
|
|
private:
|
|
|
|
// The list of items describing the stackup for fabrication.
|
|
|
|
// this is not just copper layers, but also mask dielectric layers
|
|
|
|
std::vector<BOARD_STACKUP_ITEM*> m_list;
|
2019-06-23 11:20:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-04-16 21:07:06 +00:00
|
|
|
#endif // BOARD_STACKUP_H
|