Next: , Previous: Boot sequence, Up: Running THUD


2.3 Code and data

Some say everything is code, while others say everything is data. This section describes where and how THUD makes the distinction between the driver (code) and the design (data).

2.3.1 Drivers

The drivers are Scheme files that are run from within the THUD environment. First, change into the particular directory and then invoke the driver. This can be done in two ways:

  1. From the shell, do "thud -x DRIVER".
  2. From an interactive THUD session, do "x DRIVER".

A driver is simply Scheme code that makes use of THUD primitives to do some work. The aforementioned environment restriction ensures that the driver has access to the proper definitions. This is done during THUD booting, which is different from THUD loading.

[It may be possible to merely “load” THUD into a Guile session and then `load' a driver, but that usage is discouraged because loading THUD does not boot it. Do not depend on this behavior; it may change in the future.]

To make a driver into a "standalone executable", do the following:

  1. Prepend these two lines to the file, removing the leading whitespace, and substituting the correct path to thud. Note that some operating systems limit how long the path can be.
              #!/some/path/to/thud -x
              !#
    
  2. Do "chmod +x DRIVER".

2.3.2 Designs

Designs are expressed as Scheme-based RTL files that are “added” into the workspace, where they are instantiated and linked as needed before simulation. These files typically have extension .th (for THUD HDL). Adding files can be done in five ways:

  1. From the shell, do "thud TH1 TH2 ...".
  2. From an interactive THUD session, do "add TH1 TH2 ...".
  3. From an interactive THUD session, do "add-only TH1 TH2 ...".
  4. From a driver, do "(add TH1 TH2 ...)".
  5. From a driver, do "(add-only TH1 TH2 ...)".

Note that all these forms can take multiple .th files, as indicated by the ellipses.

The add-only construct (see Data procedures) tells THUD that you probably won't be adding any other files – thus, THUD is free to instantiate and link after adding those files. If you do add other .th files afterwards, don't worry, THUD can handle it. (THUD always makes sure instantiation and linking is done before simulation; add-only is a hint that may save time but is not necessary.)