-
Notifications
You must be signed in to change notification settings - Fork 2
/
integrateSingleGates.py
52 lines (39 loc) · 1.54 KB
/
integrateSingleGates.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os, sys
from pkg_resources import resource_string
from scoville.eagleSchematic import EagleSchematic
from scoville.eagleBoard import EagleBoard
def getSchematic(schematicFilename):
schematicSource = resource_string('hw', schematicFilename + ".sch")
return EagleSchematic(schematicSource)
def getBoard(boardFilename):
boardSource = resource_string('hw', boardFilename + ".brd")
return EagleBoard(boardSource)
def saveResult(data, filename):
file = open(filename, "w")
file.write(data.toString())
file.close()
partReplacements = {
("XOR", "XOR"): "XOR",
("OR", "OR"): "OR",
("AND", "AND"): "AND",
("NAND", "NAND"): "NAND",
("NOT", "NOT-VERTICAL"): "NOT-A",
("NOT", "NOT-HORIZONTAL"): "NOT-B",
("1_BIT_SELECT", "SELECTOR-2-LANE-NOMUX"): "1-BitSelect",
("8_BIT_SELECT", "SELECTOR-8_BIT-NOMUX"): "3-BitSelect",
("7_VAL_SELECT", "SELECTOR-7_BIT-NOMUX"): "7-InputSelect",
("LEDDRIVER", "LEDDRIVER"): "LEDWithDriver",
}
if __name__ == '__main__':
sys.path.insert(0, os.getcwd())
schematic = getSchematic('composites/alu_slice')
board = getBoard('composites/alu_slice')
for key in partReplacements.keys():
(deviceSet, packageName) = key
filename = partReplacements[key]
replacementSchematic = getSchematic('singleGates/minimal/' + filename)
replacementBoard = getBoard('singleGates/minimal/' + filename)
schematic.replace(deviceSet, replacementSchematic)
board.replaceByPackage(packageName, replacementBoard)
saveResult(schematic, "build/alu_slice.sch")
saveResult(board, "build/alu_slice.brd")