TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
names.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Name conventions used to recognise parts and nets (doc 15 ยง3.1): reference letters, power and ground net
4// names, natural sort of references, component values. Pure string functions, no board access.
5#include <cstdint>
6#include <optional>
7#include <string>
8#include <string_view>
9
10namespace tmk::crules {
11
12std::string upper(std::string_view s);
13std::string lower(std::string_view s);
14// Leading letters of a reference, upper case: "C12" -> "C", "IC3" -> "IC", "FB1" -> "FB", "REF**" -> "REF".
15std::string ref_letters(std::string_view ref);
16// Natural order of references: "C2" < "C10" < "D1"; ties broken by plain string comparison.
17bool natural_less(std::string_view a, std::string_view b);
18// The last hierarchical component of a net name: "/mcu/XTAL_IN" -> "XTAL_IN".
19std::string_view net_leaf(std::string_view name);
20
21// Supply-like net names (+3V3, VCC, VDD_IO, 5V, VBUS, GND, ...), including grounds. Decision D25's test, shared
22// with the placer (place::power_like_name forwards here).
23bool power_like_name(std::string_view name);
24bool ground_like_name(std::string_view name);
25// Analog supplies, references and core-regulator outputs that power_like_name misses (VREF, AREF, VCAP, ...).
26bool analog_supply_name(std::string_view name);
27
28// Voltage in millivolts from a supply name: "+5V" 5000, "3V3" 3300, "+3.3V" 3300, "1V8" 1800, "VCC_12V" 12000.
29std::optional<int> net_millivolts(std::string_view name);
30// Capacitance in picofarads from a value field: "100nF" 100000, "4u7" 4700000, "10uF/16V" 10000000, "22p" 22.
31std::optional<std::int64_t> capacitance_pf(std::string_view value);
32
33} // namespace tmk::crules
std::optional< int > net_millivolts(std::string_view name)
Voltage in millivolts from a supply name: "+5V" 5000, "3V3" 3300, "+3.3V" 3300, "1V8" 1800,...
bool ground_like_name(std::string_view name)
std::optional< std::int64_t > capacitance_pf(std::string_view value)
Capacitance in picofarads from a value field: "100nF" 100000, "4u7" 4700000, "10uF/16V" 10000000,...
std::string ref_letters(std::string_view ref)
Leading letters of a reference, upper case: "C12" -> "C", "IC3" -> "IC", "FB1" -> "FB",...
std::string lower(std::string_view s)
std::string upper(std::string_view s)
std::string_view net_leaf(std::string_view name)
The last hierarchical component of a net name: "/mcu/XTAL_IN" -> "XTAL_IN".
bool natural_less(std::string_view a, std::string_view b)
Natural order of references: "C2" < "C10" < "D1"; ties broken by plain string comparison.
bool analog_supply_name(std::string_view name)
Analog supplies, references and core-regulator outputs that power_like_name misses (VREF,...
bool power_like_name(std::string_view name)
Supply-like net names (+3V3, VCC, VDD_IO, 5V, VBUS, GND, ...), including grounds.