Debugging Support

When ACT programs get long, it may be difficult to track down why a particular circuit is not being constructed properly. To help debug this, there are two basic debugging constructs provided.

Assertions

Sometimes it is useful to be able to check that a parameter (or an expression of parameters) has a reasonable value. To express this, ACT supports explicit assertions. We use Hoare's syntax for assertions, so the assertion that x must be 8 would be written

{x=8};

If a more meaningful message is required, the following syntax is also supported:

{x=8 : "This assertion failed"};

which also reports the message specified when the assertion failed.

During circuit development/debugging, it may be helpful to assert that two signals are connected to each other or in fact disconnected from each other at a particular point during circuit construction. To assert that a is connected to b, use:

bool a;
bool b;
 
{ a !== b : "a and b are connected connected!" };  // this will pass
a = b;
{ a === b : "a and b are not connected!" }; // this will pass
{ a !== b : "a and b are connected connected!" };  // this will fail

The operators === and !== are used to check that the two signals are connected or disconnected at the point the assertion was encountered during circuit construction.

Log Messages

ACT supports debug log messages in verbose mode. A debug log statement can be written as:

...
${ "Hello!" };   // log message "Hello"
...

When this construct is encountered, a log message is displayed. By default these messages are ignored; to see them, use the -Vconfig ACT command-line option to any ACT tool. (Note that this will also display the names of the configuration files loaded by ACT.)

A log message can include multiple values, including parameter expressions. This can be useful to check values of parameters.

${ "Parameter i has value ", i };  // display the value of i