Rochester Institute of Technology
RIT Scholar Works
Theses
Thesis/Dissertation Collections
2-1-1993
Simulation of a morphological image processor
using VHDL - Part I: Mathematical Components
Wei-chun Chen
Follow this and additional works at:
http://scholarworks.rit.edu/theses
This Thesis is brought to you for free and open access by the Thesis/Dissertation Collections at RIT Scholar Works. It has been accepted for inclusion
in Theses by an authorized administrator of RIT Scholar Works. For more information, please contact
.
Recommended Citation
Simulation of A Morphological Image Processor
Using VHDL
Part I: Mathematical Components
Wei-chun Chen
A Thesis Submitted in Partial Fullfilment Of the Requirements for the degree of
Master of Science
in
Computer Engineering
Approved by:
Professor
George A. Brown (Thesis Advisor)
Professor
Tony H. Chang, Ph. D.
Professor
Roy S. Czernikowski, Ph. D.
Department of Computer Engineering
College of Engineering
Rochester Institute of Technology
Rochester, New York
Title
ofthesis:
Simulation
ofA
Morphological
Image Processor
Using
VHDL
Part I: Mathematical Components
hereby
grant permissionto the
Wallace
Memorial
Library
andComputer
Engineering
Department
ofRIT
to
reproducemy
thesis
in
whole orin
part.Any
reproduction will notbe for
commercial use or profit.Acknowledgment
s
We
wishto
express ourgrateful appreciationto the
many
people whohelped
makethis thesis
a reality.
We
areparticularly
indebted
to
Professor
George
A. Brown
for his invaluable
advice and encouragement
throughtout this
entire project.Special
thanks
aredue
to
Jens
Rodenberg
whoprovided enormousinformation
aboutthe
MIP
systemdesign. We
are alsothankful to
Professor
Roy
S. Czernikowski
andTony
H.
Chang
whopainstakingly
readthe
entire manuscript and made valuable suggestions.
Our
sincere appreciationis
extendedto
Jeff
Hanzlik,
Chris
Insalaco,
Shishir
Ghate,
andLarry
Robin
for
their
previous effort onthe
Abstract
Very
high
speedintegrated
circuitHardware Description
Language
(VHDL)
is
utilizedin
this
projectto
model aMorphological
Image
Processor
(MIP)
Array. Both behavioral
andstructural models
have been
established atthe
systemlevel,
andthe
simulation resultsfrom
both
models are consistent with each other.The
successfulimplementation
ofthe
modelsaccomplishes our original goal
to
document
the
MIP
withVHDL.
It is
observedfrom
the
Glossary
ALU
Arithmetic/Logic
Unit
ASCII
American Standard
Code
for
Information Interchange
BLM
Behavioral
Language Model
EISA
Extended
Industrial Standard
Architecture
FIFO
First-In-First-Out
FP
Function
Processing
FPGA
Field Programmable Gate
Array
FSP
Function
Set
Processing
IMG
IMaGe file format
usedfor
frame
grabberMAP
Morphological
Array
Processor
MIP
Morphological
Image Processor
MU
Morphological Unit
RTL
Register Transfer Level
SP
Set
Processing
TIFF
Tag-based Image File Format for
storing
andinterchanging
rasterimages.
VHDL
VHSIC Hardware
Description
Language
VHSIC
Very
High Speed Integrated Circuit
Contents
1
Introduction
i2
Morphology
Theory
3
2.1
Digital Images
3
2.2
Basic
Morphological
Operations
4
2.3
Extended Morphological Operations
6
2.4
Implementation
g
2.5
Examples
g
2.5.1
Example
1:
g
2.5.2
Example
2:
9
3
VHDL
12
3.1
Overview
ofTop-down
Design
12
3.2
Entity
andArchitecture
14
3.3
Signal
vs.Variable
15
4
System
Description
18
4.1
Data Path
ig
4.2
Arithmetic
Functional Blocks
20
4.2.1
ALUs
20
4.2.2
MU
andVolume
Adder
22
4.3
Control
andStatus
Registers
23
4.3.1
Volume Adder
Registers
23
4.3.2
ALUs
23
4.3.4
Bus Interface
25
4.4
EISA
Bus
Interface
27
4.5
Operating
Procedures
29
4.5.1
Stage
A:
Memory
/
Mask Write
32
4.5.2
Stage
B:
ALUs
andMU
setup
34
4.5.3
Stage C: MIP Process
34
4.5.4
Stage
D:
Memory/Register
Read
35
5
Architecture Partition
andModeling
36
5.1
Architecture Partition
36
5.2
Behavioral
Model
ofthe
MIP
39
5.2.1
SD
Bus
Emulation
41
5.2.2
Bus
to
Integer
Conversion
42
5.2.3
8/16 Bit
Data Transfer
44
5.2.4
LA
Latching
44
5.2.5
I/O
Transfer
44
5.2.6
Mathematical
Operations
48
5.3
MIP
Structural
Model
52
5.3.1
Timing
ofthe
MIP
54
5.3.2
Overview
ofthe
MIP
59
5.4
Simulation
60
6
Mathematic Units
68
6.1
ALU1
68
6.1.1
Ports
68
6.1.2
Processes
69
6.2
MAP
74
6.2.1
Ports
77
6.2.2
Processes
77
6.3
ALU2
81
6.3.1
Ports
82
6.3.2
Processes
82
6.4.1
Ports
gg
6.4.2
Processes
gg
7
Memory
Units
90
7.1
Memory
9q
7.1.1
Ports
90
7.1.2
Process
90
7.2
Buffer
91
7.2.1
Ports
91
7.2.2
Process
92
7.2.3
Further
Implementation
92
8
Conclusion
94
A
Bus
Interface
97
A.l
Input
andOutput Signals
97
A.2
VHDL Model
ofthe
Bus
Interface
99
B
Controller
106
B.l
Master Controller
106
B.l.l
Inputs
andOutputs
106
B.l. 2
VLSI Version
vs.FPGA Version
109
B.1.3
VHDL
Model
ofthe
Master
Controller
109
B.2
Memory
Controller
124
B.2.1
Inputs
andOutputs
124
B.2.2
VHDL
Model
ofthe
Memory
Controller
124
C
Utilities
128
C.l
XEROX 7650
Scanner
128
C.2
TIFF
to
IMG
128
C.3
IMG
to
ASCII
/
ASCII
to
IMG
andDisplay
anIMG Image
129
C.4
ASCII
to
PS
129
C.5
Display
aPostScript Image
onPC
129
C.6
Connect PC
withApollo
Workstations
-DPCI
List
of
Figures
3.1
Top-down Design Process
13
4.1
MIP Data Path
19
4.2
Signal
Timing
ofReset
Bus
Cycle
29
4.3
Signal
Timing
ofRegister
R/W Bus
Cycle
30
4.4
Signal
Timing
ofMemory
R/W
Bus
Cycle
31
4.5
MIP
Process flow
33
5.1
MIP
Hierarchy
37
5.2
MIP
Behavioral
Model
withPC BUS
40
5.3
MIP Structural Model
withPC
BUS
53
5.4
MIP
Timing
Chart
55
5.5
MIP
Timing
Chart
(continued)
56
5.6
A Partial 32
X32 image in ASCII
format
60
5.7
Resultant
Image,
top-left
:originalimage,
top-right:
first
erosion,
bottom
right: second
erosion,
bottom left:
third
erosion61
5.8
Original 8-bit grey
scaleimage
63
5.9
Resultant
image
ofa complete512
x512
image
after erosion64
5.10 Resultant image
oftwo
512
x256 images
after erosion65
6.1
The
Blanking
Sequence
ofthe
MAP
76
A.l
Schematic
ofBUS
Interface
100
B.l
Schematic
ofMaster Controller
in
the
VLSI
version110
B.2
Schematic
ofMaster Controller in
the
FPGA
versionIll
List
of
Tables
2.1
Threshold Representation
of aDiscrete,
Quantized Signal
8
2.2
FSP
Dilation, Erosion, Opening,
andClosing
9
2.3
/()
andg(v)
9
2.4
illustration
of agrey
scaledilation
10
2.5
illustration
of agrey
scale erosion11
4.1
ALUs'Operations
22
4.2
The
Map
ofRegisters in
the
MIP
23
4.3
Volume
Adder
Registers
24
4.4
ALU
Registers
24
4.5
Start Register
24
4.6
Control
andStatus
Registers
25
4.7
Memory
Select
26
4.8
Memory
to
Local Bus Connection
26
4.9
On-board
Memory
Segments
26
4.10
PC
Address Control
27
4.11
System Commands
32
5.1
MIP
Entity
39
5.2
The Window
Array
62
7.1
Tri-state
Signal
Resolving
Table
92
Chapter
1
Introduction
The
aim ofthis
project wasto
model aMorphological Image Processor
(MIP)
withVHDL,
a
hardware description language.
A MIP
canbe
usedto
analyze animage based
on apredefined geometricshape
by
applying
set operations onthe
image. The
total
project was accomplishedby
the
joint
efforts ofWei-chun Chen
andHao
Chen
due
to
its complexity
and size.Two
separatethesis topics
entitledMathematical Components
andControl
Mechanism have
resultedfrom
the
projectto
create aVHDL
model ofthe
Morphological
Image Processor.
In
orderto
understandthe
operation ofthe
MIP,
the study
ofthe
MIP
theory
is
first
presented
in
Chapter 2
(by
Wei-chun
Chen),
in
whichdigital images
aredefined,
and mor phological operations are explained.Chapter 3
(by
Hao
Chen)
describes
the
important
concepts
in
VHDL,
andthe
role ofVHDL in
the top-down
design.
In Chapter 4
(by
Wei-chun andHao),
the
MIP
systemis described in detail.
The data
pathbetween
different
buses
is
explained, the
functionality
ofthe
arithmeticblocks is
discussed,
andthe
control/status
registers are presented.In
addition, the
interface
between
the
MIP
andthe
host
computer
is
illustrated,
andthe
proceduresfor
operating
the
MIP
are given.These
chaptersare shared
by
Wei-chun
Chen
andHao
Chen
for
readersto
better
understandthe
entireproject.
The
aim ofthis
projectis
to
model aMorphological Image
Processor
(MIP)
withVHDL,
ahardware description language.
A
MIP
canbe
usedto
analyze animage
based
on a predefined geometric shape
by
applying
set operations onthe
image.
The
modeling
ofthe
MIP in VHDL is discussed
from Chapter
5
to
Chapter
9.
Based
onHao)
into four different functional blocks: I/O
Unit,
Control
Units,
Arithmetic
Units,
andMemory
Units. Each functional block
consists ofoneormore physicalblocks.
Each
physicalblock has
its
corresponding VHDL
model.The behavioral
and structural models ofthe
MIP
are
discussed
in
Chapter
5
as well.Chapter
6
visitsthe
Arithmetic Units: Arithmetic/Logic
Units
(ALU1
andALU2), Morphology Unit(MU),
andVolume Adder. The
MU
is
further
decomposed
into
First-In-First-Out
(FIFO)
andMorphological
Array
Processor
(MAP).
At
last,
the
Memory
andthe
Buffer
in
Memory
Units
arediscussed
in Chapter 7.
Appendix
A
and appendixB
arewrittenby
Hao
Chen
to
describe
the
control mechanismof
the
MIP. In
appendixA,
the
Bus Interface in
I/O
unitis
described. Appendix B deals
withthe
ControDer
Units,
which consist ofthe
Master
Controller
andthe
Memory
Controller.
The
original architecture andthe
FPGA
version ofthe
MIP
weredesigned
by
Jens
Rodenberg
andJeff Hanzlik.
The first
VLSI
version ofthe
MAP
wasdesigned
by
Larry
Rubin.
The
VLSI
version ofthe
ALU1,
the
ALU2,
the
Volume
Adder,
andthe
revisedVLSI
version ofthe
MAP
weredesigned
by
Shishir Ghate.
The VLSI
version ofthe
Master
Controller
andMemory
Controller
weredesigned
by
Chris Insalaco. All
ofthe
BLM
modelsfor
the
componentsin
the
MIP
were writtenby
Jeff Hanzlik. The VHDL
models ofthe
unitsChapter
2
Morphology
Theory
According
to the
Webster
Electronic
Dictionary,
the
wordmorphology
refersto the study
of
form
and structure.In image processing,
morphology
wasfirst
usedby
G.
Matheron
as amethodology
which analyzes animage based
on a predefined geometric shapeby
applying
set operations on
the
image. The image
operations of mathematicalmorphology,
known
asmorphological
filters,
are more suitablefor
shape analysisthan
linear filters
[3].
The morphology
theory
canbe
applied on eitherbinary
or grey-scaleimages.
The
definitions
of animage
andmorphology
operations willbe
presentedin
Section 2.1.
The
hardware
implementation
ofthe
operations willbe
explainedin
Section
2.4.
2.1
Digital Images
A digital image is
normally
createdby
the
process ofsampling
a continuousimage.
The
image
canbe
represented as afunction
whosedomain is
a subset of adiscrete
space andwhose range
is
a subset ofintegers.
An
elementin
the
domain
representsthe
coordinate ofa pixel while an element
in
the
rangeis
the
signal strength of a pixel.An
image consisting
of monochromatic pixels
is
referred as agrey
scaleimage.
A
grey
scaleimage
canbe
convertedto
abinary
image
by
applying
athresholding
processing.
The
thresholding
processdefines
the
corresponding
pixel value as"1" whenthe
grey-scale pixel value
is
larger
or equalto the threshold value;
otherwise,
the
pixel valueis
"0". The
binary
image
canbe
representedby
a set of coordinatesfor
those
pixels withvalue
"1".
A
binary
image
is defined
as aset,
X:
X
{x
|
xis
the
coordinate ofthe
image,
a;G
Z2}.
(2.1)
Z
is
the
set ofintegers.
Z2is
atwo
dimensional discrete
space.A
grey-scaleimage
is
defined
as afunction,
/:
/
:E
-F,
{
1
f(x)
={y\yeF}
if
xe
E
oo otherwise
(2.2)
72
F
is
the
range ofthe
function
andE is
the
domain
ofthe
function. F
C
Z,
E
C
Z2The
thresholding
processis
accomplishedby
obtaining
thresholding
setsfor
a grey-scaleimage. A
thresholding
setis
defined
by
Ta(f)
={x
| f(x)
>
a,
aZ,
xE},
-oo<
a<
oo.(2.3)
in
which ais
athreshold
value.It is
clearby
comparing
equations2.1
and2.3
that
athresholding
setis
abinary
image. For
an8-bit
grey-scaleimage,
there
are256
threshold
values
from 0
to
255.
After
the
thresholding
process, the
grey-scaleimage is
decomposed
into 256
binary
images.
The decomposed
grey-scaleimage
canbe
reconstructedby
the
operation:f(x)
= max{a : xe
?(/)},
Vs.
(2.4)
2.2
Basic
Morphological
Operations
The
morphological operations arebased
on astructuring
elementto
analyze aninput image.
Any
small sizedimage
with a simple shape canbe
used as astructuring
element.There
arethree
categories ofprocessing
classifiedby
the
input images
andthe
structuring
elements.We
willdefine
two
basic
operationsin
each category:dilation
and erosion.The
first
category
is
setprocessing
(SP)
with abinary
input image
and astructuring
of a
binary
image X
by
abinary
structuring
elementB is
defined
as:X
B
=(j
(X +
b)
={x
+
b
|
Vx G
X
A
V6
G
B}
(2.5)
bB
Dilating
animage
by
astructuring
elementB has
the
effect of"expanding"
the
image in
a_
manner
determined
by
B.
The
erosionof abinary
image
X
by
abinary
structuring
elementB
is defined
as:X 6 B
=p|
(X
-b)
={x
|
xG
X
A
(B
+ x)
C
X}.
(2.6)
Eroding
animage
by
astructuring
element5
has
the
effect of"shrinking"the
image
in
amanner
determined
by
B.
The
secondcategory is
function
setprocessing
(FSP)
with a grey-scaleinput image
anda
binary
structuring
element.An
important
property
ofthe
FSP
operationsis
that
they
commute withthresholding.
That
is,
let
<f>denote
aFSP
operation andlet $ denote its
respectiveSP
operation.Then,
wesay
that
<f> commutes withthresholding
iff
W)]
=W)],vte?.
(2.7)
The dilation
of a grey-scaleimage
/ by
abinary
structuring
elementB is defined
as:(/
B){x)
= max{/(z-y),x-yeE}.(2.8)
y&B
The
erosion of a grey-scaleimage
/ by
abinary
structuring
elementB is defined
as:(/
G
B){x)
= min{/(x+
y),
x+
y G
E}.
(2.9)
y&BAs
seenfrom
equation2.7,
the
FSP
operationis
equivalentto
256
SP
operationsfor
a8-bit
grey-scale
image.
Therefore,
the
FSP
operationhas
received moreattentionin
mathematicalmorphology
research.The
third
category
is function
processing
(FP)
with a grey-scaleinput image
and agrey-scale
structuring
element.Let g be
afunction
whosedomain
is
I
C
Z2and whose
is defined
as:(/
g)(x)
=max{/(2/)
+ g(x-y),xE,
V(x
-y) G
/}.
(2.10)
The
erosion of a grey-scaleimage
/ by
agrey-scalestructuring
elementg is defined
as:(/
6 g)(x)
=min{/(y)
-g(y
-x),x
e
E,V(y
-x)
G
/}.
(2.11)
It
shouldbe
realizedthat the
FP
operationsdo
not commute withSP
operations.2.3
Extended Morphological Operations
The
utilization oferosion anddilation
canbe
extendedto
opening
and closing.Any
set ofthe
erosion andthe
dilation
operationsdefined
above canbe
usedin
anopening
or aclosing
operation.
The opening
operation canbe
defined
as:(XoB)
=(XQB)B.
(2.12)
The closing
operation canbe
defined
as:(XB)
=(XQB)eB.
(2.13)
2.4
Implementation
Our
goalis
to
design
and simulate a grey-scale morphologicalprocessing
system.In
the
system,
images
andstructuring
elements willbe
grey-scaleimages. A structuring
elementis
referred as a maskin
future
discussions.
In
equation2.2
wehave
shownthat the
numberoo
is
usedto
represent an undefined pixelvalue;
therefore,
a9-bit 2's
complement codeis
usedinstead
ofa8-bit
unsignedbinary
code.The
number 256is
usedto
representthe
-oo value.
Even
though the
originalimage
from
asampling
does
nothave
negative valuedpixels, the
negative valuefor
apixel can occurduring
computation.The
maximumimage
frame
sizeis fixed
to
512
by
512
(or
1024
by 1024)
pixelsfor
our system whilethe
maskThe
essential operationsin
the
MIP
system are erosion anddilation
sincethe
opening
or
closing
operations canbe
createdusing
erosion anddilation.
We
willfirst
explainthe
implementation
ofFP
operations,
then
apply
the
resultto
FSP
operations.The
definitions
ofFP
operationshave been
shownin
equation2.10
and2.11.
The
computing
proceduresfor dilation
asshownby
equation2.10
canbe described
by
the
following
pseudo code:for
(output_col_index=0;
output_col_index<512;
output_col_index++)for
(output_row_index=0;
output_row_index<512;
output_row_index++){
for
(mask_col_index=0;
mask_col_index<7;
mask_col_index++)for
(mask_row_index=0;
mask_row_index<7;
mask_row_index++){
input_row_
index
:= output_row_index-mask_row_index +
(mask_size-l)/2;
input_col_index
:= output_col_index-mask_col_index +
(mask_size-l)/2;
OUTPUT.
I AMGE
(output
_col_index,output_row_index)
:=
max(
map_add(INPUT_IAMGE(input_col_index,
input_row_index)
,MASK(mask_col_index,
mask_row_index)));
>
}
The
procedure canbe
visualized withthe
following
steps:1.
rotatethe
maskby
180
degrees;
2.
alignthe target
pixel(starting
from
column0,
row0
ofthe
image)
withthe
center ofthe mask;
3.
addthe corresponding
pixelsbetween
the
mask andthe
part ofthe
image
overlappedwith
the mask;
4.
choosethe
maximum value ofthe
summations asthe
value ofthe target
pixel;
5.
slidethe
maskto the
nexttarget
pixel and repeatthe
previous steps untilthe
wholeimage
is
processed.By
comparing
equation2.11
with2.10,
the
erosion operation canbe
computedby
negating the
mask pixel valuebut
notrotating
mask.However,
the target
valueis
nowthe
minimum value ofthe
summations.The negating
androtating
mask proceduresfor
erosion anddilation
canbe
easily
accomThere-fore,
the
systemhas been
partitionedto
computethe
summations and searchthe
maxi mum/minimumby hardware,
andto
rotate and negatethe
maskby
software.The
reader shouldbe
awarethat
if
a -oois
usedin
amask, the
negated valueis
+00
which
is
notdefined
in
our9
bit
2's
complement coded system.This
technical
problem canbe
solvedby
using
the
maximum value255 instead
of+00.
The
trade
offis
that
the
actualvalue of
255
is
indistinguishable from
+00.
The FSP
operation canbe
applied onthis
systemby
using
a proper mask.In
the mask,
0 is
usedfor
the
image
and 00for
the
background.
2.5
Examples
The
following
two
examples aremodifiedbased
onthe
works ofHaralick
[2]
andMorgos
[4].
2.5.1
Example
1:
We
willillustrate
through
an examplein
table
2.1
the
procedure ofthresholding
a1-D grey
scale
image
as well asthe
result ofFSP
operations onthe
image. The first
row showsthe
coordinate of
the pixel,
whilethe
second row showsthe
value ofthe
pixel.The
resultantthresholding
sets are shownfrom
row3
to
row6 in
which '' showsthat the
corresponding
coordinate
is
an elementin
the
set.The
equivalent representation ofthe
thresholding
setsis
the
binary
images
which are shownfrom
row7
to
row10.
The
original grey-scalefunction
can
be
reconstructedby
restoring
the
maximum valueshowing
onthe
thresholding
setsto
the
correspondent coordinate.1
X0
1
2
3
4
5
6
7
8
9
10
2
/(*)
1
1
2
1
3
0
0
1
0
2
3
3
Uf)
4
T2U)
5
Tx{f)
6
Uf)
7
h(x)
0
0
0
0
1
0
0
0
0
0
8
/2(z)
0
0
1
0
1
0
0
0
0
1
9
/i(*)
1
1
1
1
1
0
0
1
0
1
10
Mx)
1
1
1
1
1
1
1
1
1
1
The
f(x)
is
processedby
astructuring
setB
={-1,0,
1}
for
dilation,
erosion, opening,
and
closing
as shownin
table
2.2.
Each
result oftable
2.2
canbe
usedto
threshold
and generate another resultantbinary
image
sets.As
the
equation2.7
shown,
these
resultant sets shouldbe
identical
to the
resultant sets
using
the
row sevento ten
oftable
2.1
asinput
and appliedthe
setB
for
the
same
FSP
operations.X -1
0
1
2
3
4
5
6
7
8
9
10
11
fix)
oo1
1
2
1
3
0
0
1
0
2
3
00f(x)@B
1
f(x)
6
B
oof(x)
oB
oof(x)
.B
oo1
2
2
3
3
3
112
3
-oo
1
1
1
0
0
0
0
0
0
1
11110
0
0
0
0
1
12
2
3
11112
3
3
00 oo
0
oo3
ooTable 2.2: FSP
Dilation,
Erosion,
Opening,
andClosing
2.5.2
Example
2:
The
f(u)
andg{v) in
table
2.3
arethe
coordinate and pixel value oftwo
grey-scaleimages.
The
table
2.4
and2.5
arethe
computing
resultsaccording
to the
equation2.10
and2.11.
u=
15
16
17
18
19
v=0
l
2
/()=
4
7
-56
8
g(v)=l
17
-3x =
15
x =16
x-y
0
1
2
x-y
0
1
2
y
15
14
13
y
16
15
14
f(y)
4
00 00f(y)
7
4
oog(x
-y)
1
17
-3g(x-y)
1
17
-3f
+ g
5
oo oof
+
g
8
21
00(/ff)(15)
=5
(/<?)(16)
=21
x =
17
x =18
z
-2/
0
1
2
a; -y0
1
2
y
17
16
15
y
18
17
16
f(y)
-57
4
m
6
-57
g(x
-y)
1
17
-3g(x-y)
1
17
-3f
+ g
-424
1
f
+
g
7
12
4
(/flO(17)
= 2^(/</)(18)
=12
x =19
z
-y
0
1
2
y
19
18
17
f(y)
8
6
-5g{x
-y)
1
17
-3f
+
g
9
23
-8(/S)(19)
=23
a;
15
16
17
18
19
(/s)W
5
21
24
12
23
x =
15
x =16
y-x
0
1
2
y-x0
1
2
y
15
16
17
y
16
17
18
f(y)
4
7
-5f(y)
7
-56
g(y-x)
1
17
-3 g(y-x)
1
17
-3f
+
g
3
-10 -2f
+ g
6
-229
(/9<7)(15)=-10
(feg (16)
= -22x =
17
x =18
y-x
0
1
2
y-x0
1
2
y
17
18
19
y
18
19
20
f(y)
-56
8
f(y)
6
8
00g(y-x)
1
17
-3g(y-x)
1
17
-3f
+
g
-6 -1111
f
+
g
5
-9 oo(fog) (17)
= -11(/e<?)(i8)
= oox =
19
y-x
0
1
2
y
19
20
21
f(y)
8
oo 00g(y-x)
1
17
-3f
+
g
7
00 oo(feg)(i9)
= -ooX
15
16
17
18
19
(feg)(x)
-10 -22 -11 oo 00Chapter
3
VHDL
VHDL
is
an acronymfor VHSIC Hardware
Description Language. It is
anindustry
standardlanguage
usedto
describe
adigital
systemfrom
abstractlevel
to
concretelevel.
One
ofthe
important
features
ofthe
language is
that
it
has
constructsthat
enables adesigner
to
express
the
concurrent or sequentialbehavior
of adigital
system with or withouttiming.
The
advantage ofusing
VHDL
is
clearly
illustrated in
top-down
design
methodology.We
will
discuss
the top-down
design
andthe
important
role ofVHDL in
the
design before
moving
onto the topics
in VHDL.
3.1
Overview
of
Top-down
Design
In design
methodologies, top-down
design
is very
significant sinceit
reducesthe
design
cycle,
increases
the
design
flexibility,
andimproves
the
design
quality
and productivity.The
top-down
design
methodology
is
a processthat
begins
withestablishing
an architecture
anddefining
abehavioral
logic
description using
ahigh-level hardware description
such as
VHDL. This
couldbe
at a system orblock
diagram
level,
or registertransfer
level
(RTL),
but it begins
at some point above gatelevel.
[5]
Figure 3.1
showsthe top-down
design
process.The behavioral
modelis
evaluated againstits
architecture specificationsusing
realistictest
inputs
via simulationto
determine
the
correctness.Once
the
modelis
verified, the
designer
canfurther decompose
the
modelinto
sub-models asdesired,
and evaluatethe
sub-models accordingly.
Simulating
at successivelevels
ofthe
design
process andmaking
Figure 3.1: Top-down Design
Process
complete.
In addition,
simulationusing
VHDL
allows changesto
be
maderelatively
easierand
in
muchless
time.
Traditional
gate-level simulationdiscourages
trying
alternativeapproaches since schematic
capture,
logic
simulation,
andtiming
analysis require a greatdeal
oftime
andcomputing
resources.The
next stagein
the
processis
to
select atechnology
for
the
design.
This
is
anotheradvantage of
VHDL
sinceit
offers verificationsindependent
ofthe technology.
After
the
technology
is selected,
the
VHDL
models canbe
synthesized.Logic
synthesis provides alink
between VHDL
and anetlist.This feature
is extremely important
for
alarge
systemdesign
sinceit
would otherwisebe
very
difficult
to
keep
track
of afull
gate-leveldescription
using
schematic capture.The
gate-levelrepresentation obtained afterlogic
synthesisis
then
simulated and evaluated against
the
simulation resultsfrom
the
VHDL
model.Next,
this
representation
is
verifiedthrough
a combination offunctional
verification,
timing
analysis,
and
fault
simulation.The
circuit canbe
further
optimized afterfunctional
verification ortiming
analysisto
improve
the
performance ofthe
design.
Layout is
then produced,
andmore
detailed
information is
providedfor
additionaltiming
adjustment and verifications.This
processis iterated
untilthe
design is
ready
for
manufacture.After
illustrating
the
importance
ofVHDL in
top-down
design,
we willdiscuss
somefundamental
conceptsin VHDL in
the
following
sections.3.2
Entity
and
Architecture
An
entity
is
an abstraction ofthe
actualhardware
device.
The
ENTITY declaration
specifies
the
name ofthe entity
being
modeled andthe
externalinterfaces
ofthe
modeleddevice.
An
entity
caninclude
otherentities,
andit
can alsobe included in
anotherentity.Therefore,
VHDL
supportsboth
top-down
andbottom-up
design
methodologies.The
internal
details
of an
entity
aredescribed
by
an architecturebody.
Any
architectureis
associated withonly
one
entity,
but
a singleentity
canhave
multiple architectures.In general,
the
modeling
style ofamodel canbe:
structural;
behavioral;
In
structuralmodeling,
anentity is
modeled as aset ofcomponents connectedby
signals.In
the
behavioral
modeling,
however,
the
entity
is
modeledby
statementsdescribing
the
functionality
ofthe
device. When
the
description
ofanentity
containsboth
structural andbehavioral
modelelements, it
is
called mixedlevel
modeling.It
shouldbe
mentionedthat
another popular set ofmodeling
stylesincludes
data
flow
modeling in
additionto the
onesdescribed
above.The
definition
ofbehavioral modeling
in
this case,
however,
deviates from
the
definition
we gavepreviously.Here,
the
behavioral
modeling
specifiesthe
behavior
of anentity
as a set of statementsthat
are executed sequentially,
andthe
data flow
modeling
specifiesthe
functionality
ofthe entity
by
using
concurrentsignal assignment statements.
( [6],
p.16)
These
definitions
relatethe
modeling
withcoding
style,
i.e,
whether afunctionality
is
expressedsequentially
or concurrently.We
willthink
both
ofthese
asbehavioral
modeling
sincethey
both
describe
the
FUNCTIONALITY
ofan entity.
Our
modeling philosophy is
that
behavioral modeling
and structuralmodeling
canbe
coexist at each
level
through the
hierarchy
ofthe
system exceptthe very
bottom level
elements,
which canonly be
a purebehavioral
model component.The
existence of abehavioral
model provides
for
rapidfunctional
simulation,
whilethe
existence of a structural modelallows
for
final
architectural considerations.We
will elaboratethese
conceptsin
Chapter 5
through
Chapter
9,
in
whichthe
implementation
ofVHDL
for
MIP is discussed.
We
willdiscuss
in
next sectionthe
definitions
of signal andvariable,
and other conceptsrelated with
them.
3.3
Signal
vs.
Variable
A
signalis
an objectthat
has
a pasthistory
ofvalues,
a currentvalue,
and aset offuture
values.
A
variable,
onthe
otherhand,
is
an object whichholds
a single value of a giventype.(
[6],
p.28)
Signal
objects canbe
regarded as end points of wiresin
a circuit.The
information
a signal object carriesis
atwo-dimensional
waveform:The
change ofits
digital
states vs.
the
changeofthe time.
In
orderto
discuss
signal and variable objectsin
greaterdetail,
we needto
introduce
some related concepts.Event:
aterm to
indicate
the
change of a signal's value at a specified simulationtime.
Otherwise,
aneventdoes
not occur atthe
simulationtime.
Process:
the
basic
unit of execution.The
unit contains sequential statementsthat
describe
the
functionality
of a portion ofan entity.A
process statementitself
is
a concurrentstatement.
More
than
one process canbe
used within an architecturebody
to
capturethe
behavior
ofinteracting
processes.Sensitive List:
a set ofsignalsto
whichthe
processis
sensitive.Any
time
an event occurson
any
signalin
the
sensitivelist,
the
statementsin
the
process willbe
executedsequentially.
The
process suspends after execution oflast
sequential statementin
the
process and waits
for
anotherevent onany
signalin
the
sensitivelist
to
occur.Delta
Delay:
a representation ofaninfinitely
smalldelay.
This
smalldelay
correspondsto
a zerotime
delay
of adevice
andhence does
not correspondto any
real simulationtime.
Each
unit of simulationtime
canbe
consideredbeing
composed of aninfinite
number of
delta delays.
The
purpose ofdelta
delay
is
to
provide a mechanismfor
ordering
events on signalsthat
occur atthe
same simulationtime.
Therefore,
anevent on a signal always occurs at a real simulation
time
plus anintegral
number ofdelta delays.
Inertial Delay:
the
amount ofdelay
time
for
a stable signalto
propagatefrom input
to
output of a concurrent
element,
or statement.If
the
input
signalis
not stableduring
the
specifiedinertial
delay
time,
no eventfor
the
signal willbe
scheduled.Inertial
delay
is
often usedto
filter
out unwanted spikes andtransients
on signals.Since
the
inertial
delay
is
mostly
commonin digital
circuits,
it
is
the
default
delay
model.Transport Delay:
the
amountofdelay
time
for
a signalto
propagatefrom
input
to
outputof a concurrent
element,
or statement.It
models pure propagationdelay. Transport
delay
modelis
especially
usefulfor modeling
wiredelays.
Any
input pulse,
nomatterhow
smallits
width,
willbe
propagatedto
output afterthe
specifieddelay
time.
The
concepts explained above areimportant
to
understandthe
differences between
asignal and a variable.
First
ofall,
a variableis different
from
a signalin
terms
ofthe
value assignment.
A
variableis
always assigned a valueimmediately
uponevaluations,
but
an architecture
body
communicate with each otherusing
signalsthat
are visibleto
allthe
processes.
However,
variables can notbe
usedto
passinformation between
processes sincetheir
scopeis
limited
to
within a process.When
a signalis
assigned a valueinside
of aprocess,
it
uses a sequential signal assignment
statement;
when a signalis
used outside of aprocess,
it
uses a concurrent signalassignment statement.
A
concurrent signal assignment statementis
event-driven soit is
executed whenever
there
is
an event on a signalthat
appearsin its
defining
expression.A
sequential signal assignment
is
notevent-driven andis
executedin
the
orderdetermined
by
the
sequentiallist
of statementsin
a process.Although
there
aremany
otherimportant
conceptsin
VHDL,
wehave
only
chosenthe
very
small number of conceptsto
be discussed in
previous sections since wefeel
that
understanding
ofthese
conceptsis
vitalto
our systemmodeling
and simulation.In
nextChapter
4
System
Description
4.1
Data Path
In
the
previouschapter,
the
important
concepts ofVHDL
have been
introduced
anddis
cussed.
This
chapter willdescribe
the
functionality
ofthe
MIP. As
animage processing
sub-system,
the
MIP is
ableto:
receive commands
from
the
PC;
receive and store an
image
from
the
PC;
process an
image;
allow
the
PC
to
retrieve a processedimage.
The
transfer
ofdata
and commandsis
accomplishedbetween
the
Extended Industrial
Standard
Architecture
(EISA)
bus
onthe
PC
andlocal
buses
onthe
MIP,
whilethe
image
processing is done in
the
ALU1,
the
MU,
andthe
ALU2. The
detailed information
is
shownin
figure
4.1.
The dark
colored pathsin
the
figure
arethe
local buses
ofthe
system.The
paths with
light
color arethe
connective wires.The data
transactions
andimage processing
canbe
described in
four
stages:Load Data: image data
are writtenfrom
the
PC
to
the
memory
bank
through the
EISA
bus
andthe
I/O bus.
Mask data
are writtenfrom
the
PC
to
mask registersin MU
Figure
4.1
:M
I
P
DATA
PATH
Figure 4.1:
Any
image
of appropriate
size can
be
written
to
(or
read
from)
the
memory
bank
from
(or
to)
the
PC
memory.
The
morphological
mask values are written
directly
from
the PC
to
registers
in
the
MU.
The image
can
be
processed
by
ALU1, MU,
and
ALU2. The
resultant
image from ALU2 is
stored
back
to the
memory
bank. The
volume
adder
sums each pixel value
in
a
Process Image:
during
the
MIP
operation,
ALU1
uses animage
from
the
memory
bank
through
XI bus
as one operand and animage
through
X2 bus
asthe
other operand.The
output ofthe
ALU1
is
enteredinto
the
MU,
whichthen
processesthe
image
andsends out
the
resultantimage
as well asthe
originalimage
to
ALU2. ALU2
selectstwo
ofthe
three
input images
asits
operands.Two inputs
arefrom
the
MU,
andthe
third
input
is
from
the
X2 bus. For
eachprocessing
cycle, the
image
from
the
X2 bus
can
only
be
exclusively
usedby
eitherALU1
orALU2.
Store
Output:
afterthe
MIP
operation,
the
processedimage is
storedback
to the memory
bank
through
Y
bus. The
volumeofthe
image is
storedin
the
Volume
Adder
registerswhich are read
directly by
the
PC.
Read
Out:
the
image
data
in
the
memory bank
canbe
retrievedby
the
PC
through the
XI,
I/O,
andthe
EISA
buses.
The blocks
shownin
figure
4.1
arethe
functional
data blocks
for
the
MIP. The
controlmechanism
is
notincluded in
the
figure in
orderto
concentrate onthe
data-flow
portion ofthe
MIP.
4.2
Arithmetic Functional Blocks
The
arithmeticfunctions
ofthe
MIP
are accomplishedby
two
ALUs,
the
MU,
andthe
Volume Adder. The
functionality
of each componentis
explainedin
the
following
sections.4.2.1
ALUs
There
aretwo
ALUs.
ALU1 is
the
pre-processorfor
the
MU,
whileALU2
is
the
postprocessor
for
the
MU.
As
the
namesuggests, the
ALUs
perform arithmetic andlogic
operations.
ALU1
usesdata
from
the
XI
andX2 buses
asits operands,
whileALU2
usesdata from
two
ofits
three
input
ports asits
operands.These input
ports are:the
originaland processed
images
from
the
MU,
andthe
image
from any
ofthe
four
memoriesthrough
the
X2
bus. We
will referto the two
activeinput
portsin
both ALU1
andALU2
asA
andB in future discussions.
and
5x
hex
coded operations are ableto
generate
the
maximum/minimum value of aimage
on
ALU2 but
not onALU1. Each
operationis
described below:
Ox:
comparesthe
corresponding
pixels ofimages
A
andB,
and outputs animage
composedof
the
pixels withthe
minimum value ofthe
comparison.lx:
comparesthe
corresponding
pixels ofimages
A
andB,
and outputs animage
composedof
the
pixels withthe
maximum value ofthe
comparison.2x
and6x:
copiesthe
input image from
A
asthe
outputimage.
3x
and7x:
copiesthe
input image
from
B
asthe
outputimage.
4x:
searchesfor
the
minimum value of a pixelin image
A
and storesthe
resultin
aregister;
it
also copiesthe
input image
from
A
asthe
outputimage.
5x:
searchesfor
the
maximum value of a pixelin image A
and storesthe
resultin
aregister;
it
also copiesthe
input image
from
A
asthe
outputimage.
8x:
subtractsimage B from image A. If
the
value of a pixelin B is
oo, then the
outputvalue of
that
pixelis
oo.9x:
subtracts a constantfrom
image
A. If
the
value ofthe
constantis
oo, then the
wholeoutput
frame
valueis
oo.Ax
andEx:
addsimage
A
withimage B.
Bx
andFx:
adds a constant valueto
all pixelsin image A.
Cx:
subtractsimage
B from
image
A. If
the
value of a pixelin B is
oothen the
outputvalue of
that
pixelis
the
valuein A.
Dx:
subtracts a constant valuefrom
all pixelsin
image
A.
If
the
value ofthe
constantis
ALU
OPERATIONS
j
Bit
Op
ALUs
Hex
7
6
5
4
ALU1
ALU2
Ox
0
0
0
0
min(A,B)
YES
YES
lx
0
0
0
1
max(A,B)
YES
YES
2x
0
0
1
0
copy(A)
YES
YES
3x
0
0
1
1
copy(B)
YES
YES
4x
0
1
0
0
min(A),copy(A)
NO
YES
|
5x
0
1
0
1
max(A),copy(A)
NO
YES
6x
0
1
1
0
copy(A)
YES
YES
7x
0
1
1
1
copy(B)
YES
YES
8x
1
0
0
0
A-B
YES
YES
9x
1
0
0
1
A-const
YES
YES
Ax
1
0
1
0
A+B
YES
YES
Bx
1
0
1
1
A+const
YES
YES
Cx
1
1
0
0
A-B
(2)
YES
YES
|
Dx
1
1
0
1
A-const
(2)
YES
YES
Ex
1
1
1
0
A+B
YES
YES
Fx
1
1
1
1
A+const
YES
YES
Table 4.1:
ALUs'Operations
4.2.2
MU
andVolume Adder
The
Morphology
Unit
performs erosion ordilation
asdefined
by
grey-scale morphologicaloperations.
It
addsthe
value onthe
mask withthe
corresponding
pixelin sub-array
ofthe
image defined
by
the target
pixel.The
minimum valuefor
the target
pixelis
chosenfrom
the
erosion operation orthe
maximum valueis
chosenfrom
the
dilation
operation.The Volume Adder
takes
the
outputfrom ALU2
and sums eitherthe
squared value orthe
absolute value of each pixelto
producesthe
volumeof eachimage. The
outputis
storedin
registers which canbe
accessedfrom
the
PC.
Although
notincluded in figure
4.1,
the
control mechanismis
important for
the
properoperation of
the
MIP.
The
control and status registers are essentialto
accomplishthis task.
4.3
Control
and
Status
Registers
Table 4.2
showsthe
locations
and addresses ofthe
onboard
control or status registers.The
control and status registers willbe described
in
terms
oftheir
functionalities.
In
each ofthe tables
usedin
this
section,
the
ADDR
column showsthe
hexadecimal
register address accessedthrough the
PC bus.
The
BITS
columnindicates
the
corresponding bits for
a certainfunction.
The
R/W
column showsthat the
registeris
eitherread-only
by
the
PC
orwrite.only
from
the
PC. If
an addressis
shown asboth
readable andwritable, the
addressis actually
sharedby
aread-only
and awrite_only
register.The Content/Purpose
columndescribes
the
content ofthe
read-only
registers andthe
purposefor
the write_only
registers.LOCATION
REG
No.
ADDR
LOCATION
REG
No.
ADDR
Volume
Adder
0
000300
ALU2
7
000307
1
000301
8
000308
2
000302
Master
Controller
9
00030B
3
000303
10
00030C
4
000304
11
00030D
ALU1
5
000305
Bus Interface
12
00030E
6
000306
13
00030F
Table 4.2: The
Map
ofRegisters in
the
MIP
4.3.1
Volume
Adder Registers
Bit 0
ofthe
Reg_0
selectsthe
original or squared outputfrom ALU2
asthe
input
ofVol
ume
Adder
as shownin
table
4.3.
The 34-bit
volumeis
storedin
read-only
registersReg_4
through
Reg_0 in
absolutebinary
format. Bit 7
ofthe
Reg_4 indicates
that
a negative valuehas been
passedinto
the
Volume Adder.
4.3.2
ALUs
Table
4.4
showsthe
control and status registersfor
the
operations ofthe
ALUs. Each ALU
REG
ADDR
BITS
R/W
Content/Purpose
0
000300
0
W
0
sumX
input,
1
sumX Squared
input
7-0
R
Volume
Adder
resultbits 7-0
1
000301
7-0
R
Volume Adder
resultbits 15-8
2
000302
7-0
R
Volume
Adder
resultbits 23-16
3
000303
7-0
R
Volume Adder
resultbits 31-24
4
000304
1,0
R
Volume
Adder
resultbits
33,32
7
R
negative valueflag
Table 4.3:
Volume
Adder Registers
3
andbit
2
ofReg_8
selectthe
inputs
ofthe
A
andB
operandsfor ALU2. The
minimumor maximum value
for
operation4x
or5x
in
table
4.1
canbe
readfrom Reg_7
andbit 0
ofReg_8.
REG
ADDR
BITS
R/W
Content
/Purpose
5
000305
7-0
W
ALUl-const(7:0)
6
000306
0
W
ALUl-const(8)
7-4
W
ALU1
op-code7
000307
7-0
w
ALU2-const(7:0)
7-0
R
ALU2-MAX/MIN(7:0)
8
000308
0
W
ALU2-const(8)
7-4
W
ALU2
op-code3
W
selectB
(0=MU's
X-out, l=X2-Bus)
2
W
selectA
(0=MU's
Y-out,
l=X2-Bus)
0
R
ALU2-MAX/MIN(8)
Table
4.4:
ALU
Registers
4.3.3
Master Controller
Bit 0
ofReg_9
shownin
table
4.5 is
an activelow
signalto
startthe
MIP
processing.REG
ADDR
BITS
R/W
Purpose
9
00030B
0
W
0> startMIP
process
Table
4.6
showsthe
control andstatusregisterfor
the
MIP. Bit 7
andbit
6
ofReg.10
areused
for
pipelined operation.When bit
6
is
activehigh,
it indicates
that the
MIP processing
is running,
andthe
systemis
safeto
load
the
new mask orthe
newimage.
Bit 7 indicates
that the
MIP processing is
done
andthe
systemis
safeto
startthe
new processing.Bit 1
of
Reg_10
is
usedto
selectthe
X2
bus
connectionto
eitherALU1
orALU2. This
selectionmust match
the
ALU
operations.Bit 0 is
usedto
select either erosion(when
it
is
0)
ordilation (when
it is 1).
REG
ADDR
BITS
R/W
Purpose
10
00030C
7
R
OK
to
start next run6
R
OK
to
load
nextinstruction/window
1
W
bus
mode(0=X2-Bus-
ALU1,
l=X2-Bus^
ALU2)
0
W
MU's
max(0=min, l=max)
Table 4.6:
Control
andStatus Registers
Reg_ll in
table
4.7 is
usedto
configurethe
MIP bus
connectionsin
eitherlocal
orthe
PC
mode.If bits 7
to
4
are allzeros, the
MIP is in
PC
mode and one ofthe
memoriesin
the
memory
bank
shouldbe
chosen,
using bits
(3
to
0).
This
will connect one ofthe
memorieswith
the
PC
through
the
XI
bus
for
amemory
read.Otherwise,
the
MIP is in local
mode,
and all
8
bits
are usedto
configurethe
connectionbetween
one ofthe
four
memories andthe
local buses
XI, X2,
andY for MIP
processing.4.3.4
Bus
Interface
Reg_12 in Table 4.9 is
usedto
configurethe memory
segments.Bit 5
ofReg_12
is
aflag
for
a maskload
or amemory
access.When
the
flag
is
0,
bits 4
and3
ofReg_12
selectthe memory
controller which usesthe
addressfrom
the
PC
bus for
either amemory
reador write.
When
the
flag
is
1,
nomemory
controlleris
selected and eachmemory
usesthe
address generated
by
its
ownmemory
controller.The
PC
address controlis detailed
in
table
4.10. Bit
6
ofReg_13
enables writecapability
to the
on-board memories and mask registers whenit is
setto
1.
Its default
valueis
0.
Bits
r
MEMORY SELECT: PC
MODE
REG
ADDR
BITS
R/W
Purpose
11
00030D
7-4
W
0000
for PC
modelsetup
3
W
connectmemory
3
to
PC
2
W
connectmemory 2
to
PC
1
W
connectmemory 1
to
PC
0
W
connectmemory
0
to
PC
MEMORY SELECT: LOCAL
MODE
REG
ADDR
BITS
R/W
Purpose
11
00030D
7,6
W
memory 3
to
local bus
connect(see
Table
4.8)
5,4
W
memory 2
to
local bus
connect(see
Table 4.8
)
3,2
W
memory 1
to
local bus
connect(see
Table 4.8
)
1,0
W
memory 0
to
local bus
connect(see
Table 4.8
)
Note:
referto
Table Y if bits 7:4
are all zerosTable 4.7:
Memory
Select
BITS
SELECT
2x/ + l
2x1
l_
0
memory
>Xl-bus
i
1
memory
?X2-bus
i
0
Y-bus
?memory
i
1
none connectionI is
the memory
No.
Table 4.8:
Memory
to
Local
Bus
Connection
REG
ADDR
BITS