emacs font too large in Fedora linux

April 19th, 2010 by lane

Default emacs font on Fedora these days is way to big. I added the following to my .Xresources file to solve the problem:

emacs.FontBackend: xft
emacs.font: DejaVu Sans Mono-9
emacs.geometry:    80x80

I don’t think the xft option is necessary, but changing the DejaVu Sans Mono from 12 point to 9 point is what I wanted. The geometry sets the size of the buffer on startup.

Dynamic methods in Python

December 26th, 2009 by lane

To dynamically control the methods of a python class, you overload the __get_attribute__() method. Then you can do whatever you want with your class as in this example:

class myclass(object):
    def __getattribute__(self, name):
        try: # first check if this object as the requested method
            return object.__getattribute__(self, name)
        except AttributeError: # if not, do something else
            raise

#    def __setattr__(self, name, val):
#       pass

Installing Fedora 11 (F11) on Macbook Air

September 21st, 2009 by lane

I have a previous post on installing Fedora 10 on the Macbook Air. I recently upgraded to Fedora 11 through yum. Overall that went well. I followed the yum upgrade instructions without a hitch.

When I reboot into F11, sound didn’t work and multitouch stopped working. To get sound working again, I changed /etc/modprode.d/sound.conf to

options snd_hda_intel model=asus-a7m

and rebooted.

To get multitouch working, I deleted the /etc/X11/xorg.conf file I created previously and in GNOME changed my System->Preferences->Mouse->Touchpad settings to enable double and triple finger clicking.

AC Transistor Noise Analysis in HSPICE

February 18th, 2009 by lane

Whenever I perform a noise analysis on a circuit, I like to verify the result with a simulation.  I have really enjoyed Eldo’s transient noise analysis in the past, but currently I only have access to HSPICE.  All the spice simulators have AC noise analysis features.  Here is a toy example that I use to verify basic functionality prior to getting more complicated. 

Suppose you have a single NMOS transistor configured as follows where the drain is active loaded with an ideal current source and the gate is biased with an ideal voltage source.

The goal here is to calculate the input referred noise of this amplifier and verify the result with an AC noise simulation in HSPICE. The HSPICE netlist I use to simulate with is:

* HSPICE Netlist

* Include models
.lib '../../../pdk/hspicemm/cmn018_assp_v1d1.l' TT
.lib '../../../pdk/hspicemm/cmn018_assp_v1d1.l' TT_3V
.GLOBAL gnd!
m0 vd vg gnd! gnd! nch3 w='0.42u' l='0.35u' nf=1 m=1 ad='0.2016p' as='0.2016p'
+ pd='1.38u' ps='1.38u' nrd=1.14286 nrs=1.14286 sa='0.48u' sb='0.48u' sd=0
v4 vg gnd! dc=.9 ac=1
i3 gnd! vd dc='3u'

.options POST=1 parhier=local
.TEMP 45

.ac DEC 10 1000 100G
.noise V(vd) V4
.probe noise onoise onoise(m) onoise(db)
.probe noise inoise inoise(m) inoise(db) 

.probe GMO(M0)
.probe GDSO(M0)
.probe CDDBM(M0)
.end

Because the transistor models are proprietary to our manufacturer, I do not include them here. They are level=54 (BSIM 4) transistors, whose parameter descriptions can be found at this web address: http://www-device.eecs.berkeley.edu/~bsim3/bsim4_get.html. For the purposes of verifying these against hand calculations, I temporarily disabled flicker noise in the models by setting the NOIA, NOIB, NOIC parameters to 0. BSIM 4.0 models (see page 87-88 of BSIM manual) use a more complicated equation for thermal noise than the traditional thermal noise = 8/3kTgm equation appropriate for hand analysis, but as you will see, the hand analysis is pretty close.

After running this simulation, I first look at the AC response and extract the gain and bandwidth from the gm, gds, and Cdd parameters that I probed in the simulation. As the plot below shows, calculating the gain as A=gm/gds and the single pole as tau=Cdd/gds gives a first order model that matches the simulated results quite well until the a zero from the Cgd hits above 10 GHz.

From this first order model, I calculate the output referred noise spectral density as N=8/3kTgm/gds^2. This is then filtered by the same first order model (but without the gain) to produce a frequency response as shown below in green. The result from the HSPICE simulation matches to within 2dB. This discrepancy comes from the more complex noise model employed by HSPICE and BSIM 4. After integrating the PSD, spice reports the output noise as 18.2mV and I calculate 14.9mV. Not bad for a hand calculation. The input referred noise, on the other hand, is somewhat of a mystery to me. Rather than dividing by the DC gain of the circuit to input refer the noise, HSPICE divides the output PSD by the frequency response of the system, and the result is spice’s input referred noise becomes quite broadband—almost white (see red line in plot below). Integrating this to get the equivalent total input referred noise is useless. So I calculate the input referred noise by dividing the output RMS noise by the gain because the number reported by HSPICE for the input referred total noise is meaningless. Since the gain is 40 in this example, the input referred noise is 375uV.

The code I wrote to generate these plots utilizes all open source software including Numerical Python and Matplotlib, which I highly recommend as an alternative to Matlab. I modified Mike Perrott’s HSPICE Matlab Toolbox code to read hspice sim data in as a numpy array. The code follows:

from cad.sim import hspice, anal
import pylab, numpy

s,p = hspice.read("results/netlist.ac0")

f=s["HERTZ"]
gm = s["gmo(m0"][0]
gds= s["gdso(m0"][0]
C  = s["cddbm(m0"][0]

A = gm/gds
tau = C/gds
F = 1/numpy.sqrt(1+(2*numpy.pi*f*tau)**2)
H = A*F

def dB(x):
    return 20*numpy.log10(numpy.abs(x))

pylab.figure()
pylab.semilogx(f, dB(s["vd"]), label="Simulation Result", lw=2)
pylab.semilogx(f, dB(H), label="First Order Model", lw=2)
pylab.grid(True)
pylab.figtext(0.2,0.4,"A=%2.1f f=%2.1fMHz" % (A, 1/tau/2/numpy.pi/1e6), bbox=dict(edgecolor="k", facecolor="w"))
pylab.xlabel("Frequency (Hz)")
pylab.ylabel("Magnitude (dB)")
pylab.title("Transfer function from 'vg' to 'vd'")
pylab.legend(loc=3)
pylab.savefig("transfer.png")

kT = 1.38e-23 * 315; # Joules

onoise = 8/3.* kT * gm / (gds**2)
inoise = 8/3.* kT / gm
nb = 1/4./tau

sigma = numpy.sqrt(inoise * nb)

pylab.figure()
pylab.semilogx(f, s["onoise(db"], label="Simulated output noise (onoise)", lw=2)
pylab.semilogx(f, dB(numpy.sqrt(onoise)*F), label="Hand calculated output noise", lw=2)
pylab.semilogx(f, s["inoise(db"], label="Simulation input noise (inoise)", lw=2)
pylab.grid(True)
pylab.xlabel("Frequency (Hz)")
pylab.ylabel("Noise (dB/sqrt(Hz))")
pylab.title("Noise Power Spectral Density Plots")
pylab.figtext(0.2,0.6,"""Spice Total Output Noise=18.2mV
Hand Calculated Output Noise=%2.1fmV""" % (sigma*A*1e3,), bbox=dict(edgecolor="k", facecolor="w"))
pylab.legend(loc=3)
pylab.savefig("noise.png")

Weak Inversion

The previous example was for a transistor in strong inversion. When I change the operating to bias the above circuit in weak inversion, the spice generated output noise becomes= 27.6mV and my hand calculations now use the noise spectral density equation that 4*gamma*kT*gm where gamma=n/2 and where n is the subthreshold slope ideality factor. Using a ideality factor of 2, my hand calculations give the output referred noise as 26.5mV, which is within 4% of the spice result.

System Message Bus hanging on start and LDAP recovery

February 1st, 2009 by lane

I have a server that has twice filled up the primary hard drive partition and then caused me several hours of debug to figure out what happened.  The time between these two events was long enough that I had to go through the same debug path twice, and I only realized after the fact that I should have known.

Here were the symptoms:

  • Things were slow to start
  • System Message Bus took many minutes (probably more than 10)
  • LDAP server would not start.  It had a db recovery message. Ran
    /usr/sbin/slapd_db_recover -v -h /var/lib/ldap

    command to recover it after clearing out some space.

Plug for Verilator

October 24th, 2008 by lane

I am a dedicated user and contributor to open source software. I have long wished that semiconductor companies would ban together and shift their resources from paying closed-source EDA companies and instead hire software engineers to develop open source CAD tools. I think the result would be a much better CAD environment.

The advent of the Fedora Electronics Lab (FEL) raised the awareness to me of a few open source projects that have become quite mature and good–including Icarus Verilog and GTK Wave. I am now using Icarus verilog as my simulation tool of choice for quick and dirty verification of small designs or library modules. GTK Wave is also quite good as a near replica of simvision. I no longer have a need verilog-XL or simvision. I found the performance Icarus verilog lacking, however, for large scale design (in the same way verilog-XL).

When reading through something on Icarus verilog in a forum or something,someone mentioned the speed of Verilator. I had never heard of Verilator, but a quick Google search led me there. It did not take me long to realize the design principles behind Verilator are exactly what I have been looking for in a digital simulator. Here is why:

  1. It slices the feature support at the perfect place. Verilator does not support unsynthesizable code. I find this to be pure genius. I can model my unsynthesizable code in a language that is much better suited for that (like C/C++, python, etc). This is such a natural thing to do for a simulator whose goal is performance.
  2. It is open source.
  3. It is fast and able to handle large designs.

The only feature that it lacks that I do find quite problematic is “tri-states” or “inouts”. Hopefully this can get alleviated soon. It has quirks that I embrace completely. For example, it does not support the unknown state “X”. On startup, everything is initialized high, low, or randomly. This is an example of a tradeoff that is perfectly reasonable to maximize performance. When you want to verify that your chip is starting up correctly and that everything pulls out of reset, use a more feature complete simulator like Icarus verilog. When you want to run a simulation that needs every last bit of performance, forgo “X” support and use Verilator.

I now have a large design project that I have brought up in verilator. It is quite a pleasure to work with. I have created a python extension module written as a C++ wrapper around the simulation that lets me control and evaluate everything using a nice higher level language. This is the most fun I have had with simulations in a long time. I had done a similar thing for NC-Verilog using the PLI interface, but it was not nearly as pleasant as Verilator–largley because Verilator is open source and I could modify the build process to produce a shared library. The beauty of making the python extension module is that I can implement all the time consuming operations in C++ for maximum performance, while doing the higher level tasks in python. I have integrated numpy into the extension module as well, so I can work with and analyze arrays very efficiently and then I use matplotlib to plot the simulation results.

I will post a short a little “getting started” example soon on how to build a python extension module around a Verilator simulation. For now I just wanted to make a plug for Verilator. I wish I had discovered it years ago. I will no longer be using the likes of VCS or NC-verilog again.

Making Exim Case-Insensitive

October 18th, 2008 by lane

I discovered that exim is sensitive such that Lane@example.com is a different user than lane@example.com. In my past experience sendmail was tolerant of such differences. I am not sure if that is because the sendmail configuration files distributed by Fedora/Redhat had that already setup or if it is built into sendmail. Regardless, I had some users expressing problems with email and we finally figured out it was because people were trying to send them email to usernames with capital letters in them. I added the following to my exim.conf file right before the localuser: router. Order is important, so make sure you put it in the right place.

lowercase_local:
     driver = redirect
     redirect_router = localuser
     domains = +local_domains
     data = ${lc:$local_part}@$domain

Certicates on Fedora/Redhat Linux Distributions

October 18th, 2008 by lane

With Firefox 3 requiring you to jump through so many hoops to accept an personally signed certificate, I have decided to actually purchase a signed certificate to prevent my users from jumping through the hoops.  I was surprised at how easy it has become to get a signed certificate.  I used godaddy to sign my certificates since I already have an account with them.  They require a Certificate Signing Request (CSR).  The following instructions detail how to generate the requested CSR.

  1. As root, go into the /etc/pki/tls/certs. Check that you have a key already in the /etc/pki/tls/private directory called localhost.key. Then run the following command to generate the CSR:

    /usr/bin/openssl req -new -key ../private/localhost.key -out localhost.csr

    Answer all the questions. The most important question is the Common Name question. Make sure to put the host you want signed here, e.g. www.example.com. Then send this CSR to your signing agency.

  2. After you signing agency sends you back your certificate and their certificate, put them in the /etc/pki/tls/certs directory. Let’s suppose you call them mycert.crt and theircert.crt. Then update your apache configuration file to reflect these files. Here is what my squirrel mail virtual host section looks like in file /etc/httpd/conf.d/squirrelmail.conf:
    
    DocumentRoot "/usr/share/squirrelmail"
    ServerName webmail.example.com:443
    
    ErrorLog logs/webmail_error_log
    TransferLog logs/webmail_access_log
    LogLevel warn
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SSLCertificateFile /etc/pki/tls/certs/mycert.crt
    SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
    SSLCertificateChainFile /etc/pki/tls/certs/theircert.crt
    
        SSLOptions +StdEnvVars
    
    
    SetEnvIf User-Agent ".*MSIE.*" \
             nokeepalive ssl-unclean-shutdown \
             downgrade-1.0 force-response-1.0
    
    CustomLog logs/webmail_request_log \
              "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    
    
  3. Restart httpd and test it out. No more nasty messages about unsigned certificates!

Installing Fedora 10 Linux on Macbook Air

October 14th, 2008 by lane

Note: See comment below to my link for the Fedora 11 experience.

I have Fedora 10 Beta running quite smoothly on the original MacBook Air. There are several good sites from which I got most of my information. They are:

Here are the steps I followed to get Fedora installed:

  1. Use Boot Camp to make room for Fedora. Go through the wizard and resize the partitions. Then quit Boot Camp
  2. Download rEFIt and install it on the Macbook Air
  3. Download a Fedora Live CD to another Fedora Install. I tried quite unsuccessfully to get the Macbook Air to boot the live CD from a USB thumbdrive but was not able to do so ever. I was using the live cd tools command livecd-iso-to-disk to put the Live CD iso on the USB thumbdrive. rEFIt would recognize the thumbdrive and try to boot it but then give an error saying Apple’s firmware does not have good support for booting legacy OS’s.In the end I bought an external USB CDROM drive. Apple sells one that is expensive. I bought the cheapest one from Frye’s at $40. I put the Fedora Live CD on CD, plugged the external CDROM drive into the MacBook Air’s USB slot and booted. Hitting the Option during boot brings up rEFIt. It recognized linux on the CD and gave me the option to boot it.
  4. The Live CD boot took a really long time and printed several warnings and errors during the process. It finally made it to the login screen. I auto-logged in and double clicked the Live Install option. During the install, I selected “Create Custom Layout” during the disk formatting option. I changed the third partition to ext3 and reduced its size by 2GB. I created a fourth partition of type swap. I made the third partition the root directory /. I then rebooted.
  5. With linux installed, it booted much faster and without errors. I happened to have the USB to Ethernet adapter that Apple sells. This made getting everthing working much easier. The live cd is rather lean on programs, so I first did a yum update and installed some of the essentials like gcc, emacs, make, etc.
  6. Wireless: To get wireless working I used ndiswrapper from the Livna repo. Download the livna repo file and install it:
    wget http://rpm.livna.org/livna-release-9.rpm
    rpm -ihv livna-release-9.rpm

    Then I disabled the livna repo by default in the /etc/yum.repos.d/livna.repo. Then install ndiswrapper and associated kernel module:

    yum install --enablerepo livna-development ndiswrapper kmod-ndiswrapper akmod-ndiswrapper

    Run the akmods command to build the ndiswrapper kernel module. Now download the windows driver for the Broadcom wireless adapter:

    wget ftp://ftp.hp.com/pub/softpaq/sp37501-38000/sp37950.exe

    I had to use Windows to unpack this file. Grab the bcmwl5.inf file and put it on the Air. Run the command

    ndiswrapper -i bcmwl5.inf
    ndiswrapper -ml
    ndiswrapper -mi
    ndiswrapper -m

    I then had to remove all the pci related lines out of the /etc/modprobe.d/ndiswrapper file and leave only the alias wlan0 ndiswrapper line. Despite my best efforts with modprobe and ndiswrapper, I did not get a wlan0 network interface until I rebooted. After the reboot, wireless was working fine–except WPA.

  7. Sound: Sound took me quite a while to get right. I tried adding options snd_hda_intel model=mbp3 to /etc/modprobe.d/sound as suggested on other places, and still sound would not play even through reboots. Various forums said to make sure the “Speaker” option was checked in the volume control dialog. That did not help. I was doing a lot of futzing with modprobing the snd_hda_intel driver with various models, including mbp3, laptop, viao, etc. I was doing this from a virtual terminal after teliniting to runlevel 3. Then, as root I started X from a virtual terminal using the startx command and suddenly sound was working. When I tried it as regular user, it was still working. It even continued to work through a reboot. So I am not sure why it started working, but it is working. Perhaps there was a permission issue with /dev/snd/* modules? I am not sure why logging in as root would have effected any permissions though. Perhaps the also settings were adjusted correctly when I logged in as root and now they are saved? I don’t know…
  8. Keyboard:Fedora 10 does not come with an xorg.conf file. I created the following xorg.conf file to get multi-touch working:
    Section "ServerLayout"
       Identifier     "Default Layout"
       Screen      0  "Screen0" 0 0
       InputDevice    "Keyboard0" "CoreKeyboard"
       InputDevice    "Synaptics Touchpad" "CorePointer"
    EndSection
    
    #Section "Files"
    #   ModulePath      "/usr/lib/xorg/modules/extensions/nvidia"
    #   ModulePath      "/usr/lib/xorg/modules"
    #EndSection
    
    Section "Module"
       Load           "synaptics"
       Load           "extmod"
       Load           "dbe"
       Load           "glx"
    EndSection
    
    Section "InputDevice"
       Identifier     "Synaptics Touchpad"
       Driver         "synaptics"
       Option         "SendCoreEvents" "true"
       Option         "Device" "/dev/input/mice"
       Option         "Protocol" "auto-dev"
       Option         "SHMConfig" "true"
       Option         "LeftEdge" "10"
       Option         "RightEdge" "1200"
       Option         "TopEdge" "10"
       Option         "BottomEdge" "370"
       Option         "FingerLow" "10"
       Option         "FingerHigh" "20"
       Option         "MaxTapTime" "180"
       Option         "MaxTapMove" "220"
       Option         "SingleTapTimeout" "100"
       Option         "MaxDoubleTapTime" "180"
       Option         "LockedDrags" "off"
       Option         "MinSpeed" "1.10"
       Option         "MaxSpeed" "1.30"
       Option         "AccelFactor" "0.08"
       Option         "TapButton1" "1"
       Option         "TapButton2" "3"
       Option         "TapButton3" "2"
       Option         "RTCornerButton" "0"
       Option         "RBCornerButton" "0"
       Option         "LTCornerButton" "0"
       Option         "LBCornerButton" "0"
       Option         "VertScrollDelta" "20"
       Option         "HorizScrollDelta" "50"
       Option         "HorizEdgeScroll" "0"
       Option         "VertEdgeScroll" "0"
       Option         "VertTwoFingerScroll" "1"
       Option         "HorizTwoFingerScroll" "1"
    EndSection
    
    Section "InputDevice"
    
       # keyboard added by rhpxl
       Identifier     "Keyboard0"
       Driver         "kbd"
       Option         "XkbModel" "pc105"
       Option         "XkbLayout" "us"
    EndSection
    
    Section "Monitor"
       Identifier     "Monitor0"
       VendorName     "Unknown"
       ModelName      "Unknown"
       HorizSync       30.0 - 110.0
       VertRefresh     50.0 - 150.0
       Option         "DPMS"
    EndSection
    
    Section "Device"
       Identifier     "Videocard0"
    #   Driver         "nvidia"
    EndSection
    
    Section "Screen"
       Identifier     "Screen0"
       Device         "Videocard0"
       Monitor        "Monitor0"
       DefaultDepth    24
    
       Option        "AllowGLXWithComposite" "True"
       Option        "AddARGBGLXVisuals" "True"
       Option        "TripleBuffer" "True"
       Option        "UseDamageEvents" "True"
       Option        "UseRandR" "True"
       Option        "RenderAccel" "True"
       Option        "NoPowerConnectorCheck" "False"
       Option        "RandRRotation" "True"
       Option        "DynamicTwinView" "True"
       Option        "OnDemandVBlankInterrupts" "True"
       Option        "ConnectToAcpid" "True"
       Option        "EnableACPIHotkeys" "True"
       Option        "UseEvents" "True"
       Option        "ExactModeTimingsDVI" "True"
       Option        "NvAGP" "0"
    
       SubSection     "Display"
           Viewport    0 0
           Depth       24
       EndSubSection
    EndSection
    
    Section "Extensions"
      Option        "Composite" "Enable"
    EndSection
  9. Suspend: Suspend/resume works fine after creating an /etc/pm/config.d/unload_modules and with the single line:
    SUSPEND_MODULES=bcm5974
  10. I installed pommed to get the function keys to work.

Issues

  1. Don’t know how to right or middle click. Tapping the pad with two fingers initiates a right click, but still want middle click options.
  2. WPA wireless is not working.

Kerberos

August 22nd, 2008 by lane

I started using openldap for user information and automouting and I like it a lot despite the fact that it is more feature rich than I understand right now. I wanted to test afs and coda to see if they would meet our file system sharing needs, but both require Kerberos for authentication. I tried setting up Kerberos some 10 years ago and was not successful with and determined it was overkill for my small networking needs, so I was hesitant to try it again. Despite my reservations, however, tried it on both on a CentOS 5.2 and Fedora 8 server and was pleasantly surprised at how easy it was to setup. The RedHat Deployment Manual has very good instructions that I followed and had a working Kerberos setup in a very short time.

I still use LDAP for user information but am now using kerberos for authentication. To enable kerberos on the client machines, just copy the /etc/krb5.conf and run

authconfig --enablekrb5 --update