2011-11-10 15:55:05 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2012-06-08 09:56:42 +00:00
|
|
|
* Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
|
|
|
|
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
|
|
|
|
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see change_log.txt for contributors.
|
2011-11-10 15:55:05 +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 2
|
|
|
|
* 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, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-20 13:57:40 +00:00
|
|
|
/**
|
2012-09-12 17:28:55 +00:00
|
|
|
* @file routing_matrix.cpp
|
|
|
|
* @brief Functions to create autorouting maps
|
2011-09-20 13:57:40 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <common.h>
|
|
|
|
#include <pcbcommon.h>
|
|
|
|
|
|
|
|
#include <pcbnew.h>
|
|
|
|
#include <cell.h>
|
2012-06-05 19:07:33 +00:00
|
|
|
#include <autorout.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
|
|
|
|
#include <class_board.h>
|
|
|
|
#include <class_module.h>
|
|
|
|
#include <class_track.h>
|
|
|
|
#include <class_drawsegment.h>
|
|
|
|
#include <class_edge_mod.h>
|
|
|
|
#include <class_pcb_text.h>
|
2011-09-23 13:57:12 +00:00
|
|
|
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
MATRIX_ROUTING_HEAD::MATRIX_ROUTING_HEAD()
|
|
|
|
{
|
|
|
|
m_BoardSide[0] = m_BoardSide[1] = NULL;
|
|
|
|
m_DistSide[0] = m_DistSide[1] = NULL;
|
|
|
|
m_DirSide[0] = m_DirSide[1] = NULL;
|
|
|
|
m_InitMatrixDone = false;
|
|
|
|
m_Nrows = m_Ncols = 0;
|
|
|
|
m_MemSize = 0;
|
|
|
|
m_RoutingLayersCount = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MATRIX_ROUTING_HEAD::~MATRIX_ROUTING_HEAD()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
bool MATRIX_ROUTING_HEAD::ComputeMatrixSize( BOARD* aPcb, bool aUseBoardEdgesOnly )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-06-08 09:56:42 +00:00
|
|
|
aPcb->ComputeBoundingBox( aUseBoardEdgesOnly );
|
2007-08-21 14:34:54 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
// The boundary box must have its start point on routing grid:
|
|
|
|
m_BrdBox = aPcb->GetBoundingBox();
|
2011-09-20 13:57:40 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
m_BrdBox.SetX( m_BrdBox.GetX() - ( m_BrdBox.GetX() % m_GridRouting ) );
|
|
|
|
m_BrdBox.SetY( m_BrdBox.GetY() - ( m_BrdBox.GetY() % m_GridRouting ) );
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
|
|
|
// The boundary box must have its end point on routing grid:
|
2011-03-09 20:09:11 +00:00
|
|
|
wxPoint end = m_BrdBox.GetEnd();
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
end.x -= end.x % m_GridRouting;
|
|
|
|
end.x += m_GridRouting;
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
end.y -= end.y % m_GridRouting;
|
|
|
|
end.y += m_GridRouting;
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
|
2011-12-21 13:42:02 +00:00
|
|
|
m_BrdBox.SetEnd( end );
|
2011-03-09 20:09:11 +00:00
|
|
|
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
aPcb->SetBoundingBox( m_BrdBox );
|
|
|
|
|
2012-06-10 16:21:18 +00:00
|
|
|
m_Nrows = m_BrdBox.GetHeight() / m_GridRouting;
|
|
|
|
m_Ncols = m_BrdBox.GetWidth() / m_GridRouting;
|
2011-03-09 14:30:39 +00:00
|
|
|
|
2012-06-10 16:21:18 +00:00
|
|
|
// gives a small margin
|
|
|
|
m_Ncols += 1;
|
|
|
|
m_Nrows += 1;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
return true;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
int MATRIX_ROUTING_HEAD::InitRoutingMatrix()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2012-06-10 16:21:18 +00:00
|
|
|
if( m_Nrows <= 0 || m_Ncols <= 0 )
|
2007-08-21 14:34:54 +00:00
|
|
|
return 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
m_InitMatrixDone = true; // we have been called
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
// give a small margin for memory allocation:
|
2013-03-06 09:04:27 +00:00
|
|
|
int ii = (RoutingMatrix.m_Nrows + 1) * (RoutingMatrix.m_Ncols + 1);
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-06 09:04:27 +00:00
|
|
|
int side = BOTTOM;
|
|
|
|
for( int jj = 0; jj < m_RoutingLayersCount; jj++ ) // m_RoutingLayersCount = 1 or 2
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2013-03-06 09:04:27 +00:00
|
|
|
m_BoardSide[side] = NULL;
|
|
|
|
m_DistSide[side] = NULL;
|
|
|
|
m_DirSide[side] = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
/* allocate matrix & initialize everything to empty */
|
2013-03-06 09:04:27 +00:00
|
|
|
m_BoardSide[side] = (MATRIX_CELL*) operator new( ii * sizeof(MATRIX_CELL) );
|
|
|
|
memset( m_BoardSide[side], 0, ii * sizeof(MATRIX_CELL) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-06 09:04:27 +00:00
|
|
|
if( m_BoardSide[side] == NULL )
|
2007-08-21 14:34:54 +00:00
|
|
|
return -1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
// allocate Distances
|
2013-03-06 09:04:27 +00:00
|
|
|
m_DistSide[side] = (DIST_CELL*) operator new( ii * sizeof(DIST_CELL) );
|
|
|
|
memset( m_DistSide[side], 0, ii * sizeof(DIST_CELL) );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-06 09:04:27 +00:00
|
|
|
if( m_DistSide[side] == NULL )
|
2007-08-21 14:34:54 +00:00
|
|
|
return -1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
// allocate Dir (chars)
|
2013-03-06 09:04:27 +00:00
|
|
|
m_DirSide[side] = (char*) operator new( ii );
|
|
|
|
memset( m_DirSide[side], 0, ii );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2013-03-06 09:04:27 +00:00
|
|
|
if( m_DirSide[side] == NULL )
|
2007-08-21 14:34:54 +00:00
|
|
|
return -1;
|
2013-03-06 09:04:27 +00:00
|
|
|
|
|
|
|
side = TOP;
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-03-06 09:04:27 +00:00
|
|
|
m_MemSize = m_RouteCount * ii * ( sizeof(MATRIX_CELL)
|
|
|
|
+ sizeof(DIST_CELL) + sizeof(char) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-08-21 14:34:54 +00:00
|
|
|
return m_MemSize;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::UnInitRoutingMatrix()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-08-21 14:34:54 +00:00
|
|
|
int ii;
|
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
m_InitMatrixDone = false;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
for( ii = 0; ii < MAX_ROUTING_LAYERS_COUNT; ii++ )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2012-06-08 09:56:42 +00:00
|
|
|
// de-allocate Dir matrix
|
2007-08-21 14:34:54 +00:00
|
|
|
if( m_DirSide[ii] )
|
|
|
|
{
|
2011-11-10 15:55:05 +00:00
|
|
|
delete m_DirSide[ii];
|
2011-09-20 13:57:40 +00:00
|
|
|
m_DirSide[ii] = NULL;
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
// de-allocate Distances matrix
|
2007-08-21 14:34:54 +00:00
|
|
|
if( m_DistSide[ii] )
|
|
|
|
{
|
2011-11-10 15:55:05 +00:00
|
|
|
delete m_DistSide[ii];
|
2011-09-20 13:57:40 +00:00
|
|
|
m_DistSide[ii] = NULL;
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
|
|
|
|
2012-06-08 09:56:42 +00:00
|
|
|
// de-allocate cells matrix
|
2007-08-21 14:34:54 +00:00
|
|
|
if( m_BoardSide[ii] )
|
|
|
|
{
|
2011-11-10 15:55:05 +00:00
|
|
|
delete m_BoardSide[ii];
|
2011-09-20 13:57:40 +00:00
|
|
|
m_BoardSide[ii] = NULL;
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
m_Nrows = m_Ncols = 0;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-10 15:55:05 +00:00
|
|
|
/**
|
|
|
|
* Function PlaceCells
|
2012-06-26 17:57:37 +00:00
|
|
|
* Initialize the matrix routing by setting obstacles for each occupied cell
|
|
|
|
* a cell set to HOLE is an obstacle for tracks and vias
|
|
|
|
* a cell set to VIA_IMPOSSIBLE is an obstacle for vias only.
|
|
|
|
* a cell set to CELL_is_EDGE is a frontier.
|
|
|
|
* Tracks and vias having the same net code as net_code are skipped
|
|
|
|
* (htey do not are obstacles)
|
|
|
|
*
|
2009-11-12 15:43:38 +00:00
|
|
|
* For single-sided Routing 1:
|
2012-06-26 17:57:37 +00:00
|
|
|
* BOTTOM side is used, and Route_Layer_BOTTOM = Route_Layer_TOP
|
2008-11-24 06:53:43 +00:00
|
|
|
*
|
2012-06-26 17:57:37 +00:00
|
|
|
* If flag == FORCE_PADS: all pads will be put in matrix as obstacles.
|
2007-08-21 14:34:54 +00:00
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void PlaceCells( BOARD* aPcb, int net_code, int flag )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 20:09:11 +00:00
|
|
|
int ux0 = 0, uy0 = 0, ux1, uy1, dx, dy;
|
|
|
|
int marge, via_marge;
|
2013-04-04 21:35:01 +00:00
|
|
|
LAYER_MSK layerMask;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2009-09-10 15:22:26 +00:00
|
|
|
// use the default NETCLASS?
|
2014-05-20 09:29:37 +00:00
|
|
|
NETCLASSPTR nc = aPcb->GetDesignSettings().GetDefault();
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
int trackWidth = nc->GetTrackWidth();
|
|
|
|
int clearance = nc->GetClearance();
|
|
|
|
int viaSize = nc->GetViaDiameter();
|
2009-09-10 15:22:26 +00:00
|
|
|
|
|
|
|
marge = clearance + (trackWidth / 2);
|
|
|
|
via_marge = clearance + (viaSize / 2);
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
// Place PADS on matrix routing:
|
2011-12-10 05:33:24 +00:00
|
|
|
for( unsigned i = 0; i < aPcb->GetPadCount(); ++i )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2011-12-10 05:33:24 +00:00
|
|
|
D_PAD* pad = aPcb->GetPad( i );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
if( net_code != pad->GetNetCode() || (flag & FORCE_PADS) )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2012-06-17 16:06:12 +00:00
|
|
|
::PlacePad( pad, HOLE, marge, WRITE_CELL );
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-06-17 16:06:12 +00:00
|
|
|
::PlacePad( pad, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
// Place outlines of modules on matrix routing, if they are on a copper layer
|
|
|
|
// or on the edge layer
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
for( MODULE* module = aPcb->m_Modules; module; module = module->Next() )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2013-03-18 19:36:07 +00:00
|
|
|
for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
switch( item->Type() )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_MODULE_EDGE_T:
|
2011-03-09 20:09:11 +00:00
|
|
|
{
|
|
|
|
EDGE_MODULE* edge = (EDGE_MODULE*) item;
|
2014-04-25 06:00:04 +00:00
|
|
|
EDGE_MODULE tmpEdge( *edge );
|
2011-03-09 20:09:11 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
if( tmpEdge.GetLayer() == EDGE_N )
|
|
|
|
tmpEdge.SetLayer( UNDEFINED_LAYER );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2014-04-25 06:00:04 +00:00
|
|
|
TraceSegmentPcb( &tmpEdge, HOLE, marge, WRITE_CELL );
|
|
|
|
TraceSegmentPcb( &tmpEdge, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
|
2011-03-09 20:09:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
// Place board outlines and texts on copper layers:
|
2009-11-12 15:43:38 +00:00
|
|
|
for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2008-12-04 04:28:11 +00:00
|
|
|
switch( item->Type() )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_LINE_T:
|
2011-03-09 20:09:11 +00:00
|
|
|
{
|
|
|
|
DRAWSEGMENT* DrawSegm;
|
|
|
|
|
|
|
|
int type_cell = HOLE;
|
|
|
|
DrawSegm = (DRAWSEGMENT*) item;
|
2014-04-25 06:00:04 +00:00
|
|
|
DRAWSEGMENT tmpSegm( DrawSegm );
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2011-03-09 20:09:11 +00:00
|
|
|
if( DrawSegm->GetLayer() == EDGE_N )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
tmpSegm.SetLayer( UNDEFINED_LAYER );
|
2011-03-09 20:09:11 +00:00
|
|
|
type_cell |= CELL_is_EDGE;
|
2008-12-04 04:28:11 +00:00
|
|
|
}
|
2011-03-09 20:09:11 +00:00
|
|
|
|
2012-06-17 16:06:12 +00:00
|
|
|
TraceSegmentPcb( &tmpSegm, type_cell, marge, WRITE_CELL );
|
2011-03-09 20:09:11 +00:00
|
|
|
}
|
|
|
|
break;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2011-10-01 19:24:27 +00:00
|
|
|
case PCB_TEXT_T:
|
2009-09-10 15:22:26 +00:00
|
|
|
{
|
2011-03-09 20:09:11 +00:00
|
|
|
TEXTE_PCB* PtText;
|
2008-12-04 04:28:11 +00:00
|
|
|
PtText = (TEXTE_PCB*) item;
|
|
|
|
|
2013-03-18 19:36:07 +00:00
|
|
|
if( PtText->GetText().Length() == 0 )
|
2007-08-21 14:34:54 +00:00
|
|
|
break;
|
2009-06-06 18:08:49 +00:00
|
|
|
|
2011-03-29 19:33:07 +00:00
|
|
|
EDA_RECT textbox = PtText->GetTextBox( -1 );
|
2011-09-20 13:57:40 +00:00
|
|
|
ux0 = textbox.GetX();
|
|
|
|
uy0 = textbox.GetY();
|
2011-03-09 20:09:11 +00:00
|
|
|
dx = textbox.GetWidth();
|
|
|
|
dy = textbox.GetHeight();
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2008-03-05 14:57:24 +00:00
|
|
|
/* Put bounding box (rectangle) on matrix */
|
2008-12-04 04:28:11 +00:00
|
|
|
dx /= 2;
|
2009-11-12 15:43:38 +00:00
|
|
|
dy /= 2;
|
2008-12-04 04:28:11 +00:00
|
|
|
|
|
|
|
ux1 = ux0 + dx;
|
|
|
|
uy1 = uy0 + dy;
|
|
|
|
|
|
|
|
ux0 -= dx;
|
|
|
|
uy0 -= dy;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2011-12-06 08:35:13 +00:00
|
|
|
layerMask = GetLayerMask( PtText->GetLayer() );
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2012-06-17 16:06:12 +00:00
|
|
|
TraceFilledRectangle( ux0 - marge, uy0 - marge, ux1 + marge,
|
2013-05-01 17:32:36 +00:00
|
|
|
uy1 + marge, PtText->GetOrientation(),
|
2011-09-07 19:41:04 +00:00
|
|
|
layerMask, HOLE, WRITE_CELL );
|
2008-12-04 04:28:11 +00:00
|
|
|
|
2012-06-17 16:06:12 +00:00
|
|
|
TraceFilledRectangle( ux0 - via_marge, uy0 - via_marge,
|
2007-08-21 14:34:54 +00:00
|
|
|
ux1 + via_marge, uy1 + via_marge,
|
2013-05-01 17:32:36 +00:00
|
|
|
PtText->GetOrientation(),
|
2011-09-07 19:41:04 +00:00
|
|
|
layerMask, VIA_IMPOSSIBLE, WRITE_OR_CELL );
|
2009-09-10 15:22:26 +00:00
|
|
|
}
|
2011-03-09 20:09:11 +00:00
|
|
|
break;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-05 14:57:24 +00:00
|
|
|
/* Put tracks and vias on matrix */
|
2011-03-09 20:09:11 +00:00
|
|
|
for( TRACK* track = aPcb->m_Track; track; track = track->Next() )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2014-02-25 10:40:34 +00:00
|
|
|
if( net_code == track->GetNetCode() )
|
2007-08-21 14:34:54 +00:00
|
|
|
continue;
|
2008-11-24 06:53:43 +00:00
|
|
|
|
2012-06-17 16:06:12 +00:00
|
|
|
TraceSegmentPcb( track, HOLE, marge, WRITE_CELL );
|
|
|
|
TraceSegmentPcb( track, VIA_IMPOSSIBLE, via_marge, WRITE_OR_CELL );
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2009-05-28 08:42:24 +00:00
|
|
|
int Build_Work( BOARD* Pcb )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
RATSNEST_ITEM* pt_rats;
|
|
|
|
D_PAD* pt_pad;
|
|
|
|
int r1, r2, c1, c2, current_net_code;
|
|
|
|
RATSNEST_ITEM* pt_ch;
|
2012-06-05 19:07:33 +00:00
|
|
|
int demi_pas = RoutingMatrix.m_GridRouting / 2;
|
++PCBNew
* Removed Pcb_Frame argument from BOARD() constructor, since it precludes
having a BOARD being edited by more than one editor, it was a bad design.
And this meant removing m_PcbFrame from BOARD.
* removed BOARD::SetWindowFrame(), and BOARD::m_PcbFrame
* Removed the global BOARD_DESIGN_SETTINGS which was in class_board.cpp
* added BOARD_DESIGN_SETTINGS to the BOARD class, a full instance
* a couple dialogs now only change BOARD_DESIGN_SETTINGS when OK is pressed,
such as dialog_mask_clearance, dialog_drc, etc.
* Removed common/pcbcommon.cpp's int g_CurrentVersionPCB = 1 and replaced it
with build_version.h's #define BOARD_FILE_VERSION, although there may be a
better place for this constant.
* Made the public functions in PARAM_CFG_ARRAY be type const.
void SaveParam(..) const and void ReadParam(..) const
* PARAM_CFG_BASE now has virtual destructor since we have various way of
destroying the derived class and boost::ptr_vector must be told about this.
* Pass const PARAM_CFG_ARRAY& instead of PARAM_CFG_ARRAY so that we can use
an automatic PARAM_CFG_ARRAY which is on the stack.\
* PCB_EDIT_FRAME::GetProjectFileParameters() may no longer cache the array,
since it has to access the current BOARD and the BOARD can change.
Remember BOARD_DESIGN_SETTINGS are now in the BOARD.
* Made the m_BoundingBox member private, this was a brutally hard task,
and indicative of the lack of commitment to accessors and object oriented
design on the part of KiCad developers. We must do better.
Added BOARD::GetBoundingBox, SetBoundingBox(), ComputeBoundingBox().
* Added PCB_BASE_FRAME::GetBoardBoundingBox() which calls BOARD::ComputeBoundingBox()
2011-12-05 06:15:33 +00:00
|
|
|
wxString msg;
|
|
|
|
|
2007-08-21 14:34:54 +00:00
|
|
|
InitWork(); /* clear work list */
|
2012-06-10 16:21:18 +00:00
|
|
|
int cellCount = 0;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-06-03 17:18:39 +00:00
|
|
|
for( unsigned ii = 0; ii < Pcb->GetRatsnestsCount(); ii++ )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2009-05-28 08:42:24 +00:00
|
|
|
pt_rats = &Pcb->m_FullRatsnest[ii];
|
2011-03-09 20:09:11 +00:00
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
/* We consider here only ratsnest that are active ( obviously not yet routed)
|
2009-11-15 14:12:53 +00:00
|
|
|
* and routables (that are not yet attempt to be routed and fail
|
|
|
|
*/
|
2011-03-09 20:09:11 +00:00
|
|
|
if( (pt_rats->m_Status & CH_ACTIF) == 0 )
|
2007-08-21 14:34:54 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
if( pt_rats->m_Status & CH_UNROUTABLE )
|
2007-08-21 14:34:54 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
if( (pt_rats->m_Status & CH_ROUTE_REQ) == 0 )
|
2007-08-21 14:34:54 +00:00
|
|
|
continue;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
pt_pad = pt_rats->m_PadStart;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2014-02-25 10:40:34 +00:00
|
|
|
current_net_code = pt_pad->GetNetCode();
|
2007-08-21 14:34:54 +00:00
|
|
|
pt_ch = pt_rats;
|
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
r1 = ( pt_pad->GetPosition().y - RoutingMatrix.m_BrdBox.GetY() + demi_pas )
|
|
|
|
/ RoutingMatrix.m_GridRouting;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-06-10 16:21:18 +00:00
|
|
|
if( r1 < 0 || r1 >= RoutingMatrix.m_Nrows )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r1,
|
2012-06-26 17:57:37 +00:00
|
|
|
pt_pad->GetPosition().y, RoutingMatrix.m_BrdBox.GetY() );
|
2011-03-09 14:30:39 +00:00
|
|
|
wxMessageBox( msg );
|
2007-08-21 14:34:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
c1 = ( pt_pad->GetPosition().x - RoutingMatrix.m_BrdBox.GetX() + demi_pas ) / RoutingMatrix.m_GridRouting;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-06-10 16:21:18 +00:00
|
|
|
if( c1 < 0 || c1 >= RoutingMatrix.m_Ncols )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c1,
|
2012-06-26 17:57:37 +00:00
|
|
|
pt_pad->GetPosition().x, RoutingMatrix.m_BrdBox.GetX() );
|
2011-03-09 14:30:39 +00:00
|
|
|
wxMessageBox( msg );
|
2007-08-21 14:34:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-24 18:28:36 +00:00
|
|
|
pt_pad = pt_rats->m_PadEnd;
|
2007-08-21 14:34:54 +00:00
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
r2 = ( pt_pad->GetPosition().y - RoutingMatrix.m_BrdBox.GetY()
|
2012-06-05 19:07:33 +00:00
|
|
|
+ demi_pas ) / RoutingMatrix.m_GridRouting;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-06-10 16:21:18 +00:00
|
|
|
if( r2 < 0 || r2 >= RoutingMatrix.m_Nrows )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
msg.Printf( wxT( "error : row = %d ( padY %d pcbY %d) " ), r2,
|
2012-06-26 17:57:37 +00:00
|
|
|
pt_pad->GetPosition().y, RoutingMatrix.m_BrdBox.GetY() );
|
2011-03-09 14:30:39 +00:00
|
|
|
wxMessageBox( msg );
|
2007-08-21 14:34:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
c2 = ( pt_pad->GetPosition().x - RoutingMatrix.m_BrdBox.GetX() + demi_pas )
|
|
|
|
/ RoutingMatrix.m_GridRouting;
|
2011-09-07 19:41:04 +00:00
|
|
|
|
2012-06-10 16:21:18 +00:00
|
|
|
if( c2 < 0 || c2 >= RoutingMatrix.m_Ncols )
|
2007-08-21 14:34:54 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
msg.Printf( wxT( "error : col = %d ( padX %d pcbX %d) " ), c2,
|
2012-06-26 17:57:37 +00:00
|
|
|
pt_pad->GetPosition().x, RoutingMatrix.m_BrdBox.GetX() );
|
2011-03-09 14:30:39 +00:00
|
|
|
wxMessageBox( msg );
|
2007-08-21 14:34:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-06-03 17:18:39 +00:00
|
|
|
SetWork( r1, c1, current_net_code, r2, c2, pt_ch, 0 );
|
2012-06-10 16:21:18 +00:00
|
|
|
cellCount++;
|
2007-08-21 14:34:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SortWork();
|
2012-06-10 16:21:18 +00:00
|
|
|
return cellCount;
|
|
|
|
}
|
|
|
|
|
2012-06-26 17:57:37 +00:00
|
|
|
// Initialize m_opWriteCell member to make the aLogicOp
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::SetCellOperation( int aLogicOp )
|
|
|
|
{
|
|
|
|
switch( aLogicOp )
|
|
|
|
{
|
|
|
|
default:
|
|
|
|
case WRITE_CELL:
|
|
|
|
m_opWriteCell = &MATRIX_ROUTING_HEAD::SetCell;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WRITE_OR_CELL:
|
|
|
|
m_opWriteCell = &MATRIX_ROUTING_HEAD::OrCell;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WRITE_XOR_CELL:
|
|
|
|
m_opWriteCell = &MATRIX_ROUTING_HEAD::XorCell;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WRITE_AND_CELL:
|
|
|
|
m_opWriteCell = &MATRIX_ROUTING_HEAD::AndCell;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WRITE_ADD_CELL:
|
|
|
|
m_opWriteCell = &MATRIX_ROUTING_HEAD::AddCell;
|
|
|
|
break;
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
/* return the value stored in a cell
|
2011-03-09 20:09:11 +00:00
|
|
|
*/
|
2012-06-10 16:21:18 +00:00
|
|
|
MATRIX_CELL MATRIX_ROUTING_HEAD::GetCell( int aRow, int aCol, int aSide )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
MATRIX_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_BoardSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
return p[aRow * m_Ncols + aCol];
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
/* basic cell operation : WRITE operation
|
2011-03-09 20:09:11 +00:00
|
|
|
*/
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::SetCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
MATRIX_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_BoardSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
p[aRow * m_Ncols + aCol] = x;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
/* basic cell operation : OR operation
|
2011-03-09 20:09:11 +00:00
|
|
|
*/
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::OrCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
MATRIX_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_BoardSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
p[aRow * m_Ncols + aCol] |= x;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
/* basic cell operation : XOR operation
|
2011-03-09 20:09:11 +00:00
|
|
|
*/
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::XorCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
MATRIX_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_BoardSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
p[aRow * m_Ncols + aCol] ^= x;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
/* basic cell operation : AND operation
|
2011-03-09 20:09:11 +00:00
|
|
|
*/
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::AndCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
MATRIX_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_BoardSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
p[aRow * m_Ncols + aCol] &= x;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 14:30:39 +00:00
|
|
|
/* basic cell operation : ADD operation
|
2011-03-09 20:09:11 +00:00
|
|
|
*/
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::AddCell( int aRow, int aCol, int aSide, MATRIX_CELL x )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
MATRIX_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_BoardSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
p[aRow * m_Ncols + aCol] += x;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* fetch distance cell */
|
2012-06-10 16:21:18 +00:00
|
|
|
DIST_CELL MATRIX_ROUTING_HEAD::GetDist( int aRow, int aCol, int aSide ) /* fetch distance cell */
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
DIST_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_DistSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
return p[aRow * m_Ncols + aCol];
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* store distance cell */
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::SetDist( int aRow, int aCol, int aSide, DIST_CELL x )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
DIST_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_DistSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
p[aRow * m_Ncols + aCol] = x;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* fetch direction cell */
|
2012-06-10 16:21:18 +00:00
|
|
|
int MATRIX_ROUTING_HEAD::GetDir( int aRow, int aCol, int aSide )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
DIR_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_DirSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
return (int) (p[aRow * m_Ncols + aCol]);
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* store direction cell */
|
2012-06-10 16:21:18 +00:00
|
|
|
void MATRIX_ROUTING_HEAD::SetDir( int aRow, int aCol, int aSide, int x )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-03-09 14:30:39 +00:00
|
|
|
DIR_CELL* p;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-06-05 19:07:33 +00:00
|
|
|
p = RoutingMatrix.m_DirSide[aSide];
|
2012-06-10 16:21:18 +00:00
|
|
|
p[aRow * m_Ncols + aCol] = (char) x;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|