Skip to content

Instantly share code, notes, and snippets.

@rbarzic
rbarzic / read_text_file.py
Created February 25, 2015 19:59
Reading a file line by line in python (with argument)
#!/usr/bin/env python
import argparse
def get_args():
"""
Get command line arguments
"""
parser = argparse.ArgumentParser(description="""
@rbarzic
rbarzic / simple_gui1.py
Created May 5, 2015 12:05
A simple PtQt app
import sys
from PyQt4 import QtGui, QtCore
class SimpleGui(QtGui.QWidget):
"""
A simple PyQT gui example
"""
def __init__(self):
@rbarzic
rbarzic / gist:37c254d12f7cc4c5d997
Created June 18, 2015 07:06
getting stack pointer value from C using gcc
inline uint32_t get_stack_pointer(void) {
uint32_t sp;
asm("mov %0,sp" : "=r"(sp));
return sp;
}
@rbarzic
rbarzic / gist:ec8f0264f49067224a70
Created September 9, 2015 12:32
Checkout xsd file for spirit/IP-XACT
wget -r -A.xsd -l1 http://www.spiritconsortium.org/images/xmlschema/ipxact/1685-2014 -P ip-xact -nH -nd
@rbarzic
rbarzic / clang_def.sh
Created October 12, 2015 13:24
clang pre defined stuff
echo | clang -target arm-none-eabi -ffreestanding -dM -E -
@rbarzic
rbarzic / icg.v
Created October 5, 2016 06:49
Integrated clock gating cell, Code from "Low Power Design Methodologies and Flows"
// Integrated clock gating cell
// Code from "Low Power Design Methodologies and Flows"
module icg(/*AUTOARG*/
// Outputs
gclk,
// Inputs
en, clk
);
input en;
input clk;
@rbarzic
rbarzic / gist:809f3426dc65c82ae928cd5c325844a1
Created October 21, 2016 09:27
Python Xml to Dict & Dict to XML
#!/usr/bin/env python
from xml.etree import ElementTree as ET
import pprint as pp
import argparse
from collections import defaultdict
# From http://stackoverflow.com/questions/2148119/how-to-convert-an-xml-string-to-a-dictionary-in-python/10077069#10077069
def etree_to_dict(t):
d = {t.tag: {} if t.attrib else None}
# http://rightfootin.blogspot.fr/2006/09/more-on-python-flatten.html
def flatten(l, ltypes=(list, tuple)):
ltype = type(l)
l = list(l)
i = 0
while i < len(l):
while isinstance(l[i], ltypes):
if not l[i]:
l.pop(i)
i -= 1
CPP = g++
CPPFLAGS = -Wall -pedantic -O2 -g -c
SOURCES := ${wildcard *.cpp}
OBJECTS := ${SOURCES:.cpp=.o}
.PHONY: all clean
.SUFFIXES: .cpp .o
emacs_auto:
emacs --batch $(V_FILE) -f verilog-batch-auto -f whitespace-cleanup -f verilog-indent-buffer -f save-buffer
emacs --batch $(C_FILE) -f whitespace-cleanup -f verilog-indent-buffer -f save-buffer
emacs --batch $(C_FILE) --eval '(indent-region (point-min) (point-max) nil)' -f save-buffer