private void SiliconIntercellular(ILayerCell cell, bool isVertical, SiliconLink siliconLink, Rectangle cellBounds) { if (siliconLink == SiliconLink.None) { return; } Pen pen; if (cell.HasN()) { pen = NPen; } else if (cell.HasP()) { pen = PPen; } else if (siliconLink != SiliconLink.Slave ^ cell.HasPGate()) { pen = NPen; } else { pen = PPen; } GenericIntercellular(cellBounds, pen, isVertical); }
private void MetalIntercellular(ILayerCell cell, bool isVertical, Rectangle cellBounds) { if (cell.Links[isVertical ? 1 : 0]?.HasMetalLink ?? false) { GenericIntercellular(cellBounds, MetalPen, isVertical); } }
private void SiliconCellCorner(ILayerCell cell, Corner corner, Rectangle cellBounds, bool isVertCornerDetached, bool isHorzCornerDetached) { var(pen, _, _) = SelectSiliconBrush(cell); var(nearToCenter, nearToBounds, nearHorzLink, nearVertLink) = GetCellCornerBounds(cellBounds.X, cellBounds.Y, corner); var horzNeigh = cell.Links[corner.HasFlag(Corner.FarX) ? 2 : 0]; var vertNeigh = cell.Links[corner.HasFlag(Corner.FarY) ? 3 : 1]; var hasHorzLink = !isHorzCornerDetached && (horzNeigh?.SiliconLink ?? SiliconLink.None) != SiliconLink.None; var hasVertLink = !isVertCornerDetached && (vertNeigh?.SiliconLink ?? SiliconLink.None) != SiliconLink.None; GenericCellCorner(hasHorzLink, hasVertLink, pen, nearToCenter, nearToBounds, nearHorzLink, nearVertLink); if (!cell.HasGate()) { return; } var oppositeVertNeigh = cell.Links[corner.HasFlag(Corner.FarY) ? 1 : 3]; var isVerticalGate = (vertNeigh?.SiliconLink ?? SiliconLink.None) == SiliconLink.Slave || (oppositeVertNeigh?.SiliconLink ?? SiliconLink.None) == SiliconLink.Slave; var srcPoint = isVerticalGate ? nearVertLink : nearHorzLink; _graphics.DrawLine(BorderPen, srcPoint, nearToCenter); }
private void MetalCellSide(ILayerCell cell, Side side, Rectangle cellBounds, bool isSideDetached) { var(rect, nearToBounds, _) = GetCellSideBounds(cellBounds.X, cellBounds.Y, side); _graphics.FillRectangle(MetalBrush, rect); if (isSideDetached || !(cell.Links[side]?.HasMetalLink ?? false)) { _graphics.FillRectangle(BorderBrush, nearToBounds); } }
private bool IsValidGate(ILayerCell layerCell) { var isVerticalGate = layerCell.IsVerticalGate(); var baseS1 = isVerticalGate ? Side.Top : Side.Left; var baseS2 = baseS1.Invert(); var(slS1, slS2) = baseS1.GetPerpendicularSides(); return(layerCell.Links[baseS1].SiliconLink == SiliconLink.BiDirectional && layerCell.Links[baseS2].SiliconLink == SiliconLink.BiDirectional && (layerCell.Links[slS1].SiliconLink == SiliconLink.Slave || layerCell.Links[slS2].SiliconLink == SiliconLink.Slave)); }
private void MetalCellCorner(ILayerCell cell, Corner corner, Rectangle cellBounds, bool isVertCornerDetached, bool isHorzCornerDetached) { var(nearToCenter, nearToBounds, nearHorzLink, nearVertLink) = GetCellCornerBounds(cellBounds.X, cellBounds.Y, corner); var horzNeigh = cell.Links[corner.HasFlag(Corner.FarX) ? 2 : 0]; var vertNeigh = cell.Links[corner.HasFlag(Corner.FarY) ? 3 : 1]; var hasHorzLink = !isHorzCornerDetached && (horzNeigh?.HasMetalLink ?? false); var hasVertLink = !isVertCornerDetached && (vertNeigh?.HasMetalLink ?? false); GenericCellCorner(hasHorzLink, hasVertLink, MetalPen, nearToCenter, nearToBounds, nearHorzLink, nearVertLink); }
private void SiliconCellSide(ILayerCell cell, Side side, Rectangle cellBounds, bool isSideDetached) { var(_, brush, gateBrush) = SelectSiliconBrush(cell); var link = cell.Links[side]?.SiliconLink ?? SiliconLink.None; var oppositeLink = cell.Links[GetOppositeSide(side)]?.SiliconLink ?? SiliconLink.None; var hasSlaveLinkInDimension = link == SiliconLink.Slave || oppositeLink == SiliconLink.Slave; var actualBrush = hasSlaveLinkInDimension ? gateBrush : brush; var(rect, nearToBounds, nearToCenter) = GetCellSideBounds(cellBounds.X, cellBounds.Y, side); _graphics.FillRectangle(actualBrush, rect); if (isSideDetached || link == SiliconLink.None || hasSlaveLinkInDimension) { _graphics.FillRectangle(BorderBrush, nearToBounds); } if (!isSideDetached && cell.HasGate() && !hasSlaveLinkInDimension) { _graphics.FillRectangle(BorderBrush, nearToCenter); } }
private (bool, SiliconLink, SiliconLayerContent) CheckSiliconLink(ILayerCell fromCell, ILayerCell toCell, Side side) { var fromBase = fromCell.IsBaseN() ? SiliconType.NType : SiliconType.PType; var toBase = toCell.IsBaseN() ? SiliconType.NType : SiliconType.PType; if (fromBase != toBase) { var(p1, p2) = side.GetPerpendicularSides(); return(toCell.Links[p1].SiliconLink == SiliconLink.BiDirectional && toCell.Links[p2].SiliconLink == SiliconLink.BiDirectional && toCell.Links[side].SiliconLink != SiliconLink.BiDirectional && !toCell.HasVia() ? (true, SiliconLink.Master, toCell.HasGate() ? toCell.Silicon : toBase.ConvertToGate(!side.IsVertical())) : (false, SiliconLink.None, SiliconLayerContent.None)); } else { return(fromCell.HasGate() || toCell.HasGate() ? (false, SiliconLink.None, SiliconLayerContent.None) : (true, SiliconLink.BiDirectional, toCell.Silicon)); } }
public ElementaryPlaceLink(ILayerCell cell, bool isMetalLayer) { Cell = cell; IsMetalLayer = isMetalLayer; }
public static bool IsBaseP(this ILayerCell cell) => HasP(cell) || HasPGate(cell);
public static bool IsBaseN(this ILayerCell cell) => HasN(cell) || HasNGate(cell);
public static bool IsVerticalGate(this ILayerCell cell) => cell.Silicon == SiliconLayerContent.NTypeVGate || cell.Silicon == SiliconLayerContent.PTypeVGate;
public static bool HasSilicon(this ILayerCell cell) => cell.Silicon != SiliconLayerContent.None;
public static bool HasGate(this ILayerCell cell) => HasNGate(cell) || HasPGate(cell);
public CellContent(ILayerCell cell) { Silicon = cell.Silicon; HasMetal = cell.HasMetal; Pin = cell.Pin; }
private bool IsCellLocked(ILayerCell cell) { return(_isLockCheckEnabled && Template.DeadZones.Any(x => x.Contains(cell.Column, cell.Row))); }
public static bool HasPGate(this ILayerCell cell) => cell.Silicon == SiliconLayerContent.PTypeHGate || cell.Silicon == SiliconLayerContent.PTypeVGate;
public static bool HasVia(this ILayerCell cell) => cell.Silicon == SiliconLayerContent.NTypeVia || cell.Silicon == SiliconLayerContent.PTypeVia;
private static (Pen NonGatePen, Brush NonGateBrush, Brush GateBrush) SelectSiliconBrush(ILayerCell cell) { return(cell.IsBaseP() ? cell.IsBaseN() ? throw new InvalidOperationException("both P and N silicon on single cell") : (PPen, PBrush, PGateBrush) : cell.IsBaseN() ? (NPen, NBrush, NGateBrush) : throw new InvalidOperationException("no silicon on cell")); }