Home
Teal User`s Manual
Contents
1. This section describes the programming interface Note that there may be undocumented private interface data and members Creating copying and destroying a vreg To create a vreg pass in a string path down to the wire or register The path is copied so that later printing functions can print the signal by name If the path does not map to an HDL signal you get an error and all subsequent usage of this vr eg will fail vreg const std string amp path and name vreg vreg amp vreg operator const reg Sometime when designing reusable Intellectual Property IP you may not know if a particular register is going to be implkemented in every instance of the DUT Yet to minimize the chance of having different versions of IP you want to write the IP such that it always exists This is supported in the vreg class by allowing the path to be zero NULL In this case the vreg is www trusster com nnnnnnn 3l not hooked up and all operations proceed as though this was a reg obejct You can test this condition by the enabled method bool enabled Similar to the above discussion there are times when you do not know the name when the object must be constructed This case should be rare as two stage construction is more prone to errors To supported delayed hookup to the HDL the name method is used This resets the path to the register void name const std string amp path and name Finally the verific
2. reg 24 operator teal 25 operator teal reg 25 operator teal reg 25 operator teal vreg 23 31 operator teal reg 26 operator gt gt teal reg 25 operator teal reg 26 operator teal reg 26 operator teal reg 26 P posedge teal posedge 66 R RAND_32 teal RAND_32 47 RAND_8 teal RAND_8 47 RANDOM_RANGE teal RANDOM_RANGE 47 random_range teal random_range 48 80 Teal User s Guide read check teal reg 27 teal vreg 32 reduce xor teal reg 26 reg teal reg 23 run thread teal 65 S signal teal condition 67 start teal dictionary 73 stop teal dictionary 73 stop thread teal 65 teal at 66 dec 42 endl 42 error 41 expected 41 hex 42 message type 41 note task completed 65 operator 25 operator amp 26 operator 26 operator 25 run thread 65 www trusster com 81 stop thread 65 thread name 65 user thread 65 vtime 65 teal RAND 32 47 teal RAND 8 47 teal change change 66 teal condition condition 67 condition 67 signal 67 wait 67 teal dictionary find 74 find on command line 74 start 73 stop 73 teal memory add map 56 add memory bank 56 lookup 56 write 56 teal memory memory bank memory bank 56 teal memory memory bank contains 56 57 from memory 57 memory bank 56 to memory 57 teal mutex mutex 66 lock 66 mutex 66 unlock 66 teal negedge negedge 66 teal operator 25 82 Teal User s Guide teal
3. 34 and hex value OxffddO The following code will read and print those parameters void verification top dictionary start teal test txt assume it has a line foo 10 vout my log basic parameters Teal User s Guide my log lt lt teal info lt lt Foo is lt lt dictionary find foo 20 lt lt endm std string not here dictionary find not here if not here 4 my log lt lt teal info lt lt expected not_here not found lt lt endm else my log lt lt teal error lt lt not_here found lt lt endm my_log lt lt bar is lt lt dictionary find bar 20 0 lt lt endm la fancy hex value std istringstream ss dictionary find hex value uint32 hex_value 9 ss gt gt std hex gt gt hex value my log lt lt teal info lt lt Hex value is lt lt hex value lt lt endm A min max integer This example shows how to find integer parameters Assume that a file teal test txt has only one line ds0 channel range 0 23 The following code will read and print that parameter void verification_top dictionary start teal test txt assume it has a line ds0 channel range 0 23 vout my log two integer parameters std string channel text dictionary find ds0 channel range if channel text my log teal error channel range not found en
4. Format The next functions set the output type add a line feed and end a message Note that although these are functions the iomanip template allows then to be used in line as part of the lt lt expression as in the cout model Be aware that you must call endm to end a line However you may want to have multiple lines in the same message In this case call endl This inserts a note to the vout object to begin a new line vlog amp dec vlog amp a v og vlog amp hex vlog amp a v og vlog amp bin vlog amp a v og vlog amp endl vlog amp a v og vlog amp endm vlog amp a vlog 1 Simple vout a_log Basic n a log note Hello World 42 endm Assuming the previuos lines are called at simulation time 5 nanoseconds the output is Teal User s Guide 5 ns simple cpp line 3 verification top Basic Hello World 42 2 Logging a reg reg a 23 reg b length 48 b 7 4 3 vout a log Basic a log lt lt note lt lt basic a is lt lt dec lt lt a lt lt endm n u u a log lt lt expected lt lt a is lt lt hex lt lt a lt lt and al so lt lt bin lt lt a lt lt endm u a log lt lt error bis lt lt hex lt lt b lt lt endm Assuming the previous lines are called at simulation time 565 nanoseconds the output is 565 ns basic cpp line 4 verification top Basic Note basic
5. The operation is communative The functions listed next are for the mathematical binary addition and subtraction operations Note that the registers are considered unsigned reg operator const reg 6 I hs const reg amp rhs reg operator const reg amp I hs const reg amp rhs reg amp operator const reg amp rhs reg amp operator const reg amp rhs Member functions These functions sends the mathematical result back to itself the gt operators The functions listed next perform left and right shift operations There are equivalent symmetrical operators as well These functions while seemingly complex provide capabilities that make reg act like a built in type Note that zeros are shifted in during a right shift reg amp roperator uint32 rhs reg amp operator uint32 rhs vlogk operator lt lt vlog amp c const reg amp rhs reg operator gt gt const reg amp I hs const uint32 rhs Logic functions These functions implement the Boolean operations that are associated with a register Some functions also implement the logic as a four state enumeration as in the HDL As with the math functions some are global and symmetrical while others are methods By default the relational less than or greater than operators act like the normal two state mathematical less than However when a single bit is X the result is X www trusster com 295 Thereduce xor method models the unary
6. a is 64 d23 565 ns basic cpp line 6 verification top Basic EXPECTED a is 64 h23 and also 64 b00000000000000000000000000000000000000000000000000000000000101 11 565 ns basic cpp line 6 verification top Basic ERROR b is 512 hXXXXXXXXXX3X 3 Output of an object This example shows code that enables complex objects to be printed as native types First declare the base operator lt lt method as virtual to allow derived classes to have their own output class base virtual vout amp operator lt lt vout amp v const v lt lt Base class return v bi Now declare a single global function to call the virtual one The compiler automatically finds this function when you do the following www trusster com 43 44 my log lt lt note lt lt base instance lt lt endm inline vout amp operator lt lt vout amp v const base amp b return b operator v class derived public base u virtual vout amp operator vout amp v const v lt lt Derived return v ki base a base derived a derived vout a log Basic a log lt lt note lt lt a base lt lt and lt lt a derived lt lt endm Assuming the previous lines are called at simulation time 565 nanoseconds the output is 565 ns object cpp line 7 verification top Basic Base class and Derived Teal User s Guide Chapter 8 The Random Number Module This chapter
7. describes what is means to have independent streams of random numbers and why that is important for verification It then describes Teal s facilities for random number generation and shows some random number generation examples 45 Overview Using random numbers for test values is a staple of modern verification The numbers must be well distributed and stable across runs The first is important because you need to find all the possible valid values and the second is important because after you find a bug you need to rerun that simulation at least twice Once to create a vcd file Once to confirm that the bug is fixed You might want to put that run in a regression suite as well The reruns of that simulation must produce exactly the same sequence of random numbers This chapter describes Teal s random number capability Theory of operation 46 Teal s trandom class provides a stable random number generator To provide independent streams of random numbers the random class uses a string and an integer to create the start seed The start seed is the initial value for the random number generator In addition to the start seed for each instance the random class itself is initialized with a master seed which provides a tie in to all the streams In this way a single number given to the static random ini t O function possibly from the command line or test file is used to guide all random number streams The basic ran
8. in an integer you can add your own message IDs and control their display Teal User s Guide As shown above completed messages are sent to the vlog object Generally you include a message ID pair that describes the type of the message The message type is generally either steal info Used for standard messages steal fatal Used when a test must exit the simulator immediativ teal error The error type is used when the expected behavior is different from the expected The number of info and error messages is counted and can be used for end of test checking or summary reports The vlog has two main functions One is to assemble the message items into a string The other is to print them out The standard vlog see Advanced vlog below for other possibilities performs these two tasks using an output message and a local print method The local print method is basic and prints the string to standard out using printf Also there is a subclass of the standard vlog called foile vlog which can send the text to the file via fprintf Level based Logging Sometimes its more convient to implement logging as based on a debug level What you are getting in the level feature more expressive power at the expense of additional complexity The vout class supports debug printing with ethe teal debug manipulator and the level lt gt io manipulator The vout class can be constructed with a functional area string like its
9. posedge posedge 66 teal RANDOM RANGE 47 teal random range random range 48 teal reg reg 24 format binary string 27 format decimal string 27 format hex string 26 operator 25 26 26 operator amp 26 operator 24 operator 25 operator 25 operator 26 operator gt 26 operator gt 25 operator 26 operator 26 operator 26 read check 27 reduce xor 26 reg 23 teal operator 25 to int 24 triple equal 26 write through 27 teal trandom draw 48 init 47 trandom 48 teal vout error count 41 get 41 operator 42 teal vreg vreg 31 www trusster com 83 enabled 32 invalidate all vregs 33 name 32 operator 23 31 read check 32 vreg 31 write through 32 thread name teal 65 to int teal reg 24 to memory teal memory memory bank 57 trandom teal trandom 48 triple equal teal reg 26 U unlock teal mutex 66 user thread teal 65 vreg teal vreg 31 teal enabled 32 teal name 32 teal vreg 31 vtime teal 65 84 Teal User s Guide W wait teal condition 67 write teal memory 56 write through teal reg 27 teal vreg 32 www trusster com 85 86 nnnnnnn Teal User s Guide
10. Teal User s Manual Version 1 40b Part number version TUG 1 40b Release date Spetember 12 2006 www trusster com 2006 Mike Mintz and Robert Ekendahl Printed in the United States of America All rights reserved Trusster makes no representations or warranties regarding the contents of this document Information in this docun is subject to change without notice and does not represent a commitment on the part of Trusster This document is protected by United States copyright law and may not be copied reproduced transmitted or distributed in whole part without the express prior written permission of Trusster Mike Mintz or Robert Ekendahl Trusster reserves t right to make changes to this document or TEAL software without notice and advises its customers to obtain the le version ofrelevant information to verify that the information being relied on is current Trusster Mike Mintz and Robert Ekendahl assume no liability for applications assistance customer product desig software performance or infringement of patents or services described herein Contents Using this guide I Who this guide is for I What you need to know 1 Conventions used in this guide I Customer support 2 Overview 4 System requirements 4 Hardware 4 Software 4 Teal in General 5 Overview 8 Basic Teal verification components 8 Overview 12 Downloading and installing Teal 12 Running the Teal tests 12 Overview 16 Theory of operation 16 Here s wh
11. Teal library is independent of any specific hardware platform yet as of this printing it has only been compiled on Liunx based operating systems However a windows port is in progress Check the trusster com web site for the availibility You may have to modify the base types used in Teal as specified in Teal h to compile and run Teal on other hardware platforms As teal is written in C it requires a c compiler You also need an HDL simulator Teal User s Guide Teal in General Teal is a collection of C classes functions and data placed within the teal namespace This set of code along with build and run scripts that you write provides an environment for verification tests Realize that this collection of code is only a very small part of the work of verification Given Teal you must write code to stimulate the Design Under Test DUT code to check the output from the DUT and files to control the stimulus generation Also you must write some some top level code to start and stop the various stimulators generators and of course guide these to perform a test www trusster com 5 nnnnnnn Teal Chapter 2 Components of a Teal Verification System This chapter describes the various parts that make up a Teal Verification System Overview There are many different definitions of a verification system Within this manual the term is taken to mean those files needed to run a test and those files
12. at you have to do 17 C C Interface 18 Examples 19 Overview 22 Theory of operation 22 C C interface 23 Creating copying and destroying a reg 23 Reg access functions 24 Math functions 24 Logic functions 25 Printing functions 26 Functions for HDL coherency 27 Examples 27 Overview 30 Theory of operation 30 C C interface 31 Creating copying and destroying a vreg 31 Functions for HDL coherency 32 Examples 33 Overview 36 Theory of operation 36 Basic Logging 37 Level based Logging 39 Advanced vlog objects 40 C C interface 40 Examples 42 Overview 46 Theory of operation 46 C C Interface 47 Examples 48 Overview 54 Theory of operation 54 C C Interface 55 Examples 57 Overview 62 Theory of operation 62 C C interface 65 Examples 67 Overview 72 Theory of operation 72 C C Interface 73 Working with the dictionary 74 Examples 74 ii Teal User s Guide Using this guide This guide provides information about using Teal a c c Test Environment Abstraction Layer Who this guide is for This guide is for verification engineers who use or want to use C for verification Specifically engineers who want to use the Teal library to accomplish verification tasks What you need to know To understand and use the information in this guide you must Be familiar with Hardware Description Languages HDL such as Verilog or VHDL Have a general knowledge of the problem of hard
13. ation effort may be ahead of a particular implementation or there may be many varients of a chip with subsets of the full feature set In this case the C H modules may want to test for the presense of a module or wire to determine if the functionality is present In this case the static method present can be used bool present const std string amp path and name static Functions for HDL coherency 32 The methods below are overridden by vr eg to allow it to make sure the HDL signal and the c c representation agree Specifically fsThe read check method checks the current integer global state and if its value is not the same calls the HDL to get the current value of the signal Then read check setsitsinternal state variable to the global one fThe write check implementation pushes a value to the HDL as though it were a non blocking assignment fslnvalidate all vregs isa method used only by the threads management system This method is called when the c c code is called from the HDL side causing the global state value to change and causing all vregs to get a new value when or if they are referenced virtual void read check const void write through const Teal User s Guide Examples void invalidate all vregs static This section shows some basic examples of r eg and vr eg You can use these examples as an introduction to the capabilities and use of these classes Declarations std s
14. ators instead of directly putting the message type in the message These functions are placed in line with the output message teal info for normal messages teal debug for developer messages teal error for incorrect DUT behaviour messages teal fatal print the message and exit the sim This function returns the object at the top of the vlog chain vlog 6 get static Statistics As each type of message is printed vl og increments a counter You retrieve the current count of any message id by using this call int how many int where int is usually error Output of the standard types These functions handle outputting of the standard types in c c 1 Inside of this call there is a test to see if no vlog has been created If this is the case an object called local vlog is created As this is an implementation detail it is not documented further The class is imple mented in the Teal file teal vlog cpp 2 Of course you can create local scoped vlogs and they will be added abd removed from the chain as appro priate www trusster com 41 Examples 42 vlog amp operator lt lt vlog k f vlog amp vlog 6 operator double vlog 6 operator lt lt const std string 4 vlog amp operator lt lt long long unsigned int vlog amp operator lt lt long vlog 6 operator lt lt unsigned int vlog amp operator lt lt int vlog amp operator lt lt char Output
15. base vout and a default uint32 level The dictionary parameter lt functional area show level is searched for a command line or file override to the level for this functional area This is so that debug levels can be overridden without changing or rebuilding the verification environment or object file if a Verification IP provider did not provide source code When a message is written the manipulator function level uint32 is used like so vout log a test 3 log lt lt teal debug lt lt level 4 lt lt level 4 message lt lt endm www trusster com 39 In this case without a dictionary override the message will not be printed This is because the level vout was created at level 3 and the message is at level 4 The show debug level method allows the verbosity to be set programatically Note that info error and fatal messages are printed out at level 0 so they cannot be suppressed using the show debug level There are other ways and they are shown in the Advanced vlog object section Debug messages are set to level 1 until a level lt x gt is encountered so you may want to not use level and thus treat all debug messages as either all on or all off Advanced vlog objects The vlog class supports a static method get which returns the currently vlog object This is what is used by the vout to output a message However vlog is only logically a singleton It is actually implemented a
16. ceived Exit from Teal S i e hookup to Teal Figure 2 A sample Verilog testbench v Examples Given the testbench example in the previous section this simple program just runs for 20 clock pulses include teal h using namespace teal int verification top vreg clock testbench cik vout log Chapter 4 Example 1 dictionary start simple clock test txt uint number of periods dictionary find number of clocks 20 for int i 0 i lt number of periods i u log lt lt note lt lt i is lt lt i lt lt clock is lt lt clock lt lt endm di ctionary stop vlog get expected lt lt test completed lt lt endl In this example the test runs for a number of positive edges in a clock register The simple clock test txt test file picks up the duration The dictionary is discussed in a later chapter This file only has one line number of periods 23 which defines the length of the run 20 Chapter 5 The Reg Class This chapter describes one of the most basic classes in the Teal library the reg class It s main purpose is to provide arbitrary length 4 state operations 21 Overview When you go about designing a class library an important decision is the creation of the common currency of the system This chapter and the next few describe the common currency of the Teal system that is the basic generic building blocks
17. ck on the wire it would call semaphore si gnal Q on the ack object This call would cause the wait for ack method to return and the calling thread to continue running Simulation Time The current simulaton time is returned by the vtimeofunction which returns a uint64 1 Note This is exactly the same as the pthread condition variable except that the Teal one is tied in to the simulation Using the pthread condition variable will most likelv crash the simulation 64 Teal User s Guide Getting the Thread name from a thread id The function called thread name pthread t returns the name associated with the thread ID which is returned by an earlier call torun threadQ C C interface Creating and destroying threads You create a new task with run thread0 This function takes in a function to run a data parameter and a task name run thread returns an ID to be used to stop the thread or any other pthread function Thestop_thread Q function takes in a thread ID and stops that thread In general a thread runs until it is stopped by another thread If however a thread runs to completion and returns from the user thread function it must callnote task compl et ed to let Teal clean up internal data structures void user thread void user data pthread t run thread user thread void user data const std string 6 name void stop thread pthread t void teal finish iafter stopping all threads
18. dec 6 Set the environment variable ARCH to your operating system currently linux solarus and windows 7 If you want to build teal change to the teal directory and do one of these steps To remove all the binaries and object files enter this command make clean etiTo compile the sources enter this command make Teal User s Guide 2 Change to the test sub directory and do one of these steps To run all the examples enter this command run c clean SIM I test list stiTo run a single test enter this command run c SIM t some test where you replace some test with either reg test vreg test trandom test synch test mutex test or dictionary test Note that the test is implemented by a pair of cpp and Verilog files with the same root name Note also that the run script will display whether the test or test list passed or failed www trusster com 13 14 nnnnnnn Teal User s Guide Chapter 4 Verification Top This chapter describes how Teal interacts with the simulator that is what you need to add to your HDL testbench to use Teal Overview Teal uses the Programming Language Interface PLI 1 0 or 2 0 to allow c c H code to co exist with the HDL To this end you must put a call somewhere in the HDL to start Teal You usually do this in an initial block in the top level but can be in any module at any statement Of course it it is not in an initial b
19. dm www trusster com 75 76 else Std istringstream bar channel text uint32 min_val 0 uint32 max_val 0 bar gt gt min_val gt gt max_val u u u my log lt lt teal info lt lt expected Min is and max is lt lt max val lt lt endm lt lt min val lt lt Teal User s Guide Symbols condition teal condition 67 mutex teal mutex 66 reg teal reg 24 A add map teal memory 56 add memory bank teal memory 56 at teal 66 C change teal change 66 condition teal condition 67 contains teal memory memory bank 56 57 D dec teal 42 draw teal trandom 48 www trusster com TT E end teal 42 error teal 41 error count teal vout 41 expected teal 41 F find teal dictionary 74 find on command line teal dictionary 74 format string teal reg 26 27 from memory teal memory memory bank 57 G get teal vout 41 H hex teal 42 I init teal trandom 47 78 Teal User s Guide invalidate all vregs teal vreg 33 L lock teal mutex 66 lookup teal memory 56 M memory bank teal memory memory bank 56 teal memory memory bank 56 message tvpe teal 41 mutex teal mutex 66 N negedge teal negedge 66 note task completed teal 65 O operator 25 26 26 42 operator teal 25 operator amp teal 26 operator amp teal reg 26 www trusster com 79 operator teal 26 operator teal
20. dom number class generates a 0 1 0 random double on every draw The random range class maps this double to a range of integers To support stability you must carefully choose the seed string or number passed into the constructor The example section shows some common techniques that can be used to provide the appropriate level of flexibility and stability The random class is a basic one It provides all the basic operations needed it s often the use and interaction of the random numbers that are the complex part of verification Feel free to derive other classes to implement different distributions Teal User s Guide C C Interface Required Initialization Before using any random numbers you must initialize the generator There are two ways to do this The first way is to pass in a path to the master seed file Thisfile if it exists is searched for a dictionary entry of master seed If a line beginning with master seed is found the remainder of the line is assumed to be a set of hex digits used for the master seed If the master seed string is not found a master seed is chosen and the master seed and hex digits are written to the file void trandom init with file const std string amp master seed path static The other way to initialize the random number master seed is to explicitly pass it to the init method This is useful when you pickup the master seed from the dictionary This is the me
21. e It also explains how the Teal memory system can be used for more generic abstraction of reading and writing registers in zero time or through a DUT interface 53 Overview Almost every chip that is verified has internal memory or interacts with external memory This chapter describes Teal s capability for testing those interfaces It describes the types of memories that are supported and how these are mapped to integer address ranges This chapter also describes how you can use memory building blocks to support error injection grouped memory and bank front door memory access Theory of operation For simulation you can implement the memory in either c c or the HDL Implementing the memory in c c is appropriate in these cases For extremely large memories When all accesses must be checked When statistics must be gathered Because a c c implementation could be built on top of Teal using the vreg Class the run loop class see and the memory bank class see next this chapter does not discuss it This chapter is primarily concerned with accessing memory implemented in the HDL The information in this chapter is based on the assumption that you are implementing the memory as a HDL register array You can get access to HDL implemented putting a hook task into the module that contains the register bank See teal memory note DE A memory bank object is created for eachteal memory note call This object contains c
22. end the simulation void note task completed The thread name function converts between the thread id and the task name std string thread name pthread t The vtime function returns the current simulation time uint 64 vtime The at function is the main way a task pauses It is given a sensitivity list which is an object that is automatically created and destroyed by calling posedge negedge or change with a vreg as its argument The list is also extended when you have multiple vreg changes negedge posedge or change separated by the I operator www trusster com 65 66 Be aware that by default posedge and negedgeQtest only the lowest bit for the appropriate edge If you need to test for a different bit passa second parameter indicating the specific bit to test void at const sensitivity amp posedge vreg amp v uint32 bit pos 0 negedge vreg amp v uint32 bit pos 0 change vreg amp v uint32 bit pos 0 Creating and destroying a mutex Often several independent threads need to use a common hardware resource such as a bus If each thread has its own master identifier and the bus has hardware arbitrartion each task can arbitrate for the bus wing the DUT hardware In this case a mutex is not needed However if the independent tasks are the same master as if they are emulating multiple software threads on a CPU they need a simulation mechanism to arbitrate This is the pur
23. errors in the memory system You can do so in a manner similar to the grouped case where you look up the bank in question and add a new bank that handles the memory accesses Often it s helpful to randomly use either front door access via a memory bank that uses a bus transactor like PCI or AHB or back door access using a memory bank that is connected to an HDL model The front door access is slower and takes simulation time but front door access tests that HDL code path and may also test contention You can also build a memory bank that aggrgrates several vreg objects so that back door register access occurs as a result of memory reads writes C C Interface Memory functions The memory manager has a small interface You can map memory to some integer range You also can add banks of memory for special purpose memory such as ECC parity protected memory ora Context Addressable Memory CAM Later other parts of your simulation can retrieve this memory by address or by path and you can read and write this memory www trusster com 53 56 void add map const std string amp path uint64 first address uint 64 last address void add memory bank memory bank memory bank lookup const std string amp parial path memory bank lookup uint64 address in range void read uint 64 global address reg void write uint64 global address const reg amp value One item to note is that the read does not just simply
24. essage statements For example vout log a test log lt lt teal info lt lt A number lt lt hex lt lt 562393 lt lt endm This example prints assuming a file os simple cpp at line 101 thread of uart o tx and a simulation time of 77 ns 77 ns simple cpp line 101 uart 0 tx a test A number 64 h894D9 Note that when you finish a message statement using endm the vout instance adds the simulation time the file the line number the current thread name and the functional area to the message and sends it to the vlog singleton It does not send it as a text string which would not allow efficient modification of the message Rather it sends the message as a set of pairs of IDs and strings This allows you to instruct the vlog instance to modify messages based on their components The vl og class also supports decimal hexadecimal or binary output You select the output basis by placing either ahex ordec or bin in the message statement Before moving on to the vlog class and it s message manipluation capabilities you can also turn off display of parts of a message directly at the vout instance The message display function takes in an ID and a boolean If the boolean is false the message part represented by the ID is not displayed The standard message IDs are time thread name functional area error note warning expected and message data Note that since the message display function takes
25. examples are shown here reg a 45 create a 64 bit register initialized to 45 reg a 0x22 73 create a 73 bit register initialized to 0x22 The reg_slice class is another helper class that is automatically created and destroyed when a register subrange is used The reg_slice constructor is automatically used when a register is needed in an expression For example reg a 45 reg b a 10 0 creates a reg_slice of a Because reg_slice is a temporary object automatically created during left hand assignment it is not documented further The last reg constructor takes in an integer and createsa 64 bit reg set to that value This constructor allows statements such as reg a length 32 a a 5 and a 4 0 1 The operator method setsthe current value of the instance to the rhs but does not change the length of the instance Specifically the operator extends with zeros or truncates as appropriate depending on the length of the r hs The virtual destructor allows for subclasses to clean up any allocated storage reg explicit reg const reg slice amp reg uint64 uint32 length 64 reg const reg amp reg amp reg operator const reg amp www trusster com 23 reg virtual Reg access functions This set of functions convert registers to intergral types and allow access to parts of a register The to int method converts the register to a 64 bit integer Any X or Z bits are re
26. ing out uint8s Using the technique in example one to isolate random number streams in a static function at the top of the file you could have static uint8 next channel uint8 x uint32 deadlock 100000 Good enough for most cases static bool used 256 0 do RAND 8 x while deadlock amp amp used x if deadlock vout vout next channel lt lt error lt lt Deadlock no more channels at lt lt FILE lt lt LINE lt lt endm l Note that the deadlock ensures that the system never is hung up which is important whenever you constrain a random value As the interactions of the random numbers increases so does the possibility of a deadlock 4 Selecting a boolean via a 0 100 probability Sometimes it s useful to skew a random distribution so that it s not gaussian There are several ways to do this This and the following examples explore some of the ways For a single bit or a Boolean one simple way is to provide a threshold which represents probability of success Then by generating a random number between 0 and 99 and comparing it to the threshold you can skew a distribution www trusster com 49 50 static bool get use tone detection uint8 threshold dictionary get tone detection 50 default is balanced random uint8 x RAND RANGE x 0 99 return x lt threshold 5 Selecting a enum A way to randomize the selection of an enum is to all the pos
27. ion Working with a condition Once a condition is created its pointer is passed to the affected tasks or buried in a method of a class like monitor wait for ack 0 At the appropriate time one task calls wait and it blocks until another thread calls signal void signal void wait Simple at expressions This example demonstrates how a thread can be paused on a number of signals It is assumed that the testbench top module contains a register for an address and a clk vreg address testbench address vreg clk tb cik at posedge clk change address wait until next rising clk or any address change at negedge clk falling edge test www trusster com 67 68 Mutex This example demonstrates how two threads cooperate to place their address on the shared hardware register called address In addition to the testbench to having address clk and data registers it is assumed that there is a module that placed data on the bus in response to the address changing First two similar functions are defined Fach one tries to get the mutex passed in the context parameter and then puts its address on the address register One clock later they retrive the value put in the data register by the DUT and then release their mutex void master one void context mutex m static cast lt mutex gt context m lock vreg address tb address address 0x10 vreg clk tb clk at
28. ion calls one of these two methods virtual void from memory uint64 address reg pure virtual virtual void to memory uint64 address const reg amp value pure virtual 1 Simple memory use This example shows how to hookup the HDL memory to Teal It shows the most common way to read and write memory entries In your top level testbench define some regsiter banks and hook them to Teal like so module some memory reg 1 0 bank 0 1024 0 initial teal memory note bank 0 in module tb memory 1 endm module tb some memory memory 1 some memory memory 2 endm Now in the verification top of a C C source file you tell Teal how to view this memory as an address range Like so memory add map memory 1 0x100 0x200 memory add map memory 2 0x201 0x400 At this point your program can read and write this memory by address Here are some examples www trusster com 57 58 memory write 0x10a 22 write local offset Oxa in memory 1 to 22 reg val memory read 0Ox10a amp val if val 22 vout log memory example 1 u log lt lt lt lt teal error lt lt At memory 1 Oxa lt lt l val lt lt expected lt lt 22 lt lt memory write 0x20b 33 write local offset Oxb in memory 2 to 33 got lt lt reg val memory read 0x20b amp val if val 22 vout log memory example 1 log lt lt teal e
29. is chapter discusses how Teal provides these components 61 Overview Verification is a complicated task If a complicated task can be broken down to a set of simpler independent tasks the problem becomes less complicated These tasks often are concurrent This chapter describes creating managing and interacting with these concurrent tasks Theory of operation As discussed in Chapter 4 the verification top function is your top level controller thread Generally this thread waits for the DUT to be ready and then initializes the dictionary and random number subsystems Next a series of generators checkers transactors is started and some end condition is tested When the end condition occurs all threads are stopped and the main thread exits You create threads using the run thread function This function takes in the function you want to run and a pointer to a data area A thread is created and the function is called Normally the thread never returns your main thread cancels it withstop thread 01 If however the thread is a temporary one and so it returns the last line must be note thread completed Teal needs this call for internal reasons When a thread is started including verification top0 it runs until it reaches a waiting point which tells Teal that control can be returned to the HDL simulator After a wait condition has been satisfied the blocked thread runs There are three types of waiting point
30. lem in simulation getting test parameters Test parameters are separate from tests although the test should have defaults in that they bind a test to some specific range or value of parameters The dictionary namespace integrates a file heirachy and command line parameters into a uniform interface Theory of operation Sometimes you want to control a test using an external file This allows a single test to have many different directed runs These runs would still use random numbers but that their range might be constrained by the test file For example the probability of a feature or error may be an external variable Alternatively your test file might be used to turn on and off features Teal provides a dictionary namespace for this purpose After the dictionary namespace is initialized with a filename the file is opened and the first word in every line is cached Then your test can query the dictionary with the find function and recover the value after the keyword For example if the file had number of streams 33 ona line a call to dictionary find number of streams would return 33 There is one special first word include If this word is found the next word is taken as a filename and the dictionary module processes this file as well If the same word shows up in several lines in any of the files the last one processed will be the value that is stored For example assume a file named directed test t
31. lock Teal will not start at simulation time zero This PLI call that is used to start teal is teal top Other than backdoor memory access this is the only required call to hookup Teal Theory of operation When the simulation starts the call to teal top causes Teal to start the threading system and call your verification top function Your verification topQ function typically initializes global objects like the random number generator dictionary and your own top level code and then waits for aninit done Orout of reset signal from the HDL testbench After the Device Under Test DUT isout of reset you typically start a series of transactors and checkers During execution these generators and checkers print log messages of checks that pass and errors that occur Of course it sup to you to decide what your verification top should do A block level test or directed test may not need any threads and instead do everything in the verification top Theverification top usually then waits for some signal from the lower level units that they are done The signal can happen when for example a certain amount time has passed or traffic generators are done or maybe an error threshold has been reached Finally theverification topO typically prints some statistics and signals to the HDL testbench to quit The HDL testbench calls finish to shut down the simulation Note that the HDL finish call is not required in terms of Teal but
32. meter is not on the command line te default is returned Note You can pass in for the default if you want to just see if the parameter is there www trusster com nana 3 std string find on command line const std string amp parameter const std string amp default name Working with the dictionary Examples 74 There is only one function to get the value of a parameter The find function returns the string associated with the parameter or if it cannot find the word Since most parameters are not strings there is another templated function to convert the string into other forms This is based on the std istringstream class defined in C The templated find function relies on operator gt gt const std istream amp being implemented for the data type you need This is a bit complicated but fortunately C H provides this function for all the built in types int char long double etc Note that it is the default parameter that keys C to the right template instance So you can just call find my parameter my integer default to get an integer value from the dictionary See the examples below std string find const std string amp name template lt class data type inline data type find const std string 6 name data type default val Getting basic parameters This example shows how to find integer parameters Assume that a file teal test txt has only three lines foo 10 bar 12
33. most systems have clocks that keep generating events In this case some mechanism is needed to stop the simulation Alternatively you can call teal finish Here s what you have to do EIN IS 9 IF IN Add a initial teal top in your top level HDL testbench Typically add an reg test end initial begin test end 0 wait test end finish end aswell Create a directory in which to run your sims Copy the example example 1 cpp file and modify the verification top function for your test Copy the Makefile from the examples directory into your directory Copy the run script for the examples directory into your directory Make sure the environment variables ARCH SIM SIMULATOR HOME and TEAL HOME are set Type run c clean SIM t your file name user nain O at posedge reset n start transactars etc vreg finish th finish 1 Figure 1 Example Process flow C C Interface ti mesc module lt your reg cl al ways lt your initia reg te initia There is only one entry point other than the memory system for the Teal system It is the verification top The prototype is shown below void verification top Teal calls this function during initialization Shown below is a typical verilog testbench ale Ins lns testbench wires clocks etc gt 40 5 clk clk DUT instance her teal top st end begin end 0 test end KU m Verilog Re
34. n create a vreg that is tied to reset n www trusster com 27 28 c d clear all but the lowest bit of c c 0 current value of reset n d 0x0 push reset n to 0 Math on reg vreg std string path testbench top main bus the root of the bus module u vreg addr path HDL address address bit length copied from reg b length 32 b 31 0 0x12 init b addr 2 increment address push to HDL addr b lt lt 3 same as addr addr length 1 3 b addr 2 0 0 Bit fields reg b 101 std string root tb std string module bus vreg addr root module rd addr addr 1 0 b 28 27 copy the two bits push to HDL int c addr 31 28 format_int get current upper nibble of address addr 27 20 amp 0x55 do some bit bashing Teal User s Guide Chapter 6 The vreg class This chapter describes the class that is used to connect your c code to the HDL This class provides mechanisms to use signals in the DUT as though they are built in c variables The vreg class is derived from the reg class 29 Overview The reg by itself has very little to do with simulation The vr eg class which is derived from reg implements the hookup to the Hardware description Language HDL In order to do verification pre silicon co verification or software algorithm development interacting with the hardware is a basic necessity The v
35. nge This class shifts the 0 1 double into a ui nt 32 based range trandom range const std string 6 uint32 1 Stable across source file editing As a general technique you may find it useful to enclose each call to a random number generator RAND_RANGE RAND8 and so on within a static function at the top of a file This is because the default macros use __FILE__ and LINE as the seed and you don t want the line number to change as you add or remove code from a source file For example static uint32 get next channel uint32 a_min uint32 a_max uint32 r RAND RANGE r a min a max return r 2 Direct use of the trandom class You also can bypass the macro and provide your own string or number This would also be stable across code changes For example trandom my random Hello World 0 uint32 my random value 2 my random draw Teal User s Guide 3 Cycling through random numbers Sometimes you need to track which random number has been handed out This is usually either when you want to walk an entire range before returning to a previous value or make sure you never hand out a duplicate In this case the number represents a resource like an endpoint number that can be allocated and released randomly during a simulation In this case you can use a bool array of the appropriate size You can also use a std map to track the random number usage For example assume that you are hand
36. ode to access the internal memory of the simulator that is implementing the HDL register array The memory bank that is created by the hook function containsto memor y and from memor y O methods which carry out the access without advancing simulation time 1 One could augment Teal to provide a memory acessor via a string as well but it is not provided at this time 54 Teal User s Guide The memory bank also has low and high address 64 bit integers which are used to allow access to memory using an integer address The memor y namespace keeps track of all memory banks Note that memory banks are the workhorses of the memory namespace They do the actual work while the namespace just figures out which one to hand the access request to For the interface method to find the right memory bank when using an integer address you must map the memory banks into an integer address range The memory map O function maps a memory bank to an address range You can put this mapping in the initialization code of your verification top and all other code can just read write by integer address Sometimes several memory banks are grouped together to provide one logical memory bank In this case you need to write a special memory bank that first retrieves all the sub memory banks using memory bank I ookup and then adds itself to the memory namespace s list of memory banks using memory add bank Sometimes you want to inject
37. of a Teal based verification system The reg class which is the most basic is described first Theory of operation Hardware simulators compute in four possible values for a bitt 1 0 X Z In addition hardware languages support arrays of bits called reg HDLs also support a rich set of operators on regs The Teal class reg implements this four state logic and makes sure Xs propagate through calculations The reg class supports the usual HDL wire register operations such as addition subtraction shifting Boolean operations and four state comparison Note that because multiplication and division are not part of the standard HDL operations these opersations are not provided As in HDL languages bitfields or subranges of reg are supported The subranges can be on either the left or right side of an expression 1 Some simulators use 8 logic vlaues but Teal uses only four because the concept of drive strenghts are not tvpicallv relevant to functional verification Teal uses the HDL simulator for signal value resolution 22 Teal User s Guide C C interface Creating copying and destroying a reg Reg has only a few constructors and a copy constructor The default constructor creates a one bit register and is marked explicit to prevent you from accidentally creating such a register The most common constructor build 64 bit register Theer is a second optional parameter that specifices the bit width Some
38. operator of Verilog The functions listed below perform the usual logical operations enum four state zero 0 one X Z bool operator const reg amp I hs const reg amp rhs reg operator const reg amp I hs reg operator const reg amp I hs const reg amp rhs reg amp reg operator const reg amp rhs reg operator amp const reg amp I hs const reg amp rhs reg amp reg operator amp const reg amp rhs bool operator const reg amp I hs const reg amp rhs four state operators const reg amp I hs const reg amp rhs four state operators const reg amp I hs const reg amp rhs four state triple equal const reg amp I hs const reg amp rhs four state reduce xor const reg 6 Printing functions 26 The printing functions allow areg and any derived classes to be printed as part of a message line see Chapter 7 The reg operator lt lt is the virtual method that allows you to print reg and all subclasses as built in types By default operat or lt lt Senses the output format hex dec or binary and calls the appropriate string formatter described below The format hex string method returns a hexadecimal representation of the reg for example 4 hf The format decimal string method prints the register as in integer and the format binary string method prints the register as a sequence of ones and zeroes like 5 b01001 vlog 6 reg operator lt lt vlog 6 c const virt
39. pose of the mutex class Once constructed its pointer is passed to all affected modules or hidden in a common transactor like pci bus master see the mutex test in the test directory of Teal Each task calls lock to either gain access to the hardware or block until the current task is finished with the hardware Once the lock method returns you access the hardware and then call release to inform Teal that you are done with the hardware At that point any waiting threads re arbitrate for the mutex The constructor only takes in a name for the mutex mutex const std string 6 name mutex Working with a mutex There are only two operations on a Mutex One is to acquire the mutex by calling lock and the other is to release the mutex by calling unlock void lock void unlock Teal User s Guide Examples Creating and destroying a condition Whenever you have multiple tasks there is a good chance that they will need to communicate While tasks can put data into work queues and take data out there must be some mechanism to signal that one task as just put some data in or taken something out Also a monitor task may need to announce a particular condition like ack nak or byte sent There may or may not be a receiver to note the announced event The condition class provides such inter task communication A condition is given a name when constructed condition const std string 6 name Condit
40. posedge clk wait one clk pulse vreg data tb data vout log master one log teal note data is data lt lt endl void master two void context mutex m static cast lt mutex gt context m lock vreg address tb address address 0x16 vreg clk tb cik at posedge clk wait one clk pulse vreg data tb data vout log master two log teal note data is data endi Teal User s Guide The verification top function creates the common mutext and starts the two threads running It then waits for the two threads to complete void verification top mutex main bus mutex main bus pthread id one run thread master one amp bus mutex task one pthreda id two run thread master two amp bus mutex task two join thread one join thread two Semaphore This semaphore example shows a producer consumer pair of threads One thread creates data and then signals the other to get the data The consumer waits for data and then consumes the data A context structure is created that holds the semaphore and the data to be communicated Note that this is a simple mailbox scheme struct context void context mailbox main mailbox semaphore mail box std vector lt uint32 gt work queue The producer gets the context and pushes two uint32s into the queue Note that in another de
41. reg class provides the ability to stimulate inputs and interrogate respond to outputs Theory of operation 30 The vreg object uses the Verilog Procedural Language VPI or Programming Language Interface PLI depending on the compile options to find the wire or register in the HDL The path to the register or wire is the handle to the HDL register or wire The path is formed by concatnating the module names and then the wire register name For example assuming that your top level module is called testbench and you have a top level wire called usb dp and a module called uart with an internal register called cIk this is how the path would be passed in to the vreg constructor vreg testbench uart clk fsvreg testbenchb usb dp A vr eg differs from a reg in that its value is initialized and conceptually exists in the HDL Therefore any assignment or sub range assignment is pushed to the HDL as if it were a non blocking assignment The example below shows a top level module called module 1 and a register within the module 1 called addr The C C code on the left shows how to declare and use the vreg variable address Teal User s Guide Module top Figure 1 Example of how the vreg interacts with the DUT Because reg was designed with vr eg in mind there are classes to virtual methods for determining when ar eg should be written to the HDL or when the most recent HDL value is needed C C interface
42. return a reg It may seem at first appropriate to do this but then multiple data path width memory could not be supported It is fairly common for todays memory subsystem to support byte word and long word access Creating copying and destroying a memory bank An internal class derived from the memory bank class connects to the DUT This class is within the memory namespace and is created whenever a note memory bank is placed in the HDL However you may want to aggregrate or add special functions for a memory range In such a case you want to create your own memory bank The only parameter is the name of the memory bank memory bank memory bank const std string amp memory bank memory bank virtual Determining the right memory bank For the read and write memory functions to work when accessed by integer address they must determine which memory bank object will handle the access Since the memory manager namespace contains a list of memory banks the lookup functions use the cont ai ns methods to find a match The first one to return true is the bank that is used Note that there are two contains functions One for lookup by address One for lookup by name bool memory bank contains uint64 address const Teal User s Guide Examples bool memory memory bank contains const std string 6 path const Actually reading and writing memory After a bank has been selected the memory funct
43. rmat Teal is flexible enough to match almost any desired output format However this flexibility comes at a cost of some complexity It is hoped that suitable initial settings make this complexity only apparent when sophisticated flexibility is needed Theory of operation 36 Logging seems so simple when you first start writing to cout or using printf s As your code or team size grows however it becomes quite complex This is because different people think about logging in different ways Some like generous amounts of data and may post process the results file Others prefer to think of a level of debugging where a bigger number represents more verbosity and zero represents an unmaskable message Others prefer a mask based approach Orthagonal to the amount of data to be displayed there is the presentaton order of the data Should the simulation time be first or the type of message note error expected etc Also in more advanced applications you may sometimes want to redirect or duplicate the messages to a display or another unit in the system Add to all that the possibility of getting verification IP from an outside vendor or another part of the company and logging becomes downright painful Teal User s Guide Teal attemps to provide a maximum of flexibility while keeping the simple outputting simple Because of the sloping complexity of logging this section is divided into basic and several advanced pa
44. rror lt lt At memory 2 Oxb lt lt got lt lt val lt lt expected lt lt 33 2 Directly interacting with a memory bank This example shows how to read and write a memory bank directly This can be useful when a large number of reads write must be preformed to a single bank as in initing a memory or in a pre aging test or when the memory is not designed for an external address range in other words internal RAM In your top level testbench define some regsiter banks and hook them to Teal like in the previous example Then you can get a pointer to the memory bank using Teal like so memory bank bank memory lookup memory 2 partial path bank gt to memory 0x10 44 directly write a 44 to loca offset 0x10 reg val bank gt from memory 0x10 amp val if val 44 Teal User s Guide vout memory example 2 lt lt teal error lt lt At memory 2 0x10 lt lt u u got u lt lt val lt lt expected lt lt 44 www trusster com nnnn59 60 nnnnnnn Teal User s Guide Chapter 10 Concurrency in Teal This chapter discusses the mechanisms Teal provides for dividing the verification task into separate independent threads of execution There are three main components to any such system 1 a way to start stop and join threads 2 a mechanism for threads to signal one another and 3 a way for threads to serialize data access Th
45. rts Creating a results file within Teal has two basic components One is the vout class which is intended to be instianiated at each component or functional area of a design e g a each transactor checker and maybe the verification top The other object is called a singleton which means there is only one of them in the system This is the vlog class The figure below shows the relationship between your code the vout class and the vlog class Figure 1 View of many vout objects and a single vlog Basic Logging As shown above all vout instances call the single vlog to print a message This is done so there is a single point of control to reorder demote change or delete parts of any message This ability is provided by the vout get function chain and it is described below Since all messages start at the vout this will be described first www trusster com nnnnnnn 37 38 The vout class is modeled after the c cout object It directly supports output of the standard types By following a few simple guidelines you can print complex objects as conveniently as the standard types See example three in this chapter To end a message call the endm function see the basic example To describe a multi line message use endi just like cout where needed and use a final endm at the end When you create a vout you give it a string that represents the functional area it is providing messages for You can then build any mum ber of m
46. s at smutex enter ssemaphore wait 1 The exception to this rule is generallv the verification top thread which spawns other threads and then returns 62 Teal User s Guide The at function The at function the most common wait point is intended to model the sensitivity list statement in Verilog This function takes in a sensitivity list of vr eg signals The signals are matched on the posedge negedge or any change A statement such as at posedge clk change reset n would mean to pause the thread until either The cl k signal went from an X Z or 0 toa 1 Any change occurred in the reset n signal Execution would then continue after that statement The example above shows that after simulation is started in module Top the verification top function is executed It will run in zero simulation time until the at posede clause At this point the thread pauses until either clock goes positive or reset n Module top goes negative Execution then continues after the at clause at the now more advanced simulation time Figure 1 Concurrency Pausing the thread with the at clause www trusster com nnnnnnn63 The example above shows that after simulation is started in module top the verification top function is executed It will run in zero simulation time until the at posedge clause At this point the thread pauses until either the clock goes po
47. s a linked list of filters each with the ability to manipluate the list of mesage items or the formed string By constructing a new vlog the vlog constructor automatically assigns the new object to the logical singleton get The vlog class also keeps track of the previous value of get In this way a chain is formed So when a message is printed your object is the first to be able to suppress or change the message Your derived class of vlog that overrides the local print method you have the ability to get the std string that is the completed message and perform any post processing that is appropriate Also if you build a derived class of vlog that overrides the local print method you have the ability to get the std string that is the completed message and perform any post processing that is appropriate C C interface 40 Teal User s Guide Creating copying and destroying a vlog vl og is unlike a normal class in that it is expected to always be there so there is no explicit construction step You create a v og by calling the get method Also because vl og is implementing a logical singleton it cannot be copied or assigned Finally because vl og will exist for the duration of the simulation it is not destroyed The message type describes the type of message that is being printed enum message type info expected error fatal However you generally use the teal IO manipul
48. sible values and then pick a random index For example include lt vector gt using namespace std typedef enum valid address type config io cached uncached static valid address type get next address std vector lt address probability gt addresses addresses push back config addresses push back io addresses push back cached addresses push back uncached uint32 x RAND RANGE 0 addresses size 1 return addresses x bi 6 Subclassing trandom Another way to provide a non gaussian distribution is to subclass the trandomortrandom range object and apply a post processing step For example taking the log of the result of the dr aw method produces a logorithmic distibution Teal User s Guide 7 Constrained random example Often it is useful to constrain the generation of random numbers using an external to the test mechanism This allows one test to have several different runs One way to do this is to use the master seed picked differently for each run Another way is to use a test file that provides variables to be used as bounds in the thresholds or distributions shown in the previous examples For some examples of how to get external variables into your test see the dictionary namespace in Chapter 11 www trusster com 51 52 noon oo Teal User s Guide Chapter 9 Accessing Memory This chapter describes how you use Teal to read and write memory in zero simulation tim
49. sign the mailbox could have signalled just once In this case the producer would have to drain the entire work queue void producer void c context the context static_cast lt context gt c the context work queue push back 10 the context mailbox signal www trusster com 69 the context work queue push back 20 the context mailbox signal The consumer gets the context and reads the two uint32s void consumer void c context the context static_cast lt context gt c for uint8 i 0 i lt 2 i the context mailbox wait vout log consumer log lt lt received lt lt the context work queue front the context work queue pop front The verification_top function builds a context runs the two threads and waits for them to complete void verification top context my_context pthread id one run thread producer amp my_context producer pthread id two run thread consumer amp my context consumer join thread one join thread two 70 Teal User s Guide Chapter 11 The Dictionary Module This chapter describes Teal s way of getting parameters into a test The dictionary is useful if the test can cover a range of features and capabilities as it can be used to constrain the features on a per test basis 71 Overview This chapter introduces the dictionary a namespace with several functions to solve a common prob
50. sitive or reset n goes negative Execution then continues after the at clause with the now more advanced simulation time Mutex enter The mutex enter wait point is used when two or more threads need access to some common hardware resource A good example is the PCI or AHB bus in the system In the test system and in the software many threads can be competing to access the bus as the same master The mut ex enter call waits until no other thread is using that mut ex object and then locks the object After your thread finishes using the hardware you must call mut ex unl ock to tell Teal that you have finished At that point any other waiting thread is allowed to access the hardware For simple mut ex management see the mutex sentry utility object in Teal h semaphore wait The semaphore class is intended to loosely model the event object in Verilog In this context one thread is waiting for another thread to signal to it The semaphore class provides this functinality with signal and wait methods The semaphore class is most often used for inter thread communication For example suppose you have a monitor thread and your test is waiting for an ACK packet to be sent You would declare a semaphore object for ack in the monitor object which also is a separate thread and have a method wait for ack that calls semaphore wait on the ack semaphore When the main loop of the monitor object sees an a
51. that are produced by ruinning the test These components are elaborated in the next section Basic Teal verification components The basic Teal verification components are A Teal library A set of Verilog design files a design top A set of c c source files organized as traffic generators checkers and Bus Functional Models BFMs There is also probably a run shell script and some makefiles Teal User s Guide Components of Teal based verification The diagram below shows these basic components www trusster com nnnnnnn9 10 oo on oon Teal User s Guide Chapter 3 Installing Teal This chapter describes how to download and install the Teal software Overview Before you download and install the Teal software you need to verify that your system meets the requirements specified in the Using this Guide chapter As a check on the download and install process you should run the tests listed in the test subdirectory of teal Downloading and installing Teal To install Teal 1 Usinga browser go to trusster com 2 Click the download tab 3 Extract Teal to a directory making sure that the directory you use is on your INCLUDE path to enable C C compilations Running the Teal tests 12 4 Set the environment variable SIMULATOR_HOME to the path for your simulator 5 Set the environment variable SIM to your simulator currently only ivl mti ncsim vcs or al
52. thod used by the example run script and test files void trandom init with seed uint64 static Note that these functions can be called multiple times if a combination of master key seeds are desired Common macros Before describing the tr andom class you need to know about some common macros that you may use often The RAND 8 and RAND 32 macros generate random numbers of the appropriate bit length The RAND RANGE macro generates a bounded random number RANDOM RANGE output value min value max value RAND 8 output value RAND 32 output value Creating copying and destroying a trandom After the random number class is initialized you can build t random objects The constructor takes in a string and an integer both of which are optional The macros described above pass in the ansii americal national standard for information interchange standard FILE and LINE macros Note that omitting both creates identical random number generators The default copy constructor and operator can be used to copy a random number stream or set one stream to match another www trusster com 47 Examples 48 trandom const std string amp file uint32 line trandom Getting random numbers The draw method is used to draw a random number The number will be between 0 and 1 specifically 0 1 double draw Creating copying and destroying a trandom_range A simple derived class of trandomiStrandom ra
53. tring path testbench top main bus root of the main bus u vreg addr path HDL address access the address bit length from vreg clk testbench top clk vreg a 23 illegal Need a path reg b length 72 create a 72 bit register initial value of all X s b 71 32 addr set bits 71 to 32 of b to current value of address clk 0x0 force clk to 0 Bit fields reg b 101 std string root tb std string module bus vreg addr root module rd addr addr 1 0 b 28 27 copy the two bits push to HDL int c addr 31 28 format int get current upper nibble of address addr 27 20 6 0x55 I do some bit bashing www trusster com 3 3 34 nnnnnnnTeal User s Guide Chapter 7 Logging Simulation Output This chapter describes how to write to a results file This chapter covers why a uniform output format is desirable and the facilities included in Teal to make this happen Overview Often you use a log file as a trace of what happened during a simulation It is important to have a consistent message format to enable post processing error counting and possibly filtering The Teal classes vout and vlog encourages such uniformity To increase the probability that a piece of verifcation code can be reused Teal provides a very flexible formatting system Why ar ethey related Well different teams have different specification for output fo
54. turned as their encoded aval so be careful when using this method Also the result will be truncated if the register is more than 64 bits long There are three register slicing methods These methods allow access to a subset of the total bits in a register They are overloaded methods of operator The single argument operator is the single bit read only access function for a register You use this method to get a single bit To get more than a single bit you use the two argument method There are two forms of the two argument operator method The constant two argument method returns a copy of the bits of the reg as specified by the arguments This method is called automatically by the compiler when the slicing operation is on the right hand side of an expression The two argument non constant method returns a reference to the bits of the reg as specified by the arguments This method is called automatically by the compiler when the slicing operation is on the left hand side of an expression uint64 to int const char operator uint32 b const reg operator uint32 u uint32 const reg slice operator uint32 u uint32 Math functions The math functions come in two flavors 24 Teal User s Guide Global functions These functions exist because they are symmetrical They are used when it is not appropriate to define the function asa member function usually because either Reg objects are passed in
55. ual vlog 6 operator vlog 6 c const rega std string format hex string const Teal User s Guide std string format binary string const std string format decimal string const Functions for HDL coherency Examples The methods shown in the next examples are used by derived classes like vreg to allow them to make sure the HDL signal and the c c world agree Within reg all these methods do nothing The read check method is called before every access to the reg internal storage aval bval array The write check method is the corollary to read check in that it is called whenever any part of the reg is updated virtual void read check const virtual virtual void write through const virtual This section shows some basic examples of reg These examples can be used as an introduction of the capabilities and use of the reg class Note that some of these examples use the derived class vreg which is discussed in the next chapter Declarations reg a 23 64 bit register initialize it with the value 23 reg b length 323 323 bit register with the initial value of al X s b 0x11 assign b to 11 clearing the upper bits b 315 300 a set bits 315 to 300 of b to 23 a b 63 0 uses the lower 64 bits of b reg c b 323 it register with the initial value of b s current value c 440 413 1 illegal run time error bit index out of range vreg d tb chip reset
56. ware verification Be familiar with software programming in c Know the use of the how to use the Linux operating system Conventions used in this guide Throughout this guide text written in this font is intended to be written in either c c or HDL Customer support To report an error in Teal go to www trusster com and click on the teal section For support search the forums on trusster com or send e mail to supportOtrusster com 2 Teal User s Guide Chapter 1 Introduction to Teal This chapter provides a general description of Teal Overview Engineers perform verification to Minimize the probability of hardware functional errors Ensure that the hardware meets performance requirements Ensure that the hardware is usable by software Teal helps you perform verification by providing a set of capabilities that access HDL signals and enable actions based on changes in the values of these signals In addition Teal encourages independent generators transactors and checkers by providing for management of independent user created threads Because Teal is a c c library you can develop algorithms that both validate the hardware design and can be re used in the production software Verification is C C is appropriate because the language is well defined and well documented System requirements Hardware Software To install and run Teal your system must meet these requirements The base
57. xt had the following lines Figure 1 directed test txt directed test txt Teal User s Guide Also assume that the file basic text txt has the following lines Figure 2 basic text txt basic test txt Since the parameter force error is in both files and the force error setting of 1 is after the include with the force error set to 0 the setting of 1 will override the setting of 0 Since it s often the case that command line parameters also act as test parameters they are folded into the dictionary module One the command line a parameter such as my parameter my value will be entered as the word my parameter with the value my value The command line parameters override any words of the same name in any file processed Since a test may want to get the dictionay file name from the command line the find on command line function can be used before the dictionary start function is called C C Interface Dictionary main functions To use the dictionary you must first call start This function opens the file processes all include directives and copies all the entries as strings When you are done with the file call stop void start const std string amp path void stop To see if a parameter is on the command line you can use the function below This function is useful if you want to get the name of the dictionary file to open or do not want to use a dictionary file If the para
Download Pdf Manuals
Related Search
Related Contents
User`s Manual (EN) User Manual - Belkin Business User`s Manual MOB-GPC09AH - Inventor Air Conditioners Epson EMP-74L Intel SE7320 User's Manual Emerson Fisher 3660 Instruction Manual BR-1 Instruction Manual Reflecta LP-PC Copyright © All rights reserved.
Failed to retrieve file