1
00:00:01,340 --> 00:00:07,430
How can we write a test bench for a design in Vivado-HLS? Here, I am going to explain the structure of

2
00:00:07,430 --> 00:00:12,530
a test bench in Vivado-HLS and how to use that to perform design simulation and debugging.

3
00:00:14,640 --> 00:00:18,890
The C top-level function, called main(), is also the test bench top-function.

4
00:00:20,280 --> 00:00:23,580
That means a testbench should start with the main() function.

5
00:00:24,570 --> 00:00:30,150
The test bench functions won’t be synthesised. Therefore, it can call any types of function in C or 

6
00:00:30,150 --> 00:00:36,840
use any features in C language. It can accept a few arguments, and it should return an integer value. 

7
00:00:38,630 --> 00:00:44,990
While the name of the design top-function should be defined in the Vivado-HLS project settings, the name of 

8
00:00:44,990 --> 00:00:46,970
the test bench top-function is always main().

9
00:00:47,720 --> 00:00:50,850
Any function under the design top function should be synthesisable. 

10
00:00:51,380 --> 00:00:55,180
The test bench should call the design top function along with its execution.

11
00:00:58,100 --> 00:01:03,560
Self-checking is one of the test bench requirements. The test bench should check the design correctness

12
00:01:03,560 --> 00:01:06,380
and report that through the main function return statement.

13
00:01:06,560 --> 00:01:10,000
If the results are correct, the test bench should return the value of 0. 

14
00:01:10,400 --> 00:01:13,430
Otherwise, the test bench should return any non-zero values.

15
00:01:16,040 --> 00:01:22,640
Let’s consider this simple design which transfers an 8-bit date from its input to its output without 

16
00:01:22,640 --> 00:01:23,330
any changes.

17
00:01:24,620 --> 00:01:27,920
The test bench of this design consists of five stages:

18
00:01:28,760 --> 00:01:32,820
1-The C main() function is the top function and should return an integer value.

19
00:01:33,770 --> 00:01:39,800
2-Then the design inputs should be generated. As it receives an 8-bit input which can have 

20
00:01:39,800 --> 00:01:45,770
256 different cases. We use a for-loop to generate all the possible values for the input.

21
00:01:47,120 --> 00:01:52,460
3- Then the test bench should call the design top-function, pass the input and receive the output.

22
00:01:54,040 --> 00:02:00,430
4- The received output should be compared against the golden model (or known good results) which in this 

23
00:02:00,430 --> 00:02:03,980
case is very simple, and it is the original input value. 

24
00:02:04,870 --> 00:02:10,480
In the case of any discrepancy, a non-zero value should be written into the return variable, which 

25
00:02:10,480 --> 00:02:11,830
is status in this code.

26
00:02:12,850 --> 00:02:17,330
5- Then a proper message can be written to the output to report the status of the design. 

27
00:02:17,500 --> 00:02:23,950
In addition, the function returns the success of the design verification by the return status. 

28
00:02:25,020 --> 00:02:30,630
You are responsible for ensuring that the test bench checks the results. If the test bench does not check 

29
00:02:30,630 --> 00:02:36,960
the results but returns zero, Vivado HLS indicates that the simulation test has been successful 

30
00:02:37,260 --> 00:02:43,560
even though the results were not actually checked. Even if the output data is correct and valid,

31
00:02:43,590 --> 00:02:48,960
Vivado HLS reports a simulation failure if the test bench does not return the value

32
00:02:48,970 --> 00:02:49,380
zero in function main().

33
00:02:51,970 --> 00:02:59,690
The Vivado HLS GUI does not have a command console and cannot accept user inputs during the test bench execution. 

34
00:02:59,890 --> 00:03:04,240
So, using scanf C-function and similar functions are not allowed. 

35
00:03:06,600 --> 00:03:12,570
After getting familiar with the testbench concept and its coding style, we should explore its development 

36
00:03:12,570 --> 00:03:14,120
in the Vivado-HLS IDE.

37
00:03:15,340 --> 00:03:17,880
The next lecture will cope with this challenge. 

38
00:03:20,530 --> 00:03:27,970
This is our takeaway message. A test bench top-function of a design consists of four main parts: Generating 

39
00:03:27,970 --> 00:03:34,390
the design inputs. Calling the design top-function using the generated inputs. Comparing the design

40
00:03:34,390 --> 00:03:39,160
outputs with the golden model outputs. Returning the success of the design verification.

41
00:03:43,370 --> 00:03:47,780
Now the quiz of this lecture. Write a testbench function for the following design.
