Lab module 1: part 1 Objectives:

Lab
module 1: part 1
Objectives:
1. Design a digital filter.
2. Build a block diagram for simulation.
3. Run a parameterized simulation.
4. Build a hierarchical model.
5. Use DAVIS to display results and manipulate graphs.
1-1
Conventions:
Please read the lab description first before you start. The tasks can be found in both
lab description or in a box.
• Tasks that are important to the particular lab will be indicated by a ✎
boxed in :
- If there are several steps, they will be numbered (i, ii, iii, ...)
- If there is only one step, it will be indicated by a ◆.
and
• If a task is embedded in the descriptory text, it will appear in underlined bold
type. So please do not overlook these!
• A % indicates a command that should be typed from a UNIX shell window.
As you progress, the steps will no longer be detailed!
1-2
Sample rate converion in Speech Transmission.
Content of the project :
Part 1: Sample Rate Conversion
page 4
Tools introduced: cbde, QED, xsds, DAVIS
A: Design a LPF with QED
B: Test the LPF in COSSAP
C: Use the LPF in sample rate conversion (down sampling) simulation
D: Sample rate reconstruction
Part 2: Create a Dual Tone Multi Frequency (DTMF) Digit
Generator as a Hierarchical Model
page 28
Exercices (optional) :
I. Design Another FIR Filter for Part 1
page 31
II. Design an IIR Filter for Part 1 (A)
page 32
1-3
Part 1: Sample Rate Conversion (48 kHz to 8 kHz)
In order to reduce the sampling rate and to avoid aliasing at this lower rate, you must first filter
the input. You will design a 3400 Hz lowpass filter using QEDesign and run a simple simulation
to demonstrate that the filter works. You will then use this filter in a simulation that
downsamples to 8 kHz.
You will use the provided src_down schematic to downsample from 48 kHz to 8 kHz. The
block diagrams roughly depict the idea. We will use a sine wave generator (sampled at 48kHz)
instead of sampled speech data.
sample rate:
8 kHz
sample rate:
48 kHz
sine wave
generator
write to
output file
lowpass
filter
out_8k.cb
Later, you will build a schematic src_up to upsample from 8 kHz to 48 kHz.
sample rate:
48 kHz
sample rate: 8
kHz
read from
file
out_8k.cb
lowpass
filter
write to
implicit
dataset
automaticallynamed file;
use DAVIS to display
1-4
A. Design a lowpass filter (LPF) with QED.
1. ( ) Login and go to the COSSAP configuration directory (c under your COSSAP project
directory, training). Start up the COSSAP Block Editor, from where you can also launch
the other COSSAP tools.
✎
i. % scp training
This switches you to the training project and puts you in the c directory.
ii.
%
cbde &
The first time you start up the block editor, it will take a while since it builds up all the fonts; it
will not go through this step again next time.
iii. In the COSSAP Block Editor, move the mouse to Tools and hold the left mouse
button and pull down to qed.
You will see some messages like: "QED requires X windows for ..." in the UNIX
window where you started cbde. Then you will see a QEDesign 2000 window with pull-down
menu items.
2. ( ) Design a FIR lowpass filter.
There are Lab Reference Pages after Lab 3. As you do certain tasks in the three labs, please
write down the page number as indicated. Afterwards, the pages will serve as a task index for
you.
☞
Write down this page number in your Lab Reference Pages.
MISC: Filter Design Tool.
✎
i. Use the left mouse button to pull down the menu
Design -> FIR Filter Design
Next
Use the following specification:
sample rate
passband
stopband
passband ripple
stopband ripple
48000
3400
4000
1
40
Next
Use the default Kaiser window method and the estimated number of coefficients (filter length).
You do not need to enter/change the desired filter length.
ii. Note here the number of taps:
1-5
__________
Next
You should now see six plots, each in a separate window.
You can also find the information about the filter by expanding any of the windows to the point
that you see the displayed text under the graph.
To scale the display, use
(1)
Output -> Plot Control
E.g., change the frequency range. Press the Plot button and notice the change in your
displays. Close the window when you no longer need it.
(2)
Press down the right mouse button and select an area in the window of your interest (the
first 4 windows), then release the mouse button and you will notice the in your displays.
Click the right mouse button in the window again to undo the scaling.
3. ( ) Create a (generic) filter coefficient file.
✎
i. Output -> Quantization Options
Quantization Switch -on
Quantization Type -Floating
Number of Bits -24 (length of the mantissa)
In our case, only the section for Realization Type for FIR Filters is pertinent.
No scaling should be selected.
Accept
Close
ii. Output -> Create Coefficient File
lpf4-48
(File Name)
Accept
You will see a message: "lpf4-48.flt has been created."
Close
1-6
4. ( ) Create a COSSAP dataset.
✎
◆
Output -> Create COSSAP dataset
Select the filename that you created above. Use the default options. The field "fixed format"
has no meaning for a floating point dataset. COSSAP cannot process files with comments.
Accept
You should get a message: "lpf4-48.abl has been created."
Cancel
(the Create COSSAP Dataset window)
5. ( ) Leave QED.
✎
◆
System -> exit
6. ( ) You can use the text editor to look at the files with the filter coefficients.
Since you started cbde from your c directory of the training project, the files will be there. You
should now be in the c directory of the training COSSAP project.
lpf4-48.flt contains the QED coefficient output.
lpf4-48.abl is in the ASCII_BL_EOR data format for use as a COSSAP input dataset for
COSSAP model FIRDS.
Conclusion:
You have learned how to:
• design a filter with QED.
1-7
B. Test the filter in COSSAP.
1. ( ) Open the ready-made design schematic for simulation.
✎
i.
File -> Open
Design Type:
Library:
Design:
Schematics
CDIR
lpf_test.sch
OK
This configuration generates a sum of two sinusoids as input and uses the FIR filter. This could
be any kind of FIR filter, e.g., lowpass or highpass, but you will configure it with your LPF
coefficients that you generated in QED.
The add_2sin block is an instantiation of a hierarchical model, indicated by the double-line
horizontal borders of the block. The other blocks with single-line borders are instantiations of
primitive models.
The XWAVE blocks are used to start up displays during the simulation.
2. ( ) Practice zooming in and out of the design.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Zoom.
✎
i.
Press and hold the right mouse button somewhere within the empty space of the
schematic. Pull down to Zoom In. Your mouse cursor should now be a magnifying glass
instead of an arrow.
ii. Press and hold the left mouse button around the area that you want to zoom into. When you
release the left button, you will be zoomed into that area. Note that the cursor is still a
magnifying glass. If you want to further zoom in, press, hold, and release again.
iii. To cancel the zoom operation, press the middle mouse button. Note that the cursor returns
to an arrow.
iv. To return to the full view, press the right mouse button and pull down to Zoom Full.
v. You can also zoom in using the button on the left menu bar. Press the Zoom In button on the
left menu bar. Note the magnifying glass mouse cursor. Instead of selecting an area by pressing
and holding the left mouse button, you can also simply press the left mouse button once on the
area in which you want to zoom.
vi. Return to the full view.
1-8
3. ( ) Look at the online information for FIRDS.
✎
i. click with the left mouse button on FIRDS (the arrow should point to somewhere
within the block border, but not on any of the text inside the border). The block border should
have changed from solid to dashed lines.
If it does not, press the middle mouse button to cancels whatever you had selected and select
FIRDS again.
ii. While the block is still selected (indicated by the dashed lines) move the mouse outside
of the block. Hold the R mouse button. Note that you get the Zoom menu.
Now move the mouse within the selected block. Hold the R mouse button. You see a menu
which applies to this selected instance. Pull down to View Mdef.
You can now view the model definition file of this instance.
The file has read-only permissions (i.e., you can not change it).
The words that start with a period (.) are called tokens. You will probably be most interested in
the DESCRIPTION. When it comes time to configure the instance you will probably be
interested in the PARAMETERS, INPUT_PORTS, OUTPUT_PORTS, INPUT_DATASETS,
and OUTPUT_DATASETS. Note that not all models have parameters, input datasets, etc.
iii. To close the window displaying the mdef file,
File -> Exit
4. ( ) Configure FIRDS with the coefficients of the filter you designed.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Configure an input dataset.
✎
i. Make sure that FIRDS is still selected (border in dashed lines). With the mouse inside
the block, use the R button to pull down to Configure Instances.
Leave the Implementation set as DEFAULT_IMPLEMENTATION.
ii. For the Input Dataset, you must assign a dataset ID (some "handle" or mnemonic by which
you refer to the entire dataset). Click on the blank field under ID and enter, e.g., coeffs.
You may leave the File Type as implicit (default).
iii. Click on the field under File Format and hold the R mouse button. You will see a list of
different file types. Pull down to ASCII_BL_EOR. QED writes out coefficients in this format.
iv. Click on the field under File Name and enter:
1-9
${COSSAP_USER_C}/lpf4-48.abl
v. OK
(Currently, if you do not fully specify the filename with path information (or use a COSSAP
environment variable) but simply type lpf4-48.abl (without prefixing it with the COSSAP
environment variable), your design would pass the check design step, since it looks for the file in
the project's c directory. However, when you simulate, you would get a message like: Cannot
open file. Unknown file.)
To be explicit about the location of your file, you may prefix it with the COSSAP environment
variable, ${COSSAP_USER_C}, referring to your c directory, your configuration directory.
Likewise,
${COSSAP_USER_D} refers to your d (development) and
${COSSAP_USER_V} refers to your v (viewing) directory.
5. ( ) Check the design for errors (e.g., unconfigured instances, unconnected instances).
✎
i. Click on the Check Design icon on the top toolbar. You will see the situations that are
checked. You can designate what situations should be checked and whether warnings or errors
should be communicated. You can use the defaults. Push the Check Design button.
ii. You should see the message: CONGRATULATIONS, NO ERRORS!
If you do not, correct the errors and/or warnings and check your design again. When you get the
above message, Cancel and Close both of the Check Design windows.
(If you get the message Symbol out-of-date, cancel the check design windows. Go to the
Edit menu and pull down to Update Symbols. If all symbols are updated, this Edit -> Update
Symbols menu option will be grayed out.)
6. ( ) Run the simulation.
The exit mask has already been set for this example. The two XWAVE blocks comprise the
mask. To see the exit mask, select the ATTRIB TABLE icon on the top toolbar. You will see
that both xwave instances M3 and M2 belong to Mask 01. There are no other exit masks set.
The simulation ends once both XWAVE blocks have set their exit flags , i.e., processed
SignalElementsToProcess (which have been pre-configured to 1000 for each of the XWAVE
blocks).
☞
Write down this page number in your Lab Reference Pages.
SIMULATION: Run a Simulation.
✎
i. Create a netlist for simulation.
Netlist -> Create
1-10
Your Target should be the COSSAP Stream Driven Simulator (SDS).
Library should display CDIR. Netlists for the SDS can only be created in the c directory.
The Name contains the automatically assigned netlist name and cannot be changed.
You can enter a short description which will appear under the .SHORT_DESCRIPTION token in
the to-be-generated model definition (.mdef) file. If your netlist name was, e.g., 355, there
would be a s00355.mdef file in your c directory after this create netlist step.
ii. Push the Create&Start button.
Standard output messages appear in the window from which you started the CBDE. You will
see messages like the following:
☞
Possible errors:
• If you see the words UNKNOWN DATA-TYPE, doublecheck the configuration of the FIRDS
input dataset. Your file format is probably incorrect.
(There is a certain amount of overhead involved when utilizing the interactive displays. The
start-up may be a little slow depending on your workstation. This has nothing to do with
simulation speed.)
You should see two windows open up for displaying the input and the output of the filter. Note
that the high frequency sinusoid has been filtered out.
How do you know which monitor corresponds to which block in the block diagram? Turn the
page ...
1-11
☞
Write down this page number in your Lab Reference Pages.
SIMULATION: What instance does the interactive display correspond to?
You can find out which xwave display corresponds to which block output simply by selecting
the graph within its sheet, then automatically the corresponding name is highlighted in both the
workbook and dataset windows. The window is displaying the output samples of this
highlighted instance name. If the instance name contains a dot separator, that indicates a
hierarchical model. E.g., M0.M2 means instance M2 of the hierarchical model M0 (at the top
level of the schematic).
iv. What is the model label name (the name on the block) of the M0.M2 instance?
__________________
Hint: Select the M0 instance. Now the Push In icon in the top toolbar is selectable (i.e., no
longer greyed out). Push the Push In button. Find the instance name M2.
v. You may close both DAVIS display windows. To close a DAVIS display window, pull down
the menu with the left mouse button
File -> close for the last appeared DAVIS window ( slave window )
File -> exit
for the first appeared DAVIS window ( master window )
1-12
In fact the first appeared DAVIS window is the master and the second one is a slave monitored
by it. Deleting the master would directly delete both windows.
This is the clean method; don’t use the window manager menu to close the window.
7. ( ) Save the schematic (overwrite the lpf_test schematic).
✎
◆
File -> Save
select lpf_test.sch
OK
You can also simply click on the <Save File> symbol under edit to save the changes to the same
file.
Conclusion:
You have learned how to:
• configure a model with an input dataset
• start a simulation
You have seen:
• xwave DAVIS displays
1-13
C. Use your LPF in the sampling rate conversion simulation.
1. ( ) Close the lpf_test schematic (File -> Close). Open the src_down schematic. This
design downsamples a 48 kHz sampled sine signal to an 8 kHz sampled signal. The design uses
the DMPNR block which saves samples to a file. The frequency of the sine wave is a
simulation parameter.
If we were going to use this schematic with real 48 kHz-sampled speech data, we would replace
the add_sin block with the RSTR block. RSTR would restore samples from an input file.
2. ( ) Configure the instances.
✎
i. Configure the FIRDS input dataset with your filter coefficients.
Select FIRDS.
Hold the R mouse button and pull down to Configure Instances,
OR press the Config icon in the top toolbar.
ID:
File Type:
File Format:
File Name:
coeffs
implicit
ASCII_BL_EOR
${COSSAP_USER_C}/lpf4-48.abl
ii. Configure the parameter, DecimationFactor, of SRDEC with the value 6.
Select SRDEC.
Press Config icon.
Set the Parameter Expression to
6
iii. The DMPNR blocks have been partially configured for you. DMPNR requires both
parameters (indicating which samples to save to a file) and an output dataset.
Select one of the DMPNR blocks and then select the other DMPNR block by using the middle
mouse button. Both DMPNR blocks should have dashed borders. Push the Config button in the
top toolbar.
You should now have two Configure Instance windows, one for each DMPNR instance. The
window title indicates which instance name (M1 and M2).
What is the SAMPLING_TIME configured to for:
DMPNR (M1)
_________________
DMPNR (M2)
_________________
1-14
This SAMPLING_TIME is used by DAVIS when displaying the samples saved by DMPNR,
where the default plot format is to display sample value vs. TIME. This value is only to aid you
in understanding the time associated with the samples.
iv. Configure the output dataset for each of the DMPNR blocks.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Implicit / explicit output dataset.
The default file type (IMPLICIT) indicates that data will be written to an automatically named
COSSAP_BINARY (default format) file.
Note the scroll bar under the Output Dataset attribute. The scroll bar is here because all the
fields do not fit in the display window. Move the slider to the far right. Now you can see the
Plot Format. If this output dataset is displayed in DAVIS, the default plot format (1) will be to
display the samples vs. TIME. To see the other plot formats (used when displaying the data in
DAVIS), select the field under Plot Format and hold the right mouse button.
We will accept the default values for DMPNR instance M1, but we still must assign the dataset
id. This should be a name that's intuitive to you, e.g., in_48k, for DMPNR (M1). We do not
need a file name since this will be assigned automatically (IMPLICIT file type).
We would like to save the data in DMPNR(M2) to an explicitly named file so that we can use it
in the next section of lab, where we will reconstruct the 48 kHz signal from the 8 kHz signal.
Since we will be using DAVIS to display this file and we will also be using this file in our next
simulation, this file should be written to the c directory. Configure the output dataset, e.g., with:
ID:
File
File
File
Plot
Type:
Format:
Name:
Format:
out_8k
EXPLICIT
COSSAP_BINARY
${COSSAP_USER_C}/out_8k.cb
1
v. Everything should be properly configured and connected. Check the design. Push the
Check Design icon in the top toolbar. Fix any error messages until you get the message:
CONGRATULATIONS, NO ERRORS!
SIN_GEN_TBL has been pre-configured for you. Take a look at the parameters. A variable,
$SIN_FREQ, has been used. This variable is a simulation parameter and must be set to a
numerical value in the assignment file.
3. ( ) Assign a value to the simulation parameter.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Assign a value to a simulation parameter.
1-15
✎
i.
Netlist -> Create
In the text area for the Assignment, type: src_down.asn
Push the Edit button.
You are now in the default editor.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Change default editor.
To change the default viewing editor to xedit, for example, put the
following in your .cshrc file:
setenv COSSAP_VIEWER xedit
This would be used when you can change files, e.g., when creating an
assignment file.
For those non-UNIX experts : exit the COSSAP block editor, logout of
your account and login again in order that the environment variables are
changed.
You see several lines that start with dash-dash (--). These are comments. A terse syntax
explanation is available in the file comments. See Block Diagram Editor (index: assignment
files) for more information.
ii. Edit the file to set the SIN_FREQ simulation parameter to equal 1700.
{
SIN_FREQ := 1700; -- (I)
}
iii. Save the edited file (e.g., in vi edit mode, :wq! )
iv. Stay in the Create COSSAP Netlist window.
4. ( ) Create a netlist and start the simulation.
✎
i. Write down the simulation number:
________________
ii. Create&Start
Note that very time you click on the Create or Create&Start the simulation number will be
incremented by 1.
5. ( ) Display the results in DAVIS.
☞
Write down this page number in your Lab Reference Pages.
DAVIS : Display results.
1-16
✎
i.
In the COSSAP Block Editor, start DAVIS (Tools -> DAVIS). Open the
simulation by clicking on the button File -> Open Simulation.
Make sure that the simulation number of the netlist you wrote in step (4) above is already set in
the number dropdown of the “open simulation” dialog window, which shoud be the case if the
simulation has properly ended. Alternatively, you can click on the popup menu arrow beside to
see what simulations have completed and are available for viewing in the v directory. If you do
this, you select the netlist (simulation) number just by clicking on it.
Select the dataset in_48k by clicking on it in the dataset list box and then press the OK button.
Now you see the sin_gen_tbl block output appearing on the DAVIS window. You can have a
more precise view of the graph simply by zooming on an area of the graph : for that purpose
simply push the + key of the keybord and select an area in the graph bu draging and droping the
mouse. If you want to see the whole waveform again click on the zoom full button.
ii. In order to overlay the now appearent waveform with the out_8k graph, open the simulation
like before, select the in_8k dataset, select Visuallization -> To Selected Sheet and click on
the OK button.
Now you see the two waveforms. The delay for the first sample to "ripple" through the long FIR
filter is apparent. To remove the filter delay and have a better signal alignment, you can use
DELR model to delete the filter delay at the beginning of the simulation; see part D.
Conclusion:
You have learned how to:
• configure instances with parameters and datasets
• set up a simulation assignment file
• use DAVIS to display results
1-17
☞
Write down this page number in your Lab Reference Pages.
DAVIS : Graph symbol.
graph symbol : here a lozange
6. The waveforms are shown with lines connecting the samples. To demonstrate the difference
in samples/unit time, change the graph attributes to show sample markers.
☞
Write down this page number in your Lab Reference Pages.
DAVIS : Change attributes of graphs.
Double click either on the waveform or on the corresponding graph name in the Visualization
box. The Graph Options dialog box should appear as it is represented on next figure :
1-18
Cross the Show check box of the Markers area and select the squares in the Type dropdown.
Make them smaller or bigger by using the Size dropdown and select the color you prefer by
using the Color dropdown. You can see the results of these modifications by clicking on the
Apply button.
Now quit this Graph Options dialog box and repeat the same operation for the other waveform :
this time you may add circle markers.
Now let’s see how to scale the display other than using the zooming device. Just double click on
the framed coordinate at the top of the y axis. Then a Zoom Area dialog box appears on the
screen, like in next figure :
1-19
Now you can change the attributes inside each edit box in order to define the limits of the area
containing what you want to see. You may also want to have a global view of the graph for one
or both dimensions : click on Fit X, Fit Y or Fit X-Y buttons if so. Once you have finished
playing with the scaling capabilities close the dialog box and return to the main DAVIS window.
At last close the DAVIS application by selecting file Æ exit in the master DAVIS window and
without saving the changes when you are proposed to.
Try and increase or reduce the size of the displaying window. Select one of the bottom
corners of the window frame and drag it outward to make it smaller. Note that its contents
doesn't shrink.
If you want to resize the picture within the displaying DAVIS window, you must click on the
Zoom + button ( or simply press the + key of your keybord ). Then you can see that your mouse
pointer is no longer an arrow but a zooming pattern. Now drag the mouse in order to surround
the area you want to display, then drop it.
If you want the largest diplay of your picture,click on the resize full button :
at the bottomright part of the DAVIS window. It is also possible to make zooming in only the x or y
dimension by clicking previously on one of the lock button :
also at the bottom-right part
of the DAVIS window. Clicking on both of them will freeze the zooming capabilities of
DAVIS.
☞
Write down this page number in your Lab Reference Pages.
DAVIS : Resize picture.
1-20
D. Use your LPF in the reconstruction (8 kHz -> 48 kHz) sampling rate
conversion simulation.
1. Iconize or exit DAVIS, and in cbde, if you still have it up. Save then close the src_down
design schematic.
2. ( ) Now you will create a schematic from scratch to reconstruct the 48kHz signal from the 8
kHz signal which you stored to the file out_8k.cb in your c directory. The blocks you will need
are depicted in Figure 2:
RSTR
SREXP
FIRDS
DELR
MULS
DMPNR
Figure 2
✎
i. Instantiate the necessary models.
Click on the Instance button in the left toolbar.
Select the text window by Select Models by and hold the left mouse button. You can
choose your models by names, libraries, etc. Since you have been given the names of the models
and they come from different libraries, Names will be the most useful for you.
1-21
Select the text field by Model Name Filter and type rst*. Now in the Models window all
models that start with the rst string (case-insensitive) are displayed. You can now select RSTR
from the window and its one line description is displayed..
Now when you move the cursor to the schematic area you'll see a crosshair mouse cursor and an
outline of where the instance will be placed if you press the left mouse button. Press the left
mouse button in the place where you want to instantiate RSTR.
Move the mouse and notice that you still have the crosshair cursor and the outlined instance.
You can continue to place RSTR instances by pressing the left mouse button.
Since we only want one instance, press the middle mouse button to cancel the operation. Note
the cursor returns to an arrow.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Instantiate models.
Continue instantiating the other models.
You can change the orientation of the model during instantiation or after you have instantiated it.
During instantiation, when you are in the schematic area and see the outline of the instance, press
the right mouse button and you can rotate, flip horizontal, or flip vertical. After this, you will
see the outline of the newly-oriented instance. Press the left button to instantiate the model in
the cbde. You can press the right mouse button again and change the orientation again.
Once you have instantiated a model, you can change the orientation by selecting the block and
holding down the right mouse button within the block.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Change orientation of instances.
ii. Connect the instances with nets.
Zoom in a little closer on the instances that you want to connect. Push the Net button on the left
toolbar.
Click on the triangle output port of the RSTR instance and click on the input port triangle of
SREXP. You should now see both triangles filled in, indicating a connection between the two
instances. Remember that you are still in net connect mode until you press the middle mouse
button to cancel it (or select some other functionality, e.g., the select button).
Continue connecting the instances.
1-22
iii. Configure the instances as follows:
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Configure instances.
RSTR input dataset
ID:
in
File Type:
IMPLICIT
File Format:
COSSAP_BINARY
File Name:
${COSSAP_USER_C}/out_8k.cb
(the file which we wrote to in the src_down design)
SREXP
RateFactor
$upsample_value
By configuring this parameter with a COSSAP variable (starting with a $), we are creating a
simulation parameter.
FIRDS
(same as in the last simulation ...)
ID:
coeffs
File Type:
IMPLICIT
File Format:
ASCII_BL_EOR
File Name:
${COSSAP_USER_C}/lpf4-48.abl
DELR
NUM_ITEMS
($FilterLength-1)/2
if odd $FilterLength is odd, and
$FilterLength/2
if$FilterLength is even. Or int($FilterLength/2).
(This DELete Real model is needed because of the delay through the downsample filter and this
upsample filter, where we assume we're using the same filter)
MULS
Scalar
(scaling)
real($upsample_value)
DMPNR
FIRST_ITEM
1
NUM_ITEMS
500
SAMPLING_TIME
1/48000.0
If you do not use the real number 48000.0 (as opposed to the integer number 48000), you will
get an integer divide and SAMPLING_TIME will be considered to be 0.0.
For the output dataset, use the defaults and assign it a dataset id, e.g., reconstruct_48k.
Remember, no filename is necessary since the File Type is IMPLICIT (automatically named).
iv. Set an exit mask that contains DMPNR.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Set an exit mask.
1-23
Edit -> Attributes
(Alternatively, you could have chosen the ATTRIB TABLE icon on the top toolbar).
The SDS index tab stands for Stream Driven Simulator. DCG stands for DSP Code Generator.
Make sure the SDS tab is selected.
We will only be setting one exit mask. In the column under Mask 01, for the dmpnr instance,
type or pull down to YES.
OK
v. Check the design for errors.
You should see three messages (non-verbatim):
(1) Design (untitled). You must save the schematic as, e.g., src_up.sch. (File -> Save As)
(2) Unsupported data type for parameter FilterLength. This is a simulation parameter which we
used to configure DELR. COSSAP cannot infer the data type (real or integer). We must define
the type (step vi).
(3) rstr is not included in any exit mask. It is possible to include RSTR in an exit mask, but we
have excluded it (NO) in step (iv) above. This message is OK for this design.
Take care of any other error messages you see.
vi. Define the simulation parameters' types.
Edit -> Configure Design
This window displays all the simulation parameters and what instances have been configured
with simulation parameters. Note that the Type for FilterLength is <?>. This must be declared
as I (integer) or R (real).
Select the text field for the Type of FilterLength.
Hold the right mouse button and pull down to I.
vii. Check the design for errors.
You should only see the warning about rstr and the exit mask.
3. ( ) Create an assignment file to configure the simulation parameters.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Create an assignment file.
✎
i.
Netlist -> Create
In the text area for the Assignment, type: src_up.asn
Push the Edit button.
ii. Edit the file:
1-24
{
FilterLength
:=
upsample_value :=
<X>;
6;
-- (I)
-- (I)
}
where <X> = the value you wrote down in Part 1, e.g., 179
iii. Save the edited file (e.g., in vi edit mode, :wq! )
iv. Stay in the Create COSSAP Netlist window.
4. ( ) Create a netlist and start the simulation.
✎
i. Create&Start
ii. Write down the simulation netlist number:
________________
PROBLEMS?
error in input dataset ...
• Did you fully specify the filename, including the path, e.g., ${COSSAP_USER_C}/...?
• Is the file the right file type?
5. ( ) Save the schematic as src_up.
6. ( ) When the simulation is done, use the DAVIS window that you opened in Part 1 (C) (if
exited, start up a new one) to display the results.
Push open simulation button
Make sure the simulation number is selected
in the Visualization window dropdown select To Same New Sheet
in the Display New Sheet window select In New Window
press OK button when done.
A new slave DAVIS window should appear. You should see the reconstructed sine wave on it,
again at the 48 kHz sample rate.
If you see one value at x=0, check the configuration of the DMPNR instance.
SAMPLING_TIME should be 1/48000.0 (i.e., divided by a REAL number). Re-run the
simulation.
ii. Calculate the FFT of this signal in DAVIS.
☞
Write down this page number in your Lab Reference Pages.
DAVIS : Calculate an FFT.
Push the calculator button : a calculator should appear :
1-25
click on the FFT header
then type mag(fft(reconstruct_48k_07004_1)) in the result;
Instead of typing, you can also click mag, fft and then
double click reconstruct_48k_07004_1 in the simulation
result dataset in the calculator browsing window.
Push the Apply button and then the calculation results
should automatically replace the current graph in the DAVIS
window. Close the calculator.
If you want to see both graph and its fft magnitude then in the same DAVIS window :
click on the Windows menu
select Show All Sheets Æ In Splitters
iii. Open up another picture to display the FFT result.
☞
Write down this page number in your Lab Reference Pages.
DAVIS : Open up another DAVIS picture.
click on the Windows menu
select Show All Sheets Æ In Windows
Now you see the FFT of the 1700 Hz sine wave that we've reconstructed in a new DAVIS
window.
iv. Calculate the FFT of the original sine wave signal from the src_down simulation.
1-26
Open the simulation with the Part C(4) simulation number
dataset id : in_48k
select To Same New Sheet and In New Window
Now you see the waveform of the original 48 kHz signal in an other new slave DAVIS window.
Calculate the FFT of this signal and when doing it
select also To New Sheet and In New Window in Calculator
Instead of using the whole in_48k signal, you can also
Select, say, in_48k[1..500], for the calculation of FFT.
Now you see the FFTs of both signals in two different windows. You may see both on the same
window simply by draging one different result into an already displaying window.
Conclusion:
You have learned how to:
• create a simulation from scratch
• create an exit mask
• use and define a simulation parameter
• use DAVIS to calculate an FFT of a waveform
1-27
Part 2: Create a DTMF digit generator as a hierarchical model.
Create a hierarchical model called ADD_SIN that adds two sinusoids. It should have three
parameters: sin1 (frequency of sinusoid 1), sin2, samp_freq.
SIN_GEN_TBL
ADD2
SIN_GEN_TBL
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Create a hierarchical model.
1. ( ) Create a new file. Insert and configure the instances. Use ADD2 and two instances of
SIN_GEN_TBL.
To configure one of the SIN_GEN_TBL models use, for example:
NumberOfItems
= int(10 * $samp_freq / $sin1)
NumberOfPeriods
= 10
A
= 1.0
Leave the Configure Instance window open; let’s call this M0.
(Recall: the integer parameters NumberOfItems and NumberOfPeriods are defined as follows:
since 2π(f/fs) NumberOfItems=2π NumberOfPeriods, f/fs=NumberOfPeriods/ NumberOfItems.
As long as this ratio is correct, the correct sine wave will be generated.)
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Copy parameters from one instance to another.
Select the other instance of SIN_GEN_TBL and open its Configure Instance window; let’s call
this M1.
In the M0 Configure window, select Expression in the Parameter row. You should see all three
parameter values highlighted:
Edit -> Copy Row
In the M1 Configure window, select Expression in the Parameter row. You should see all three
parameter values (blank) highlighted:
Edit -> Paste Row
Change $sin1 to $sin2.
1-28
That is, the other SIN_GEN_TBL model should be:
NumberOfItems
= int(10 * $samp_freq / $sin2)
NumberOfPeriods
= 10
A
= 1.0
2. Route the nets from the SIN_GEN_TBL models to ADD2.
3. ( ) Indicate and rename the output port.
✎
i. Push the OUTPUT button from the left toolbar.
Move it to the area in the schematic where you would like it, and press the left mouse button to
instantiate it.
ii. Push the NET button. Route the net from the ADD2 Output port triangle to the output port
you just placed.
iii. Rename this output port to add_sin_out.
Edit -> Configure Design
Select the text field under Output Port Name and change the automatically generated name
to add_sin_out.
Stay in the Configure Design window.
4. ( ) Define the data types of the parameters we are using, which will become parameters of
our hierarchical model.
Lengthen the window a little. Note that more parameter names show up in the window. Note
that the types of the parameters are <?>. We must define these to be R (real) or I (integer).
Define all of them to be I (integer). You can do this at once by selecting Type and then setting it
to I. (You can ofcourse define it to be R (real)).
5. ( ) Check the design.
You may see an error message about an untitled schematic. In fact, this is ok for an hierarchical
model, since after the model creation (see below), the schematic is automatically saved.
However, you can also save your schematic.
6. ( ) Create the model and put it in the training library.
☞
Write down this page number in your Lab Reference Pages.
BLOCK EDITOR: Put hierarchical model in a library.
✎
◆ Netlist -> Create
This time your Target should be set to COSSAP hierarchical model instead of COSSAP
Stream Driven Simulator.
Library: TRAINING
Name:
add_sin
1-29
Create Symbol: (should be marked)
Add a Short Description (optional).
Creat
7. ( ) Test your hierarchical model using the lpf_test schematic.
i.
Open the lpf_test schematic that you were using in Part 1 B.
ii.
Select the add_2sin instance.
iii. Edit -> Delete
iv.
Add the instance add_sin that you just created in the place where add2_sin was. If you
place its port right on the remaining net, it will be connected (indicated by the filled
triangle). If not, you will need to connect a net going out of add_sin to the remaining
portion of the net.
v.
Configure your add_sin block with:
sin1
2400
sin2
5000
samp_freq 48000
Note that the text “2700 + 6500 Hz.” on the schematic was inserted manually. It has nothing to
do with what you configured your add_sin with. You may want to either delete this text or
change it to correlate with the configuration you used.
vi. Make sure that the target is set back to Stream Driven Simulator!
Create&Start the simulation. If you get a message that the replacement model, add_sin, is outof-date with respect to its master, do the following:
Edit -> Update Symbols
Update
Conclusion:
You have learned how to:
• build a hierarchical model
• edit your schematic
1-30
EXERCISE I. Design another FIR filter with QED.
Use similar design specifications as you used in Part 1 (A). You may want to change, e.g., the
window or maybe the passband and/or stopband ripple. Use the layout, src_up, that you used
in Part 1 (D) and run a two iteration simulation. The first iteration would be with the original
FIR, the second with the new FIR.
Use a parameterized input dataset for FIRDS. For the dataset id of FIRDS, enter a variable,
e.g., $coeff_id. The other dataset fields will then be ignored.
You will then make the assignments in an assignment file. Your assignment file should look
like:
{
FilterLength
:= (the length of your first FIR);
upsample_value := 6;
coeff_id
:= ("coeffs1", 0, 0, 'i', "ASCII_BL_EOR",
"${COSSAP_USER_C}/lpf4-48.abl");
}
{
FilterLength
:= (the length of your second FIR);
upsample_value := 6;
coeff_id := ("coeffs2", 0, 0, 'i', "ASCII_BL_EOR",
"${COSSAP_USER_C}/NewFilterName");
}
1-31
EXERCISE II. Design an IIR filter.
Use the same specification as in Part 1 (A). Use the default settings (bilinear transformation,
cascaded 2nd order, elliptic). Note the savings in coefficients needed. Note the non-linear phase
and the pole-zero plot.
Save the coefficients in a COSSAP input dataset. To do this, you must quantize the coefficients
and then save the coefficients to a file before making a COSSAP dataset.
Output
-> Quantization Options
Quantization Switch -on
Quantization Type -Floating
Number of Bits -24 (length of the mantissa)
When selecting quantization options, choose the second order section (floating point -- 4
multiplies) under the category, "Realization Type for Cascaded Sections." The other sections,
e.g., "Realization Type for Parallel Sections," etc. do not apply to our filter.
The locations of the poles and zeros affect the frequency response of the system. Poles near
points of the unit circle correspond to frequencies to be emphasized; zeros correspond to
frequencies to be de-emphasized. Poles must be within the unit circle in order for the filter to be
stable.
To experiment with the effect of poles and zeros, use the Design -> Graphical
Pole/Zero Design feature of QED. Selecting File -> Input will copy the poles and
zeros from your IIR design. You can then move them around, etc., and see the effect it has on
your magnitude response. Select the Object (Pole, Zero), and then you can place the
mouse on such an object and move it around.
Create a COSSAP simulation to demonstrate that the filter works. In place of FIRDS, you will
have to use the IIRDS_CBQ4 (IIR defined by DataSet Cascaded Biquad Structure, 4 multiplies)
model.
1-32
`