Skip to content

Instantly share code, notes, and snippets.

@morganp
morganp / shm_waveforms.md
Last active August 10, 2023 02:49
Creating SHM waveforms with irun

To run a verilog simulation using irun and create a shm waveform file,

initial begin
  $shm_open("waves.shm"); $shm_probe("AS");
end

run with irun -access +r testcase.sv

Or create this tcl file:

@morganp
morganp / fft_demo.m
Last active February 6, 2018 15:21
Basic Matlab FFT
%% Trial FFT
% http://www.mathworks.co.uk/help/matlab/math/fast-fourier-transform-fft.html
fs = 48000; % Sample Rate
n = 4096; % Power of 2 number of samples/ length of FFT
% Get/Generate data
t = 0:1/fs:(n-1)/fs; % n/fs sec sample
x = (1.3)*sin(2*pi*1500*t) ... % 1.5k Hz component
+ (1.7)*sin(2*pi*4000*(t-2)) ... % 4.0k Hz component
@morganp
morganp / generic_file
Created December 16, 2012 17:38
Example file for FileScraper
Generic Content
@morganp
morganp / Cow_Rainbows.md
Created October 8, 2012 15:08
Rainbows

Install Gems:

gem install cowsay rainbow_say

Command line:

cowsay boo | rainbow_say

@morganp
morganp / calc.rb
Created September 10, 2012 11:54
Calculate rom sixes and House size
def sqm_to_sqft(num)
num*10.763910
end
# http://www.espc.com/properties/details.aspx?pid=315620&sid=25446441807
data = [
[3.75, 3.32],
[2.95, 2.87],
[3.78, 2.47],
[1.88, 1.45],
@morganp
morganp / to_b.md
Created May 21, 2012 10:38
String Integer to Boolean

Jeff Gardner, Catch all

class String
  def to_bool
    return true if self == true || self =~ (/(true|t|yes|y|1)$/i)
    return false if self == false || self.blank? || self =~ (/(false|f|no|n|0)$/i)
    raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
  end
end
@morganp
morganp / maruku_html_snippet.rb
Created April 25, 2012 07:01
Maruku Snippet Generation
# encoding: UTF-8
require 'maruku'
## TODO or maybe not, we currently cut styling -- == underlining if it is on the line after the cut off length.
# would you want a snippet ending with a heading though?
def maruku_html_snippet(markdown,lines=-1 )
if lines == -1
markdown_temp = markdown
else
@morganp
morganp / rake
Created January 23, 2012 09:40
ruby gem deployment rake task
## Idea of using $? from:
##http://tech.natemurray.com/2007/03/ruby-shell-commands.html
namespace :deploy do
## name and version from
## https://github.com/mojombo/rakegem
def name
@name ||= Dir['*.gemspec'].first.split('.').first
end
@morganp
morganp / new_run.m
Created November 28, 2011 10:32
Matlab run Simulink modern syntax
%% Run simulation
sim_length = samples/fs_in;
% [answer.t, answer.x, answer.y] = sim( 'testharness', sim_length );
paramNameValStruct.StartTime = '0.0' ;
paramNameValStruct.StopTime = num2str(sim_length) ;
sim_result = sim( 'testharness', paramNameValStruct);
%% Get the results