Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
akrinke committed Apr 22, 2015
1 parent 8a8a050 commit aee50cf
Show file tree
Hide file tree
Showing 4 changed files with 220 additions and 1 deletion.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Workgroup for Electronic Design Automation
Copyright (c) 2015 Andreas Krinke <[email protected]>, http://www.ifte.de

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
62 changes: 62 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
guLF - Gate Size Updater for Logic Friday
=========================================

guLF allows to change the gate sizes used by Logic Friday during gate diagram
synthesis.

Introduction
------------

Logic Friday (http://sontrak.com/) is a very good and easy-to-use tool for
logic optimization, analysis, and synthesis. It uses espresso for logic
function minimization and misII for gate diagram synthesis.

While it supports the optimization of the die area during gate diagram
synthesis, the size of the individual logic gates is fixed and can not be
changed by the user.

guLF allows to change these gate sizes using a simple GUI.

![guLF](https://ifte-eda.github.io/guLF/guLF.png)

How does it work?
-----------------

For gate diagram synthesis, Logic Friday calls the external program misII and
passes a pre-defined gate library containing all gate sizes. guLF wraps misII
and changes the sizes in the gate library prior to executing the original misII
binary.

Building
--------

Requirement: Python, pyinstaller (http://www.pyinstaller.org/)

In the directory of misII.py and guLF.py run:
```
> pyinstaller.exe misII.py
> pyinstaller.exe --noconsole guLF.py
```

These commands create the directories dist/misII and dist/guLF. All files in
dist/misII have to be copied to the directory misii in Logic Friday's
installation directory (**do not overwrite misII.exe**). The second directory
dist/guLF contains all files of the graphical editor (see next section).

Installation
------------

1. Download and install Logic Friday (http://sontrak.com)
2. Go to its installation directory (default: `C:\Program Files (x86)\Logic Friday 1`)
3. Change to directory misii and rename misII.exe to misII-orig.exe
3. Copy all files from directory misII (that comes with guLF) here

The graphical editor guLF does not need to be installed. Just run guLF.exe.

Usage
-----

Use guLF.exe to set the gate sizes. In Logic Friday, choose "Map to Gates" and
select all gate types you want to use. Finally, choose "Die Area" as
optimization type.

83 changes: 83 additions & 0 deletions guLF.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python
import ConfigParser
import os
import Tkinter as tk

class Application(tk.Frame):
def __init__(self, master=None):
self.configPath = os.environ['APPDATA'] + '\\Logic Friday\\gate-sizes.ini'
self.config = ConfigParser.RawConfigParser()
self.config.read(self.configPath)
self.gates = ['Inverter',
'2-In NAND', '3-In NAND', '4-In NAND',
'2-In NOR', '3-In NOR', '4-In NOR',
'2-In XOR',
'2-In MUX',
'2-In AND', '3-In AND', '4-In AND',
'2-In OR', '3-In OR', '4-In OR']
tk.Frame.__init__(self, master)
self.grid(sticky=tk.NSEW, padx=5, pady=5)
self.createWidgets()

def createWidgets(self):
top = self.winfo_toplevel()
top.rowconfigure(0, weight=1)
top.columnconfigure(0, weight=1)
#self.rowconfigure(0, weight=1)
self.columnconfigure(1, weight=1)
lbl = tk.Label(self, text='Size')
lbl.grid(row=0, column=1)
self.entries = []
i=1
validateEntryCommand = self.register(self.validateEntry)
for gate in self.gates:
self.rowconfigure(i, weight=1)
lbl = tk.Label(self, text=gate+':')
lbl.grid(row=i, sticky=tk.E)
e = tk.Entry(self, width=10,
validate='all', validatecommand=(validateEntryCommand, '%P'))
iniLabel = gate.replace(' ', '_')
if self.config.has_option('Gate Sizes', iniLabel):
value = self.config.getfloat('Gate Sizes', iniLabel)
else:
value = 0
# ignore decimal places that are zero
value = "%g"%value
e.insert(0, value)
e.grid(row=i, column=1, sticky=tk.EW, padx=10, pady=5)
self.entries.append(e)
i=i+1

frame = tk.Frame()
frame.grid(row=i, column=0, columnspan=2)
self.saveBtn = tk.Button(frame, text='OK', width=10,
command = self.save)
self.saveBtn.grid(row=0, column=0, pady=10, padx=5)
cancelBtn = tk.Button(frame, text='Cancel', width=10,
command = self.quit)
cancelBtn.grid(row=0, column=1, pady=10, padx=5)

def validateEntry(self, newValue):
if newValue == "":
return True
try:
float(newValue)
return True
except:
return False

def save(self):
# don't use ConfigParser to retain order of keys
with open(self.configPath, 'w') as f:
f.write('[Gate Sizes]\n')
for i in range(len(self.entries)):
label = self.gates[i].replace(' ', '_')
value = self.entries[i].get()
if value == "":
value = "0"
f.write('%s = %s\n'%(label, value))
self.quit()

app = Application()
app.master.title('guLF')
app.mainloop()
74 changes: 74 additions & 0 deletions misII.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import ConfigParser
import os
import re
import subprocess
import sys

mapping = {
'inv1' : 'Inverter',
'mux2' : '2-In_MUX',
'or2' : '2-In_OR',
'or3' : '3-In_OR',
'or4' : '4-In_OR',
'and2' : '2-In_AND',
'and3' : '3-In_AND',
'and4' : '4-In_AND',
'exor2': '2-In_XOR',
'nor2' : '2-In_NOR',
'nor3' : '3-In_NOR',
'nor4' : '4-In_NOR',
'nand2': '2-In_NAND',
'nand3': '3-In_NAND',
'nand4': '4-In_NAND'
}

conf_dir = os.environ['APPDATA'] + '\\Logic Friday'
userlib = conf_dir + '\\user.genlib'
sizelib = conf_dir + '\\gate-sizes.ini'

try:
f = open(sizelib)
f.close()
except IOError:
with open(sizelib, "w") as f:
# save default sizes
f.write("""\
[Gate Sizes]
Inverter = 1
2-In_NAND = 2
3-In_NAND = 3
4-In_NAND = 4
2-In_NOR = 2
3-In_NOR = 3
4-In_NOR = 4
2-In_XOR = 5.5
2-In_MUX = 4
2-In_AND = 2
3-In_AND = 2
4-In_AND = 2
2-In_OR = 2
3-In_OR = 3
4-In_OR = 4
""")

config = ConfigParser.RawConfigParser()
config.read(sizelib)

with open(userlib) as f:
lib = f.read()

for src, dst in mapping.items():
if config.has_option('Gate Sizes', dst):
size = config.getfloat('Gate Sizes', dst)
size = '%g'%size
else:
size = "0"
lib = re.sub(r'( %s\t)[\d\.]+'%src, r'\g<1>%s'%size, lib)

with open(userlib, 'w') as f:
f.write(lib)

sys.argv[0] = "misII-orig"

process = subprocess.call(sys.argv)
sys.exit(process)

0 comments on commit aee50cf

Please sign in to comment.