Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cr1901
cr1901 / get_csrs.py
Last active August 26, 2015 19:44
Migen BankArray
class YMScope(Module, AutoCSR):
def __init__(self, cpu_core, device_to_test):
self.submodules.stop_cpu = CSRStorage(8)
# Will not actually generate a bank... BankArray doesn't actually
# check whether the object passed in has a get_csrs method.
# BankArray only checks whether the object's attributes have a get_csr
# method. Why is that?
# MiSoC's SoC class inherits from AutoCSR, but calling csrgen.BankArray succeeds- BankArray
# detects the SoC's get_csrs function. What am I doing wrong?
self.submodules.csrbankarray = csrgen.BankArray(self, mem_map, data_width=8, address_width=16)
@cr1901
cr1901 / ddtemplate.m4
Created June 16, 2014 06:20
ddrescue command generator
define(`LQ',`changequote(<,>)`dnl'
changequote`'')dnl
define(`RQ',`changequote(<,>)dnl`
'changequote`'')dnl
# m4 -DSRCDRV=$1 -DDESTDIR=$2 -DIMGNAME=$3 -DLOGNAME=$4 ddtemplate > $2/rescue.sh;
if [ -e curr_phase_`'DESTDIR ]; then
CURR_PHASE=`'LQ()`'cat curr_phase_`'DESTDIR`'`'LQ()`'
else
CURR_PHASE=1
@cr1901
cr1901 / build.m4
Last active August 29, 2015 14:03
NetBSD ./build.sh generator for separate builds
#!/bin/sh
define(`_CONTAINER_NAME', `ARCH'`-'`TARGET')dnl
define(`_CAPITALIZE', `translit($1, a-z, A-Z)')dnl
define(`_NETBSD_XSRC', ifdef(`BUILD_X', ` -x -X ../xsrc'))dnl
define(`_TOOLS_SUB', ifdef(`TOOLS_SUBDIR', TOOLS_SUBDIR, _CONTAINER_NAME))dnl
NETBSD_SRC=NETBSD_SRC_DIR
MAKECONF=MAKECONF_DIR/mk.conf._CONTAINER_NAME
@cr1901
cr1901 / scope.c
Created July 31, 2014 23:46
Variable Scope Fun
#include <stdio.h>
#include <stdlib.h>
/* Topics to review:
definition vs declaration
scope vs storage duration
storage classes- auto, static, extern, register
internal vs external linkage */
static int my_static = 1; /* This is a definition. This current file and THIS
@cr1901
cr1901 / gmacros.asm
Last active August 29, 2015 14:12
NASM Macros for Bare Metal/DOS x86 (8086-80386 PM)
[list -]
%ifndef GLOBAL_MACROS_ASM
%define GLOBAL_MACROS_ASM
;Macros to create a stack frame
%macro prolog 0.nolist
%ifidni CPU_TARGET, 8086
push bp
mov bp, sp
%else
@cr1901
cr1901 / Makefile
Created February 4, 2015 13:00
NASM Map Unix Sections to DOS Segments
.SUFFIXES : .asm .obj
AS=nasm
ASPPFLAGS=-DAPI=MSDOS_API -DCPU_TARGET=8086
ASFLAGS=-fobj
LINK=wcl
LINKFLAGS=-zq -bcl=dos -fm
RM=rm
RMFLAGS=-rf
@cr1901
cr1901 / rust-errors-symbols-missing.txt
Created February 8, 2015 11:52
Errors: Rust build with nonstandard paths
warning: removing previous 'librustc_llvm-*.so' libraries: i686-unknown-linux-gn
u/stage1/lib/librustc_llvm-4e7c5e5c.so
cp i686-unknown-linux-gnu/stage0/lib/rustlib/i686-unknown-linux-gnu/lib/stamp.ru
stc_llvm i686-unknown-linux-gnu/stage1/lib/stamp.rustc_llvm
cp -R i686-unknown-linux-gnu/stage0/lib/rustlib/i686-unknown-linux-gnu/lib/libru
stc_llvm-*.so i686-unknown-linux-gnu/stage1/lib
info: now are following matches for librustc_llvm-*.so libraries:
i686-unknown-linux-gnu/stage1/lib/librustc_llvm-4e7c5e5c.so
MATCHES=""; if [ -n "$MATCHES" ] ; then echo "warning: removing previous" \'libr
ustc_back-*.so\' "libraries:" $MATCHES; rm $MATCHES ; fi
@cr1901
cr1901 / config.log
Created February 8, 2015 12:06
Rust internal LLVM config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by LLVM configure 3.6.0, which was
generated by GNU Autoconf 2.60. Invocation command line was
$ /home/william/Projects/rust/src/llvm/configure --enable-targets=x86,x86_64,arm,aarch64,mips,powerpc --enable-optimized --enable-assertions --disable-docs --enable-bindings=none --disable-terminfo --disable-zlib --disable-libffi --build=i686-unknown-linux-gnu --host=i686-unknown-linux-gnu --target=i686-unknown-linux-gnu --with-python=/usr/bin/python2.7
## --------- ##
## Platform. ##
@cr1901
cr1901 / llvm_boostrap.sh
Created February 8, 2015 14:21
Compile LLVM/Rust on Ubuntu 12.04 using non-standard paths.
#!/bin/sh
BOOTSTRAP_ROOT=/home/william/Projects
#TEMP_TOOLS=$BOOTSTRAP_ROOT/llvm-temp-tools
TEMP_TOOLS=$BOOTSTRAP_ROOT/llvm-toolchain
LLVM_TOOLCHAIN=$BOOTSTRAP_ROOT/llvm-toolchain
FETCH=wget #Try BSD FTP if wget doesn't exist.
NUM_JOBS=4
#export PATH=$TEMP_TOOLS/bin:$PATH
export LD_LIBRARY_PATH=$TEMP_TOOLS/lib:$LD_LIBRARY_PATH
@cr1901
cr1901 / r1timing.py
Last active August 29, 2015 14:17
65816 Prop Delay Timing Helper Program
#!/usr/bin/env python
if __name__ == '__main__':
#Python 3 compatibility stuff
try:
input = raw_input
except:
pass
data_setup_time = 10