Thursday, August 30, 2012

Xilinx + Modelsim

I keep forgetting how to compile Xilinx libraries and import them into modelsim...so here goes a list


use compxlib from appropriate Xilinx version, select version of modelsim (in my case 10.0d)
--Will output to Xilinx\Ver##\ISE\verilog\modelsim_10dbli

In Modelsim, right click work, add library

DONE

Simulate and include the appropriate libraries as so...
vsim -L SimPrim_Vers10 -L UniMacro_Ver10 -L UniSim_Ver10 -L XilinxCoreLib_Ver10 work.afe_tb work.glbl

Remembering to include the global file glbl

Tada!

Thursday, June 21, 2012

Colleges and Alumni donations

My grad and undergrad alumni associates have decided to call me as often as possible, in attempts to get donations.  

I'm always confused by this.  The time period in which I give them money in exchange for goods or services has past.  This isn't like PBS, which I actively use

Target does not call me up to see if I'm enjoying the Gatorade I purchased from them, and ask me if I would like to pay them more retroactively for it

Particularly undergrad -- you guys didn't bother to give me scholarships, opting for more need based over academic based.  Sorry friends, knock on those people's doors

Sunday, June 10, 2012

Birth Control Statistics in GNU Octave

Hello!  A fun thought occurred to me while looking over an old statistics textbook -- how effective is our birth control?

For the sake of argument, lets say that condoms, used properly, have a 97% effective rate.  A birth control pill, properly used, have a 99% effective rate.  Those may sound high, but they aren't really.  Lets take a look and assume you are having sex once a week for two years. What is the likelihood that you will have at least one condom break, the pill be ineffective, or both failing simultaneously? Rut Roe!

Since each condom use can be considered an independent test, the probability of failure is 1 - 0.97, or 3% chance of failure.  Similarly, the pill would have a 1% chance of failure.  The data is as follows:

Probability of faulty birth control method over time

What does this graph tell us?  It is 1- (the chance of getting X amount of condoms in a row that are successful), or  the ever increasing chance that your next condom / birth control pill, combination will be faulty.  As the blue line shows, over two years, or 104 condom uses, you have a ~95% chance of one of those condoms being defective and failing.  With straight birth control and 104 tests, you have a 63% chance that at least one time it did not work.   The best though, is the redundant method: The chance that during a two year period that both the condom and the birth control would fail at exactly the same time.  This would be the same as modeled as a system in parallel:
 (1 - 0.03*0.01) = 99.7% individual chance of success with some kind of protection in parallel system per sexy times.  Hooray.  The green line shows that over 104 weeks,  the chance of double failure is nearly negligible.  This is the way to be!

So wait wait wait, a failed condom or birth control pill does not necessarily mean pregnancy occurs.  Every menstrual cycle, there are about ~5 days of which sperm in the system could meet an egg.  5 days out of every 28, or ~18% of all days in a year.  This reduces the 1 / week for 104 week chance of issue significantly, as the following graph shows:

This graph basically states that, having random sex once / week, over two years, presents a 17% chance of a condom breaking while in ovulation, a 11% chance of the pill not working during ovulation, and basically a 0% chance of the pill and the condom breaking at exactly the same time.

Lesson in all of this?  Redundancy in parallel systems is the way to go.

Saturday, April 21, 2012

Dragon Laser Viper 55mW review

The Viper 55mW green laser

I like lasers.  It all started when I was getting married.  We needed presents for all the guys in our wedding party, but didn't want to go with something normal like a tie, or a flask.  Queue lightbulb -- something severely dangerous and with no practical use

An awesome laser.

That batch of lasers came from wickedlasers.com.  They were of okay quality.  3/4 lasers worked perfectly.  The last one worked intermittently, and appeared to have a short in it based on my testing.  They were also more expensive than comparative lasers purchased elsewhere, but I went with a "name brand" company I had heard of for my first purchase.

Still, I was hooked.  After some research, many people recommended dragonlasers.com.  A friend of mine was getting married, and I thought, "yes, lasers are the new wedding china", and used this as an excuse to give dragonlasers a try.

I was not disappointed.  Shipping is from Beijing, which accounts for most of the delay in between pushing the buy button and having the laser in my hands.  This box will need to go through customs if you are shipping to the US, which was a giant pain.  The shipping method was trackable via USPS, but after customs tracking stopped.  It claims to be in customs now, despite having been in my hands for several weeks.

I would say it took them about a workweek to get the laser shipped, followed by a two week wait on getting it to my door.  Not too bad for the price they charged for shipping, considering the oceans it had to cross.

The build quality is excellent.  It is heavy in my hand, and feels solid.  This is in noticeable contrast to my WickedLaser's purchases.  It isn't that WickedLasers is cheap feeling, it is just that DragonLasers is a much higher quality.

Unlike WickedLasers, however, DragonLasers hand held laser pen does not appear to have a safety feature.  The laser from Wicked had the ability to take a "pin" out, effectively cutting power even with the two AA batteries in.  No such feature exists on DragonLasers, so care must be taken as you are wielding a dangerous toy.

Here is a picture of me shining the green Viper at a wall in my home

Large green dot

I took it outside, and kept the shutter on my camera open for 8 seconds, while I moved it around...most likely scaring the neighbors
Looks almost like a photoshop filter

The beam is highly visible at night, and I am working on capturing that in picture form.

Overall, I highly recommend dragonlasers.com for their excellent quality hand held lasers.  Just be prepared to wait, as not everything can be 2-day shipped from Amazon.com  

I would like to do some power measurement tests in the future, as well as a total usage / set of batteries measurement.  The laser itself runs on two AAA batteries, meaning to achieve 55mW we're looking at a current draw of ~0.017A or 17mA.   Given the low side of alkaline AAA batteries are rated for 250mAh, that is going to theoretically give a use time of around 14 hours between changes.
The laser resting itself after a long day of blinding me


Thursday, March 1, 2012

Xfce Tab and auto-complete terminal via VNC

I switched my windows system from Gnome to Xfce4 for a change, and ran into an interesting problem:  After I configured my ~/.vnc/xstartup profile to use the new window system, anytime I'd attempt to auto-complete in terminal (/ho<tab> for /home, for instance), the cursor would just blink, and no auto complete would occur.

This only seemed to happen with VNC sessions, but I did not explore this much because of the headless nature of my server.

Turns out Xfce was assigning something called <Super>Tab to the Tab key...removing this binding allows auto-complete to function.

It can be reached by Settings --> Window Manager ---> Keyboard, as detailed in the following image:


Setting up an SSH server in a Debian derivative

sudo apt-get install openssh-server

done!


Tuesday, February 14, 2012

Handbrake GTK and Debian Squeeze

Handbrake isn't a stable package, you need to edit etc/apt/sources.list to allow testing packages temporarily...as in changing


  ###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ squeeze main contrib non-free 
deb-src http://ftp.us.debian.org/debian/squeeze main contrib non-free


To


  ###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ testing main contrib non-free 
deb-src http://ftp.us.debian.org/debian/testing main contrib non-free


Save, do a sudo apt-get update, followed by a sudo apt-get install handbrake-gtk, and watch those dependencies get met.

Remember, change back to the previous stable area when complete!

It will install a lot...or at least did for me.  But success is reached at the end.  

Monday, January 30, 2012

Sign extension in VHDL

Okay, I am using VHDL at my new job, and haven't used it in years.  I was trying to sign extend basic logic circuits and it was driving me crazy.  Finally I found this, and it seems like it works:

Input signal to sign extend was
 
wimax_out       :in  std_logic_vector(15 downto 0); -- output of wimax modulator



in the architecture area...


-- sign extent input to 18-bits
wimax_sign_ext_18                             <= wimax_out(15) & wimax_out(15) & wimax_out;

-- sign extend to 48-bit C input
wimax_sign_ext_48(47 downto 16)     <= (others => wimax_out(15));
wimax_sign_ext_48(15 downto 0)       <= wimax_out;


So concating works (&) and the others => work, at least according to modelsim and the 'signed decimal' signals.  I am willing to bet other methods work, or perhaps work more properly, but I do not care

Verilog all the way




Thursday, January 12, 2012

FPGA Timing

All right, I keep forgetting how FPGA timing works, so I'm writing it down here so I don't have to continue to search the internet

There are four main time periods we care about dealing with FPGA timing: Tclk, Tsu, Th, and Tco.


  • Tclk is the period of the clock the registers in question are synchronous to.
  • Tsu (Setup time) is the amount of time before the edge trigger of a register that the data must be settled on the input of the register
  • Th (Hold time) is the amount of time after the edge trigger of a register that the data must remain stable on the input of the register
  • Tco (Clock to output time)  is the amount of time from the edge trigger of the register to when the newly latched data is available as an output.

FPGA Timing Diagram Example

Here is an attached picture of three registers on the same clock, with the above time periods
From this we can see the amount of time a signal has to get from one register to another register in an FPGA is defined as
Time Skew = (Tclk - Tco - Tsu)

Skew is eaten into by delay that is a function of the speed of light, the trace material dielectric, the width of the trace, and probably something else I am forgetting.

These rules hold true in SDR or DDR -- we just care about the data with respect to the appropriate edge.  It can get more complicated with Center Aligned data or Edge Aligned, or dealing with external interfaces to the FPGA, but the main rule applies:

Data has to be there a certain amount of time before and after the sampling edge (Tsu and Th), and will take a certain amount of time before being available as an output (Tco), and is constrained by the clock period (Tclk) and the laws of physics.