CSE467: Advanced Logic Design

Carl Ebeling, Winter 2004

Homework 4

Distributed: Feb. 13 - Due Friday, Feb. 27 (beginning of class)


Below is a computation that is performed repeatedly on an input stream to produce an output stream.  (Ignore the fact that this is a completely made-up example.) Assume that the variables have been initialized appropriately, that the x[i] inputs are available when needed and that the y[i] output is done implicitly. Assume that multiplies take 10ns. and adds and take 5ns.

     for (i=0;i<N;i++) {

       t1 = x[i] * t6;

       t6 = x[i] + t5;

       t2 = t1 * t6;

       t5 = t1 + t4;

       t4 = t2 + t3;

       t3 = t2 * t5;

       y[i] = t6;

     }

a) Assuming that you have unlimited hardware, what is minimum theoretical clock period that could be used to produce outputs? (Hint: Draw the computation graph and use the max-ratio cycle theorem to find the minimum clock period.)

 

b) What is the minimum clock period that can be used in practice?  Draw a circuit that achieves this clock period.  (Hint: Use a combination of pipelining and retiming on the computation graph.)


Project Problem – Due Friday, Feb. 27

The next step in the project is to build a physical model of a plucked string as described in Rob’s lecture and in the paper by Smith. Figure 17 from the paper gives the basic setup:

 

 

 

 

 

 

 

 

 

 

1) A wavetable (at the left, not shown in the figure), provides an initial impulse to the string. When a key is pressed, the wavetable contents are shifted into the delay-line. This can be done easily by adding the output of the wavetable to the feedback from the filter to the delay-line input, or by selecting the wavetable as the input of the delay line. The wavetable should output 0 when it is not plucking the string. 

2) A delay-line (shift register) that models the length (actually twice the length) of the string. The length of the delay-line determines the frequency of the string. You should not use a shift register to implement this; instead, use a memory, reading and writing one entry per cycle. You can change the length of the delay by using an input that indicates the size of the memory.  This can be set to just about anything dynamically. Note that the frequency is now quantized unless you can figure out how to insert a delay of less than one clock cycle!

3) A simple low-pass (FIR) filter provides frequency-dependent dampening. The low-pass filter should look as in the paper, with coefficients of 0.5. You should experiment with a damping term, e.g. .99, to make the tone die out. You should also check for overflow and “saturate”, i.e. set the result to the most positive or most negative on overflow. You should also perform saturation when adding in the wavetable impulse.

 

Design each of the components of your model with an enable input, which you will assert only when you want to do a new computation. The TakingData from the codec interface then should be used to enable the string model. Since this model is so simple, you can easily generate a sample every cycle, so you can assert DataValid every cycle. The wavetable should always be sending samples: when it is not producing an impulse, it should be producing 0 to add into the delay-line.

 

Use simulation to test your design.  Don’t use the codec interface until you go to hardware – use the audioout_tf module instead so that you can go to a wave file.  About a minute of simulation will give you many seconds of audio.  You may want to prototype this in C just to make sure you understand things.  But it’s so simple, you might as well stay in Verilog.

 

Make sure everything is reset when you start.  Since this is a feedback system, if X’s get into the pipeline, they will propagate.  In particular, use an “initial” block (just like an always block but only executed once at the start of simulation), to clear the memory.  When you synthesize, the initial block will be ignored, but you don’t have to worry about the X’s in the real hardware.  (You could initialize the memory to random values and things would still work.)

The Next (Last?) Project Problem (due. March 5)

Your string model should sound pretty good.  There are lots of ways to play with the sound: you can change the low-pass filter and you can play with the impulse you put in your wavetable. The next thing we will ask you to add is a more complicated filter onto the output of the string model, which will model the resonance of the instrument the string is attached to.  This is the BiQuad filter which is shown in the following figure. We won’t teach you Z-transforms, but the figure shows how you compute the parameters based on the resonant and antiresonant (canceling) frequencies, where T = 1/f.  rp and rz are typically .95 - .99 (rp has to be less than 1) and g must be set to keep the gain of the filter below 1.

 

 

 

 

 

 

 

 

 

 

 

As we saw in class, the BiQuad filter has feedback, aka loop-carried dependencies, so it is not easily pipelined. You should retime your circuit to get good performance; however, you may still need more than one clock cycle to produce a sample.

 

You can play with this filter on the output (or even the feedback) to see what sounds you can generate.  You can even add several BiQuad filters to generate several resonant frequencies.

Extra Credit

Some of you may be ansty to start generating serious sound.  There are many ways to extend this project. These include adding bowing to the string model, adding the ability to play multiple notes simultaneously, modeling an air column instead of a string, or even more interesting, modeling something more stiff, like a bar, or a 2-dimensional object like a gong.  If you are interested in one of these ideas, contact me, or Bruce Hemingway, or one of the TAs.  We will make the book by Perry Cook that has lots of information and ideas available in the lab.  (I would be particularly interested in the 2D idea – the basic model is not all that complicated me-thinks.


ebeling@cs.washington.edu