Skip to content

Instantly share code, notes, and snippets.

@cr1901
cr1901 / freq_count.py
Created March 23, 2016 16:35
MiSoC Frequency Counter
from migen.fhdl.std import *
from migen.genlib.fifo import AsyncFIFO
from migen.fhdl.bitcontainer import flen
from migen.bank.description import *
class FreqCounterDebug(Module, AutoCSR):
def __init__(self, counter_param_list):
for params in counter_param_list:
setattr(self.submodules, params[0], FreqCounter(*params[1:]))
@cr1901
cr1901 / nco.py
Created March 21, 2016 18:17
Migen NCO Example
from migen import *
from migen.fhdl import verilog
import numpy as np
import matplotlib.pyplot as plt
import struct
class NCO(Module):
def __init__(self, out_width=8, depth=10, acc_out_width=24, base_freq=1000000, clk_freq=50000000):
self.norm_freq = base_freq/clk_freq
num_entries = 2**depth
@cr1901
cr1901 / solvespace.js
Created March 21, 2016 04:28
Solvespace.js Progress
SolvespaceCamera = function( render_width, render_height, scale, up, right, offset ) {
THREE.Camera.call( this );
this.type = 'SolvespaceCamera';
this.render_width = render_width;
this.render_height = render_height;
this.zoom_scale = scale; /* Avoid namespace collision w/ THREE.Object.scale */
this.up = up;
this.right = right;
SolvespaceCamera.prototype.updateProjectionMatrix = function() {
temp = new THREE.Matrix4();
offset = new THREE.Matrix4().makeTranslation(this.offset.x, this.offset.y, this.offset.z);
n = new THREE.Vector3().crossVectors(this.right, this.up);
rotate = new THREE.Matrix4().makeBasis(this.right, this.up, n);
/* TODO: If we want perspective, we need an additional matrix
here which will modify w for perspective divide. */
scale = new THREE.Matrix4().makeScale(2*this.zoom_scale, 2*this.zoom_scale, this.zoom_scale);
/* FIXME: Where did the negative sign in the zScale come from?
@cr1901
cr1901 / file_fun.rs
Last active March 17, 2016 16:31
I got nothing...
// TODO: Why doesn't try! work?
let mut fp = match File::open(obj) {
io::Result::File(x) => { x },
io::Result::Error(x) => { panic!("Error opening {}: {}", obj, x) }
};
/* src\main.rs:62:17: 62:36 error: no associated item named `File` found for type `core::result::Result<_, std::io::error::Error>` in the current scope
src\main.rs:62 io::Result::File(x) => { x },
^~~~~~~~~~~~~~~~~~~
src\main.rs:63:17: 63:37 error: no associated item named `Error` found for type `core::result::Result<_, std::io::error::Error>` in the current scope
@cr1901
cr1901 / todo.md
Last active February 22, 2016 19:11
ScanWidget Todo

To Fix (Bugs)

  • Check that recalculating the zoom transform in fact has a relative error of 10^-15, not absolute error. If latter, rethink transform.
  • Slider positions need to be updated during zoom; have not figured out a "clean" way to do this that doesn't involve signals or unnecessary inter-object communication. I may remove the event filter completely.
  • Fix FitToView and ZoomToFit idempotency.
    • Related to slider-to-pixel transform having an offset of slider_width/2 pixels.
  • At large zooms, the sliders start taking the wrong positions due to floating point errors?
  • Remove asserts (or catch AssertionFailure) and just refuse to honor zooms at some point.
  • Implement offset/magnitude visualization properly, as it seems to get stuck.
  • Need to add a "max number of ticks to display" to ticker class to avoid label overlap.
From 853153920e7f2d4b6e5bf311a57c2c3184036909 Mon Sep 17 00:00:00 2001
From: "William D. Jones" <[email protected]>
Date: Wed, 27 Jan 2016 10:49:45 -0500
Subject: [PATCH] Add test frequency counters using minispartan6 board.
---
gateware/freq_count.py | 55 ++++++++++++++++++++++++++++++++++++++++++++
targets/minispartan6_base.py | 34 +++++++++++++++++++++++++++
2 files changed, 89 insertions(+)
create mode 100644 gateware/freq_count.py
@cr1901
cr1901 / build.hint
Created January 27, 2016 13:03
MiSoC Freq Counters
make BOARD=minispartan6 TARGET=base MISOC_EXTRA_CMDLINE="-sFreqSoC -Ob source True -Ob run False" gateware
@cr1901
cr1901 / freq_count.py
Last active January 27, 2016 08:49
Migen Frequency Counter
from migen.fhdl.std import *
from migen.genlib.fifo import AsyncFIFO
from migen.fhdl.bitcontainer import flen
from migen.fhdl import verilog
class FreqCounter(Module):
# measured_sig: Signal to measure frequency
# ref_clk: counts up to a gate_time number of cycles. It should be at least
# twice as fast as the maximum frequency of the measured signal to avoid
@cr1901
cr1901 / main.py
Last active January 10, 2016 05:55
Debug Rebase for Scanwidget
import asyncio
import atexit
import os
import scanwidget
# First two are portable between PyQt4 and 5. Remaining are not.
from quamash import QApplication, QEventLoop, QtGui, QtCore, QtWidgets