aboutsummaryrefslogtreecommitdiff
path: root/src/ee/souffle/kicad.dl
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/souffle/kicad.dl')
-rw-r--r--src/ee/souffle/kicad.dl147
1 files changed, 112 insertions, 35 deletions
diff --git a/src/ee/souffle/kicad.dl b/src/ee/souffle/kicad.dl
index ed9bf4a..3df801f 100644
--- a/src/ee/souffle/kicad.dl
+++ b/src/ee/souffle/kicad.dl
@@ -4,49 +4,81 @@
.decl add_fact(part_uri:symbol, key:symbol, value:symbol)
.output add_fact
-/*
-.decl is_resistor(uri:symbol)
-.decl is_capacitor(uri:symbol)
-.decl is_inductor(uri:symbol)
+// ---------------------------------------------------------------------------------------------------------------------
+// Resistor rules
-is_resistor(Ref) :-
+.decl resistor_symbol(lib:symbol, name:symbol)
+
+.decl resistor_lib(lib:symbol)
+resistor_lib("Resistor_SMD").
+resistor_lib("Resistor_THT").
+
+.decl resistor(uri:symbol)
+
+resistor(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib),
resistor_lib(lib).
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib).
-is_capacitor(Ref) :-
- capacitor_lib(lib).
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib).
+resistor(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name),
+ resistor_symbol(lib, name).
-is_inductor(Ref) :-
- inductor_lib(lib).
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib).
-*/
+add_fact(Part, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#resistor") :-
+ resistor(Part).
-.decl resistor_lib(name:symbol)
-resistor_lib("Resistor_SMD").
-resistor_lib("Resistor_THT").
+// ---------------------------------------------------------------------------------------------------------------------
+// Capacitor rules
-.decl capacitor_lib(name:symbol)
+.decl capacitor_symbol(lib:symbol, name:symbol)
+
+.decl capacitor_lib(lib:symbol)
capacitor_lib("Capacitor_SMD").
-.decl inductor_lib(name:symbol)
+.decl capacitor(uri:symbol)
+
+capacitor(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib),
+ capacitor_lib(lib).
+
+capacitor(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name),
+ capacitor_symbol(lib, name).
+
+add_fact(Part, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#capacitor") :-
+ capacitor(Part).
+
+// ---------------------------------------------------------------------------------------------------------------------
+// Inductor rules
+
+.decl inductor_symbol(lib:symbol, name:symbol)
+
+.decl inductor_lib(lib:symbol)
inductor_lib("Inductor_SMD").
-add_fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#resistor") :-
- resistor_lib(lib),
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib).
+.decl inductor(uri:symbol)
+
+inductor(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib),
+ inductor_lib(lib).
+
+inductor(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name),
+ inductor_symbol(lib, name).
-add_fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#capacitor") :-
- capacitor_lib(lib),
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib).
+add_fact(Part, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#inductor") :-
+ inductor(Part).
-add_fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#inductor") :-
- inductor_lib(lib),
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#footprint-library", lib).
+// ---------------------------------------------------------------------------------------------------------------------
+// Net tie rules
// Net ties and test points should probably not be marked as components to buy. Test points is possible to buy and
// install so that needs to be an option.
+.decl net_tie_lib(lib:symbol)
+
.decl net_tie_symbol(lib:symbol, name:symbol)
net_tie_symbol("Device", "Net-Tie_2").
net_tie_symbol("Device", "Net-Tie_3").
@@ -54,10 +86,24 @@ net_tie_symbol("Device", "Net-Tie_3_Tee").
net_tie_symbol("Device", "Net-Tie_4").
net_tie_symbol("Device", "Net-Tie_4_Cross").
-add_fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#net-tie") :-
- net_tie_symbol(lib, name),
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name).
+.decl net_tie(uri:symbol)
+
+net_tie(Part) :-
+ net_tie_lib(lib),
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib).
+
+net_tie(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name),
+ net_tie_symbol(lib, name).
+
+add_fact(Part, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#net-tie") :-
+ net_tie(Part).
+
+// ---------------------------------------------------------------------------------------------------------------------
+// Test point rules
+
+.decl test_point_lib(lib:symbol)
.decl test_point_symbol(lib:symbol, name:symbol)
test_point_symbol("Connector", "TestPoint").
@@ -66,7 +112,38 @@ test_point_symbol("Connector", "TestPoint_Alt").
test_point_symbol("Connector", "TestPoint_Flag").
test_point_symbol("Connector", "TestPoint_Probe").
-add_fact(Ref, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#test-point") :-
- test_point_symbol(lib, name),
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
- fact(Ref, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name).
+.decl test_point(uri:symbol)
+
+test_point(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ test_point_lib(lib).
+
+test_point(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name),
+ test_point_symbol(lib, name).
+
+add_fact(Part, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#test-point") :-
+ test_point(Part).
+
+// ---------------------------------------------------------------------------------------------------------------------
+// Mounting hole rules
+
+.decl mounting_hole_lib(lib:symbol)
+
+.decl mounting_hole_symbol(lib:symbol, name:symbol)
+mounting_hole_symbol("Mechanical", "MountingHole").
+
+.decl mounting_hole(uri:symbol)
+
+mounting_hole(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ mounting_hole_lib(lib).
+
+mounting_hole(Part) :-
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-library", lib),
+ fact(Part, "http://purl.org/ee/kicad-sch-fact-type#symbol-name", name),
+ mounting_hole_symbol(lib, name).
+
+add_fact(Part, "http://purl.org/ee/fact-type/ee-component-type", "http://purl.org/ee/part-type#mounting-hole") :-
+ mounting_hole(Part).