TDEB Top Bar

Trending
Semiconductor Industry News — The Digital Electronics Blog
Follow Us

TDEB Masthead

The Semiconductor Hub

Semiconductors.  Chips and Systems.  Innovation.

Indexed by leading Search Engines, AI and referenced by Engineers worldwide 500+ Articles 10M+ Pageviews 30+ Reports 50+ Citations

Comit-TX: Extracting a Verilog Testbench for a Single Module

mg
by
0
Share Facebook X LinkedIn WhatsApp Email

Comit-TX, a free tool from Comit Systems, pulls a self-checking Verilog testbench for any single module out of a design that already has a system-level testbench. With that extracted testbench you can verify a replacement version of the module on its own, in exactly the conditions it sees inside the full system, without simulating the whole chip each time.

The problem it solves

Large designs rarely arrive complete. Early on, some modules exist only as high-level models; later they are replaced with RTL or gate-level versions. Even after that, modules keep changing for area or timing reasons. Every time a module is swapped or optimized, you need to show that its behavior and its interface to the rest of the design are unchanged.

The obvious way is to rerun the full system simulation, but that is slow, and most of the simulation time goes to logic you did not touch. A module-level testbench would be much faster, but writing one by hand that reproduces the real traffic the module sees in the system is a lot of work, and it may still miss the corner cases the system test happens to exercise.

How Comit-TX works, in outline

According to the Comit-TX user manual, the tool is written as a Verilog PLI (programming language interface) extension and is linked into the Verilog-XL simulator. You call a new system task, $comit_tx, from the system testbench and give it the hierarchical name of the instance you care about. While the full system simulates, the tool records what happens on that instance's ports. It then writes out a stand-alone testbench that:

  • drives the module's inputs with the same values, at the same times, that it saw in the system run, and
  • checks the module's outputs against the values recorded in the system run, reporting any mismatch.

Because the testbench checks itself, verifying a new version of the module is just a matter of running the short simulation and reading the report.

When you would use it

The manual lists three typical cases:

  • Showing a customer that a sub-system does what it should as a stand-alone block, even though it was verified inside the full system.
  • Checking that optimizations or edits made to a module on its own did not change its behavior.
  • Replacing a high-level model with a detailed RTL or structural version and confirming the new one behaves exactly like the old one.

What it cannot do

The manual is clear about two assumptions. First, the extracted testbench is only as good as the system testbench it came from: if the system test never exercised a feature of the module, the extracted test will not either. Second, it treats whatever the module did in the system run as correct. It is a regression tool that detects change, not a checker that proves the original module was right.

Deep dive: the numbers and details

This part holds the figures, equations and worked examples. Skip it if the overview is all you need.

Calling the tool

The manual documents the call as:

$comit_tx(instance_name, sub_module_name, [inout_count],
          [io_1], [ctl_1], [cval_1], ..., [io_n], [ctl_n], [cval_n]);

The first argument is the hierarchical instance name, the second the module name. For each bidirectional (inout) port you also pass the port, the control signal that sets its direction, and the control value at which the port acts as an input, so the tool knows when to drive the bus and when to check it. A typical call sits in an initial block, for example $comit_tx("test.micro.ALU.mult", "multiplier");.

The outputs are two files per instance: instance.v, the top-level test module that declares and instantiates the module, and instance.vlg, the stimulus and checking commands. Running the extracted test produces instance.rpt, which lists any difference between the stand-alone behavior and the behavior recorded in the system run.

The listed requirements reflect the tool's age: Cadence Verilog-XL version 2.5 or higher, SunOS or Solaris 5.5 or higher, and Perl 5.0.

Worked example: why extraction saves time

Assume a full-chip regression takes 4 hours, and the multiplier you are optimizing accounts for 2% of the design's logic. If simulation time scales roughly with the amount of logic simulated, a stand-alone run of the multiplier with recorded stimulus could take on the order of 2% of 4 hours, about 5 minutes. Over 20 optimization iterations, that is about 1.6 hours of simulation instead of 80. The figures are illustrative: real savings depend on how much of the system time goes to the testbench itself and how the simulator scales.

Doing the same today without the tool

Comit-TX targets an old simulator and operating system, but the idea, often called record and replay, is easy to reproduce in plain Verilog. A monitor in the system testbench logs the module's ports on every clock:

// In the system testbench: record the ports of u_mult every cycle
integer f;
initial f = $fopen("mult_trace.txt", "w");
always @(posedge clk)
  $fwrite(f, "%h %h %h\n", dut.u_mult.a, dut.u_mult.b, dut.u_mult.p);

A stand-alone testbench then reads the trace, applies the inputs and compares the outputs:

// Stand-alone replay testbench (one line per clock in the trace)
reg [15:0] a, b; reg [31:0] p_exp; wire [31:0] p;
multiplier u_mult (.clk(clk), .a(a), .b(b), .p(p));
integer f, n, errors = 0;
initial f = $fopen("mult_trace.txt", "r");
always @(negedge clk) begin
  n = $fscanf(f, "%h %h %h\n", a, b, p_exp);
  if (n != 3) begin $display("done, %0d errors", errors); $finish; end
end
always @(posedge clk) #1
  if (p !== p_exp) begin errors = errors + 1;
    $display("mismatch at %0t: got %h, expected %h", $time, p, p_exp); end

This sketch assumes a single clock and registered outputs, and lines up the check with the recorded cycle; a real version must handle reset, multiple clocks, latency and bidirectional ports, which is exactly the bookkeeping Comit-TX automated. In SystemVerilog-based flows, the same job is usually done with interface monitors that write transactions to a file and a sequence that replays them.

Points to watch

IssueWhy it matters
Coverage inherited from the system testUnexercised features stay untested in the extracted bench
Golden behavior is "whatever happened"A bug in the original module becomes the expected result
Cycle-accurate comparisonA deliberate change in latency, for example after retiming, shows up as a mismatch even if the function is still correct
Bidirectional busesThe tool must know when to drive and when to check, hence the extra arguments

Further reading

Share Facebook X LinkedIn WhatsApp Email

Post a Comment

0 Comments

Your comments will be moderated before it appears here.

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!