All my series of “Learning to Develop KiCad” posts are listed in FAQ
Index:
- Use cases in regexp filter used during DDR4 routing
- Add a Dialog
- Add Netlist in the Dialog
- Add two levels data items
- Code reading / analysis of length calculation in Length Tuning Tool
This is a copy from my medium article, which is a translation of my Chinese article:
What I am using is a locally built version based on KiCad master branch. However, the use cases in this article should be common between stable release and master/nightly build.
I am still a new learner in High-Speed signal designing, and trying to use KiCad to design an SoC board with DDR4 memory. Please pointed me out any errors (of technical ones or grammar, etc ) in this article.
KiCad net name filter supports regexp (regular expression). It is more “Programmer friendly” style filter, but everyone is willing to learn it, it will be a very powerful tool. Many advanced editor or IDE also support regexp in its Find/Replace functionality.
Because KiCad uses wxWidgets as a foundation, so all regexp that KiCad can support is referenced at wxWidgets documentation
I’ll demonstrate it with my DDR design.
I used hierarchical sheets to manage my schematic blocks, and it is useful for block reuse.
Schematic Hierarchy
DDR Chips sheet includes two DDR4 chips:
The two DDR sheets ( chips ) are instances of a single hierarchical sheet:
Here is the actual DDR memory chip symbol (excluded Power domain part)
Net Classes
Before starting routing, we need to define proper netclasses:
Note that: I used default values in all netclasses. That is because according to results of impedance calculator from JLC or nextpcb, the values (track width, clearance, DP width, etc) are different among different layers ( basically outer layers or inner layers), I’ll use custom design rules ( may be described in my next article) to set different values for different layers.
Clock lines
DDR clock lines are differential impedance of 100 ohm. Their net names are: /DDR/DDR4_CLK_N
and /DDR/DDR4_CLK_P
.
The full path of net names can be obtained through click the net label in Schematic Editor (eeschema):
For filter pattern, the simplest method is wildcard, that is, * (star) for zero or any characters:
? (question mark) for one any character:
Or we can use regexp to do a precise pattern match:
Here [NP] means this character is either N or P.
For clock lines, it is in fact no potential differences between wildcard or regexp method. But it is important not to mix use wildcard and regexp together in one pattern.
Let’s see other signal lines.
Address Lines
The prefix of address lines are same to clock lines. The suffix is from A0 to A16, where A14, A15, A16 are multiplexing lines with additional suffixes. For address lines alone, we can use either wildcard or regexp method, but for a more complex use cases, we use regexp method here.
A[0–9] means A0, A1, A2 … A9, here we only have one digit. For multiple digits, we can use + (plus sign):
Plus sign + means one or more characters as previous pattern ( note: the previous pattern is one character from 0 to 9): 00 to 09, 10 to 19, …, 90 to 99, 000 to 009, 010, to 019, … , 990, to 999.
Note here, the pattern does not match A14, A15, A16, we can use a simple .* pattern ( dot . means any character, star * means zero or more characters of previous pattern ( here is dot ) ):
Now we matched all address lines.
Control lines
There are two lines BA0 and BA1. We can write a single pattern:
But these two lines are similar to address lines, we can use ? (question mark, there is or not, don’t mix wildcard and regex together.) to combine two patterns:
There is another BG0 line, we can use [] (any one of these characters) again to combine it into previous pattern:
There is an ODT0 line, we can write a single pattern or use () (group) and | (logic or) to combine it into previous pattern:
Here, B?[AG] is one group, ODT is another group, they are separated by () and combined with |.
There are nACT and nCS0 (actual text is ~{ACT} and ~{CS0})
We add a new group:
Be careful with matched pairs of (), syntax error will fail the match. New learner can write separated patterns first.
When we get familiar with regex, we can use it also in net inspector:
It supports to use , (comma) to separate multiple groups:
But for now, KiCad Net Inspector doesn’t support manage groups ( name, edit them separately ). And KiCad doesn’t support save these patterns between restarts of KiCad, it is fixed since my Merge Request #17949. It is merged to master already, but not merged to stable release branch as of this writing.
Welcome to subscribe my Youtube Channel: youtube.com/@qdiotpi