My First ASIC

For the first time in the past few years, I’m really having a lot of fun, and I owe it to my ASIC design course.  For a previous homework assignment, I had to modify and customize a simple counter device.  I then had to simulate and find the optimal clock period with Synopsys.  In the next homework assignment, I had generate the back-annotated delays, and then re-simulate, re-synthesize, and finally analyze for power consumption.  Using the Cadence Encounter tool that is available on campus, the result of my efforts is shown below.

My First ASIC - a simple counter


Now I just have to learn how to read what Encounter is showing me (Fence, Guide, Obstruct, etc.) …


Verilog Include files with ModelSim

I am currently using ModelSim to verify some hardware modules for my term project, and I have developed some tasks and macros that are useful when working with SRAM modules.  I decided to put these in a separate file from my testbench code, and then have the testbench code use the `include verilog macro to include these tasks in the testbench.  This has two advantages:

  1. The tasks and macros can be shared and used in other testbenches
  2. The testbench code is significantly easier to read

For those not familiar with the `include macro, from section 19.5 of the IEEE1394-2001 Verilog Language Reference Manual,

The file inclusion (`include) compiler directive is used to insert the entire contents of a source file in another file during compilation. The result is as though the contents of the included source filea ppear in place of the `include compiler directive.

Please note that you can also use `ifndef/`define/`endif macros, just as you would with C/C++ header files, to prevent compiler issues due to multiple inclusions of the included file.  Also like C/C++ compilers, ModemSim’s verilog compiler looks in the current directory for included files.  Any files not in the current directory will not be found by the compiler, as shown below.

> vlog testbench/sram_tb.v
# Model Technology ModelSim PE Student Edition vlog 10.0a Compiler 2011.02 Feb 20 2011
# — Compiling module sram_tb
# ** Error: testbench/sram_tb.v(120): Cannot find `include file “sram_tb_util.v” in directories:
#     C:/Modeltech_pe_edu_10.0a/ovm-2.1.1/../verilog_src/ovm-2.1.1/src, C:/Modeltech_pe_edu_10.0a/uvm-1.0/../verilog_src/uvm-1.0/src
# C:/Modeltech_pe_edu_10.0a/win32pe_edu/vlog failed.

There are two ways to specify the include path.  The first method is to pass the incdir option to the vlog command.  The command below tells the verilog compiler to look in the testbench directory for any files included in the sram_tb.v file.

vlog testbench/sram_tb.v +incdir+./testbench

The other way is to use the GUI to set the include directories for project.  Right-click on any verilog source file in the Project View, and select “Properties…”.  In the dialog box that appears, select the Verilog & System Verilog tab, and use the “Include directories…” button to add paths to include directories.

Whenever you compile your verilog source files, the paths specified in the include directories will be searched when the `include macro is encountered in your source files. Please note that this only works when you compile with the GUI compile button.  Users who prefer to use the command shell in the GUI –like myself–will still have to add the +incdir+ option to the vlog command.  I suppose the designers of ModelSim are encouraging us to write Tcl build scripts…

Final Thoughts on Ada

I’ve been dabbling with Ada off and on for the past three years now.  It has been very interesting and it has changed the way I think about software.  That said, I think I am letting it go now.  Let me explain.

I have been working on a model and software tool for a ASIC design course I’m taking this semester.   Essentially I need to do some preprocessing of data that is to be stored in a ROM in the hardware.  We are free to use any technology to implement the software part, and I was torn between C++ and Ada initially.  I’m most proficient and productive in C++, but I thought it would be a good opportunity to really learn how to use Ada in a non-trivial way.

I ended up picking Ada, and at first all was well.  The compiler caught a lot of silly errors and the algorithms just seemed to flow.  Despite my unfamiliarity with Ada, the syntax felt intuitive and I did not run into too many issues implementing my algorithms. I particulary apprecaited the assignment operator (:=) and wished for it in C++ at a later point.  Exceptions when dereferencing my pointers was also much more pleasant than core dumps and gdb sessions.

Ada let me down in three areas however: strings, text I/O, and generic containers.  Working with strings and text in Ada is just down-right painful, and I think Ada really shows its age here.  The I/O subsystem is also as primitive as its gets, and something as simple as printing an integer as a hexadecimal number without the 16#…# was not easy and I ended up having to writing somewhat of a hack.  I am sure there is a better way, but there just isn’t a large enough community and Internet pressence around Ada to quickly figure out the better way to do things.

Generics in Ada were also quite awkward to work with.  The most annoying aspect about generics is the having to use package methods to operate on the generic objects.  The containers package also lacks some very fundamental data structures such as simple queues.  In general I don’t like generics in Ada, they feel like an afterthought and a poor immitation of the Standard Template Library of C++.  I realize there are third party libraries like the Booch Components or Charles Library, but to a novice Ada developer I found it difficult to build and install things with GPR files rather than Makefiles.

In the end, I reverted back to C++.  Despite the cryptic nature of C++ and a frustrating debugging session where the cause was “if( a = b)”–which Ada would have caught–I was able quickly reimplement the code in C++ and move onto the hardware design…the reason for enrolling in a hardware design course.  Where C++ really shined was with the STL and Boost library.  STL containers and algorithms are simple to use, and Boost shared_ptr saves one from having to worry about memory management and allows one to focus on algorithms and the problem at hand.  And program_options makes creating a command line program a breeze.

I am sure that Ada really shines in embedded systems where string processing is much less common, and the features of Ada are in high demand. To master Ada, I also think one would need access to a strong mentor as the books and available resources for Ada are lacking in this day and age.

I came to appreciate many featuers in Ada, but in the end I just do not think it is the right tool for the type of things I do at work, school, and home.  C++ does everything I need at the momement, and I should probably focus my attention and software energies on learning new C++0x features or even exploring Erlang, my favorite programming technology at the moment.

Femtocell Trial

One of the disadvantages of living in a small city in North America is that mobile phone cell coverage can be rather poor.  I have very poor reception in my home and as a result I still have both a fixed telephone line and a mobile phone.  I never experienced anything like this while I was living in Japan.  My previous carrier, T-Mobile, was no better than the current.  AT&T Wireless, my current carrier, recently sent me an offer for a free 3G microcell for use in my home. I am not familiar with the microcell and cannot recall it from the 3GPP specifications, but I guess that it is something like a femtocell that is mentioned in 3GPP.  Being keen on dropping the fixed line subscription and its high-priced, limited-usage long-distance call plan, I decided to accept the offer.

I picked up the microcell at a local retail shop and the salesman took care of the activation.  At home I unboxed the microcell and was surprised that for its size it was quite light-weight, much lighter than my 802.11 wireless router.  I wonder if the size is due to the antenna, or perhaps EM shielding?  I followed the simple quick start guide and after the 90-minute setup period, sure enough I have a much stronger 3G signal in my home.

For those worrying about leechers and security, not just anyone can use the microcell.  Up to 10 mobile numbers can be registered and managed with AT&T via their website.

I will not be canceling the fixed line just yet, but if this microcell works consistently for awhile then hopefully this solution will allow me to finally kick that money-hungry fixed line operator out of my home.