Logic IC Similarity Calculator Skill
Guidance for working with LogicICSimilarityCalculator in the lib-electronic-components library.
For metadata-driven similarity architecture, see /similarity-metadata:
- SpecImportance levels (CRITICAL, HIGH, MEDIUM, LOW, OPTIONAL)
- ToleranceRule types (exactMatch, percentageTolerance, minimumRequired, etc.)
- SimilarityProfile contexts (DESIGN_PHASE, REPLACEMENT, COST_OPTIMIZATION, etc.)
- Calculator integration patterns and gotchas
Overview
The LogicICSimilarityCalculator compares logic ICs based on:
- Logic function - NAND, NOR, NOT, AND, OR, flip-flops, etc.
- Technology family - LS, ALS, HC, HCT, F, etc.
- Part number series - 74xx vs CD4000
Applicable Types
ComponentType.LOGIC_IC
ComponentType.LOGIC_IC_NEXPERIA
ComponentType.LOGIC_IC_DIODES
ComponentType.IC // Generic IC type also supported
Returns false for null type.
Similarity Thresholds
HIGH_SIMILARITY = 0.9; // Same function, compatible technology
MEDIUM_SIMILARITY = 0.5; // Related parts
LOW_SIMILARITY = 0.3; // Different functions
74xx Series
Technology Families (Interchangeable within groups)
| Family |
Speed |
Power |
Compatible With |
| LS |
Fast |
Low |
ALS, F, HC, HCT |
| ALS |
Faster |
Lower |
LS, F, HC, HCT |
| F |
Fast |
Medium |
LS, ALS, HC, HCT |
| HC |
Fast |
Very Low |
LS, ALS, F, HCT |
| HCT |
Fast |
Very Low |
LS, ALS, F, HC |
// Compatible technologies = HIGH
calculator.calculateSimilarity("74LS00", "74HC00", registry);
// Returns 0.9
calculator.calculateSimilarity("74LS04", "74ALS04", registry);
// Returns 0.9
Function Groups
| Function |
Part Numbers |
| NAND Gates |
00, 10, 20, 30, 40 |
| NOR Gates |
02, 12, 22, 32, 42 |
| Inverters |
04, 14, 24, 34, 44 |
| AND Gates |
08, 18, 28, 38, 48 |
| OR Gates |
32, 42 |
| Flip-Flops |
73, 74, 75, 76, 77, 78 |
| Multiplexers |
151, 153, 157, 158 |
| Decoders |
138, 139, 154, 155 |
// Different functions = LOW
calculator.calculateSimilarity("74LS00", "74LS74", registry);
// Returns 0.3 (NAND vs Flip-Flop)
CD4000 CMOS Series
Common CD4000 Parts
| Part |
Function |
| CD4001 |
Quad 2-input NOR |
| CD4011 |
Quad 2-input NAND |
| CD4013 |
Dual D flip-flop |
| CD4017 |
Decade counter |
| CD4040 |
12-bit binary counter |
| CD4051 |
8-channel mux |
| CD4066 |
Quad bilateral switch |
CD4000 Package Codes
| Suffix |
Package |
| BE |
PDIP (plastic) |
| BM |
SOIC |
| UBE |
Unbuffered PDIP |
| N, P |
DIP variants |
| DG, PW, DR |
SMD variants |
// Same CD4000 IC, different package = HIGH
calculator.calculateSimilarity("CD4001BE", "CD4001BM", registry);
// Returns 0.9
// Different CD4000 ICs = LOW
calculator.calculateSimilarity("CD4001BE", "CD4011BE", registry);
// Returns 0.3
Cross-Series Comparison
74xx and CD4000 are generally not interchangeable:
// 74xx vs CD4000 with same function
calculator.calculateSimilarity("74HC00", "CD4011BE", registry);
// Returns LOW (different series, even if same function)
Test Examples
// Same 74xx, compatible technologies
calculator.calculateSimilarity("74LS00", "74HC00", registry);
// Returns 0.9
// Same CD4000 IC, different package
calculator.calculateSimilarity("CD4001BE", "CD4001BM", registry);
// Returns 0.9
// Same function group in 74xx
calculator.calculateSimilarity("74LS04", "74ALS04", registry);
// Returns 0.9
// Different functions
calculator.calculateSimilarity("74LS00", "74LS74", registry);
// Returns 0.3
Learnings & Quirks
74xx Part Number Structure
74 LS 04 N
│ │ │ │
│ │ │ └── Package (N=DIP)
│ │ └───── Function (04=Inverter)
│ └──────── Technology (LS=Low-power Schottky)
└─────────── Series prefix
CD4000 Part Number Structure
CD 4001 BE
│ │ │
│ │ └── Package (BE=Plastic DIP)
│ └─────── Function number
└────────── Series prefix
Metadata-Driven Implementation (January 2026)
Status: ✅ Converted (PR #119)
The LogicICSimilarityCalculator now uses a metadata-driven approach with spec-based comparison.
Specs Compared
| Spec |
Importance |
Tolerance Rule |
Description |
| function |
CRITICAL |
exactMatch |
NAND, NOR, NOT, AND, OR, flip-flop, etc. |
| series |
HIGH |
exactMatch |
74xx vs CD4000 |
| technology |
MEDIUM |
exactMatch |
LS, HC, HCT, ALS, F, etc. |
| package |
LOW |
exactMatch |
N, D, P, PW, etc. |
Implementation Pattern
// Short-circuit check for CRITICAL incompatibility
if (!function1.isEmpty() && !function2.isEmpty() && !areSameFunction(mpn1, mpn2)) {
return LOW_SIMILARITY;
}
// Short-circuit for series incompatibility (74xx vs CD4000)
if (!series1.isEmpty() && !series2.isEmpty() && !series1.equals(series2)) {
return 0.0;
}
// Extract function from both 74xx and CD4000 series
private String extractFunction(String mpn) {
if (mpn.matches("^CD4.*")) {
// CD4001 → "001", CD4011 → "011"
return cmosPatternMatcher.group(1);
}
// 74LS00 → "00", 74HC138 → "138"
return ttlPatternMatcher.group(3);
}
Behavior Changes
| Comparison |
Legacy Result |
Metadata Result |
Notes |
| 74LS00 vs 74HC00 |
0.9 |
0.88 |
Compatible technologies |
| CD4001BE vs CD4001BM |
0.9 |
0.96 |
Same IC, different package |
| CD4001 vs CD4011 |
0.3 |
0.3 |
Short-circuit on function |
| 74LS00 vs CD4001 |
undefined |
0.0 |
Short-circuit on series |
Why more accurate: Metadata approach correctly handles both 74xx and CD4000 series, with series check preventing false matches.
Technology Compatibility Notes
- HC is CMOS, LS is TTL - but they're voltage compatible at 5V
- HCT is specifically designed for TTL compatibility
- 74LVC series is for 3.3V operation
Function Group Patterns
- The 2-digit function number after technology code determines function
- Same function number = same function across technologies
1---2name: similarity-logic3description: Use when working with logic IC similarity calculations - comparing 74xx series, CD4000 CMOS, technology families (LS, HC, HCT), function groups (NAND, NOR, flip-flops), or logic IC-specific similarity logic.4---5
6# Logic IC Similarity Calculator Skill
7
8Guidance for working with `LogicICSimilarityCalculator` in the lib-electronic-components library.
9
10---
11
12**For metadata-driven similarity architecture**, see `/similarity-metadata`:
13- SpecImportance levels (CRITICAL, HIGH, MEDIUM, LOW, OPTIONAL)
14- ToleranceRule types (exactMatch, percentageTolerance, minimumRequired, etc.)
15- SimilarityProfile contexts (DESIGN_PHASE, REPLACEMENT, COST_OPTIMIZATION, etc.)
16- Calculator integration patterns and gotchas
17
18---
19
20## Overview
21
22The `LogicICSimilarityCalculator` compares logic ICs based on:
23- **Logic function** - NAND, NOR, NOT, AND, OR, flip-flops, etc.
24- **Technology family** - LS, ALS, HC, HCT, F, etc.
25- **Part number series** - 74xx vs CD4000
26
27## Applicable Types
28
29```java
30ComponentType.LOGIC_IC
31ComponentType.LOGIC_IC_NEXPERIA
32ComponentType.LOGIC_IC_DIODES
33ComponentType.IC // Generic IC type also supported
34```
35
36Returns `false` for `null` type.
37
38## Similarity Thresholds
39
40```java
41HIGH_SIMILARITY = 0.9; // Same function, compatible technology
42MEDIUM_SIMILARITY = 0.5; // Related parts
43LOW_SIMILARITY = 0.3; // Different functions
44```
45
46## 74xx Series
47
48### Technology Families (Interchangeable within groups)
49| Family | Speed | Power | Compatible With |
50|--------|-------|-------|-----------------|
51| LS | Fast | Low | ALS, F, HC, HCT |
52| ALS | Faster | Lower | LS, F, HC, HCT |
53| F | Fast | Medium | LS, ALS, HC, HCT |
54| HC | Fast | Very Low | LS, ALS, F, HCT |
55| HCT | Fast | Very Low | LS, ALS, F, HC |
56
57```java
58// Compatible technologies = HIGH
59calculator.calculateSimilarity("74LS00", "74HC00", registry);
60// Returns 0.9
61
62calculator.calculateSimilarity("74LS04", "74ALS04", registry);
63// Returns 0.9
64```
65
66### Function Groups
67| Function | Part Numbers |
68|----------|--------------|
69| NAND Gates | 00, 10, 20, 30, 40 |
70| NOR Gates | 02, 12, 22, 32, 42 |
71| Inverters | 04, 14, 24, 34, 44 |
72| AND Gates | 08, 18, 28, 38, 48 |
73| OR Gates | 32, 42 |
74| Flip-Flops | 73, 74, 75, 76, 77, 78 |
75| Multiplexers | 151, 153, 157, 158 |
76| Decoders | 138, 139, 154, 155 |
77
78```java
79// Different functions = LOW
80calculator.calculateSimilarity("74LS00", "74LS74", registry);
81// Returns 0.3 (NAND vs Flip-Flop)
82```
83
84## CD4000 CMOS Series
85
86### Common CD4000 Parts
87| Part | Function |
88|------|----------|
89| CD4001 | Quad 2-input NOR |
90| CD4011 | Quad 2-input NAND |
91| CD4013 | Dual D flip-flop |
92| CD4017 | Decade counter |
93| CD4040 | 12-bit binary counter |
94| CD4051 | 8-channel mux |
95| CD4066 | Quad bilateral switch |
96
97### CD4000 Package Codes
98| Suffix | Package |
99|--------|---------|
100| BE | PDIP (plastic) |
101| BM | SOIC |
102| UBE | Unbuffered PDIP |
103| N, P | DIP variants |
104| DG, PW, DR | SMD variants |
105
106```java
107// Same CD4000 IC, different package = HIGH
108calculator.calculateSimilarity("CD4001BE", "CD4001BM", registry);
109// Returns 0.9
110
111// Different CD4000 ICs = LOW
112calculator.calculateSimilarity("CD4001BE", "CD4011BE", registry);
113// Returns 0.3
114```
115
116## Cross-Series Comparison
117
11874xx and CD4000 are generally not interchangeable:
119
120```java
121// 74xx vs CD4000 with same function
122calculator.calculateSimilarity("74HC00", "CD4011BE", registry);
123// Returns LOW (different series, even if same function)
124```
125
126## Test Examples
127
128```java
129// Same 74xx, compatible technologies
130calculator.calculateSimilarity("74LS00", "74HC00", registry);
131// Returns 0.9
132
133// Same CD4000 IC, different package
134calculator.calculateSimilarity("CD4001BE", "CD4001BM", registry);
135// Returns 0.9
136
137// Same function group in 74xx
138calculator.calculateSimilarity("74LS04", "74ALS04", registry);
139// Returns 0.9
140
141// Different functions
142calculator.calculateSimilarity("74LS00", "74LS74", registry);
143// Returns 0.3
144```
145
146---
147
148## Learnings & Quirks
149
150### 74xx Part Number Structure
151```
15274 LS 04 N
153│ │ │ │
154│ │ │ └── Package (N=DIP)
155│ │ └───── Function (04=Inverter)
156│ └──────── Technology (LS=Low-power Schottky)
157└─────────── Series prefix
158```
159
160### CD4000 Part Number Structure
161```
162CD 4001 BE
163│ │ │
164│ │ └── Package (BE=Plastic DIP)
165│ └─────── Function number
166└────────── Series prefix
167```
168
169## Metadata-Driven Implementation (January 2026)
170
171**Status**: ✅ Converted (PR #119)
172
173The `LogicICSimilarityCalculator` now uses a **metadata-driven approach** with spec-based comparison.
174
175### Specs Compared
176
177| Spec | Importance | Tolerance Rule | Description |
178|------|-----------|----------------|-------------|
179| **function** | CRITICAL | exactMatch | NAND, NOR, NOT, AND, OR, flip-flop, etc. |
180| **series** | HIGH | exactMatch | 74xx vs CD4000 |
181| **technology** | MEDIUM | exactMatch | LS, HC, HCT, ALS, F, etc. |
182| **package** | LOW | exactMatch | N, D, P, PW, etc. |
183
184### Implementation Pattern
185
186```java
187// Short-circuit check for CRITICAL incompatibility
188if (!function1.isEmpty() && !function2.isEmpty() && !areSameFunction(mpn1, mpn2)) {
189 return LOW_SIMILARITY;
190}
191
192// Short-circuit for series incompatibility (74xx vs CD4000)
193if (!series1.isEmpty() && !series2.isEmpty() && !series1.equals(series2)) {
194 return 0.0;
195}
196
197// Extract function from both 74xx and CD4000 series
198private String extractFunction(String mpn) {
199 if (mpn.matches("^CD4.*")) {
200 // CD4001 → "001", CD4011 → "011"
201 return cmosPatternMatcher.group(1);
202 }
203 // 74LS00 → "00", 74HC138 → "138"
204 return ttlPatternMatcher.group(3);
205}
206```
207
208### Behavior Changes
209
210| Comparison | Legacy Result | Metadata Result | Notes |
211|-----------|--------------|-----------------|-------|
212| 74LS00 vs 74HC00 | 0.9 | 0.88 | Compatible technologies |
213| CD4001BE vs CD4001BM | 0.9 | 0.96 | Same IC, different package |
214| CD4001 vs CD4011 | 0.3 | 0.3 | Short-circuit on function |
215| 74LS00 vs CD4001 | undefined | 0.0 | Short-circuit on series |
216
217**Why more accurate**: Metadata approach correctly handles both 74xx and CD4000 series, with series check preventing false matches.
218
219---
220
221### Technology Compatibility Notes
222- HC is CMOS, LS is TTL - but they're voltage compatible at 5V
223- HCT is specifically designed for TTL compatibility
224- 74LVC series is for 3.3V operation
225
226### Function Group Patterns
227- The 2-digit function number after technology code determines function
228- Same function number = same function across technologies
229
230<!-- Add new learnings above this line -->