Skip to content

feat(mcu):修复弹簧开关朝向和符号问题,然后解决c11电容和接地的问题#306

Open
rhaingenix wants to merge 52 commits into
devbisme:masterfrom
Doris619619:clean-dev
Open

feat(mcu):修复弹簧开关朝向和符号问题,然后解决c11电容和接地的问题#306
rhaingenix wants to merge 52 commits into
devbisme:masterfrom
Doris619619:clean-dev

Conversation

@rhaingenix

Copy link
Copy Markdown

Summary

这个 PR 主要针对 TG032-MCU 这类 MCU 原理图的局部布局进行优化,重点修复 MCU 周边触摸按键 TK 符号显示,以及 MCU 去耦电容 C11 的接地布线样式。

修改内容

1. 修复 MCU 左侧 TK 触摸按键符号显示

修改位置主要在:

  • src/skidl/schematics/topology/mcu.py
  • 必要的 KiCad 导出相关逻辑

原来的问题是:

  • TK_Spring_CenterTK_Spring_Side 在生成原理图时显示风格不一致
  • TK2 的符号方向和下面几个 TK 不统一
  • 如果直接整体 mirror/rotate,会导致文字也被翻转
  • 生成结果不符合人工 KiCad 原理图习惯

本次修改后:

  • 将 MCU 左侧的 TK touch key 器件统一按照小型 connector/arrow 风格显示
  • TK2 / TK3 / TK1 / TK4 的符号方向保持一致
  • 符号朝向右侧连接电阻和 MCU 引脚
  • 器件文字保持正常方向,不再被镜像或倒置
  • 不改变原始 netlist 中的连接关系

2. 优化 MCU 去耦电容 C11 的 GND_0 接地布线

修改位置主要在:

  • src/skidl/schematics/topology/mcu.py

重点涉及的函数包括:

  • _mcu_decouple_ground_context
  • _mcu_force_place_decouple_at_signal_pin
  • _mcu_route_decouple_ground_net

原来的问题是:

  • C11 的一端连接 P35/T1/TKCAP
  • C11 的另一端连接 GND_0
  • GND_0 同时连接 MCU 的 VSS
  • 但是生成出来的接地结构不够自然,GND 符号和电容、VSS 之间的布局比较混乱
  • 电容到 GND trunk 的连接方式不太像人工画图

本次修改后:

  • 保留 C11 的原始网络连接关系
  • C11 上端仍然连接 P35/T1/TKCAP
  • C11 下端连接到一根水平的 GND_0 trunk
  • MCU 的 VSS 引脚水平接出到这根 GND_0 trunk
  • GND 符号从 GND_0 trunk 下方单独挂出
  • 整体结构更接近人工绘制的 KiCad 原理图

3. 保留现有 routing 逻辑

本 PR 没有重写全局 routing 算法。

没有修改:

  • netlist-to-sch-via-skidl
  • 输入 .net 文件
  • 自动生成的 TG032-MCU.py
  • 全局 route 主流程
  • netlist conversion 流程

修改集中在 skidl-pnr-opt 的 MCU topology / local routing 处理逻辑中。

验证方式

使用 TG032-MCU 示例进行验证:

cd C:\Users\py\netlist-to-sch-via-skidl
python examples\TG032-MCU\TG032-MCU.py

打开生成的 schematic:

examples\TG032-MCU\kicad_generated_h\TG032-MCU.kicad_sch

检查结果:

  • 左侧 TK 符号显示一致
  • TK2 / TK3 / TK1 / TK4 连接关系保持正确
  • C11 上端连接 P35/T1/TKCAP
  • C11 下端连接 GND_0
  • GND_0 水平连接到 MCU VSS
  • GND 符号从 GND_0 trunk 下方接出
  • 没有修改 netlist conversion 逻辑

Scope

本次 PR 只针对 MCU 专用布局中的局部显示和局部布线规则进行修复,主要服务于 TG032-MCU 这类 MCU 周边电路的可读性优化。

Doris619619 and others added 30 commits May 13, 2026 20:36
feat(pnr): 增加 human_readable 布局与走线稳定化
feat(schematic): 新增小组弱对齐模块并修正 human_readable 布局过强对齐
feat(sch): 支持配置原理图布线疏松程度
feat(pnr):修复凸起,直连线并且运行大图例子
保留本地 phased remove_jogs 循环与进度日志,并入远端的
route_straight_nets、straighten_aligned_pin_connection 与
local_detour_visited。

Co-authored-by: Cursor <cursoragent@cursor.com>
feat(schematic): human_readable 下 generic driver 拓扑识别、rail 布局与预布线
fear(sch) : 修复器件名称不完整的问题
fix(gensch): 移除flatten参数
Doris619619 and others added 22 commits May 26, 2026 02:30
feat(route):修复了主干道布线对于小图例子的问题,对于小图采取普通力导向布线
fix(label):修复NetTerminal 和 stub 标签重复导出,导致同一网络出现多个标签
# feat(mcu): 修复MCU 引脚分叉感知布局与布线
@lachlanfysh

Copy link
Copy Markdown

Nice work — there's a lot here. A few notes as a fellow contributor poking at the same placement/label area:

Bits I really liked (and plan to adopt on my branch, with credit to this PR):

  • The conservative tidy in place_small_group.py — snapping parts into aligned Y-bands but rolling back any move that creates a bbox overlap or brings different-net pins too close. Clean, general rollback discipline.
  • _walk_colinear_chain / hub-pin-side placement — laying a hub + its passive chain co-linear off a pin is a tidy, reusable primitive.
  • _classify_net_semantic and the post-placement wire-vs-label decision from real geometry.

I'm going to adapt those generic pieces (crediting this PR in the commits), and separately have a go at an inter-group idea on top of SKiDL's existing group_parts/place_blocks — packing the wire-connected units into an orderly grid by size. Flagging so we don't duplicate effort.

One thing worth flagging: I tried the branch on a mixed, non-MCU board of mine (a mux + pots sheet, some identical driver ICs, a connector) and every sheet fell through to the fallback layout / labels-only. Reading topology.py, I think it's because the classifier keys on MCU signatures (chip-name tokens, PAxx pins, crystal/reset subgraphs), so sheets with no dominant recognizable MCU never reach the mcu/weak_mcu path. The generic pieces above don't actually need MCU detection — might be worth letting them run on a non-MCU fallback too.

Heads-up: FWIW the maintainer asked me to base my PR on development rather than master — might save a rebase round-trip if you retarget there.

@devbisme

devbisme commented Jun 2, 2026

Copy link
Copy Markdown
Owner

It was mentioned above that you are both working on the same section of code, so the issue is how to eventually integrate these efforts within SKiDL. You'll either need to find a way to cooperate or else one PR will have to be accepted and the other declined which is obviously a waste of someone's effort. I want to avoid that if at all possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants