Triangle Rendering Engine
2013
EE465 FINAL PROJECT REPORT IOWA STATE UNIVERSITY
YIWEN MENG
SU AI
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
1
Introduction
The purpose of this project is design a triangle rendering engine, which is available to
rendering computation and outputs a sequence of outputs after test bench provides three con-
secutive pairs of coordinate input for a triangle. The project require the final engine has to work
appropriately, also require to optimize it to reduce the delay time, area, power consumption as
lower as we can.
Procedure
Our first design of the Verilog Code is to confine calculation of the points in the red rec-
tangular area define the three points of the inputs, so which will save a lot of time and area cir-
cuit of calculation. The graph shows below which reveals two position of triangle will possibly
place.
Figure 1. Calculation Area of triangle render engine
In order to realize this method and because the magnitude of x1 and x2 is not so clear,
so we write a code as below to do the comparison of x1 and x2 to set the smaller value to rx0,
and set the larger value to rx1.
Figure 2. Code for Comparison
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
2
The picture below display the input, output and register in our design. We have rx0 and
rx1 just as we described above. These two stores the value of the x-axis to define the calcula-
tion area in the design. rx and ry as coordinates of the cursors, which will go through the points
of the rectangular area one by one to find the points in the triangle. The register a1 to a3, b1 to
b3, x1 to x3, y1 to y3 are registers to store the input value. The register data is x and y stores
the value from inputs. The counter is flag to indicate the input and send the value of input to
each register in our design. The finish is a flag to indicate whole calculation is finished. The im-
port is a flag to indicate if there are inputs from the test bench. The compare is a flag to indicate
whether the comparison of x1 and x2 is finished or not.
Figure 3. Input, Output and Register
The picture below revels how we send the value of the inputs to our registers. As the flag coun-
ter increase, it will send the input value to the store registers one by one. After importing all the
inputs, we set the busy signal to one to indicate the calculation of the points.
Figure 4. The Importing Method
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
3
For the calculation, we divided rectangular calculation area to the upper sub-rectangle and
lower sub-rectangle by the value of y2, so in each sub-rectangle area, we only have one line to
do the calculation and comparison, which highly saves the registers to store the calculation
value and the area for another multipliers.
Figure 5. Two Sub-Rectangles Calculation Area.
As you can see in the code below, we divided the calculation into two sub-areas based
on the value of ry. So we defined area as ry <= y2; r2 < ry <=y3. We do the calculation of the
points when busy signal equal to 1. And for each sub-area, we only defined one register for the
line which we use to figure out whether the point is in the triangle or not. By doing so, not only
did we save the area for the register and multiplier for the calculation, but also we save the
time for calculation. We set the beginning point of the cursor at the left lower corner of the
whole rectangular region. The Y-axis of the cursor we first increase one by one, and the calcula-
tion will begin after the coordinates was changed. After the X-axis of the cursors equals to rx1
which is the larger value of X-axis of the input. We set the X-axis to rx0 which is the smaller
value of x-axis input, and we set the Y-axis of the cursor increased by one. After the cursor go-
ing from one point to another point from the left lower corner of the rectangular calculation
area to its right upper corner. We finished the calculation and send out the output which are
the coordinates of points in the triangle.
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
4
Figure 6. Code for Calculation
After cursor reach the right upper corner of the first rectangular calculation area. The machine
will start to do the calculation of the second triangle. Also we first do the comparison of the x-
axis of the inputs to define the second rectangular calculation area. After that we sets the cur-
sor at the left lower corner and do the calculation again. The register round will increase by one
which means the machine is doing the calculation of the second triangle now. After it finished
the calculation of two triangles. The register finished will be changed to one.
Figure 7. Code for Changing from triangle 1 to 2
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
5
Results of First Version Engine
This is the transcript after the simulation. As you can see in the red box. All the outputs
of the triangle rendering engine we designed here match all the results. And total time is
105000ns.
Figure 8. The transcript after the simulation of the first Triangle rendering engine
Figure 9. The waveform of the results from the simulation of the first version of the triangle rendering en-
gine
The two registers rx and ry are the value of the coordinates of x-axis and y-axis of the
cursor, relatively. As you can see in the red box of the waveform below, the register rx will in-
creased from 001 to 111 one by one. After it reached to 111, it will go back to 001. At the same
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
6
time, the register ry will increased by one. As you can see yellow box below, we only have one
register to do the calculation and comparison for the cursor each time. And it will decide
whether the cursor is in the triangle or not.
Figure 10. Waveform of the register rx, ry and line
RTL compiler
Figure 11. The layout of the first version of triangle rendering engine after doing RTL compiling
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
7
Figure 12. The report of the power and area
Figure 13. The timing report of the slack time
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
8
The encounter synthesis
Figure 14. The floor plan in the encounter
Figure 15. The layout of the triangle rendering engine in encounter
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
9
Figure 16. The report of timing and power in encounter
Figure 17. The measurement of the area for the layout in encounter, the size = 114.625 * 227.200
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
10
Optimization
The basic idea of the optimization is to reduce the numbers of the calculation to the minimum,
so it can reduce the power consumption and the delay time for the design. The power con-
sumption is a major problems nowadays. Therefore, we focus on solve power consumption
problems, and do our best to reduce it as much as we can. At same time, put area and delay
time change in control.
Methodology and procedure
We notice that the starting point of the triangle is the x1 and y1, and it is in the triangle
region, so we decided to start the cursor at x1 and y1, and send it to output without cal-
culation. After that we set a cursor to the beginning point of line above that, and do the
regular calculation of the points one by one. Besides, we also find the phenomenon that
all the points whose value of y-axis equals to y2 are all in the triangle, so we also just send
these points to the output without calculation.
Figure 18. The design of the calculation area in the optimization
As you can see in the red box below, we always set the begging point of the cursor to x1 y1
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
11
Figure 19. Code for optimization 1
The code in the red box is how we send the first point of the cursor, which equals to x1 y1 with-
out any calculation and set the cursor to the first point in the line above. As you can see in the
green box, when the y coordinates cursor equal to y2, we send out all the points on this line to
the output without any calculation.
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
12
Figure 20. Code of optimization 2
Results of optimaztion
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
13
The waveform in the pink box approves how we set the initial value of the register rx ry to x1
y1, and you can see the waveform in the green box, there’s a period of time in which the regis-
ter line hold at one value. That is when ry = y2, so we didn’t do the calculation for these points
on the line, but just send them to the output
Figure 21. Waveform 1
Figure 22. Waveform 2
As you can see in the red box, all the results matched well after optimization, and we also re-
duced the total delay from 105000ns to 94000ns.
Figure 23. The transcript of simulation after optimization
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
14
Figure 24. The waveform of the results from the simulation of the first version of the triangle rendering
engine
RTL Compiler
Figure 25. The layout of the triangle rendering engine after optimization
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
15
Figure 26. The report of area and power after optimization
Figure 27. The timing report of slack timing after optimization
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
16
Encounter Synthesis
Figure 28.the layout of triangle rendering engine after optimization in encounter
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
17
Figure 29. The report of power and timing in encounter after optimization 1
Figure 30. The report of power and timing in encounter after optimization 1
TRIANGLE RENDERING ENGINE YIWEN MENG & SU AI
18
Analysis
After finished all design and testing, we collected data and find out the differences be-
tween before and after optimization.
Slack time(ps) Net Power(nW) Total Area
Before Optimization 405 115739.36 1426.60
After optimization 411 82652.48 1774.8
To meet the low power consumption nowadays, we reduced net power consumption by
28.58%. However, to reach this optimization, we slightly increase the area and delayed time,
but it’s still in control. For long-term using, low power consumption will benefit more than
smaller area or lower delay time.
Summary
After all the procedures and results above, we design a triangle rendering engine and the pro-
ject meet all function requirements. The optimization process help our project works much bet-
ter and efficiently. After this project, we learned how to use Verilog to design the circuit to
solve problem. The project problem have difference with real life problems, but it’s still give us
opportunities to learn circuit development process.
Contribution
Yiwen Meng 55% Su Ai 45%