Archive for the ‘Uncategorized’ Category

Plug for Verilator

Friday, 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.

Installing Fedora 10 Linux on Macbook Air

Tuesday, 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.