section8soln.doc

advertisement
10/19 & 10/21
CS150
Section week 8
Solutions in red
This week: Successive Approximation Design( HW8, #1 ), Top Down Design ( Project ), Clocking ( ~HW7, #3 )
If there’s extra time: Video Details (Checkpoint #2), UART ( Serial communications -Checkpoint #1), Interfacing
With Other Devices ( General Interest... )
1.
Successive Approximation Design / Top Down Design
The idea of Successive Approximation Design is that you make a guess at an answer to a
problem, then get some new information from the results of your guess that tells you how to make a better
guess the next time.
For example:
You go bowling. Your first ball goes in the left gutter. What do you do? You throw the next one
farther to the right... You’ve guessed and then got some information from the results of your guess to
make it so you can make a better guess the next time you throw the ball.
There are a couple of approaches to solving this problem.
After throwing the ball into the left gutter, you could adjust your throws one degree to the right at
a time until you get the results you want. This may take some time.
Or you could turn 90 degrees to the right and throw it into the next lane, which would give you
the information that you went too far to the right... Then you could adjust your throw 45 degrees back to
the left, then 22.5 degrees, then 11.25 degrees, etc., which would, in a lot of cases, get you to your desired
results quicker than the first method.
These are two examples of choosing a usable adjustment amount. There is also the chance that
you choose to turn 180 degrees the first time and throw the ball into the refreshment stand which wouldn’t
give you much helpful information and you might never figure out which way to throw the ball. This is an
example of a bad adjustment amount.
It is also important that you pick a starting point that will not lead you off in a wrong direction. If
you throw the bowling ball while you’re in the bathroom it won’t give you any real useful information...
Problem:
Following the Top Down Design steps done in class, design a circuit which calculates the square
root of an 8 bit number.
Following the top down design steps talked about in class:
1. Understand problem: Design circuit which calculates the square root of an 8 bit number. Let’s also
add that only squares of integers can be used as inputs ( just to make the circuit simpler ).
2. Identify inputs and outputs of circuit: We’ll need the NUMBER and the CLK as inputs, and the
SQRT as an output. Since we’ll be using successive approximation as our algorithm, we’ll also need
an input to tell the circuit to make its first guess, START.
3. Decide algorithm: Not giant so inputs & outputs
NUMBER[7:0]
should be fine in parallel. And we’ll use
successive approximation to find SQRT.
START
4. Rough block diagram:
SQRT[7:0]
CLK
First think of the parts you’ll need. You’ll need
something to save your guess values in between evaluations and recalculations ( a register ). You’ll
need something to calculate next guess ( a block ), and you’ll need something to evaluate your guess (
another block ).
Next/First
Present
Guess
Guess Logic
START
Guess
Next Guess
Evaluation
Guess
DONE
NUMBER[7:0]
CLK
Present guess so you can make next guess
Information on how good guess was for making next guess
To evaluate guess, need NUMBER
SQRT[7:0]
4b. If any block is more complicated than something on the level of a Xilinx component ( multiple
functions in a single block, functionality that you can’t easily understand... ), go back to #1 for that block.
Back to #1 for Next/First Guess Logic Block
1. Understand specs. Makes first guess and
subsequent guesses.
2. Identify inputs and outputs.
Back to #1 for Guess Evaluation Block
1. Understand specs. Gives information
On how good your guess was. Tells you
when you’re done.
2. Identify inputs and outputs
START
NUMBER[7:0]
NUMBER[7:0]
INFO
8
New Guess
8
8
DONE
GUESS[7:0]
INFO
8
DONE
GUESS
8
INFO: We’ll have more information about this
after we decide which algorithm to use.
INFO: See what information the Next/First
guess block needs then define.
2. Decide algorithm.
2. Decide algorithm.
Not too big so parallel input and output should be
Parallel input and output.
fine. Pick a simple algorithm.
Evaluation method:
First guess = ¼*NUMBER[7:0]
Square guess and compare to NUMBER.
If !DONE
If GUESS is too big
3. Block diagram
Square
Next guess = previous guess – 1
COMPM8
Guess
else
GUESS[7:0]
Next guess = previous guess + 1
LT
8
GT
8
So now we see we need to know if GUESS
was too big or small. So let’s make INFO
information from the evaluator whether the
NUMBER[7:0]
GUESS was too big or not ( GT ).
8
3. Block diagram
BRLSHFT8
NUMBER[7:0]
8
New Guess
8
Shift
Amount
=2
8
ADSU8
GUESS[7:0]
START
+/1
INFO ( GT=1 then ‘-‘, GT=0 then ‘+’ )
Things to get out of this exercise: Process of top down design
How to draw block diagrams
Steps after completing the block diagrams: 5. List control signals ( none for this design ), 6. Generate
timing for control signals ( none ), 7. Design/simulate data path, 8. Design/simulate controller, 9. Put
together.
DONE
INFO(GT)
2.
WE changes on the falling edge of the clock.
Everything else changes on the rising edge of the clock.
When drawing the STD for this circuit, consider the CLK
value when assigning states and use the CLK value as an
input value on your arcs between states.
Clocking
a. Using the falling edge of the clock
Timing for SRAM write ( from lab 7 )
Three cycles:
Two cycles:
CLK
CLK
OE.L
OE.L
0
WE.L
WE.L
DATA/
ADDR
ENABLE
DATA/
ADDR
ENABLE
DATA/
ADDR
DATA/
ADDR
b. Two phase clocking
Gives you more rising edges to run your logic off of. Extra edges may make it possible to speed up circuit.
c. Two phase non-overlapping clocking
3.
Makes it possible to work with level sensitive
components in a circuit that has feedback. ( Q. Why’s
this good? A: Think about how this would make memory components possible. ) Most times level sensitive
components are faster than edge triggered components. How could you use this to
Homework #7, problem #3
make your circuit faster?
You are given a 16MHz clock. Generate a glitch free clock signal with an average frequency of
4/13. ( 16MHz  4.92MHz ).
12
0
1
2
3
4
5
6
7
8
9
10
11
12
0
16MHz CLK
Some possible clocks: a)
4.92MHz
CLK
b)
c)
Clock edges are what’s important, not duty cycle.
PS3
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
a.
Implement using ROM ( Using clock b). )
PS2
0
0
0
0
1
1
1
1
0
0
0
0
1
1
1
1
PS1
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
PS0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
NS[3:0]
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
0000
0000
0000
0000
CLK2
1
0
0
1
0
0
1
0
0
1
0
0
0
0
0
0
ROMs
N3=0x0f80
Register
N2=0x0878
N1=0x0666
PS
NS[3:0]
PS
N0=0x0555
OUT’
OUT=0x0249
OUT
b.
Implementing with Counters
Some possible STDs:
Simplest ( using clock a). ):
OUT=1
OUT=0
OUT=0
OUT=1
OUT=0
OUT=0
OUT=1
OUT=0
OUT=0
OUT=1
OUT=0
OUT=0
OUT=1
Using multiple FSMs ( using clock c). ):
Clock click #7 or #8
LOOP 3
LOOP 4
Clock click #10 or #11
LOOP4
LOOP3
Wait
Output
ignored
Wait
Output
ignored
OUT=1
LOOP3
LOOP4
LOOP3
LOOP4
OUT=0
OUT=1
OUT=1
OUT=0
OUT=0
OUT=1
And then there’s the single FSM + counter ( using clock a). ):
Reset is counter reset.
OUT=1
Reset=1
Count = 12
OUT=1
Reset=0
OUT=0
Reset=0
Count = 3 OR Count = 6 OR Count = 9
How would you make this self starting?
Download