Thursday, March 10, 2011

Comparing Signal Strength in Verilog/Systemverilog


Language doesn’t allow you directly to compare the signal strength. But you can compare strengths by converting the strings. By using the following macro you can achieve the required function.

`define compSigValues(siga, sigb)
  begin
  string sigaStr, sigbStr;
  $sformat(sigaStr, "%v", siga);
  $sformat(sigbStr, "%v", sigb);
  if ( sigaStr == sigbStr )
$display("Signal values %s and %s match", sigaStr, sigbStr);
  else
$display("Signal values %s and %s don't match", sigaStr, sigbStr);
 end

Monday, March 7, 2011

Escaped Identifiers in hierarchical Path usage in Verilog/Systemverilog

An identifier in Verilog and SystemVerilog is the name of some object, such as the name of a module, the name of a wire, the name of a variable, or the name of a function. The legal characters in an identifier are alphabetic characters, numbers, underscore or dollar sign. All other characters, such as +, -, (, ), [ and ], are illegal in an identifier name.
Verilog and SystemVerilog allow these illegal characters to be used in a name by escaping the identifier. A name is escaped by preceding the name with a back slash ( \ ) and terminating the name with a white space character.


module \d-flop (output q, \q~ , input \d[0] ,clk, \rst- ); 
...
endmodule


Note in the above example that a white space character must be used before the commas that separate an escaped identifier from the next item in the list. A white space is also required between the last escaped name, \reset-, and the closing parenthesis.
The gotcha is when an escaped identifier is used as part of a hierarchy path. The escaped identifier must be terminated by a white space. That white space looks like it breaks the hierarchy path into two identifiers, but the terminating white space is ignored, which, in effect, concatenates the two names into one name.


The following examples illustrate the use of white space after references to escaped identifiers. Module chip uses named port connections to escaped port names identifiers. The $display contains a relative hierarchy path that contains an escaped identifier.


module chip (output [7:0] q, input [7:0] d, input clk, rstN); 
\d-flop \d-0 (.q(q[0]), .\q~ (), .\d[0] (d[0]), .clk(clk), .\rst- (rstN));
initial 
begin 
$display(“d = %b”, \d-0.\d[0] );    // Error - As White Space is missing
$display(“d = %b”, \d-0 .\d[0] );   // Correct Usage as White Space is used.
end
endmodule


The Netlist file normally will be using Escaped Identifiers to preserve the hierarchical path of design.

Tuesday, March 1, 2011

Adding Validation support to OVM Agents

OVM Agents need to be developed to support the Validation activity also. Sometimes during validation we will be having requirement to provide the Packets or input data in file format. If OVM Agents has the capability to dump the packet into file at various abstraction levels, that file can be used as Input during validation. Adding this logic may not be overhead to Agent when compared against the advantages.

Monday, February 28, 2011

Duplicate or multiple OVM banners

    When executing vsim on a design containing OVM, two or more OVM banners appear on the screen and/or in the transcript file.
    # ------------------------------------------------- 
    # OVM-2.1.1 
    # (C) 2007-2009 Mentor Graphics Corporation 
    # (C) 2007-2009 Cadence Design Systems, Inc. 
    # ------------------------------------------------- 
    # ------------------------------------------------- 
    # OVM-2.1.1 
    # (C) 2007-2009 Mentor Graphics Corporation 
    # (C) 2007-2009 Cadence Design Systems, Inc. 
    # -------------------------------------------------
    
    
    
    
    The message is printed in method ovm_report_handler::report_header() in src/base/ovm_report_handler.svh
    This is called only from OVM code in method ovm_report_object::report_header() in ovm_report_object.svh
    This too is called only from OVM code in ovm_root::new() in ovm_root.svh

Solution:
All possible causes of multiple printout of this message and suggestions for resolution: 

1. User code has instantiated ovm_root multiple times via multiple calls to ovm_root::new().  This should not be done and will need to be corrected. 

2. User code has extended ovm_root and changed its behavior. This also should be not be done and will need to be corrected.

3. User code calls ovm_report_handler::report_header() directly via an ovm_report_handler object handle.

4. User code calls ovm_report_object::report_header() directly via an ovm_report_object handle or subclass method override calling super.report_header(). 

5. One additional and very likely possibility is that there are multiple ovm_pkg universes compiled separately and integrated at runtime. This can happen in a simulation scripting case, which compiles separate units (e.g. VIPs or testbench bits) each of which correctly does an import ovmpkg::*. Those units are then integrated in to a toplevel testbench by `include instead of by import my_subunit1::*; import my_vip2::* etc 


Don't use `include for this case. Use only `import. Otherwise the outcome is that each package, while called ovm_pkg, is actually a different package namespace with a different ovm_root etc.

Wednesday, February 23, 2011

Virtual Signal Spy...Debugging Made easy

If you are using Questasim, your waveform debugging will be easy if start using Virtual Signal Option. With the help of this option New Signals can be created by applying the expressions on the Existing signals. You can also delay the signals by certain amount when comparing input with output which will be general case many times.



Few examples include:
Create a virtual signal that is the same as /top/signalA except it is delayed by 10 ps. 
  virtual signal -delay {10 ps} {/top/signalA} myDelayedSignalA

Create a three-bit signal, chip.address_mode, as an alias to the specified bits. 
  virtual signal { chip.instruction[23:21] } address_mode

Create a two-bit signal (with an enumerated type) based on the results of the subexpressions. For example, if aold equals anew, then the first bit is true (1). Alternatively, if bold does not equal bnew, the second bit is false (0). Each subexpression is evaluated independently.
  virtual signal {(aold == anew) & (bold == bnew)} myequalityvector

Create signal newbus that is a concatenation of bus1 (bit-reversed) and bus2[7:4] (bit- reversed). Assuming bus1 has indices running 7 downto 0, the result will be newbus[11:0] with the upper 8 bits being bus1[0:7] and the lower 4 bits being bus2[4:7]. 
  virtual signal {(concat_reverse)(bus1 & bus2[7:4])} newbus

I personally felt this option saves lot of time and effort during debugging.
Hope the same for you too...

Tuesday, January 18, 2011

Spare Cells in ASIC

What are spare cells and why the heck do we need them?
Spare cells are basically elements embedded in the design which are not driving anything. The idea is that maybe they will enable an easy (metal) fix without the need of a full redesign.


Sometimes not everything works after tape-out, a counter might not be reseted correctly, a control signal needs to be additionally blocked when another signal is high etc. These kind of problems could be solved easily if “only I would have another AND gate here…”
Spare cells aim to give a chance of solving those kind of problems. Generally, the layout guys try to embed in the free spaces of the floor-plan some cells which are not driving anything. There is almost always free space around, and adding more cells doesn’t cost us in power (maybe in leakage in newer technologies), area (this space is anyhow there) or design time (the processes is 99% automatic).


Having spare cells might mean that we are able to fix a design for a few 10K dollars (sometimes less) rather than a few 100K.

So which spare cells should we use? It is always a good idea to have a few free memory elements, so I would recommend on a few flip-flops. Even a number as low as 100 FF in a 50K FF design is usually ok. Remember, you arenot trying to build a new block, but rather to have a cheap possibility for a solution by rewiring some gates and FFs.

What gates should we through in? If you remember some basic boolean algebra, you know that NANDs and NORs can create any boolean function! This means that integrating only NANDs or NORs as spare cells would be sufficient. Usually, both NANDs and NORs are thrown in for more flexibility. 3 input, or even better 4 input NANDs and NORs should be used.



A small trick is tying the inputs of all NANDs to a logical “1″ and all inputs of the NORs to a logical “0″. This way if you decide to use only 2 of the 4 inputs the other inputs do not affect the output (check it yourself), this in turn means less layout work when tying and untying the inputs of those spare cells.
The integration of spare cells is usually done after the synthesis step and in the verilog netlist basically looks like an instantiation of library cells. This should not done before, since the synthesis tool will just optimize all those cells away as they drive nothing. The layout guy has to somehow by feeling (or black magic) spread the spare cells around in an even way.


I believe that when an ECO (Engineering Change Order) is needed and a metal-fix is considered – this is where our real work as digital designers start. I consider ECOs, and in turn the use of spare cells to solve or patch a problem, as the epitome our usage of skills, experience, knowledge and creativity!