• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Blogs
  2. Verification
  3. Creating Code from Tables
teamspecman
teamspecman

Community Member

Blog Activity
Options
  • Subscribe by email
  • More
  • Cancel
Specman
Tables
e
verification

Creating Code from Tables

30 Nov 2016 • 6 minute read

Some things are best described with tables—each column shows the values for one category, and each row encapsulates one given set of values for all categories. e verification language code is a perfect fit.

This blog describes how to use tables in your verification environment code to make the code more readable and more easily maintained. The tables can be written in the code or they can be pulled in from an external file. For example, you can pull a Microsoft Excel file defining device configuration into your verification environment, eliminating the need to manually convert the data in the excel file into code. More than that, as the last example in this blog illustrates, you can create any code you want based on data read from Excel.

Our first example is a basic one, illustrating how to create tables in the code itself, by using the e in_table. Assume a device whose configuration is defined by bus type, bus width, and speed.  Constraining the configuration unit using a table format is simple to write and, more importantly, simple to read and maintain:

type bus_type : [ISA, EISA, VL_BUS, PCI];

unit config {
    b_type  : bus_type;
    b_width : byte;
    b_speed : byte;

    keep (b_type,   b_width,   b_speed) in_table {
           ISA,     [16, 32],    8;
           EISA,     32,         8;
           PCI,     [32, 64],    33;
           ISA,      64,       [66, 133];
    };
};

The information about the legal configuration modes is required not only during generation. Some checks, for example, might depend on the device configuration. You can use tables anywhere in the code:

  if  (b_type, b_width, b_speed) in_table {
         ISA,    64,    [66, 133];
        } {
          ///… write checks that are relevant to this mode
        };

  if  (b_type,  b_width,  b_speed) in_table {
         ISA,    [16, 32],  8;
         EISA,     32,      8;
         PCI,    [32, 64], 33;
     } {
        ///… actions that are relevant to this mode
     };
  };

This code is valid, but what about reuse? Copying and pasting these lines is error prone and challenging to maintain. Instead of copying the tables, let’s define a table once and use it multiple times in the code. To define a table, we define one or more rows using the e table_row type:

define <slow'table_row> "SLOW_CONFIGURATIONS" as {
    ISA,  [16, 32], 8;
    EISA, 32, 8;
    PCI,  [32, 64], 33;
};

define <normal'table_row> "FAST_CONFIGURATIONS" as {
    ISA,  64, [66, 133];
};

define <all'table_row> "ALL_CONFIGURATIONS" as {
    SLOW_CONFIGURATIONS;
    FAST_CONFIGURATIONS;
};

After these tables are defined, they can be used in constraints, in checks, just about anywhere:

    keep (b_type, b_width, b_speed) in_table {
       ALL_CONFIGURATIONS;
  };

  check() is also {
      if  (b_type, b_width, b_speed) in_table {
          FAST_CONFIGURATIONS;
         } {
          ///… write checks that are relevant to this mode
      };

      if  (b_type, b_width, b_speed) in_table {
            SLOW_CONFIGURATIONS;
         } {
            ///… actions that are relevant to this mode
      };       
  };

Now let’s take this one step further. Not only can you define tables in e, you can also read tables from another file – for example, from a CSV or an Excel file. With this capability, the person who writes the configuration file needs to know nothing about how the verification environment is structured and implemented, and the person who writes the verification environment doesn’t have to be told of every change in the configuration.

For reading the configuration table from a CSV file, you would use the e csv_to_table() operator. For reading the configuration table from an Excel file, you would use the e excel_to_table() operator.

For example, assume the CSV file “config.cvs” contains these two tables:

SLOW_CONFIGURATIONS
#type, #width, #speed
ISA,  "[16,32]",  8
EISA, 32,         8
PCI,  "[32, 64]", 33

FAST_CONFIGURATIONS
#type,  #width,  #speed
ISA,     64,   "[66, 133]"

You can read these tables from your e code as follows:

    keep (b_type, b_width, b_speed) in_table {
       table from csv_to_table("config.csv" "SLOW_CONFIG") with {
            <#type>, <#width>, <#speed>;
       };
  };

And why stop there? Tables can be a good source for creating code that follows any kind of regular pattern.  Each row in the table holds the values for one instantiation of the pattern.

For example, if the verification environment defines a core unit that contains several fields, the properties for specific cores can be provided by an external file. The following code reads a table and, for each row in the table, instantiates a unit of the type core and constrains its fields according to the row’s data:

table from csv_to_table("config.csv", "Cores Info") with {
    <#id> : <#id> core is instance;
    keep <#id>.kind == <#kind>;
    keep <#id>.address == <#address>;
};

As you can see – the code within the “with {}” block is simple e code, and each <#> is replaced with the value in the relevant column. 

The input file could look something like this:

Cores Info

#id,   #kind,  #address, #enabled, #retainable
CORE0,  A34,   0x1000,   TRUE,      TRUE     
CORE1,  BL,    0x8000,   FALSE,     TRUE     
CORE2,  B5,    0xaa00,   TRUE,      FALSE
//...

These constructs – in_table, table_row, and table from file with are all part of Specman. Use them to make your verification environment more user friendly, more readable -- and more reusable.

 

Enjoy Verification, Enjoy e,

Team Specman 

Related Resources:

  • Incisive Specman Elite
  • Specman Fundamentals for Block-Level Environment Developers (Training)

 

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information