0% found this document useful (0 votes)
380 views22 pages

Ee 465 Final Project Report

The document summarizes a student project to design a temperature sensor device that can calculate either the moving average or standard deviation of up to 12 temperature readings. It describes the design of the modules to calculate moving average, moving square average, and moving average square. It also explains how standard deviation is calculated from these in a hardware-efficient manner by approximating the square root. Test simulations are provided to verify the accuracy and functionality of the design.

Uploaded by

api-482007969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
380 views22 pages

Ee 465 Final Project Report

The document summarizes a student project to design a temperature sensor device that can calculate either the moving average or standard deviation of up to 12 temperature readings. It describes the design of the modules to calculate moving average, moving square average, and moving average square. It also explains how standard deviation is calculated from these in a hardware-efficient manner by approximating the square root. Test simulations are provided to verify the accuracy and functionality of the design.

Uploaded by

api-482007969
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

CPRE_465_Lab Final_Project_Report

Final Project: Moving Average and Standard Deviation Approximator


for Temperature Sensor

Report by: ___Isaac_Klein_and_Nathan_Nordling____

Date: ______________12/17/2019_____________________

Report submission date:

Lab Section: 1

Graded by __________________________________________________

Score ______________________________________________________

Project Design:
Project Planning : Nathan Nordling & Isaac C Klein
Verilog Design: Isaac C Klein
Testing and Simulation: Isaac C Klein & Nathan Nordling
Genus Simulation: Nathan Nordling
Innouvus Simulation: Nathan Nordling
Documentation: Nathan Nordling & Isaac C Klein
Introduction:
In this project we work to design a device that can take any number of random input
temperatures and calculate the Moving average when mode equals 0 or the standard deviation
when mode equals 1. The device will calculate up to 12 temperature readings at a time
prioritizing the last 12 temperatures entered by the user. Once the user stops inputting values the
last 12 or less values will be computed for either moving average or standard deviation. Once it
is done calculating the values it signals a flag to the user saying it has completed with the
solution through the wire vector AVG/SD. Once it has been done and is ready for use again it
will send a SAMPLE flag to the user for a clock cycle indicating to give it fresh new data to
calculate. Each future reading of standard deviation uses a guess value which gets faster to find
in future readings.
CPRE_465_Lab Final_Project_Report

The Design

The design consists of an input TN of 12 bit value that is demuxed by the mode input to either
MA which calculates moving average and outputs to AVG/SD or to the Standard Deviation
branch. The Standard Deviation is calculated in a three step process. First MSA the Moving
Square Average which first squares each of the inputs then takes the moving average and outputs
as a 24 bit value. Second MAS the moving average square averages the incoming inputs then
squares the value to a 24 bit output. Next SD the Standard Deviation Takes the square root of the
difference of MSA and MAS. More details are shown in the following image.
CPRE_465_Lab Final_Project_Report

The Square Root


Computing square root in hardware is not an easy tasks and there are tricks we can get away with
to make the computation easier and more Hardware efficient as far as power and area.
The equation to the left shows a way of doing this that cheats this
using an aproximation that gets closer and closer to the value
needed as it is used over a period of clock cycles. However wed
like to lower our design even more so that the division is only needed once, so we have the
following function instead:
CPRE_465_Lab Final_Project_Report

Moving Average

Moving Average was designed to save power when no inputs were coming and was designed to
calculate moving average even while inputs were less then 12 values.
CPRE_465_Lab Final_Project_Report

As we can see from the test the Moving Average is calculated while values are being brought in
as early as 3 clock cycles after the initial input, but it only sends a ready flag to the other
components after input stops coming in. It also shows its ability to keep calculating accurate
values after completion.
As shown in the test bench it tests with more
then 12 values being input but only the
average of the last 12 values is being
considered with each calculation after that
limit.

(55+54+55+55+56+57+56+55+55+54+53+53) / 12
floored = 54
CPRE_465_Lab Final_Project_Report

Moving Square Average

Moving Square Average was made in a very similar fashion to moving average but it first
squared the input and converted all registers to 24 bit registers to avoid overflow. Therefore each
input is not directly used initially and it needs to wait one more cycle for the first calculation,
causing more avoidance and special cases to build it for power efficiency.
CPRE_465_Lab Final_Project_Report

In order to see the process at work I used two simulations that test higher and lower temperatures
being used to see the consistency. Same as moving average when the inputs stop coming in up to
12 previous temperatures is computed as an output and a ready flag is sent, and it can compute
all over again.
(55²+54²+55²+55²+56²+57²+56²+55²+55²+56²+57²)/12 floored = 2828
(5²+4²+4²+3²+3²+4²+4²+5²+5²+5²+6²+5²)/12 floored = 20
CPRE_465_Lab Final_Project_Report
CPRE_465_Lab Final_Project_Report

Moving Average Square

Moving Average Square behaves very similar to Moving Square Average in that it initially
processes each value but instead of squaring the first value it squares the final value. Therefore
each register can stay at 12 bits up until the final output register. Because of an added clock
cycle to square the output, the system is allowed to calculate one more cycle after inputs stop
coming in and looks not only for incoming temperature but the first registers temperature.
CPRE_465_Lab Final_Project_Report

Once again I simulated with two test bench to show approximate accuracy with two ranges I
values. It behaves very similar to Moving Square Average in simulation.
((55+54+55+55+56+57+56+55+55+54+53+53)/12 )2 = 3025
((5+4+4+3+3+4+4+5+5+5+6+5)/12)2 = 20
CPRE_465_Lab Final_Project_Report
CPRE_465_Lab Final_Project_Report

Standard Deviation

The standard deviation was made in a series of steps and we used if statements to make sure the
different steps were not activated unless needed to save on power consumption. We also reduced
to using a single division step to save on more area and power consumption. We first take the
difference of the input MSA and MAS then make caluclations based on out previous formula.
The device is built to send a next signal whenever the data is calculated so the approximation
that is input can be replaced with the output of this device. It will keep doing this till the value
cur which is the approximation upon input is equal to the output of the device, that is when we
can know we are at the true square root of the value, and thus we have calculated the Standard
Deviation of the input data.
CPRE_465_Lab Final_Project_Report

As we can see here the two values are input at different times, but it will wait till both values are
present to begin calculation once the input aprox is equal to the output of the device over a
period of clock cycles a flag is set saying the data is ready, and all other values are reset back to 0
to save on power consumption. We can see this with two test values one where the difference is
210 - 110 => 100 and the standard deviation is calculated to be 10 in the end, and where the
difference is 190 - 120 => 70
CPRE_465_Lab Final_Project_Report
CPRE_465_Lab Final_Project_Report

Temperature Sensor Device


The temperature sensor device takes in
4 inputs: Reset, Mode, 12 bit Tn, and
Clk, and it outputs 3 values: Sample,
Done, and AvgSd. If mode is set to 0 it
computes moving average and sends a
done flag, the done flag also tells the
device it is ready for a new sample from
the user, and then asks the user for a
new sample. If mode is set to 1 it then
goes to compute the standard deviation
of the incoming temperatures in TN.
Each steps is hidden in if statements to
save from power consumption and
when values are done being used they
are set to 0. When mode is set to 1 the
MAS and MSA are calculated and when
both have received a done flag the SD
begins to be calculated. It calls next
each time the approximation which is
initially set to 1024 as specified in the
design doc should be set to the output of
the SD. Once the output of SD is equal
to the input approx for a full cycle the
SD sends a done flag and the output of
the device is set along with a done flag
to the device. All value are reset back
to 0 that are not used and the
approximation is left at its current
value. The Sample flag is then sent to
the user to request more data to
compute. The next request for standard
deviation should then be calculated
much quicker given the approximation
is much closer to the users temperature
range.
CPRE_465_Lab Final_Project_Report

As we can see from the test above the user first sends a string of data to the sensor with mode set
to 0, the moving average is then calculated in approximately 14 clock cycles. The device then
sends a ready flag followed by a sample flag, and the user then sends more data to the device
with mode set to 1 to calculate the standard deviation. The device then calculates the standard
deviation and in about 15 to 16 clock cycles computes the MSA and MAS to use in calculating
the Standard Deviation. The approximation is then lowered to the standard deviation in about 34
to 35 clock cycles and the Done flag is sent along with another sample request.
CPRE_465_Lab Final_Project_Report

This larger test bench shows the process for a brand new set of data, but it shows that the
calculation for standard deviation process is lowered down to about 10 cycles for the second
request for standard Deviation, being that the approximation is closer now to the users new
samples of data. Adding this new time with the MSA and MAS time of about 15 cycles, any
after first requests to standard deviation is calculated in approximately 25 clock cycles.
CPRE_465_Lab Final_Project_Report
CPRE_465_Lab Final_Project_Report

Next we made a test that would run 3 different sets with temperatures in different ranges of
values to show it would consistently run the tests back to back. We have a moving average
calculation followed by a standard deviation test for each set of data. Each data set after the first
data set calculates standard deviation much quicker. The first in about 35 clock cycles, the
second in about 20-25 clock cycles, and the third in 15-20 clock cycles. Then the simulation
completes after all data is completed setting all dormant registers back to 0 for power efficency.
CPRE_465_Lab Final_Project_Report

Finally I show through simulation that both Moving


Average and Standard Deviation can be repeatedly
calculated with less that 12 values inserted into the
device. Here I show the user inputting only 6 values
instead of 12 and getting results in fewer clock cycles.
CPRE_465_Lab Final_Project_Report

Results From Genus and Innovus

clock period Slack Area Average Power Average Cell Latency Throughput
(ps) (ps) (μm2) Consumption (W) Energy
Count (Cycles (Requests
Consumptio
n per temp per per
reading
Calculation) Second

Genus 490 ps 0 ps 1332 4.29955e-04 W 377 ~15 avg 1.2e8

Innovus 490 ps -43 ps 1529 1.57521e-03 W 406 ~50 SD 1st


~35 SD After

Layout Generated By Innouvus


CPRE_465_Lab Final_Project_Report

Conclusion and Discussion


We learned a significant lot about object oriented design using modular pieces to get to the end
product. We learned about power consumption and area, using correct Verilog techniques to
pipeline and minimize area and power consumption. The device worked to retrieve data from
the user and calculate Moving Average or Standard Deviation as requested. It was slightly off on
calculation however, It always had a value aproximately close to the value expected with a slight
deviance. It worked for as little data as the user chose to input and calculated from a maximum
of 12 input temperatures. The device seem to work properly and genus and innouvus simulation
ran flawlessly. The device was designed to reduce power by turning off different pieces if the
device is left inactive.

You might also like