imrishabh18/pedometer

This code defines and assembles a simple radio receiver hardware circuit using specific imported capacitors, inductors, RF connectors, and oscillator components with precise footprints and schematic attributes.

Version
1.1.3
License
unset
Stars
0

through-via-drc.ts

/** Capacity 0.0.851 scores vias only on their transition endpoint layers.
 * Our fabrication stack uses through holes, so the repair evaluator must see
 * the annulus on every routing layer. Expand only its temporary scoring copy;
 * the solver's routes, via centers and exported transitions are unchanged. */
export function scoreThroughVias(evaluate: (input: any) => any, layerCount: number) {
  return (input: any) => {
    const key = input.routes ? "routes" : "hdRoutes";
    const routes = input[key];
    if (!routes) return evaluate(input);
    return evaluate({ ...input, [key]: routes.map((hd: any) => {
      const route: any[] = [];
      for (let i = 0; i < hd.route.length; i++) {
        const p = hd.route[i], previous = hd.route[i - 1];
        if (previous && previous.z !== p.z &&
            Math.hypot(previous.x - p.x, previous.y - p.y) < 1e-9) {
          for (let z = 0; z < layerCount; z++) {
            if (z !== previous.z && z !== p.z) route.push({ ...p, z });
          }
        }
        route.push(p);
      }
      return { ...hd, route };
    }) });
  };
}

/** Keep this workaround at the repair stage, before final routing output. */
export function enableThroughViaDrc(solver: any, layerCount: number) {
  for (const step of solver.pipelineDef) {
    if (step.solverName !== "exactGeometryDrcForceImproveSolver") continue;
    const getParams = step.getConstructorParams;
    step.getConstructorParams = (pipeline: any) => {
      const [params] = getParams(pipeline);
      const evaluate = scoreThroughVias(params.drcEvaluator, layerCount);
      return [{ ...params, drcEvaluator: evaluate, viaInPadDrcEvaluator: evaluate,
        maxIterations: 96, viaInPadMaxIterations: 96 }];
    };
  }
}