Note to mods: Do not move this thread. This project is an unreleased, work-in-progress project in the extremely early stage with nothing to show so far, its completion is not even guaranteed. So it's only a "Technical Chat", not a "Project".Currently, most free and open source PCB transmission line impedance calculators are based on hardcoded, closed-form formulas. The most popular calculator is
TransCalc [1]. It's currently included in both KiCad and Qucs, but began as a standalone project. This has the advantage of simplicity and accuracy - you can't be wrong with test-and-proven formulas that give you the standard result. But with some important limitations, such as the inability to solve transmission lines with multiple different dielectric layers.
Fortunately, we do have something more powerful, such as ATLC [2] and TNT-MMTL [3]. The subject of this post is TNT-MMTL. It's a 2D electromagnetic field solver that solves transmission lines with an arbitrary circuit board layer stackup using the Boundary Element Method (a.k.a. Method of Moments) according to the laws of electrostatics. It was developed by Mayo Clinic's Special Purpose Processor Development Group (SPPDG) from the 1980s to the 1990s. In the early 2000s, it was released as free software under the GPLv2+ license. Development was then discontinued, and the project fell into obscurity and is mostly forgotten.
Today, the upstream code doesn't even compile anymore, unless you're a Unixhead who knows where to look (NetBSD's software repository has some patches). The engine is also far from perfect [4]. But in spite of these flaws, it's still a powerful tool in the free and open source world. At least for the simple cases I've tried - microstrip with solder mask coating - the results are comparable to Si9000.
Recently, I was thinking about things I can do to revive its ancient but still useful code. And I realized the answer is obvious: WebAssembly. WebAssembly is a technology that allows one to execute portable binary code in a Web browser via a virtual machine sandbox with a hypothetical CPU and its own instruction set. For old-timers, it's basically a Pascal p-code machine.
Moreover, recent versions of LLVM compiler allows one to cross-compile code directly to WebAssembly, as if it's just another CPU. Furthermore, the project emscripten provides a "mockup" C standard library that allows many C/C++ programs to run directly without modifications. It has already been well-demonstrated that programs as complex as the original Doom game, 3D CAD, or x86 emulator with pre-installed Linux or Windows 95, or an entire FPGA place-and-route engine [5] can be ported to the Web browser in WebAssembly. In many cases, there's "only" a 2x performance hit compared to native code - which is often good enough.
This technology is not without its critics - if JavaScript spyware is not good enough for you, now you can even make them in WebAssembly! It also allows proprietary software vendors to strengthen their "everything is a cloud Web app" strategy to increase their monopolistic power and control over the users. Others may say it encourages developers to put more inefficient bloatware in the Web browser.
I'm sympathetic with these views. However, I also believe the technology itself can be used for good.
A PCB impedance calculator that runs directly in a Web page without the need to
download install anything sounds like a perfect candidate. Right now I'm working on project to port the TNT-MMTL to the Web browser with the power of WebAssembly. Now I've managed to reimplement its graphical user interface, "TNT", in JavaScript. The underlying MMTL-BEM engine is also running flawlessly.
To me, it's a technical marvell - the MMTL-BEM code is written in C++, but the linear algebra kernel was written in FORTRAN, some code was copied directly from the original LINPACK from 1978 written by Jack Dongarra himself! But I was able to compile the FORTRAN code directly to WebAssembly as well, without any modification!
The next step of the project is:
1. Keep reimplementing the TNT GUI in JavaScript.
2. Add parametric sweep.
3. TNT-MMTL requires users to model each layer of the PCB manually. The next step is writing a GUI that works at a level higher than TNT, instead of modeling each layer of the board, it would generate the stackup automatically based on the type of transmission lines and its parameters, in Si8000/Si9000 style. My hope is to create the ultimate PCB impedance calculator on the Web.
[1]
https://transcalc.sourceforge.net/[2]
https://atlc.sourceforge.net/[3]
https://mmtl.sourceforge.net/[4] Lossy line is not supported, and occasionally, some inputs can generate ill-formed matrices that can't be solved.
[5]
https://github.com/YoWASP/nextpnr