CmdHere Power Toy
Allows you to right click anywhere in Windows Explore and open a cmd prompt at that location
Google Desktop
Actually enables you to find your documents
Ruby
Programmers swiss army knife (made in Japan)
Tortoise SVN
life without source control is just dangerous
Trillian
Stay connected with people
UltraMon
You always need more then one monitor, ultramon makes multi-monitors a joy
Putty
What can you do without SSH
WinSCP
Windows Explorer over SSH (just handy)
Tuesday, September 25, 2007
ModelSim is exiting with code 211.
Verilog 3 to 8 decoder and 1 to 8 demux RTL
module decoder3_8(
output [7:0] out,
input [2:0] sel);
assign out = ( sel == 3'b000) ? 8'b1111_1110 :
( sel == 3'b001) ? 8'b1111_1101 :
( sel == 3'b010) ? 8'b1111_1011 :
( sel == 3'b011) ? 8'b1111_0111 :
( sel == 3'b100) ? 8'b1110_1111 :
( sel == 3'b101) ? 8'b1101_1111 :
( sel == 3'b110) ? 8'b1011_1111 :
( sel == 3'b111) ? 8'b0111_1111 :
8'b1111_1111;
endmodule
module demux1_8 (
output[7:0] sig_out,
input[2:0] sel,
input sig_in);
wire[7:0] selout;
decoder3_8 selector(selout, sel);
or finalor[7:0](sig_out, selout, sig_in);
endmodule
Structural 16bit CLA adder in Verilog
A whole 16 bit adder
module pfa(
output p, g, s,
input a, b, cin);
xor #1 sumer(s, a, b, cin);
xor #1 proper(p, a, b);
and #1 gener(g, a, b);
endmodule
//cla module 4 bit
module cla(
output p_up, g_up,
output [3:0] cout, // assumed [3:1] was typo becuase it made design less elegant
input [3:0] p, g,
input cin);
//assign p_up = &(p);
and #1 (p_up, p);
wire p3g2, p3p2g1, p3p2p1g0, p3p2p1p0cin;
and #1(p3g2,p[3],g[2]);
and #1(p3p2g1,p[3],p[2],g[1]);
and #1(p3p2p1g0,p[3],p[2],p[1],g[0]);
and #1(p3p2p1p0cin,p[3],p[2],p[1],p[0],cin);
//assign g_up = g[3] | p[3]&g[2] | p[3]&p[2]&g[1] | p[3]&p[2]&p[1]&g[0];
or #1 (g_up,g[3],p3g2,p3p2g1,p3p2p1g0);
//assign cout[3] = g[3] | p[3]&g[2] | p[3]&p[2]&g[1] | p[3]&p[2]&p[1]&g[0] | p[3]&p[2]&p[1]&p[0]&cin;
or #1(cout[3],g[3],p3g2,p3p2g1,p3p2p1g0,p3p2p1p0cin);
wire p2g1,p2p1g0,p2p1p0cin,p1g0,p1p0cin,p0cin;
and #1(p2g1,p[2],g[1]);
and #1(p2p1g0,p[2],p[1],g[0]);
and #1(p2p1p0cin,p[2],p[1],p[0],cin);
and #1(p1g0,p[1],g[0]);
and #1(p1p0cin,p[1],p[0],cin);
and #1(p0cin,p[0],cin);
//assign cout[2] = g[2] | p[2]&g[1] | p[2]&p[1]&g[0] | p[2]&p[1]&p[0]&cin;
or #1(cout[2], g[2],p2g1,p2p1g0,p2p1p0cin);
//assign cout[1] = g[1] | p[1]&g[0] | p[1]&p[0]&cin;
or #1(cout[1],g[1],p1g0,p1p0cin);
//assign cout[0] = g[0] | p[0]&cin;
or #1(cout[0],g[0],p0cin);
endmodule
//put the cla and #1 adders together to make them easier to merge
module adder4_cla(
output co,
output [3:0] s,
output p_up,g_up,
input [3:0] a,b,
input cin);
wire [3:0] p,g;
wire [3:0] carry;
pfa add[3:0](.p(p),.g(g),.s(s),.a(a),.b(b),.cin({carry[2:0], cin}));
cla localcla(.p_up(p_up),.g_up(g_up),.cout(carry),.p(p),.g(g),.cin(cin));
assign co = carry[3];
endmodule
module add16(
output co,
output [15:0] s,
input [15:0] a,b,
input cin);
wire [3:0] carry, p, g;
wire p_up, g_up;
wire c1,c2,c3,c4;
adder4_cla add1 (.co(c1),.s(s[3:0]),.p_up(p[0]),.g_up(g[0]),.a(a[3:0]),.b(b[3:0]),.cin(cin));
adder4_cla add2 (.co(c2),.s(s[7:4]),.p_up(p[1]),.g_up(g[1]),.a(a[7:4]),.b(b[7:4]),.cin(carry[0]));
adder4_cla add3 (.co(c3),.s(s[11:8]),.p_up(p[2]),.g_up(g[2]),.a(a[11:8]),.b(b[11:8]),.cin(carry[1]));
adder4_cla add4 (.co(c4),.s(s[15:12]),.p_up(p[3]),.g_up(g[3]),.a(a[15:12]),.b(b[15:12]),.cin(carry[2]));
cla finalcla(.p_up(p_up),.g_up(g_up),.cout(carry),.p(p),.g(g),.cin(cin));
assign co = carry[3];
endmodule
Structural CLA verilog 4bit module with expanded terms
Carry Look Ahead adders are amazing, unfortunately they are a pain to design... here is a module I use quite often.
//cla module 4 bit
module cla(
output p_up, g_up,
output [3:0] cout, // assumed [3:1] was typo becuase it made design less elegant
input [3:0] p, g,
input cin);
//assign p_up = &(p);
and #1 (p_up, p);
wire p3g2, p3p2g1, p3p2p1g0, p3p2p1p0cin;
and #1(p3g2,p[3],g[2]);
and #1(p3p2g1,p[3],p[2],g[1]);
and #1(p3p2p1g0,p[3],p[2],p[1],g[0]);
and #1(p3p2p1p0cin,p[3],p[2],p[1],p[0],cin);
//assign g_up = g[3] | p[3]&g[2] | p[3]&p[2]&g[1] | p[3]&p[2]&p[1]&g[0];
or #1 (g_up,g[3],p3g2,p3p2g1,p3p2p1g0);
//assign cout[3] = g[3] | p[3]&g[2] | p[3]&p[2]&g[1] | p[3]&p[2]&p[1]&g[0] | p[3]&p[2]&p[1]&p[0]&cin;
or #1(cout[3],g[3],p3g2,p3p2g1,p3p2p1g0,p3p2p1p0cin);
wire p2g1,p2p1g0,p2p1p0cin,p1g0,p1p0cin,p0cin;
and #1(p2g1,p[2],g[1]);
and #1(p2p1g0,p[2],p[1],g[0]);
and #1(p2p1p0cin,p[2],p[1],p[0],cin);
and #1(p1g0,p[1],g[0]);
and #1(p1p0cin,p[1],p[0],cin);
and #1(p0cin,p[0],cin);
//assign cout[2] = g[2] | p[2]&g[1] | p[2]&p[1]&g[0] | p[2]&p[1]&p[0]&cin;
or #1(cout[2], g[2],p2g1,p2p1g0,p2p1p0cin);
//assign cout[1] = g[1] | p[1]&g[0] | p[1]&p[0]&cin;
or #1(cout[1],g[1],p1g0,p1p0cin);
//assign cout[0] = g[0] | p[0]&cin;
or #1(cout[0],g[0],p0cin);
endmodule
Structural PFA verilog Partial Full Adder
module pfa(
output p, g, s,
input a, b, cin);
xor #1 sumer(s, a, b, cin);
xor #1 proper(p, a, b);
and #1 gener(g, a, b);
endmodule
3bit counter verilog
module counter(
output [2:0] out,
input clk, rst);
wire [2:0] ns;
counter_code code(ns, out);
dff DFF[2:0](out, ns, clk, rst);
endmodule
// 7,1,6,2,5,3,4,0 start over
module counter_code(
output [2:0] next,
input [2:0] c);
wire [2:0]c_n;
not cnot[2:0] (c_n, c);
// this is where your logic goes for the counter steps
and(n0mid1,c_n[2],c_n[1],c_n[0]);
and(n0mid2,c[2],c[1],c[0]);
and(n0mid3,c_n[2],c[1],c_n[0]);
and(n0mid4,c[2],c_n[1],c[0]);
or(next[0],n0mid1,n0mid2,n0mid3,n0mid4);
nor(n1mid1,c[2],c[1]);
and(n1mid2,c[2],c_n[1],c[0]);
and(n1mid3,c[2],c[1],c_n[0]);
or(next[1],n1mid1,n1mid2,n1mid3);
not(next[2] ,c[2]);
endmodule
Thursday, September 6, 2007
Ruby Capture Key Presses - getc doesn't work
Problem: (doesn't work)
In an almost religious pursuit of ways of capturing keypresses in ruby (for windows) I found a few different technologies that help.
Solution 1 (curses): works! except arrow keys
* keypad(true) isn't implemented on windows
Solution 2: Using win32 api
And this works for arrow keys so I am happy
while true
ch = getc #return immediately the key I just pressed (enter, a, down arrow)
puts ch
end
In an almost religious pursuit of ways of capturing keypresses in ruby (for windows) I found a few different technologies that help.
Solution 1 (curses): works! except arrow keys
require 'curses'
#stdscr.keypad(true) # would be great if this was implemented for windows
while true
ch = Curses.getch
puts ch
end
* keypad(true) isn't implemented on windows
Solution 2: Using win32 api
require 'Win32API'
$win32_console_kbhit = Win32API.new("msvcrt", "_kbhit", [], 'I')
$win32_console_cputs = Win32API.new("msvcrt", "_cputs", ['P'], 'I')
$win32_console_getch = Win32API.new("msvcrt", "_getch", [], 'I')
def console_input_ready?
$win32_console_kbhit.call != 0
end
def console_input
$win32_console_getch.call
end
def console_output( str )
$win32_console_cputs.call( str )
end
while true
if console_input_ready? then
ch = console_input
puts "ch: #{ch.chr}"
end
end
And this works for arrow keys so I am happy
Ruby text to speech on windows
Using the win32-sapi ruby can speak!
Install the gem
Speak some words
*Remember ruby is case sensitive
Other cool features:
More info: Microsoft Documentation on SpVoice
Install the gem
gem install win32-sapi
Speak some words
require "win32/sapi5"
include Win32
v = SpVoice.new
v.Speak("Shall we play a game?")
*Remember ruby is case sensitive
Other cool features:
v = SpVoice.new
v.ole_get_methods
v.Status
v.Voice
v.Rate
v.Volume
v.Priority
More info: Microsoft Documentation on SpVoice
Wednesday, September 5, 2007
Sick of undefined method * for nil:NilClass
Cool ruby trick to simply your code: if ['href'] == nil then use ""
So undefined method * for nil:NilClass basically means that the method your calling doesn't exist on the Nil class i.e. a NullReferenceException.
a = nil
a.size
=> undefined method * for nil:NilClass
but if you want to assume a default you can use the || operator to fake out ruby
(nil || "") => ""
a = nil
(a || "").size
=> 0
Sweet huh! :-)
So undefined method * for nil:NilClass basically means that the method your calling doesn't exist on the Nil class i.e. a NullReferenceException.
a = nil
a.size
=> undefined method * for nil:NilClass
but if you want to assume a default you can use the || operator to fake out ruby
(nil || "") => ""
a = nil
(a || "").size
=> 0
(!a['href'] || "").index('javascript:')
Sweet huh! :-)
Monday, September 3, 2007
Ruby Documentation Library that doesn't suck
Very good organization of ruby documentation, with SEARCH!
http://www.noobkit.com/
1: Search
2: Browsable
3: Can post comments
4: Many corpuses in one spot
http://www.noobkit.com/
1: Search
2: Browsable
3: Can post comments
4: Many corpuses in one spot
Pandora for Facebook = Wonderful
One of the better apps I've seen developed for the Facebook platform. I think this is truly GREAT. All that hard work turning the perfect station, let your friends auto discover it :-)
http://apps.facebook.com/pandora
http://apps.facebook.com/pandora
Practical Programming: Getting Real
A fascinating programming book published by 37signals Getting Real. Basically practical Extreme programming. I think I am going to use this books Table of Contents as a reference when ever I am planning out a project. Great book because:
1: super clear principles
2: just feels right
3: things you already "know" but things you need to hear
1: super clear principles
2: just feels right
3: things you already "know" but things you need to hear
Learning Ruby = Programming Ruby Book
Learning ruby or been coding it for years. I dislike programming books, but if your doing anything with ruby. Programming Ruby, by Pragmatic Programmers is a must have; because:
1: The raw amount of cool nifty ruby tricks presented.
2: Reading good code -> to writing better code
3: Great example use of standard libraries
4: 800 pages of expert is currently better then google (this will change)
1: The raw amount of cool nifty ruby tricks presented.
2: Reading good code -> to writing better code
3: Great example use of standard libraries
4: 800 pages of expert is currently better then google (this will change)
Putty Numpad doesn't work
Just learned a new trick for putty. Sometimes you press numpad numbers and the program (via ssh) processes these as special characters. If you press Ctrl+Numlock you can manually force putty to use the numpad = numbers.
Ctrl+NumLock = Working Numpad
Auto-mounting Linux Directories through SSH
Automount via SSH
Access your files on any of your machines with auto mounting
Access your files on any of your machines with auto mounting
cd /mnt/ssh/remote1/
ls
=> yields your files where remote1 can be any remote host
Subscribe to:
Posts (Atom)