HDL verification with Maia

Maia is a lightweight verification language, and was created specifically to automate the test and specification of HDL designs. You don't need to know any Verilog or VHDL to use it: in fact, you don't even need to know anything about verification. If you know what outputs your device should produce from a given set of inputs, then you can write a test.

You can use Maia to quickly create automated self-checking testbenches. In production environments, Maia is primarily used in a Test Driven Development flow, and for creating automated regression and unit test environments. However, there's nothing to stop you from using your own test framework, or simply using Maia to write stand-alone tests.

Maia has a very different emphasis and use case from 'Hardware Verification Languages' such as e and SystemVerilog. The problem it addresses is a more fundamental one: writing testbenches is just Plain Hard Work, and is completely unlike designing hardware. This means that hardware designers, by and large, don't write testbenches. Maia addresses this by defining a simple control language which allows easy and direct access to your RTL code, and which greatly simplifies the process of driving the RTL, and checking the resulting outputs. The language features include:

  • DUT ports and internal signals can be driven directly from your code, and automatically tested against arbitrary expressions
  • SDC-compatible syntax for declaring clocks and timing
  • 2-state and 4-state variables, with arbitrary bit widths, arbitrary-precision arithmetic, and direct bitslice accesses
  • Multi-threaded functions, functions which trigger on predefined hardware conditions, reference parameters, and so on
  • Simplified version of C, with extensions

Many simple C programs will run directly when compiled as Maia code and run on an HDL simulator. There is a full built-in preprocessor, and many features (including scoping, expression syntax, operator precedence, arrays, structures, initialisation, and control statements) are identical to C, with some extensions. The major differences are:

  • The type system is different, because Maia is primarily concerned with explicitly-sized variables, and bitfields within those variables
  • Pointers are not supported (C++-style references can instead be used for function parameters)
  • There is a very simplified 'standard library', including a handful of functions (report, which is essentially printf, together with assert, rand, and so on). Generic file I/O is not supported, but a new stream type automates the use of 'test vector' files

You can download a free compiler ('mtv') from the downloads section, for both Linux and Windows. mtv translates a Maia program into a Verilog testbench. You can add this testbench to your project in exactly the same way as any other file, and simulate your design with your favourite simulator. If you haven't got a simulator, you will need to get one first. If you are testing VHDL designs, you will need a mixed-language simulator; if you are testing Verilog designs, a Verilog simulator will be sufficient. The simulator must support Verilog-2005 (IEEE 1364-2005). No SystemVerilog support is required.

The download also includes a compiler driver ('rtv'). You don't need rtv to simulate the Verilog output file produced by mtv, but it does automate the process of carrying out a full batch-mode simulation. rtv is driven by a configuration file, which lists the instructions required to run supported simulators. If your simulator isn't currently supported, it's straightforward to add your own instructions to this file.

Because rtv automates batch-mode simulations, it can be used to build regression and unit test environments. The tutorials code in the distribution includes a Tcl-based infrastructure which runs rtv and automates the execution and test of the tutorial examples. This is driven from a list of the tests to be run, and can be easily modified to run your own regressions or unit tests. You will need to install Tcl if you intend to use rtv in this way. You can find out more about the test framework here.

Where next?

Check out the Introduction section on the menu. This includes some simple examples of language usage, and some background on the history of the language and its development. You'll also find tutorials and a language reference.

As a first step, you should try downloading one of the distributions and working through the Tutorial code. This will be enough to get you up and running quickly, and should take no more than a couple of hours.