Project Alessandro Montanari
Project Alessandro Montanari
VHDL Project
Digital System Design with VHDL - 6 Credits
Group 1
Date
13/06/2011
Student
Alessandro Montanari
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
2
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
Table of Contents The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
1 Introduction!......................................................................6
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
1.1 Project Requirements!.........................................................................6
2 Theoretical Concepts!......................................................8
2.1 VGA Video Signals!.............................................................................8
3 Design!.............................................................................19
3.1 Overview!............................................................................................19
3.2.3 Simulation!......................................................................................................31
3.3.3 Simulation!......................................................................................................37
3.4.3 Simulation!......................................................................................................
Abstract 41
3.7 Test!.....................................................................................................46
Appendix B - fifo_linebuffer.vhd!...........................................................50
Appendix C - double_fifo_linebuffer.vhd!..............................................51
Appendix D - sync_signals_delayer.vhd!..............................................52
Appendix E - cache_system.vhd!...........................................................54
Appendix F - sobel_kernel.vhd!..............................................................57
March 18, 2011 1 Aart Mulder and Kolja Roese
Appendix G - edge_sobel_wrapper.vhd!...............................................58
Appendix H - num_rom.vhd!...................................................................59
Appendix I - number_displayer.vhd!......................................................62
Appendix J - bcd_converter.vhd!...........................................................63
Appendix K - trigger_generator.vhd!.....................................................64
Appendix L - distance_measurer.vhd!...................................................65
4
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Appendix M - range_sensor.vhd!...........................................................66
Appendix N - top_vga.vhd!.....................................................................67
Appendix O - top_vga.ucf!Abstract
......................................................................68
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
5
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
1 Introduction The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
The first aim of this project is to create
complex anwireless
FPGA based
network embedded
structure was designedvideo
with thesystem that is ofable
flexible integration to
multiple
sensor devices. A possible application is the observation of temperature in several server
emphasize the edges of the incoming images using the Sobel operator. The system is basically
systems with hard disk storage in order to maintain the reliability. The report contains a short
composed by a camera that acquire the video
introduction of sensor
in wireless the networks
real world, an the
and describes FPGA and
complete a monitor
process to
of development.
display the processed video stream. The last chapter deals with a conclusion and covers possible improvements and enhancements.
The second aim of this project is to measure the distance between the lens of the camera and
the object in front of it. To achieve this purpose an external range sensor is used to find out the
distance of interest. The detected distance has to be displayed on the monitor overlapped with
the processed video stream that comes from the FPGA.
C
A
M 1.32
E
R
A
Object FPGA \
S
E
N
S
O
R
6
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
The project should be implemented in hardware in the development board mentioned before, for
this reason particular attention must be kept in order to ensure that the entire code of the project
is synthesizable. For achieve the best result in terms of speed and area occupation, during the
entire design some best practices are used.
7
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
2 Theoretical Concepts The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
In this chapter will be explained thecomplex
theoretical concepts
wireless network that
structure was are lying
designed withbehind the
the flexible development
integration of multiple
sensor devices. A possible application is the observation of temperature in several server
of the project, like the signals used systems
to display images on the screen, the Sobel operator, how to
with hard disk storage in order to maintain the reliability. The report contains a short
read and process the distance detected fromin the
introduction range
wireless sensor sensor and
networks and whattheiscomplete
describes the BCD encoding.
process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
640
(0,0) (639,0)
480
(0,479) (639,479)
paintsto 1thepixel
In addition at signals
previous a timethere from leftato
is also right.
clock, At defined
usually the end of the
as Pixel firstthat
Clock,
row, the
represents thetime
row increments
available to display one andpixel theof information.
column address is reset to
the first column. Once the entire screen has been painted, the
refresh process begins again 8
The video signal must redraw the entire screen 60 times per
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
In the Figure below is shown the timing for the VGA synchronization signals.
pixel clock
Abstract
frame sync
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
row sync row 0 row 1devices. A possible
sensor row 2 applicationrow 477
is the observationrow 478
of temperature in row 479
several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
Figure 2.1.2 - VGA Synchronization Signals
The Row Sync signal is high for the entire period necessary to display one line on the screen,
when this signal goes down it marks the end of the previous line and the start of the next one.
While the Row Sync signal is high the monitor displays one pixel for each rising edge of the
pixel clock with the color of the pixel defined as a mixture of the three primary colors, Red,
Green and Blue.
On the other hand, the Frame Sync signal marks the start and the end of a frame made up of
video lines. This signal is high for the time necessary to display one entire frame on the screen.
While this signal is high the monitor uses the Row Sync signal to determines when it has to
display a new line.
In more detail, is not possible to display information through the entire interval when the Frame
Sync and the Row Sync signals are high. Indeed there are two intervals, called Front Porch
and Back Porch, during which the screen is not able to display the pixels. These intervals are
present for both synchronization signals, how it is possible to see in Figure 2.1.3. The only
interval where the pixels are printed into the screen is the Display Time and how it is possible to
see it is composed by 480 lines and each line is composed by 640 pixels (obviously for a
640x480 monitor).
The Frame Sync, Row Sync and Pixel Clock determine the screen resolution (ex. 640x480) and
the refresh rate of the entire screen (ex. 60Hz). There are different VGA monitors with different
resolutions and refresh rate, for each of those monitors there are different timings for the
synchronization signals and for the Pixel Clock. For the most common VGA mode 640x480 with
March 18, 2011 1 Aart Mulder and Kolja Roese
the refresh frequency of the entire screen equal to 60 Hz, the timings for the synchronization
signals are reported in the table below. Usually the Pixel Clock frequency is 25.175 MHz.
9
anual www.digilentinc.com
d to each pixel location (the Nexys2 uses three bits per pixel). The controller must
Mid Sweden University
mory as the beams
Department move across the display,
of Information Midand
Swedenretrieve and apply video data to
University
ely the time the electron Department of Information
Technology and Media beam
(ITM) is moving across a given pixel.
technology and media (ITM).
For simulate the behavior of the monitor and the camera is used a particular test bench which is
Figure
e specified, to20: Schematic
ablepublished,
read an imageforfrom
a VGA
thecontroller
filesystemcircuit
and produce the synchronization signals like in the
by the VESA
VGA organization
standard: row sync, frame sync and pixel value (gray scale - 8 bits). At the same time this
followingtest
VGA system
bench also providesFigure
the possibility
16: VGA pinto write a grayand
definitions scale imagecircuit
Nexys2 on the filesystem using the
rovided same
as an VGA
example of
signals.
might be driven in 640 by 480 mode. For more precise information, or for
VGA frequencies, refer to documentation available at the VESA website.
pxlclk
data_out
data_in 8
8 img_testbench fsync_out
fsync_in
rsync_in Abstract rsync_out
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
Figure 2.1.5 - img_testbech Module
the requirement of environmental monitoring with the focus on temperature observation.
A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
As it is possible to see in the previous figure the test bench is called img_testbench and has
systems with hard disk storage in order to maintain the reliability. The report contains a short
four inputs and three outputs. The outputs
introductionrepresent thenetworks
in wireless sensor signals andgenerated duringprocess
describes the complete the ofreading of
development.
a certain image on the filesystem while
The lastthe inputs
chapter represent
deals with a conclusionthe signals
and covers used
possible to write
improvements an image
and enhancements.
on the filesystem. In other words this module is at the same time a “camera” and a “monitor”.
This test bench was not created but was already provided for the project.
The test bench just mentioned is not able to handle the porch intervals, in other words the
period necessary to display a line (or a frame) is exactly the time necessary to display 640
pixels (or 480 lines) and not more. The entire design is developed keeping in mind this fact,
with the future intention of improve it from this point of view.
Before to talk about the Sobel operator here we report a brief explanation of what is an edge
inside an image and the basic concepts used to detect it.
Edges characterize boundaries as well as giving the information of the location object, shape
and size. Therefore, edge detection is a fundamental practice in image processing. For
simplicity we will focus only on the gray-scale images. Intuitively an edge is a gray-level
transition from a start value to a final value as it is possible to see in Figure 2.2.1.
Figure 2.2.1 - Image and profile of an ideal edge and of a ramp edge
11
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
In the picture above it is possible to notice that an ideal edge is a set of connected pixels (in the
vertical direction in the example) each of which have a completely different gray value from the
other pixel. In the real world, however the edges are blurred and so they have a profile that is
very similar to a ramp (this effect can be reduced using a good quality acquisition system). In
Abstract
this case the transition from one pixel to the adjacent one is not strong as in the ideal case and
so there isnʼt anymore a thin edge (one pixel thick) as in the ideal case but now the edge is
contained in the ramp and is more thick. The blurring effect makes more difficult to recognize
the exact position of an edge usingTheonly the
project grayinvalue
is placed the fieldof
of adjacent pixels,
Wireless Sensor forItthis
Networks. reason
is developed the
to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
most used techniques to detect complexan edge are based upon the first-order or second-order
wireless network structure was designed with the flexible integration of multiple
derivative. sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
As it is possible to see in Figure The
2.2.2 the deals
last chapter first-order derivative
with a conclusion and coversis positive
possible at the
improvements points of
and enhancements.
transition into and out of the ramp as we move from left to right along the profile and it is
constant for points in the ramp and is zero in areas of constant gray level. The second-order
derivative instead is zero along the ramp and in areas of constant gray level and is different
from zero (negative or positive) at the start and at the end of the ramp (from left to right).
From this brief explanation is possible to notice that the magnitude of first-order derivative can
be used to detect an edge at a point of 18,
March an2011
image, in other words1 is possibleAart
toMulder
understand if a
and Kolja Roese
point is on a ramp that represents a gray level transition. Similarly, the sign of second-order
derivative can be used to determine if a edge pixel lies on the dark (start of the ramp) or light
side (end of the ramp) of an edge.
An important concept that should not be forgotten is that for detect edges inside an image we
are dealing with local computations because we are measuring the transition between adjacent
pixels, for this reason a point in an image can be classified as an edge point if the transition
associated with that point is “significantly” stronger than the background at that point. Therefore
a threshold must be used to determine if the value is “significant” or not. In a formal way it is
possible to say that: a point in an image is an edge point if its first-order derivative is equal or
greater than a specified threshold. If the second-order derivative is used the threshold is used to
check if the two spikes are stronger enough and then the edge point is located at the zero-
12
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
crossing point (point where the line that join the extreme positive and negative values of the
derivative cross the x-axis). It is easy to notice that in general an edge detection technique that
uses the first-order derivative will lead to more thicker edges in relation with techniques that use
the second-order derivative. When all the edge points are discovered, a connectedness criterion
Abstract
must be used to connect all these points to define an edge.
In the next section we will analyze more deeply the technique used to detect edge points based
upon the first-order derivative sinceThe
it isproject
one isofplaced
the aims of this
in the field project.
of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
2.2.2 First-Order Derivative sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The Sobel operator is one of the fundamental operators
The last chapter deals for and
with a conclusion edgecoversdetection algorithms.
possible improvements It is of
and enhancements.
the family of first-order derivative because it is computed using the digital gradient of the image.
The digital gradient of an image f(x, y) at location (x, y) is defined as the vector:
!"
!! !"
!! ! ! ! ! !" !!!
!
!"
!!"
!! direction
The gradient vector points in the !" of maximum rate of changes of f at coordinates (x, y).
An important quantity!! ! ! detection,
in edge !
! ! !!
!" as!!!
! !"#
stated!! !!! ! !section,
! !previous
in the !
!! is the magnitude of
this vector, denoted ∇f, is computed in !"
this way:
!
!! ! !!! ! !! !!
!! ! !"# !! !! ! ! !! !!! !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!"! !!!
! ! !
! ! !"
This quantity gives the!maximum
! ! !! ! !rate
!! !!!
of increase ! !
of f(x, y) per unit distance in the direction of ∇f
!"
and is the value that should be checked
! ! !! ! ! !
!! !! ! !! !!the
against !!threshold
!! !"
!! !!!! in !!!order
! !!to!determine
!! !! if a point is
! ! ! ! ! ! !
an edge point or not.
! !! ! !! ! !! ! !" !! ! !!! ! !! ! !! !!
Computing the gradient
!
! of an image is! based on obtaining the partial derivatives ∂f/∂x and ∂f/∂y
at every pixel location!and! ! !! ! !! ! !!
! !! !
there are different !ways!!! !
!"# to!!!compute
! !!!!! !!!!! ! !!! !
them: Roberts, Prewitt and Sobel
operators. Using the 3x3!! ! area! shown ! ! ! 2.2.3,
in Figure
! ! !! !!!! ! !!!! ! !
! !!!the ! simplest
!!!
!!! !!! !!!approximation
! !!! ! !! !!to a first-order
derivative is the Roberts approximation!where
! ! the two components
! ! !! ! !!! ! !! ! !!! ! !!! ! !! !!
are computed in this way:
! ! !
March
! !!! ! !! !!
18,! 2011 1 Aart Mulder and Kolja Roese
!
!! ! !! ! !!!! ! !!! ! !! ! !! ! ! !!
! !!!! ! ! !!
! ! !
!!!! !
!! ! !! ! !!! ! !! !!!!! ! !! ! ! ! ! !
! ! ! !! !!
! ! !! !
! !
! z1 ! ! ! !
z2! z3 ! ! ! ! !
! ! !!! ! !! ! !! !!
!! ! !! ! !! ! !! ! !!! ! !! ! !! !!
!! ! ! !! ! !! ! z4 !!!!!!!!!!!!!!!!!!!!!!!"!
z5 z6 !!!
! ! ! ! !
!z7 0z8 z9
! -1 0 -1 !
! !! ! !! ! !!! ! !! ! !!!! ! !!! ! !! !!
0!!zʼs!are 1 gray-level
! !! ! !!! ! !! ! !!!! ! !!! ! !! !!
Figure 2.2.3 - A 3x3 region of an image (the 1 values). 0 Also called neighborhood of z5.
!
! !
-1 0
! 0! -1 !
!
0 1 1!!
-1 ! -1 ! !!
!
0 13! -1 !! ! -1 0 1 !
! ! ! !
0 0 0 -1 0 1 !
! !
!! ! ! !! ! ! !" !!!
! ! !"
!
! ! ! !! ! !! !!"! ! ! ! ! !! ! !! ! !!! ! !! ! !! !!
! ! ! !! ! !! ! !! !!
! !! ! !! ! !!! ! !!! ! !! ! ! !! ! !! !!
Mid Sweden University !!! ! !
! !! ! !!!
!"# ! !University
!!! !! !!!!
! !! ! !!!! ! !! !!
! Department
Mid Sweden !
! ! !!! ! !!! !
!
!!! ! !"# !!of Information
Department of Information
Technology and Media (ITM)
! technology and media (ITM).
!
! !! ! !!!!! ! !!! ! !! ! !!! ! !!! ! !! !!
!!! ! !!
This operators can be implemented !!!convolving
! !! !! ! ! ! !
the masks!!! !in!! ! ! !2.2.4
Figure ! !! with the entire image,
!! ! !! !
!! !
! ! ! ! !!
!!to!!
! ! ! !! ! ! ! ! ! !! ! ! !! ! ! ! !!
but since masks of size 2x2!are ! !awkward
! !!! ! !! ! !! ! !!because
! implement ! ! !!! ! they!! !!donʼt !have a clear center,
a different approach is use! masks
! ! ! !! !
! !of size ! !!
! 3x3 (Figure 2.2.5) in conjunction with the Prewitt
operators computed in this way: !! !
!! ! !! Abstract
! !!!!! ! !! ! ! ! ! ! ! !!
!! ! ! ! !! !!!! !! !! !!
! !!! ! !!! ! !! ! !! !!
! ! ! ! !
!! ! ! ! !! ! !! ! !! ! ! !!! !! !! ! !! !!
! ! ! ! ! ! !
!! ! ! !The ! !
! project ! !
! is placed ! !! !
! in the !field of ! ! ! ! !!
Wireless!Sensor Networks. It is developed to fulfill
!!!
!! ! the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
!
!!! ! !!systems ! ! !! !!in!!order
devices.! A! ! application ! !! is the! !the
! !!reliability. The report contains a short
sensor possible observation of temperature in several server
!hard disk!! storage !
!!! ! !!introduction
!! !!0!in!
!"
with
!!! sensor
! !! ! !! ! !!! !!
to maintain
!! ! !!
! ! !! ! ! !! !! ! ! 0 !!networks
!! ! !!
-1 ! -1
wireless ! describes
and ! the complete process of development.
-1 0 !"
!!!!! !!!! !
The !last !!
! !deals
!!with!a conclusion
!!! ! !! !! ! !possible
! !! improvements and enhancements.
!! !chapter 0 -1
!" !!!
and covers
!
!! 0 10 1
!" 1 01 !
0 !
! !!!! Figure
! !! 2.2.4!! !- Roberts!! ! masks for gradient
!! ! ! !"#! !! !!! ! ! !! ! ! ! ! !
!! ! !! ! !
!! -1 -1! !-1 ! -1 ! !
-1 -1
-1 -1 0 10 1
!
! !! !
0 0 0 -1 0 1 !
!!!! 0! !!!0! !! !!0 ! -1 0 1 !
!!! -1 1! -1 ! -1 !
1! !!!1 0! !! !!1 0
1 1
-1 0 10 1 !
! -1 0 0 -1 !! ! !
! 0Figure! 12.2.5 -! Prewitt 1 masks 0 for!! gradient
0 !1 1 0
!!! ! !! ! !! ! !! ! !!! ! !! ! ! !! !!
!!!! -1
A little variation of the previous
!two equations
! !!are-1 !the Sobel operators
!!10!! that 1 uses ! a weight! of 2 in
!!-2 -1! !! -1 -2 -1! ! !-1
!! 0! !
the center coefficient in order ! to achieve some smoothing by giving more importance
! ! to the
! -1 -1 -1 -1 0
-2 1
center point: 0 00 00 0 -2 0 20 2
!! !
! -1 -1 -1 -1 0 1
0 01 02 -1 0
-1 10 1 !! !
!! 10! !!20 ! !!!10 ! !! 1!-1 !!
-1 ! ! 0
0!! ! ! 1
1 ! ! !!
!!
!! 1! !!1! !!!1! !! !-1 !!! ! 0!!! !1!! !! !
! 1 1 1 -1 0 1 !!
! !
!
!! ! ! ! !! ! ! !
! !
! !
! -1 -2 -1 ! -1 0 1
-1 0 1 !!
! -1 -2 -1
-2 0 12
0 0 18, 0
March 2011
!! Mulder and Kolja Roese
Aart
! 0 0 0 -2 0 2
!
! 1 2 1 ! -1 0 1
!
1 2 1 -1 0 1 !
-1 Figure 0 2.2.6 - Sobel 0 masks !
-1 for gradient !
!
0 1 1 0 !
An important thing that should be noticed is that the coefficients in masks in Figures 2.2.5 and
! they would give a response of 0 in an area of constant gray level,
2.2.6 sum to 0, indicating that
as expected of a derivative! operator.
!
Using the masks described-1 before-1it is possible-1 to-1 compute 0 the 1two components of the gradient
!
(x and y), these two values0then 0 must be 0 combined -1 computing 0 1 the magnitude of the gradient
using the expression reported in Eq. 1. Since the computational burden of! implementing this
1 1 1 -1 0 1 !
14 !
!
!
!! ! !! ! !! ! !! ! !!! ! !! ! !! !!
!! ! !! ! !! ! !! ! !!! ! !! ! !! !!
Mid Sweden University !
Mid Sweden University
Department of Information
Technology and Media (ITM)
! Department of Information
!! ! technology
!! ! !! ! ! !! ! !!! ! !!! ! !! !!
and media (ITM).
15
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network
Original Image structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
In this project was made the choice to keep the resulting image of the same size of the original
one and it was choice to adopt as black the pixels that are out of the image boundaries as
shown in Figure 2.2.7.
In Figure 2.3.1 is depicted the sensor and the connections that must be made for use it in the
Mode 1. As it possible to see only four pins has to be connected: two for the power (5V and 0V)
and two for the Trigger and Echo signals. The pin Mode should be disconnected because it is
used only in Mode 2. The pins on the right side of the sensor must be disconnected because
they are used for program the internal controller of the sensor, if this pins are connected the
correct behavior of the sensor could be compromised.
16
%&'()$/5#3,2#+$A*2"$+#5,3,2#$23*<<#3$,-:$#="/$5*-+9$0*F#$2"#$%&'(8?$!"#$%&'()$*-=01:#+$,$+7,00$:#0,4$;#6/3#$2"#
#="/$510+#$2/$<*.#$+0/A#3$=/-23/00#3+$+1="$,+$2"#$G,+*=$%2,75$,-:$H*=,>#$2*7#$2/$#>#=12#$2"#*3$510+#$*-$=/77,-:+?
Mid :-82&;&'&!"#$<&0-=5,*/>)2&'&!25,+,*2&3+/112+&,.8&?04-
Sweden University
!"*+$7/:#$1+#+$+#5,3,2#$23*<<#3$,-:$#="/$5*-+9$,-:$*+$2"#$+*750#+2$7/:#$2/$1+#?$@00$=/:#$#>,750#+$6/3$2"#$%&'(8
Department of Information Mid Sweden University
A*00$A/3F$6/3$2"#$%&'()$*-$2"*+$7/:#?$!/$1+#$2"*+$7/:#9$I1+2$0#,.#$2"#$7/:#$5*-$1-=/--#=2#:$J$2"#$%&'()$",+$,-
Technology and Media (ITM) Department of Information
technology and media (ITM).
*-2#3-,0$5100$15$3#+*+2/3$/-$2"*+$5*-?
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
In Figure 2.3.2 is depicted the timing diagram for the sensor used in Mode 1. The users of the
sensor only need to supply a 10us pulse to the Trigger input to start the measure of the
distance. The period between each Trigger pulse must be at least 50ms, this interval should be
respected in order to ensure that the previous ultrasonic signal will not cause a false echo on
the current measure. After the Trigger pulse the sensor will send out an 8 cycle burst of
ultrasound at 40kHz and raise its Echo pin high. Then the sensor listens for an echo,
84947$,2,-784/0-:;-4;5<=>=:8?"%7,-.;.76 #=@ and as
soon as it detects one it lowers the Echo pin again. In this way like described before, the width
of the pulse on the Echo pin is proportional
!"##$"%$#&
to distance to the object. The maximum measurable
'()"%*+,-./0-12*34-56,/71704/
distance of this sensor is about 4 meters and this distance is represented by an echo pulse of
25ms. If no objects are detected in front of the sensor, the Echo pin will become lower anyway
after 30ms.
!"#$%&%'%()*+,$%-)*%."/%0"12%3/)++$/%4*#%562"
!"#$%&'()%*$)$%+%$#,-.)%/#,%0'1%2'3"%!1#--)1%+,(%45"'%$#-,+.$6%+,(%#$%()$#-,)(%3'%$+7)%7+.*+2.)%/#,$%',%)&2)(()(
5',31'..)1$8%!'%*$)%3"#$%&'()6%5',,)53%3")%&'()%/#,%3'%3")%97%:1'*,(%/#,8%!")%)5"'%$#-,+.%;#..%+//)+1%',%3")%$+&)
/#,%+$%3")%31#--)1%$#-,+.8%!")%<=>9?%;#..%,'3%1+#$)%3")%)5"'%.#,)%*,3#.%@99*<%+03)1%3")%),(%'0%3")%31#--)1%$#-,+.8%A'*
17
"+7)%3"+3%.',-%3'%3*1,%3")%31#--)1%/#,%+1'*,(%+,(%&+B)%#3%+,%#,/*3%+,(%3'%"+7)%C'*1%/*.$)%&)+$*1#,-%5'()%1)+(C8%!")
DEF<GH%5'&&+,(%0'*,(%',%&+,C%/'/*.+1%5',31'..)1$%(')$%3"#$%+*3'&+3#5+..C8
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Measuring the width of the Echo pulse is possible to calculate the distance in centimeters or in
another unit. In particular if the width of the pulse is measured in micro-seconds, the distance in
centimeters can be calculated dividing the width by 58 (us / 58 = cm).
Abstract
2.4 Binary-Coded Decimal
The binary-coded decimal is a digital
Theencoding method
project is placed for ofdecimal
in the field numbers
Wireless Sensor where
Networks. each digit
It is developed is
to fulfill
represented with a binary sequence. In BCD each digit is represented using four bits like in theA
the requirement of environmental monitoring with the focus on temperature observation.
complex wireless network structure was designed with the flexible integration of multiple
table below. sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
DecimalThe last chapter deals with a conclusion BCD
and covers possible improvements and enhancements.
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Table 2.4.1 - BCD Encoding
It is obvious that using the Uncompressed method to store numbers in BCD encoding is not
efficient like using the Packed method. However using the BCD encoding there is, in general,
less efficiency, from the storage point of view, instead of using a typical binary format. After the
inefficiency from the storage point of view, the second most important drawback in using BCD
encoding is that some operations are more complex to implement and therefore slower during
the execution. Nevertheless the BCD format is sometimes used because it makes really easy
the conversion between machine and human-readable formats and also because it makes
possible to achieve a more precise machine-format representation of decimal quantities. For
example the representation of fractions is easier in BCD than in binary.
18
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
3 Design The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
In the following chapter is explained thewireless
complex implementation
network structure ofwasthe project
designed with theonflexible
the integration
board Nexys2
of multiple
sensor devices. A possible application is the observation of temperature in several server
using the VHDL language. The first systems
section provide a generic description of the main modules in
with hard disk storage in order to maintain the reliability. The report contains a short
the design, the following sections analyze inindetail
introduction wirelesseach module.
sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
The code for each module described in this section can be found in the Appendix.
3.1 Overview
top_vga
pxlclk pxlclk
data_out data_in data_out
FROM THE data_in 8 8 TO THE
8 edge_sobel_wrapper fsync_out fsync_in number_displayer fsync_out
CAMERA fsync_in
rsync_out
MONITOR
rsync_out rsync_in
rsync_in
pos_row pos_col meters decimeters centimeters
10 10 4 4 4
255 255
In Figure 3.1.1 are depicted the main blocks of the project. The module edge_sobel_wrapper
implements the Sobel algorithm for edge detection. This module takes the synchronization
signals and the value of each pixel from the camera, it modifies
March 18, 2011 1
the value of each pixel in
Aart Mulder and Kolja Roese
accordance to the Sobel operator and put on the outputs the same synchronization signals in
input and the new data for the pixels. These values are then used from the number_displayer
module to recognize the position where the numbers representing the distance should be
displayed. The new values of the pixel data together with the synchronization signals are then
send to the VGA interface.
The range_sensor module is responsible to send the trigger signal to the range sensor and then
measure the echo received from it. The distance is then processed to convert it in meters,
decimeters and centimeters, these values are encoded in BCD and then send to the
number_displayer module.
19
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
In Figure 3.2.1 is depicted the edge_sobel_wrapper module. This module is responsible to take
the synchronization signals and the pixel values from the camera and compute the gradient for
each pixel using the Sobel operators.
edge_sobel_wrapper
pxlclk
fsync_out fsync_in
rsync_out rsync_in
data_out1 data_in1
8
data_out2 data_in2
8
pxlclk data_out3 data_in3
data_in
8 data_out
8
8 data_out4 data_in4 fsync_out
fsync_in cache_system 8 sobel_kernel
rsync_in rsync_out
data_out5 data_in5
8
data_out6 data_in6
8
data_out7 data_in7
8
data_out8 data_in8
8
data_out9 data_in9
8
This module takes, directly from the camera, the two synchronization signals (frame sync and
row sync) and the pixel values (8 bits in gray scale) and put as outputs the values of the eight
pixels that represent the neighborhood of the pixel in the center of the 3x3 kernel, as shown in
20
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Figure 2.2.3. This module have also to put as outputs the synchronization signals with the right
timings.
The first problem here is the fact that every frame is produced by the camera using the vga
standard reported in section 2.1, Abstract
for this reason it is not possible to emit the pixels of the
resulting image during the reading of the original image in the same order, in other words it is
not possible to emit the first pixel of the resulting image after the reading of the first pixel of the
original image because are not yet The available
project isall theinpixels
placed the fieldin
of the neighborhood
Wireless Sensor Networks. of It that pixel.toThis
is developed fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
fact can be noticed more clearly in Figure 3.2.3,network
complex wireless here structure
it is possible to with
was designed notice that for
the flexible compute
integration the
of multiple
value of the pixel in position (0,0) in the resulting image, nine pixels are needed (from z1 to z9 in
sensor devices. A possible application is the observation of temperature in several server
the position 1), five of these pixels systems
(z1, z2,with hard disk storage in order to maintain the reliability. The report contains a short
z3, z4, z7) are assumed to be black (gray value of
introduction in wireless sensor networks and describes the complete process of development.
zero) as explained at the end of the The section
last chapter 2.2.2.
deals withThe others
a conclusion fourpossible
and covers pixels (z5, z6,and
improvements z8, z9) are
enhancements.
available only after the reading of the entire first line and of the first two pixels of the second
line. This basically means that the emission of the pixels in the resulting image is in “late” of one
line and two pixels respect to the reading of the original image. This also means that for emit
each pixel in the resulting image it is necessary to accumulate the two previous lines of the
original image (in Figure 3.2.3, lines 3 and 4 for positions 4, 5 and 6) and during the reading of
the third line (line 5 in Figure 3.2.3) it is possible to emit the pixels in the line 4 of the resulting
image.
0 1 2 3 ....................................................................... 639
z1 z2 z3 z1 z2 z3 z1 z2 z3
0 z4 z5 z6 z4 z5 z6 z4 z5 z6
1 z7 z8 z9 1 z7 z8 z9 2 z7 z8 z9 3
2
3 z1 z2 z3 z1 z2 z3 z1 z2 z3
4 z4 z5 z6 z4 z5 z6 z4 z5 z6
5 z7 z8 z9 4 z7 z8 z9 5 z7 z8 z9 6
...........................................
Original Image
z1 z2 z3 z1 z2 z3 z1 z2 z3
479 z4 z5 z6 z4 z5 z6 z4 z5 z6
z7 z8 z9 7 z7 z8 z9 8 z7 z8 z9 9
Figure 3.2.3 - Convolving a 3x3 mask with an image. With numbers from 1 to 9 are marked the relevant
positions of the mask.
For cope to this problem the basic idea was to create a memory architecture that was able to
stores two lines of the image. The basic structure of this memory is in Figure 3.2.4.
21
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
d1 d2 d3
z9 z8 z7
Abstract
z6 z5 z4 z3 z2 z1
The 3.2.4
Figure project -isMemory
placed in the field of Wireless
Architecture Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
As it is possible to see in the previous
sensor figure
devices. there are
A possible two fifo
application line
is the buffersof that
observation are responsible
temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
to accumulate exactly the number ofintroduction
pixels in one line
in wireless sensor(640).
networksThese buffers
and describes haveprocess
the complete a First-In-First-
of development.
Out policy, this means that the pixelThevalues
last chaptergo out
deals withfrom the and
a conclusion buffer with the
covers possible same and
improvements order which
enhancements.
they entered and they start to go out only when the line buffer is full. The elements marked with
labels from z1 to z9 (from now called pixel elements) represent a smaller copy of pixel values
which are also stored in the line buffers and they are necessary to extract from the line buffers
exactly the pixel values that must be used from the Sobel kernel. All of these elements are
driven by the pixel clock, this means that at every rising edge of the pixel clock the pixel values
are stored in the line buffers and pass trough the small elements. For example, for the position
5 (Figure 3.2.3) the fifo_linebuffer 1 will hold the line number 4 and the fifo_linebuffer 2 will hold
the line number 3 and when the pixel z9 of the line 5 is read the small elements will contains all
the pixels in the neighborhood of z5.
Consequently the cache_system module has to properly delay the synchronization signals in
order to ensure that the sobel_kernel module will understand when the nine pixel values are
valid. Indeed, the sobel_kernel module has to wait until the cache_system module has
accumulate the right number of lines and pixels so it can start to compute the gradient with the
right values for the nine pixels. This synchronization can be achieved delaying the two
synchronization signals (frame sync and row sync) for the right time, in this case the
cache_system module will rise the frame sync and the row sync after one line and two pixels
because for the position number 1 only the first line is necessary since the pixels z1, z2 and z3
are assumed black.
The implementation of this module (Figure 3.2.5) was divided into several parts:
1. double_fifo_linebuffer : responsible of accumulate two lines of the original image;
2. sync_signals_delayer : responsible of delaying the synchronizations signals;
3. counter : general counter used to count the lines and the pixels during the reading.
The pixel elements responsible ofMarch
storing only the neighborhood
18, 2011 1 pixels ofAart
a Mulder
givenandpixel are
Kolja Roese
created using variables inside the cache_system itself, as described later.
22
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
cache_system
pxlclk
fsync_in
Abstract fsync_out
sync_signals_delayer
rsync_in rsync_out
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
z9 a short
systems with hard disk storage in order to maintain the reliability. The report contains
pxlclk pdata_out1
introduction in wireless sensor networks and describes the complete8 process of development.
8 z8
The last chapter deals with a conclusion and covers possible improvements and enhancements.
c1
fsync 8
z7
rsync 8
pdata_in z6
8 double_fifo_linebuffer pdata_out2 8
8 z5
c2
8 z4
8
z3
pdata_out3 8 8
z2
c3
8 z1
8
In the following Figure is depicted the module that is responsible to store an entire line (640
pixels) using the FIFO policy.
pxlclk
fsync
fifo_linebuffer pdata_out
8
rsync
pdata_in
8 March 18, 2011 1 Aart Mulder and Kolja Roese
To implement the FIFO policy this principle is used: always read a pixel value from the memory
before writing in the same cell. To achieve this behavior is used the pixel clock and is inverse
(clk2), in this way the rising edges of the pixel clock are used to read from the memory and
instead, the rising edges of clk2 are used to write into the memory in the same cell of the
reading. A variable is used as a counter that is incremented after each writing and is used to
determine the cell inside the memory for reading/writing phase. Using this approach during the
reading of the first line the output of this module will be Undefined because the memory is not
23
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
initialized, but during the reading of the second line in output there will be the pixel values of the
first line in the same order they entered inside the memory.
Special attention in the code style has been used in order to ensure that XST will use a RAM
Abstract
device already available inside the board, this will lead to a less usage of flip-flops and also to a
better performance. To achieve this result two processes inside the code are created, one for
the reading phase, driven by the pixel clock and one for the writing phase driven by the inverse
of the pixel clock. The frame sync The
andproject
row issync
placedsignals
in the fieldare used Sensor
of Wireless like the enable
Networks. It is and reading/
developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
writing enable signals respectively [3] [4] [5].
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
In the next picture is depicted the simulation of this module: the img_testbench module
introduction in wireless sensor networks and describes the complete process of development.
described in section 2.1 is used to
Theread an deals
last chapter imagewith afrom the
conclusion andfilesystem and for simulate
covers possible improvements the
and enhancements.
synchronization signals. It is possible to see that during the reading of the first line the output of
the module is Undefined while when the second line is started, the first line starts to come out.
In the next figure there is a detail of the start of the second line: the signals in the high part of
the image represent the first five cells of the RAM inside the module. As it is possible to see for
each rising edge of the signal clk2 (in red) the values inside the memory change: the old values
are overwritten with the new ones that are taken from the input signal. At the same time in the
output signal are emitted the old values.
As described before, it is necessary to store two lines in order to have all the pixels in the
neighborhood of a given pixel, for this reason another module, called double_fifo_linebuffer is
created combining two instances of the fifo_linebuffer module as shown in Figure 3.2.9. As it is
possible to notice there are three output signals: pdata_out1 is the current line, pdata_out2 is
the previous line and pdata_out3 is the line before the one on pdata_out2.
24
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
double_fifo_linebuffer
As expected the simulation of this module shows that the pdata_out1 signal copy the input
signal while pdata_out2 and pdata_out3 signals are Undefined respectively for the first and for
the second line.
Pixel Elements
This part is designed using three variables called cache1, cache2 and cache3. Each of them
are logically divided into three parts as shown in Figure 3.2.12. Each of those parts is 8 pixels
wide and have the responsibility to hold one pixel value. The three outputs of the
double_fifo_linebuffer module are “connected” with the high part (23-16) of the variables and in
particular: pdata_out1 is connected with cache1, pdata_out2 with cache2 and pdata_out3 with
cache3 as shown in Figure 3.2.5.
25
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
cache1 z9 z8 z7
23 16 15 8 7 0
Abstract
cache2 z6 z5 z4
23 The16project
15 is placed in the field of
8 Wireless
7 Sensor Networks. 0 It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
cache3 z3 systems with hard diskz2storage in order to maintain z1
the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
23 The16 15
last chapter 8 and
deals with a conclusion 7 covers possible improvements
0 and enhancements.
For each rising edge of the pixel clock the pixels inside the variables are shifted from the high
part (23-16) to the low part (7-0) and after that they will lost. This mechanism is the
implementation of the structure depicted in Figure 3.2.4.
As described in section 2.2.2 the pixels that lie out of the image boundaries are assumed to be
black, so it is important to detect the various positions in which the kernel will stay as shown in
Figure 3.2.3, because for the positions close to the boundaries the module must emit black
pixels. The easiest way to detect those positions is to count the rows and columns during the
display time, so, a generic counter, was designed, with active low reset and then instantiated
two times: one counter is used to count the rows and the other is used to count the columns
(pixels inside one row). The counter for the rows has to count the rising edges of the rsync
signal so this counter takes as clock the rsync signal. This counter is reseted when the signal
fsync goes low because this means that a frame was displayed and will start a new one so the
counter for the rows should restart from 0. Instead the counter for the columns has to count the
rising edges of the pixel clock only when the rsync signal is high because this means that the
monitor is displaying a certain row, so this counter uses as clock, the pixel clock and as enable
the rsync signal. The counter for the columns is reseted when the signal rsync goes low
because this means that a row was displayed and a new one will start, so the columns counter
should restart from 0.
March 18, 2011 1 Aart Mulder and Kolja Roese
fsync_temp en
fsync_temp reset Counter out RowsCounterOut
10
rsync_temp clk
26
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
rsync_temp en
rsync_temp reset Counter out ColsCounterOut
10
pxlclk clk
Abstract
Figure 3.2.14 - Columns
The project is placedCounter
in the fieldConnections
of Wireless Sensor
Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
The outputs of these two counterscomplex are usedwirelessinside
network structure
a process was designed with the flexible
to understand integration
where theof Sobel
multiple
sensor devices. A possible application is the observation of temperature in several server
kernel is positioned, in this way it issystems
possible
with hardtodisk
emit the
storage rightto maintain
in order pixel values taken
the reliability. fromcontains
The report the three
a short
cache variables or using the constant value of zero that represent the color black.
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
One thing should be notice: the signals used as input to the counters (fsync_temp and
rsync_temp) are the signals properly delayed by the sync_signals_delayer and not the original
synchronization signals. This because the Sobel kernel starts “to move” only after the first line of
the original image.
pxlclk
fsync_out
fsync_in sync_signals_delayer
rsync_in rsync_out
This is the module responsible of delaying the synchronization signals of one line and two pixels
in order to ensure that the memories are filled with the appropriate pixel values. The design was
divided into five phases:
1. delay the row sync signal of two pixels (two clock cycles), this signal will called rsync2;
2. count the rising edges of the signal rsync2 using an instance of the previous counter.
The output of the counter will put in a signal called rowsDelayCounterRising;
3. when the signal rowsDelayCounterRising
March 18, 2011 assume the value
1 2, theAart
output
Mulderframe
and Koljasync
Roese
signal will go high;
4. count the falling edges of the signal rsync2 and put the value of the counting in the
signal rowsDelayCounterFalling;
5. when the signal rowsDelayCounterFalling assume the value 0, the output frame sync
signal will go low.
In the following figures is depicted the simulation of this module (in red the delayed signals).
The figures show that the fsync_out signal goes high after the reading of the first line and
exactly after two clock cycles, and it goes low in late of one line respect to the original signal.
The row sync signal is synchronized with the frame sync signal and delayed of two clock cycles.
27
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
Figure 3.2.16 - sync_signal_delayer Simulation
complex wireless network structure Start with
was designed Image the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
Simulation
In this subsection is reported the simulation of the entire cache_system module. The Figure
3.2.20 depicts the start of the image, in other words when the Sobel kernel is in the position
number 1 (Figure 3.2.3), as it is possible to see the pixels z1, z2, z3, z4, and z7 are black (0)
because they lie outside the original image (the only pixels from the original image are z5, z6,
28
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
z8 and z9). Instead in Figure 3.2.21 is reported the position number 3: in this case the pixels
that are outside the image are z1, z2, z3, z6 and z9, indeed they are black.
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
29
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
pxlclk
fsync_in Abstract
rsync_in
data_in1The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
8
the requirement of environmental monitoring with the focus on temperature observation. A
data_in2complex wireless network structure was designed with the flexible integration of multiple
8
sensor devices. A possible application is the observation of temperature in several server
data_in3systems with hard disk storage in order to maintain the reliability. The report contains a short
8 data_out
introduction in wireless sensor networks and describes the complete
8 process of development.
data_in4The last chapter
sobel_kernel fsync_out
deals with a conclusion and covers possible improvements and enhancements.
8
rsync_out
data_in5
8
data_in6
8
data_in7
8
data_in8
8
data_in9
8
The next step was to design the module responsible of the computation of the approximation of
the gradient, in every pixel of the image, using the Sobel operators. The module is implemented
using a process: into two variables are stored the horizontal and vertical magnitude using the
Sobel kernel (the coefficient 2 in the mask is obtained shifting to the left of one position the pixel
value), if the resulting numbers are negative they are converted into positive with a complement
operation (not number + 1), the 11th bit is used to understand if a number is negative or not.
Then the two magnitudes are combined together as described in section 2.2.2 (Eq. 2). At the
end a threshold of 127 is applied: if the value is higher than the threshold the output will be
withe (255), otherwise only the least 8 bits are taken and put in output.
In the following figure is reported the simulation of the module: in red is depicted the output
signal that change when the input signals change, in the example when all the inputs are zero
the output is zero (the same if the inputs are
March 18, 2011255). Instead when some
1 of theAart
pixel areand
Mulder black and
Kolja Roese
some are white the output is white because the value of the magnitude is above the threshold.
30
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
3.2.3 Simulation
In this section is tested the edge_sobel_wrapper module using the img_testbench with different
test images reported below. The first image have a withe background and three shapes with 1
Abstract
pixel lines thick: the white background is chosen to test the response of the module along the
borders of the image, indeed the expectation is to obtain an image with black background and
with white borders, this depends to the fact that the pixels that lie outside the image boundaries
are assumed to be black. In the second image
The project instead
is placed in the the borders
field of of theNetworks.
Wireless Sensor resulting
It is image
developedwill be
to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
of different colors because the background of the image is not perfectly black but there are
complex wireless network structure was designed with the flexible integration of multiple
many pixels with different values (like noise).
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
31
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
Figure 3.2.26
The last-chapter
Resulting Image
deals with 1 Waveform
a conclusion and covers possible improvements and enhancements.
The previous two figures depict the signals of the edge_sobel_wrapper during the simulation.
From the Figure 3.2.26 it is possible to notice that the entire first line is white and from the
Figure 3.2.27 it is possible to see that each line ends and starts with a white pixel.
In Figure 3.29 is depicted the number_displayer module. This module is responsible to take the
video signals that come from the Sobel Edge Detection module and display three decimal
numbers at a certain position. For achieve this aim the module takes 9 inputs:
1. pxlclk: is the pixel clock used to display one pixel.
2. data_in: this signal has a width of 8 bits and represents the value of each pixel in gray
scale. With 8 bits is possible to represent 256 different gray values.
3. fsync_in: frame synchronization signal.
32
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
One of the main problems encountered during the development of this module is about how to
display numbers on the screen since the only informations available are the values of the single
pixels. This problem was solved implementing a ROM memory where, for each number in the
range 0 - 9 and for the decimal dot, stores the values of the pixels that have to be displayed in
order to create the shape of the different numbers. The ROM module is depicted in Figure 3.3.
en
rd num_rom data_out
8
address
7
The ROM is a combinational module: when the input signals en and rd are high the output is the
value present in the location specified from the address signal, otherwise if en and rd are low
the output signal is in high impedance.
33
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Addresses Output
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
How it is possible to see Figure 3.31 for each address, the memory will provide as output 8 bits
that represent one line of a certain number: those 8 bits can not be displayed immediately on
the screen. Indeed each bit from the output of the ROM must be extended to 8 bits and then in
correspondence of each rising edge of the pixel clock these 8 bits must be displayed. The effect
of this procedure is that the numbers will be displayed in white on a black background because
looking at the Figure 3.4 it is possible to understand that the bits with the value of 0 will
generate black pixels (0 = 00000000), instead the bits with the value of 1 will generate white
pixels (255 = 111111111)."
For display the numbers at the exact specified position the value for each pixel that should be
displayed has to be ready before the respective rising edge of the pixel clock. Therefore using a
March 18, 2011 1
combinational ROM it is necessary to start to emit the address for the Aart
ROM Mulder and Kolja Roese
one pixel in
advance. For example if we want to display the numbers in position (255, 255) the address for
the first line will be emitted when the position (255, 254) is detected, in this way during that
period of the clock the ROM will put as outputs the values for the pixels in the position (255,
255) and also for the pixels in the next 7 columns. In Figure 3.5 are depicted the waveforms of
the signals when a number is displayed. It is possible to see (red circle) that using a
combinational ROM when an address is provided the value of the pixel (data_out) will be
available inside the same clock cycle.
34
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Using a synchronous ROM it is still possible to print a number at the exact specified position but
in this case the address must be emitted two times in advance. For example if we want to
display the numbers at (255, 255), the address for the first line must be emitted when the
location (255, 253) is detected. This happens because this kind of memory accepts the address
in correspondence of the rising edge of the clock and provides the output a short time later this
edge. It is possible to see the waveforms for this case in Figure 3.33.
pixel clock
cols count 252 253 254 255 256 257 258 259
address 0001000
It was choose to use a combinational ROM rather than a synchronous one because using the
latter kind of memory will lead to a more complex design instead of using the combinational
memory.
The drawback of this choice is that is not possible to start the printing of a number in the pixel 0
of each row because in this case it is impossible to detect the previous pixel. Moreover is not
possible to print the numbers in a position too close to the right side of the screen because we
35
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
have to consider the space necessary to display all the numbers 8 pixels * 4 digits = 32 pixels
(Figure 3.34).
Given a certain position in terms of row and column (that from now we will call pos_row and
pos_col respectively) these coordinates represent the position of the pixel in the left top corner
of the first number as depicted in Figure 3.34.
pos_row 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 1 1 1 1 0
0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 1 1 0 0 0 1 1
0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 1 1
0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 1 1 1 0
0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 1 1 1 0
0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 1
0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 0 0 0 1 1 0 0 1 1 0 1 1 0 0 0 1 1
pos_row + 7 0 0 1 1 1 1 1 1 0 0 0 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 1 1 1 1 1 0
As it is possible to see the other numbers have to follow the first number horizontally. Since the
display is row by row during the display of a certain row should be displayed one line of each
number, this means that the address for the ROM that contains the shape of the numbers must
change when the monitor passes from one number to another. For obtain this result four if
statements are used to distinguish the area of each single digit (numbers and decimal dot) and
inside each if the correct address for the number is generated simply concatenating the
number that should be displayed in that position and the difference between the current row and
March 18, 2011 1 Aart Mulder and Kolja Roese
the row where the user want to print the number. This difference is necessary to create the least
significant part of the address (Figure 3.4) that goes from 0 to 7. Now each bit of the output of
the ROM has to be extended to 8 bits in order to display a valid pixel black or white. For the first
number, to achieve this result is calculated the difference between the current column and the
column where the user want to display the number and the result of this difference is used as
index inside the output of the ROM to indicate which bit has to be extended. For the other
numbers the principle is the same but has to keep in consideration that the following numbers
have a different start and end point inside the screen, so some constants (8, 16, 24) are used to
generate the correct difference (from 0 to 7). The constant -1 is used to achieve the result
explained in the section 3.2.1 about the combinational ROM. The first if statement present in
the process is used to understand if the monitor is displaying the pixels outside the area of the
36
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
numbers and in this case the value of each pixel is left unchanged from the input. In this way
only the area necessary to display the numbers is changed.
3.3.3 Simulation
Abstract
For test the functionality of this module is used the img_testbench module with the following
configuration.
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
pxlclk complex wireless network structure was designed with the flexible integration of multiple
pxlclk
data_in sensor devices. A possible application
data_out data_inis the observation of temperature in several server
data_out
8
fsync_in number_displayer systems with hard disk storage
fsync_out in order to maintain
fsync_in the reliability.
img_testbench The report contains 8a short
fsync_out
rsync_in introduction in wireless
rsync_out sensor rsync_in
networks and describes the complete process of development.
rsync_out
The
pos_row pos_col meters decimeters last chapter deals with a conclusion and covers possible improvements and enhancements.
centimeters
10 10 4 4 4
60 60 2 7 9
The outputs of the test bench are connected with the Number Displayer module in order to
display three fixed numbers (2.79) and the outputs of this module are put in the inputs of the
test bench: in this way the image is read, modified and the written on another file.
The result of this test can be see in the following images. The numbers are flipped because in
the img_testbench the image is read in the opposite direction compared to the VGA standard:
from the bottom left corner to top right corner.
From the previous figure is possible to see that when the line 60 and column 59 is reach the
module starts to emit the appropriate addresses for the font ROM (light-blue signals): in this
example initially is emitted the address for the first row of the number 2 (0010000) and then for
the decimal dot (1111000) (an then, for the others two numbers, not displayed here).
37
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
meters
fpgaclk 4
decimeters
range_sensor 4
centimeters
pulse March 18, 2011 1 4 Aart Mulder and Kolja Roese
trigger
In Figure 3.4.1 is depicted the module that is responsible of the following three tasks:
1. Generate the trigger pulse of the right width necessary to activate the range sensor
and start the distance measure.
2. Measure the width of the echo pulse (from the range sensor) and convert it in a
distance in meters, decimeters and centimeters.
3. Encode the distance in three BCD digits.
38
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
To simplify the work, the design is divided into three different modules, one for each task. The
generic overview and the connections between each module can be seen in the next figure.
Abstract
range_sensor
clk hundreds
4
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
pulse distance_measurer distance
the requirement of environmental
input bcd_converter tens
monitoring with the focus on temperature observation. A
9 4
complex wireless network structure was designed with the flexible integration unit of multiple
trigger 4 server
sensor devices. A possible application is the observation of temperature in several
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
The trigger_generator uses the fpga clock to generate the trigger signal for the range sensor.
The distance_measurer receive the echo pulse and convert it into a 9 bits number that
represent the distance in centimeters. Finally the bcd_converter encode the distance into three
BCD digits.
The bcd_converter module is explained in detail in the next section.
This module has only one input signal, the fpga clock and one output signal, the trigger signal
that has to be connected with the trigger input in the range sensor. The module is essentially
based upon one counter. The counter is used to perceive the passage of the time: when the
time is greater than 250ms the trigger signal is activated and is kept high for 100us. When the
time reach the value of 250ms + 100us the trigger signal is deactivated and the counter is
reseted: in this way a new interval of 250ms is measured and a new pulse of the trigger signal
will be generated.
March 18, 2011 1 Aart Mulder and Kolja Roese
The values of 250ms for the interval between each pulse and 100us for the width of each pulse
are chosen to be sure that the range sensor can work properly without problems and without
any interferences between each trigger pulse. Indeed these timing values are quite greater than
the values specified on the technical documentation as explained in the section 2.3. We made
this choice even because we assumed that the distance between the camera and the object will
not change too much frequently so we can sense this distance with a lower frequency than the
maximum permitted, however if it is necessary is possible to reach this limit changing two
constants in the design.
In the following figure is depicted the waveform of the simulation of this module and is possible
to see that the trigger is activated after 250ms and it remains high for 100us.
39
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
Figure 3.4.3 - Trigger
the requirement Generator monitoring
of environmental Simulation
with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
This module is responsible to measure the width of the echo pulse generated from the range
sensor and convert it into a distance in centimeters. As explained in the section 2.3 for convert
the width of the pulse in a distance in centimeters we have to measure the width in micro-
seconds and then divide it by 58. Since the fpga clock has a period of 20ns using it we will get a
time in nano-seconds. In fact if X is the number of the clock cycles counted when the echo
pulse is high, to convert this number in a distance in centimeters the expression is the following:
X * 20 X
= = cm
1000 * 58 2900
The number of cycles X is multiplied by 20 and divided by 1000 to convert it into a time in micro-
seconds, after that is possible to apply the standard expression (section 2.3) and divide it by 58.
Making some simplifications we can Marchget the final expression where
18, 2011 1 the number
Aart Mulder of
and counted
Kolja Roese
cycles has to be divided by 2900. Divide the number X by a big number such 2900 is quite
expensive in hardware. In general the division is a complex operation to implement in hardware.
The standard algorithms indeed, leads to an hardware implementation that is expensive in
terms of both propagation delay and hardware resources. For these reasons, in general, we try
to not use the divisions in our designs.
To solve this problem we figured out that the number 8192 = 213 and that 8192 is quite close to
the number 8700 that is equal to 2900 * 3. So the division by 2900 can be approximated by
multiplying X by 3 and then divide it by 8192 that is not perfect because it is not 8700 but is
useful because the division by 8192 can be done simply shifting X to the right of 13 positions.
The new expression is the following:
40
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
To implement this behavior one counter is used to count the clock cycles when the echo pulse is
high. The trigger signal generated from the module explained in the previous section is used to
reset this counter: indeed we know that when the trigger signal goes low a new measure is
started so the counter has to be reseted to count
The project is placedainnew width
the field of theSensor
of Wireless echo pulse.ItAs
Networks. it is possible
is developed to fulfill
the requirement
to see in the following figure the counter of environmental
is reseted when the monitoring
triggerwithsignal
the focusisonhigh.
temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
pulse en
The last chapter deals with a conclusion and covers possible improvements and enhancements.
trigger reset Counter out CounterPulseOut
22
fpgaclk clk
Then a process is used to detect when the echo pulse goes low and to calculate the distance
using the approximation explained before. The distance is a 9 bits number.
In the following picture is reported the simulation of the distance_measurer module. The signals
trigger and pulse are generated manually inside the test bench. It is possible to see that when
the pulse signal goes low the distance is calculated and put as output. The test bench simulates
two different distances.
3.4.3 Simulation
In Figure 3.4.7 is depicted the waveform of the simulation of the entire range_sensor module.
The echo pulse is generated manually inside
March 18, 2011 the test bench. As1 it is possible to see
Aart Mulder andafter the
Kolja Roese
echo pulse the distance is put in output encoded in three BCD numbers.
41
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
In this section is described the approach used to implement a module that permits to convert a
binary number into a BCD format. In particular the objective is to convert the 9-bits number that
represent the distance (as explained in the previous section) and convert it into three 4-bits
numbers in BCD notation. This can be easily done dividing the number by 10 for three times
and after each division taking the remainder which represents respectively the units, the tens
and hundreds of the number. After the divisions the number can be represented in BCD simply
converting the units, the tens and the hundreds in BCD. This solution is simple but the main
drawback is due to the fact that it uses the division. As explained in the previous section the
division is an expensive operation and if it is possible it is avoided.
For implement the binary-BCD conversion without using the division operation the Double-
Dabble algorithm is used. The steps for convert a n-bit binary number are the following:
1. Reserve enough space to hold both the original number and its BCD representation.
This space can be calculated as n + (4n / 3). The reserved space is conceptually
divided into hundreds, tens and units like in Figure 2.5.
2. Shift the binary number left one bit.
3. If n shifts have taken place the BCD number is ready in hundreds, tens and units
places.
4. If the binary value in any of the BCD columns (hundreds, tens, units) is greater than 4,
add 3 to the value in that BCD column.
5. Go to step 2.
March 18, 2011 1 Aart Mulder and Kolja Roese
In the Figure below are reported the different phases necessary for convert the number 24310 =
111100112 in BCD.
42
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
The shifting is the double part of the algorithm because after each shift the values in the BCD
columns become the double of the previous values, this happens first for the units, then for the
tens and finally for the hundreds in the case of a three digits number (0 - 999). If one of the
numbers in the BCD columns is greater than 4 this means that after the next shift the number
will become 10 or more (depends from the value of the bit that enters in the BCD column) and
this means that another ten (or hundreds) should be added to the tens (or hundreds) column.
For do this is sufficient to add 3 to the number, in this way after the next shift the number will
become 16 or greater, so one bit with the value of 1 will pass into the next BCD column and this
represents the fact that a new tens (or hundreds) was detected. This happens because if you
add 3 to a 4-bit number that is greater than 4 (for example 5,6,7,8,9) the resulting number will
have the most significant bit set to 1 so after the next left shift this bit will pass into the next BCD
digit.
This algorithm is a good alternative to the use of the division operation because it uses only shift
and add operations that are faster than the division. Furthermore it is also easy to implement in
VHDL because no particular constructs are necessary.
This module is implemented as a combinational module where the three BCD numbers are put
as output only when the 9-bit number Marchin
18,input
2011 changes. For make
1 this possible a process
Aart Mulder that
and Kolja Roese
has the input number in the sensitivity list is used. Inside the process initially is reserved the
space necessary for the algorithm like explained in the step 1: a signal of 21 bits is created and
in the 9 least significant bits is loaded the binary number that represents the distance, the other
bits are initialized to zero. After that using a for...loop the steps from 2 to 5 are
implemented. Inside the for...loop the number is first left shifted and then each part of the
signal that represents a BCD digit is checked if its value is greater than 4 or not: if it is the
number 3 is added to that value like explained in the algorithm. At the end of the for...loop
the signal is divided into the three BCD digits and these parts are put on the output signals
(hundreds, tens and unit). The bits from 20 to 17 represent the hundreds, the bits form 16 to 13
represent the tens and the bits from 12 to 9 represent the units.
43
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
3.5.3 Simulation
In the following figure is depicted the waveform of the simulation of the BCD Converter module.
Three different 9-bit numbers are generated and converted in three BCD digits.
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
specified, published,
the VESA organization
lowing VGA system Figure 16:3.6.1
Figure VGA- pin definitions
Nexys2 and Nexys2
VGA Generation circuit
Circuit
vided as an example of
ht be driven in 640 by 480 mode. For more precise information, or for
A frequencies, refer to documentation available at the VESA website.
Using eight signals is possible to display 256 different colors, one for each unique 8-bit pattern.
But for the purpose of this project we are interested only in gray scale images, so we have to
keep the three components equal: R = G = B = gray. In this way when the three values are
summed on the screen, it will generate an image with colors from white to black with various
shades of gray in the middle. Abstract
To physically connect the signals inside the design with the right pins on the board a UCF file is
used. This file specifies the mappingThebetween the signals
project is placed in the fieldand the pins.
of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
The entire design was made with intention to implement
sensor devices. the project
A possible application itself on
is the observation a evaluation
of temperature board,
in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
how is stated in the requirements. introduction
For this reason some useful guidelines are used in order to
in wireless sensor networks and describes the complete process of development.
obtain optimal performances in terms
Theoflastspeed andwith
chapter deals area occupation:
a conclusion and covers possible improvements and enhancements.
1. adopt a correct style for the RAM and ROM design to ensure that the FPGA-specific
resources are used;
2. when a process is used all inputs are put into the sensitivity list of the process itself.
This is useful because XST will put automatically all the inputs into the sensitivity list,
so the result obtained in the simulation could be different from the result in real world;
3. inside a process, when it is possible, the output signals are assigned under all
conditions. This will reduce the inference of latches that are responsible of timing
problems.
In the following figure is reported the design summary after the implementation. As it is possible
to see this design is not so large and there are still resources available for other applications if
necessary.
45
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
3.7 Test
Abstract
After the setup of the hardware the design is synthesized and the BIT file necessary for program
the board is generated.
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
The result of the project running onthethe boardof is
requirement reportedmonitoring
environmental in the with
following two
the focus on images.
temperature As it isA
observation.
complex wireless network structure was designed with the flexible integration of multiple
possible to see the scene took fromsensor the devices.
camera is processed in order to detect the edges of the
A possible application is the observation of temperature in several server
objects and the three numbers, that represent
systems the
with hard disk distance
storage in order tofrom
maintainthe cameraThetoreport
the reliability. thecontains
object in
a short
introduction
front of it, are displayed in the top left corner.in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
46
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
In the previous image is reported a detail of the numbers displayed. It is possible to see that
with characters of 8 x 8 pixels, the numbers are readable without problems.
47
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
4 Conclusions and Future Works The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
As shown in the previous section the project
complex is network
wireless completedstructurewith success,
was designed so flexible
with the now integration
it is possible to
of multiple
sensor devices. A possible application is the observation of temperature in several server
use it in applications where is useful to emphasize edges and where the distance from the
systems with hard disk storage in order to maintain the reliability. The report contains a short
camera to the object is relevant. Moreover
introductionthe modular
in wireless structure
sensor networks of thethe
and describes project
completepermits to reuse
process of development.
The last chapter deals with a conclusion and covers possible
the components in other projects, for example the range_sensor module or the bcd_converter improvements and enhancements.
module can be used in many different projects without problems because these modules are
designed to be independent form the whole project. Same reasoning applies to the
number_displayer module that can be easily modified in order to display more numbers or
different informations.
In the other hand there are still some points that could be improved. For example with the
current implementation the number_displayer module can not print the numbers in the first pixel
of each row, this means that is not possible to print the numbers on the borders of the monitor
and this could be a problem for some applications.
Another problem is about the distance measure. Indeed, now the measure is approximated in
order to keep the implementation fast and easy, but some applications can require a very
accurate measure (using precision sensors). So in the future could be a good idea to spend
time to remove the approximation during the measure and keeping, at the same time, the
design fast and easy.
An important thing that should be explored is the possibility to make the design so general that
the modules will adapt automatically to different mask sizes, for example if a mask of 5x5 is
needed.
Finally the test bench used to read/write an image from/into the filesystem can be fixed and
improved in order to respect the VGA signals and timings because this test bench is a useful
tool to test the implementation without using the board and the monitor.
48
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
References The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
[1] - Get your Priorities Right – Make yourwireless
complex Design Up structure
network to 50%wasSmaller (Ken
designed with theChapman)
flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
http://www.xilinx.com/support/documentation/white_papers/wp275.pdf
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
[2] - The last chapter
Get Smart About Reset: Think Local, deals with (Ken
Not Global a conclusion and covers possible improvements and enhancements.
Chapman)
http://www.xilinx.com/support/documentation/white_papers/wp272.pdf
[5] - XST User Guide for Virtex-4, Virtex-5, Spartan-3, and Newer CPLD Devices
http://www.xilinx.com/support/documentation/sw_manuals/xilinx13_1/xst.pdf
49
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
Appendix The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
Appendix A - counter.vhd complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
library IEEE;
The last chapter deals with a conclusion and covers possible improvements and enhancements.
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity Counter is
generic(n : POSITIVE := 10);
Port ( clk : in STD_LOGIC;
en : in STD_LOGIC;
reset : in STD_LOGIC; -- Active Low
output : out STD_LOGIC_VECTOR(n-1 downto 0) );
end Counter;
begin
process (clk, reset)
begin
if(reset = '0') then
num <= (others => '0');
elsif(clk'event and clk = '1') then
if (en = '1') then
num <= num + 1;
end if;
end if;
end process;
end Behavioral;
Appendix B - fifo_linebuffer.vhd
March 18, 2011 1 Aart Mulder and Kolja Roese
PACKAGE TYPES IS
subtype SMALL_INTEGER is INTEGER range 0 to 639;
END PACKAGE;
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use WORK.TYPES.all;
entity FIFOLineBuffer is
generic (
DATA_WIDTH : integer := 8;
50
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
begin
clk2<=not clk;
--NB: putting the two IF about fsync and rsync inside the clk and clk2 IFs
-- will lead to an automatic inference of a RAM
end Behavioral;
Appendix C - double_fifo_linebuffer.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
51
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
entity DoubleFiFOLineBuffer is
generic (
DATA_WIDTH : integer := 8;
NO_OF_COLS : integer := 640 );
port(
clk : in std_logic;
Abstract
fsync : in std_logic;
rsync : in std_logic;
pdata_in : in std_logic_vector(DATA_WIDTH -1 Sensor
The project is placed in the field of Wireless downto 0); It is developed to fulfill
Networks.
pdata_out1 : out std_logic_vector(DATA_WIDTH
the requirement of environmental monitoring-1 withdownto
the focus on 0);
temperature observation. A
complex wireless network structure was
pdata_out2 : buffer std_logic_vector(DATA_WIDTH -1 downto 0); designed with the flexible integration of multiple
pdata_out3 : buffersensor devices. A possible application is the observation of temperature in several server
std_logic_vector(DATA_WIDTH -1 downto 0) );
systems with hard disk storage in order to maintain the reliability. The report contains a short
end DoubleFiFOLineBuffer; introduction in wireless sensor networks and describes the complete process of development.
The last chapter deals with a conclusion and covers possible improvements and enhancements.
architecture Behavioral of DoubleFiFOLineBuffer is
component FIFOLineBuffer is
generic (
DATA_WIDTH : integer := 8;
NO_OF_COLS : integer := 640 );
port(
clk : in std_logic;
fsync : in std_logic;
rsync : in std_logic;
pdata_in : in std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out : buffer std_logic_vector(DATA_WIDTH -1 downto 0));
end component;
begin
LineBuffer1 : FIFOLineBuffer
generic map (DATA_WIDTH => DATA_WIDTH, NO_OF_COLS => NO_OF_COLS)
port map(clk, fsync, rsync,pdata_in, pdata_out2);
LineBuffer2 : FIFOLineBuffer
generic map (DATA_WIDTH => DATA_WIDTH, NO_OF_COLS => NO_OF_COLS)
port map(clk, fsync, rsync, pdata_out2, pdata_out3);
end Behavioral;
Appendix D - sync_signals_delayer.vhd
library IEEE; March 18, 2011 1 Aart Mulder and Kolja Roese
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity SyncSignalsDelayer is
generic (
ROW_BITS : integer := 9 );
port(
clk : in std_logic;
fsync_in : in std_logic;
rsync_in : in std_logic;
fsync_out : out std_logic;
rsync_out : out std_logic );
end SyncSignalsDelayer;
52
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
COMPONENT Counter is
Abstract
generic (n : POSITIVE);
Port ( clk : in STD_LOGIC;
en : in STD_LOGIC;
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
reset the
: requirement
in STD_LOGIC; --onActive
of environmental monitoring with the focus temperatureLowobservation. A
complex wireless network structure was
output : out STD_LOGIC_VECTOR(n-1 downto 0)); designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
end COMPONENT;
systems with hard disk storage in order to maintain the reliability. The report contains a short
introduction in wireless sensor networks and describes the complete process of development.
begin The last chapter deals with a conclusion and covers possible improvements and enhancements.
-- Step 2
RowsCounteComp : Counter generic map(ROW_BITS)
port map(rsync2, fsync_in,fsync_in,rowsDelayCounterRising);
rsync_out <= rsync2;
fsync_out <= fsync_temp;
-- Step 1
p1 : process(clk)
begin
if clk'event and clk='1' then
-- Step 1 - delay of two clock cycles
rsync2 <= rsync1;
rsync1 <= rsync_in;
end if;
end process p1;
-- Steps 3 and 5
p2 : process(rowsDelayCounterRising, rowsDelayCounterFalling)
begin
-- rows2 = 2
if rowsDelayCounterRising = "000000010" then
fsync_temp <= '1';
elsif rowsDelayCounterFalling = "000000000" then
fsync_temp <= '0';
end if;
end process p2;
-- Step 4
p3 : process(rsync2)
begin
if rsync2'event and rsync2March
= '0' then
18, 2011 1 Aart Mulder and Kolja Roese
if fsync_temp = '1' then
-- 479
if rowsDelayCounterFalling < "111011111" then
rowsDelayCounterFalling <= rowsDelayCounterFalling + 1;
else
rowsDelayCounterFalling <= "000000000";
end if;
else
rowsDelayCounterFalling <= "000000000";
end if;
end if;
end process p3;
end Behavioral;
53
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Appendix E - cache_system.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
Abstract
entity CacheSystem is
generic (
DATA_WIDTH : integer :=
The8; project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
WINDOW_SIZE : integer := 3;
ROW_BITS : integer := 9; the requirement of environmental monitoring with the focus on temperature observation. A
COL_BITS : integer := 10; complex wireless network structure was designed with the flexible integration of multiple
NO_OF_ROWS : integer := 480;devices. A possible application is the observation of temperature in several server
sensor
NO_OF_COLS : integer := 640 );
systems with hard disk storage in order to maintain the reliability. The report contains a short
port(
clk introduction
: in std_logic; in wireless sensor networks and describes the complete process of development.
fsync_in : in std_logic; The last chapter deals with a conclusion and covers possible improvements and enhancements.
rsync_in : in std_logic;
pdata_in : in std_logic_vector(DATA_WIDTH -1 downto 0);
fsync_out : out std_logic;
rsync_out : out std_logic;
pdata_out1 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out2 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out3 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out4 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out5 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out6 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out7 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out8 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out9 : out std_logic_vector(DATA_WIDTH -1 downto 0) );
end CacheSystem;
COMPONENT Counter is
generic (n : POSITIVE);
port ( clk : in STD_LOGIC;
en : in STD_LOGIC;
reset : in STD_LOGIC; -- Active Low
output : out STD_LOGIC_VECTOR(n-1 downto 0));
end COMPONENT;
COMPONENT DoubleFiFOLineBuffer is
generic (
DATA_WIDTH : integer := 8;
NO_OF_COLS : integer := 640 );
port(
clk : in std_logic;
fsync : in std_logic;
rsync : in std_logic;
pdata_in : in std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out1 : out std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out2 : buffer std_logic_vector(DATA_WIDTH -1 downto 0);
pdata_out3 : buffer std_logic_vector(DATA_WIDTH -1 downto 0) );
end COMPONENT;
COMPONENT SyncSignalsDelayer
generic (
ROW_BITS : integer := 9 );
port(
clk : IN std_logic;March 18, 2011 1 Aart Mulder and Kolja Roese
fsync_in : IN std_logic;
rsync_in : IN std_logic;
fsync_out : OUT std_logic;
rsync_out : OUT std_logic);
end COMPONENT;
54
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
begin
DoubleLineBuffer: DoubleFiFOLineBuffer
GENERIC MAP (
DATA_WIDTH => DATA_WIDTH,
NO_OF_COLS => NO_OF_COLS )
PORT MAP ( Abstract
clk => clk,
fsync => fsync_in,
rsync => rsync_in,
pdata_in => pdata_in,
pdata_out1 => dout1,
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
pdata_out2 => dout2, the requirement of environmental monitoring with the focus on temperature observation. A
pdata_out3 => dout3 ); complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
Delayer: SyncSignalsDelayer
systems with hard disk storage in order to maintain the reliability. The report contains a short
GENERIC MAP (
ROW_BITS => ROW_BITS ) introduction in wireless sensor networks and describes the complete process of development.
PORT MAP ( The last chapter deals with a conclusion and covers possible improvements and enhancements.
clk => clk,
fsync_in => fsync_in,
rsync_in => rsync_in,
fsync_out => fsync_temp,
rsync_out => rsync_temp);
55
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
-- counter2=639
elsif RowsCounterOut="000000000" and ColsCounterOut="1001111111" then --3
pdata_out1<= (others => '0');
pdata_out2<= (others => '0');
pdata_out3<= (others => '0');
pdata_out4<= cache2((DATA_WIDTH - 1) downto 0 );
Abstract
pdata_out5<= cache2(((WINDOW_SIZE-1)*DATA_WIDTH - 1) downto DATA_WIDTH );
pdata_out6<= (others => '0');
pdata_out7<= cache1((DATA_WIDTH - 1) downto 0 );
pdata_out8<= cache1(((WINDOW_SIZE-1)*DATA_WIDTH - 1) downto DATA_WIDTH );
pdata_out9<= (others => '0');
56
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Abstract
Appendix F - sobel_kernel.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
use IEEE.STD_LOGIC_ARITH.ALL;
the requirement of environmental monitoring with the focus on temperature observation. A
use IEEE.STD_LOGIC_UNSIGNED.ALL;
complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
entity edge_sobel is
systems with hard disk storage in order to maintain the reliability. The report contains a short
generic (
introduction in wireless sensor networks and describes the complete process of development.
DATA_WIDTH : integer := 8 );
The last chapter deals with a conclusion and covers possible improvements and enhancements.
port (
pclk_i : in std_logic;
fsync_i : in std_logic;
rsync_i : in std_logic;
pData1 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData2 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData3 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData4 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData5 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData6 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData7 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData8 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pData9 : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
begin
if (pclk_i'event and pclk_i = '1') then
if summay(10)='1' then
summa2:= not summay+1;
57
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
else
summa2:= summay;
end if;
summa:=summa1+summa2;
Abstract
-- Threshold = 127
if summa>"00001111111" then
pdata_o<=(others => '1');
else
pdata_o<=summa(DATA_WIDTH-
The project is placed in the field of1Wireless
downto 0);Networks. It is developed to fulfill
Sensor
end if; the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
END IF; sensor devices. A possible application is the observation of temperature in several server
end if; systems with hard disk storage in order to maintain the reliability. The report contains a short
end if; -- pclk_i introduction in wireless sensor networks and describes the complete process of development.
end process edge_sobel; The last chapter deals with a conclusion and covers possible improvements and enhancements.
end Behavioral;
Appendix G - edge_sobel_wrapper.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity edge_sobel_wrapper is
generic (
DATA_WIDTH : integer := 8
);
Port ( clk : in STD_LOGIC;
fsync_in : in STD_LOGIC;
rsync_in : in STD_LOGIC;
pdata_in : in STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0);
fsync_out : out STD_LOGIC;
rsync_out : out STD_LOGIC;
pdata_out : out STD_LOGIC_VECTOR (DATA_WIDTH-1 downto 0));
end entity edge_sobel_wrapper;
begin
58
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
PORT MAP(
clk => clk,
fsync_in => fsync_in,
rsync_in => rsync_in,
pdata_in => pdata_in,
fsync_out => fsynch_int,
rsync_out => rsynch_int,
Abstract
pdata_out1 => pdata_int1,
pdata_out2 => pdata_int2,
pdata_out3 => pdata_int3,
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
pdata_out4 => pdata_int4,
the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
pdata_out5 => pdata_int5,
sensor devices. A possible application is the observation of temperature in several server
pdata_out6 => pdata_int6,
systems with hard disk storage in order to maintain the reliability. The report contains a short
pdata_out7 => pdata_int7,
introduction in wireless sensor networks and describes the complete process of development.
pdata_out8 => pdata_int8,
The last chapter deals with a conclusion and covers possible improvements and enhancements.
pdata_out9 => pdata_int9
);
end Structural;
Appendix H - num_rom.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
March 18, 2011 1 Aart Mulder and Kolja Roese
entity Num_Rom is
port(
en : in STD_LOGIC;
address : in STD_LOGIC_VECTOR(6 downto 0);
rd : in STD_LOGIC;
data_out : out STD_LOGIC_VECTOR(0 to 7)
);
end Num_Rom;
begin
process(en,rd,address)
begin
59
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
-- 2
when "0010000" => data_out <= "00111110";
when "0010001" => data_out <= "01100011";
when "0010010" => data_out <= "01100011";
when "0010011" => data_out <= "00000110";
when "0010100" => data_out <= "00001100";
when "0010101" => data_out <= "00011000";
when "0010110" => data_out <= "00110011";
when "0010111" => data_out <= "01111111";
-- 3
when "0011000" => data_out <= "00111110";
when "0011001" => data_out <= "01100011";
when "0011010" => data_out <= "00000011";
when "0011011" => data_out <= "00001110";
when "0011100" => data_out <= "00001110";
when "0011101" => data_out <= "00000011";
when "0011110" => data_out <= "01100011";
when "0011111" => data_out <= "00111110";
-- 4
when "0100000" => data_out <= "00000110";
when "0100001" => data_out <= "00001110";
when "0100010" => data_out <= "00011110";
when
March"0100011"
18, 2011 => data_out <=1 "00110110";
Aart Mulder and Kolja Roese
when "0100100" => data_out <= "01100110";
when "0100101" => data_out <= "01111111";
when "0100110" => data_out <= "00000110";
when "0100111" => data_out <= "00000110";
-- 5
when "0101000" => data_out <= "01111111";
when "0101001" => data_out <= "01100000";
when "0101010" => data_out <= "01100000";
when "0101011" => data_out <= "01111110";
when "0101100" => data_out <= "00000011";
when "0101101" => data_out <= "00000011";
when "0101110" => data_out <= "01100011";
when "0101111" => data_out <= "00111110";
60
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
-- 6
when "0110000" => data_out <= "00111110";
when "0110001" => data_out <= "01100011";
when "0110010" => data_out <= "01100000";
when "0110011" => data_out <= "01111110";
Abstract
when
when
"0110100"
"0110101"
=>
=>
data_out
data_out
<=
<=
"01100011";
"01100011";
when "0110110" => data_out <= "01100011";
when "0110111" => data_out <= "00111110";
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
--the7 requirement of environmental monitoring with the focus on temperature observation. A
complex
when wireless network
"0111000" => structure
data_out was designed with the flexible integration of multiple
<= "01111111";
sensor devices. A possible application is the observation of temperature in several server
when "0111001" => data_out <= "01100011";
systems with hard disk storage in order to maintain the reliability. The report contains a short
when "0111010" => data_out <= "00000110";
introduction in wireless sensor networks and describes the complete process of development.
when "0111011"
The last => adata_out
chapter deals with conclusion and<= "00001100";
covers possible improvements and enhancements.
when "0111100" => data_out <= "00011000";
when "0111101" => data_out <= "00011000";
when "0111110" => data_out <= "00011000";
when "0111111" => data_out <= "00011000";
-- 8
when "1000000" => data_out <= "00111110";
when "1000001" => data_out <= "01100011";
when "1000010" => data_out <= "01100011";
when "1000011" => data_out <= "01100011";
when "1000100" => data_out <= "00111110";
when "1000101" => data_out <= "01100011";
when "1000110" => data_out <= "01100011";
when "1000111" => data_out <= "00111110";
-- 9
when "1001000" => data_out <= "00111110";
when "1001001" => data_out <= "01100011";
when "1001010" => data_out <= "01100011";
when "1001011" => data_out <= "01100011";
when "1001100" => data_out <= "00111111";
when "1001101" => data_out <= "00000011";
when "1001110" => data_out <= "01100011";
when "1001111" => data_out <= "00111110";
-- .
when "1111000" => data_out <= "00000000";
when "1111001" => data_out <= "00000000";
when "1111010" => data_out <= "00000000";
when "1111011" => data_out <= "00000000";
when "1111100" => data_out <= "00000000";
when
March"1111101"
18, 2011 => data_out <=1 "00000000";
Aart Mulder and Kolja Roese
when "1111110" => data_out <= "00011000";
when "1111111" => data_out <= "00011000";
end case;
else
data_out <= (others => 'Z');
end if;
end process;
end Behavioral;
61
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Appendix I - number_displayer.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
Abstract
entity Number_Displayer is
generic ( The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
DATA_WIDTH : the
integer := of
requirement 8;environmental monitoring with the focus on temperature observation. A
COL_BITS : integer
complex wireless := 10 );
network structure was designed with the flexible integration of multiple
port( sensor devices. A possible application is the observation of temperature in several server
clk : in STD_LOGIC;systems with hard disk storage in order to maintain the reliability. The report contains a short
fsync_in : in STD_LOGIC;
introduction in wireless sensor networks and describes the complete process of development.
rsync_in : in STD_LOGIC;
The last chapter deals with a conclusion and covers possible improvements and enhancements.
data_in : in STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0);
pos_row : in STD_LOGIC_VECTOR(COL_BITS-1 downto 0);
pos_col : in STD_LOGIC_VECTOR(COL_BITS-1 downto 0);
meters : in STD_LOGIC_VECTOR(3 downto 0);
decimeters : in STD_LOGIC_VECTOR(3 downto 0);
centimeters : in STD_LOGIC_VECTOR(3 downto 0);
fsync_out : out STD_LOGIC;
rsync_out : out STD_LOGIC;
data_out : out STD_LOGIC_VECTOR(DATA_WIDTH-1 downto 0) );
end Number_Displayer;
component Counter is
generic(n : POSITIVE := 10);
port ( clk : in STD_LOGIC;
en : in STD_LOGIC;
reset : in STD_LOGIC; -- Active Low
output : out STD_LOGIC_VECTOR(COL_BITS-1 downto 0) );
end component;
component Num_Rom is
port(
en : in STD_LOGIC;
address : in STD_LOGIC_VECTOR(6 downto 0);
rd : in STD_LOGIC;
data_out : out STD_LOGIC_VECTOR(0 to NUMBERS_DIM-1) );
end component;
begin
RowsCounter : Counter port map(rsync_in, fsync_in,fsync_in,RowsCounterOut);
ColsCounter : Counter port map(clk, rsync_in,rsync_in,ColsCounterOut);
LUTFont : Num_Rom port map('1',FontAddress,'1',FontDataOut);
process(RowsCounterOut,ColsCounterOut,pos_row,pos_col,meters,decimeters,centimeters,
data_in)
variable rowLUT : STD_LOGIC_VECTOR(COL_BITS-1 downto 0);
variable colLUT : STD_LOGIC_VECTOR(COL_BITS-1 downto 0);
begin
-- First Number
62
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
-- Third Number
elsif(RowsCounterOut >= pos_row and RowsCounterOut <= (pos_row+7) and
ColsCounterOut >= (pos_col+24-1) and ColsCounterOut <= (pos_col+31-1)) then
rowLUT := (RowsCounterOut - pos_row);
colLUT := (ColsCounterOut - (pos_col+24-1));
FontAddress <= (centimeters & rowLUT(2 downto 0));
data_out <= (others => FontDataOut(conv_integer(colLUT(2 downto 0))));
-- Original Image
else
FontAddress <= (others => '0'); -- Only to not make infer a latch
data_out <= data_in;
end if;
end process;
end Behavioral;
Appendix J - bcd_converter.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity bcd_converter is
Port ( input : in STD_LOGIC_VECTOR(8 downto 0);
hundreds : out STD_LOGIC_VECTOR(3 downto 0);
tens : out STD_LOGIC_VECTOR(3
March 18, 2011 downto 0); 1 Aart Mulder and Kolja Roese
unit : out STD_LOGIC_VECTOR(3 downto 0));
end bcd_converter;
begin
process(input)
variable i : integer:=0;
variable bcd : std_logic_vector(20 downto 0);
begin
-- Initialization phase: the space for the BCD representation is reserved
bcd := (others => '0');
bcd(8 downto 0) := input;
63
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
for i in 0 to 8 loop
-- Left shift one bit
bcd(19 downto 0) := bcd(18 downto 0) & '0';
end loop;
Appendix K - trigger_generator.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
entity trigger_generator is
port(
clk : in STD_LOGIC;
trigger : out STD_LOGIC
);
end trigger_generator;
component Counter is
generic(n : POSITIVE := 10);
Port ( clk : in STD_LOGIC;
en : in STD_LOGIC;
reset : in STD_LOGIC;
March 18, 2011 -- Active Low
1 Aart Mulder and Kolja Roese
output : out STD_LOGIC_VECTOR(n-1 downto 0));
end component;
begin
process(clk)
constant ms250 : STD_LOGIC_VECTOR(23 downto 0) :=
"101111101011110000100000";
constant ms250And100us : STD_LOGIC_VECTOR(23 downto 0) :=
"101111101100111110101000";
64
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
begin
if(clk'event and clk = '1') then
if(outputCounter >= ms250 and outputCounter < ms250And100us) then
trigger <= '1';
else
trigger <=
Abstract
'0';
end if;
if(outputCounter = ms250And100us)
The project is placed in the field then
of Wireless Sensor Networks. It is developed to fulfill
resetCounter <= '0';
the requirement of environmental monitoring with the focus on temperature observation. A
else complex wireless network structure was designed with the flexible integration of multiple
sensor devices. A possible application is the observation of temperature in several server
resetCounter <= '1';
systems with hard disk storage in order to maintain the reliability. The report contains a short
end if; introduction in wireless sensor networks and describes the complete process of development.
end if; -- clk The last chapter deals with a conclusion and covers possible improvements and enhancements.
end process;
end Behavioral;
Appendix L - distance_measurer.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use IEEE.NUMERIC_STD.ALL;
entity distance_measurer is
port ( clk : in STD_LOGIC;
trigg : in STD_LOGIC;
pulse : in STD_LOGIC;
distance : out STD_LOGIC_VECTOR(8 downto 0) := (others => '0') );
end distance_measurer;
component Counter is
generic(n : POSITIVE := 10);
Port ( clk : in STD_LOGIC;
en : in STD_LOGIC;
reset : in STD_LOGIC; -- Active Low
output : out STD_LOGIC_VECTOR(n-1 downto 0) );
end component;
DistanceProcess : process(pulse,CounterPulseOut)
variable temp : integer;
variable tempVar : STD_LOGIC_VECTOR(23 downto 0);
begin
if(pulse'event and pulse = '0') then
tempVar := CounterPulseOut * "11";
temp := to_integer(unsigned(tempVar(23 downto 13)));
if(temp > 458) then
distance <= "111111111";
else
distance <= STD_LOGIC_VECTOR(to_unsigned(temp,9));
65
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
end if;
end if;
end process DistanceProcess;
end Behavioral;
Abstract
Appendix M - range_sensor.vhd
library IEEE; The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
use IEEE.STD_LOGIC_1164.ALL; the requirement of environmental monitoring with the focus on temperature observation. A
use IEEE.STD_LOGIC_UNSIGNED.ALL;complex wireless network structure was designed with the flexible integration of multiple
use IEEE.NUMERIC_STD.ALL; sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
entity range_sensor is introduction in wireless sensor networks and describes the complete process of development.
port ( The last chapter deals with a conclusion and covers possible improvements and enhancements.
fpgaclk : in STD_LOGIC;
triggerOut : out STD_LOGIC;
pulse : in STD_LOGIC;
meters : out STD_LOGIC_VECTOR(3 downto 0);
decimeters : out STD_LOGIC_VECTOR(3 downto 0);
centimeters : out STD_LOGIC_VECTOR(3 downto 0) );
end range_sensor;
component distance_measurer is
Port ( clk : in STD_LOGIC;
trigg : in STD_LOGIC;
pulse : in STD_LOGIC;
distance : out STD_LOGIC_VECTOR(8 downto 0) );
end component;
component trigger_generator is
port( clk : in STD_LOGIC;
trigger : out STD_LOGIC );
end component;
component bcd_converter is
Port ( input : in STD_LOGIC_VECTOR(8 downto 0);
hundreds : out STD_LOGIC_VECTOR(3 downto 0);
tens : out STD_LOGIC_VECTOR(3 downto 0);
unit : out STD_LOGIC_VECTOR(3 downto 0) );
end component;
begin
measurer : distance_measurer
port map(fpgaclk,triggOut,pulse,distanceOut);
BCDConv : bcd_converter
port map(distanceOut,meters,decimeters,centimeters);
end Behavioral;
66
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
Appendix N - top_vga.vhd
library IEEE;
use IEEE.STD_LOGIC_1164.ALL; Abstract
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity topVGA is The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
the requirement of environmental monitoring with the focus on temperature observation. A
port(
complex wireless network structure was designed with the flexible integration of multiple
clk : in std_logic;
sensor devices. A possible application is the observation of temperature in several server
dbg : out std_logic;
systems with hard disk storage in order to maintain the reliability. The report contains a short
grd : out std_logic;
introduction in wireless sensor networks and describes the complete process of development.
mode : in std_logic;
The last chapter deals with a conclusion and covers possible improvements and enhancements.
trigg : out std_logic;
begin
dbg <= '0';
grd <= '0';
rs : entity work.range_sensor
port map(
fpgaclk =>March
clk, 18, 2011 1 Aart Mulder and Kolja Roese
pulse => mode,
triggerOut => trigg,
67
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
nm : entity work.number_displayer
port map(
clk => pixel_clk,
Abstract
fsync_in => FV_OUT_SOBEL,
rsync_in => LV_OUT_SOBEL,
The project is placed in the field of Wireless Sensor Networks. It is developed to fulfill
data_in => DATA_O, the requirement of environmental monitoring with the focus on temperature observation. A
complex wireless network structure was designed with the flexible integration of multiple
fsync_out => FV_OUT,sensor devices. A possible application is the observation of temperature in several server
systems with hard disk storage in order to maintain the reliability. The report contains a short
rsync_out => LV_OUT,introduction in wireless sensor networks and describes the complete process of development.
data_out => DATA_FOR_VGA,
The last chapter deals with a conclusion and covers possible improvements and enhancements.
Appendix O - top_vga.ucf
## clock pin for Nexys 2 Board
NET "clk" LOC= "B8"; # Bank = 0 , Pin name = IP_L13P_0/GCLK8 , Type = GCLK , Sch
name = GCLK0
68
Mid Sweden University
Department of Information Mid Sweden University
Department of Information
Technology and Media (ITM)
technology and media (ITM).
69