1. Field of the Invention
The invention relates to a method for testing a hardware circuit block and, more particularly, to a method for testing a hardware circuit block written in a hardware description language (HDL).
2. Description of Related Art
To increase the efficiency and re-usability of a large-scale circuit design, a hardware description language (HDL) such as VHDL or Verilog is currently used in the design. The codes written in the HDL (HDL codes) is synthesized, placed and routed to thereby correspond to a hardware circuit block, such as a random generator, counter, adder, multiplier or the like. The hardware circuit block is referred to as an intelligent property (IP). A result of executing the HDL codes equals to a result of executing the hardware circuit block. By repeatedly calling the HDL codes, the hardware circuit block can be easily copied, thereby achieving the purpose of reusing a hardware IP.
When a user completely programs the HDL codes, the HDL codes are regarded as a device-under-test (DUT) for being tested to ensure the correctness of the HDL codes. The user also programs a test pattern for the device-under-test. The test pattern further includes a desired result. Next, a simulator system performs a testing on the device-under-test in accordance with the test pattern and compares a test result and the desired result. The aforementioned process is also referred to as a unit test. However, manual labor and time are wasted due to the test pattern written by the user. In addition, when an error occurs on the device-under-test, there is no error reply mechanism available for notifying the user of an appropriate text debug message and the possible error position, which causes the user to have a trouble when a unit test is performed. Therefore, it is strongly desirable to provide an improved method to mitigate and/or obviate the aforementioned problems.
The object of the invention is to provide a method for testing a hardware circuit block written in a hardware description language (HDL), which can automatically produce a test pattern and an error message.
To achieve the object, there is provided a method for testing a hardware circuit block written in a hardware description language (HDL). The method includes: (A) converting an original class into a wrapper class, wherein the wrapper class, as compared to the original class, additionally records input and output data of the hardware circuit block; (B) producing a top module required for a hardware logic simulation; (C) converting an original unit testing into an extended unit testing; (D) using the extended unit testing to perform a unit testing on the wrapper class to thereby produce an input pattern file; (E) performing the hardware logic simulation on the hardware circuit block in accordance with the top module and the input pattern file.
Other objects, advantages, and novel features of the invention will become more apparent from the following detailed description when taken in conjunction with the accompanying drawings.
With reference to
The original class includes public method(s), parameter(s) and return value(s). Accordingly, step S10 additionally defines the public methods, the parameters and the return values as private data members of the wrapper class. As shown in
Step S100 sets private data members corresponding to the respective parameters and return values in accordance with the 4-phased signal protocol used by the SOCAD system.
Step S102 uses an input parameter to call a corresponding public method of the original class.
Step S104 records a return value in a corresponding private data member.
Step S106 resets the corresponding private data member in accordance with the 4-phased signal protocol.
Step S108 sequentially records the contents of steps S100, S104 and S106 in a queue of the wrapper class by two times.
Step S110 adds the definitions of public methods, such as reset, clear, initialization, in the original class in accordance with the SOCAD system requirement.
Referring again to
Step S14 converts the original unit testing into an extended unit testing. In order to match an error position occurred in a simulation for a hardware behavior with a corresponding software description, the hardware behavior is divided into blocks, each corresponding to a text debug message. To achieve the object, the executed hardware actions between a current assert function and the last called assert function are recorded. A SOCAD_ASSERT function has two essential features: one for converting the record in step S108 into a text input pattern and storing the text input pattern in an input pattern file, and the other one for appropriately modifying the collected text debug messages for integrating with the input pattern file. Accordingly, the SOCAD_ASSERT function can integrate hardware execution behaviors with text debug messages that are collected from the wrapper class and output to a test pattern file. In accordance with the queue in step S108 and the 4-phased signal protocol used by the SOCAD system, the last second action in the queue is a computation phase along with a SOCAD_ASSERT call, and the last action is a reset phase corresponding to the computation phase. Thus, the user can implement a unit testing by extending the original assert_function through the following pseudo codes.
In case of an action without any assert message, the action is labeled with another message consisting of an immediately following assert message plus a “Before” string to thereby divide all behaviors on a hardware logic simulation into blocks by using text debug messages as boundary lines.
Step S16 uses the extended unit testing to perform the unit testing on the wrapper class to thereby produce the input pattern file. The behavior of the original unit testing is a subset of all behaviors during the process. Because the wrapper class, in addition to the descriptions of the original class, also adds the actions corresponding to the hardware circuit blocks, and the original unit testing is changed into the extended unit testing, the extended unit testing is used to perform the unit testing on the wrapper class to thus produce the input pattern file. The input pattern file includes the hardware actions corresponding to the unit testing, the text debug messages used by the unit testing and the divided blocks of the hardware logic simulation behavior.
Step S18 performs the hardware logic simulation on the hardware circuit block based on the top module and the input pattern file. SOCAD can convert a software method into a hardware circuit block, and uses Modelsim simulator to perform the hardware logic simulation in accordance with the top module and the input pattern file. When a comparison result is affirmative, the subsequent operations are executed; otherwise, the top module can display an appropriate assert message in accordance with the input pattern file. For example, during the hardware logic simulation, a content of the assert message is shown as follows.
Error
In Function testRandom: In 8th interation Computing
Interface: retsimpleRandoml, expected=0000000010, but actual=0000000001
Time: 68us Iteration:0 Instance:/random_test_top
From the above, the user can refer to a call “simplerandom(ture)” in the exemplary content of the original unit testing, which shows a desired result of two but the hardware logic simulation returns one, further, an error obtained in the assert message occurs at the 9-th (zero to eight) time for loop execution. It is assumed that a content of the assert message is shown as follows.
Error
In Function testRandom: BEFORE In 0th interation Computing
Interface: bAck4P, expected=1, but actual=0
Time: 34us Iteration:0 Instance:/random_test_top
From the above, the user can obtain an error occurred before a loop execution at an interface “bAck4P”. Accordingly, the error is determined to occur at a segment “ThisRandom.setB(8, false)”. By the cited two examples, the user can determine corresponding error positions in accordance with the content of the assert message, and correct the errors.
Although the present invention has been explained in relation to its preferred embodiment, it is to be understood that many other possible modifications and variations can be made without departing from the spirit and scope of the invention as hereinafter claimed.
Number | Date | Country | Kind |
---|---|---|---|
095100187 | Jan 2006 | TW | national |