The goal of this assignment is to train students on the concepts related to the generalization of the HB technique from the single-tone to the multi-tone excitation. The target
circuit used for this purpose is the doubly-balanced mixer circuit shown in Figure 1.
VDD VDD
RD RD
RL
VRF1 VRF2
VLO1 VLO2
Vout1 Vout2
Xb
Xa Xb
Xa Xb
Xb
Xa
Xa
IO
Figure 1: The circuit schematic
This circuit is simulated by two sources of two different frequencies. The first source
is the output of some local oscillator, whose waveform is given by
vLO1(t) = −vLO2(t) = 0.125 × sin
2 × π × 109 × t
(1)
and the second source is the waveform of some RF frequency given by
vRF1(t) = −vRF2(t) = 0.0125 × sin
2 × π × 900 × 106 × t
(2)
The output of the circuit is a differential output taken between the nodes vout1 −vout2. Thus,
the input sources to this circuit is two-tone ω1 = 2π × 1GHz and ω2 = 2π × 0.9GHz, and
hence its response will contain frequencies at multiples, and combinations of multiples, of
ω1 and ω2. The circuit is designed to filter out all the components at the output nodes except
for the component at the difference between the frequencies, that is, the output vout1 − vout2
will have one dominant frequency ω1 − ω2 = 2π × 100MHz.
The main objective in this assignment is to perform the diamond truncation method
and compute the Fourier coefficients of the truncated frequency spectrum using the HB
technique based on the artificial frequency mapping technique. This objective is broken
down into the following several parts.
Part (a)
In this part of the assignment, you are required to develop a MATLAB program to perform the diamond truncation for the two-tone ω1 and ω2. This should be a one file, called
compute diamond trunc.m, which will take as input the two tones and f1, f2 in Hz
and the diamond truncation index, K and will produce as output all the frequencies grouped
under diamond truncation scheme. Thus, the first line in this program should look like the
following line,
1 function freq = compute_diamond_trunc(f_1,f_2,K)
where,
• f_1 and f_2 are the frequencies of the two tones in Hz,
• K is the truncation bound used by the diamond truncation.
• freq is the a vector of all frequencies, in Hz, extracted from the diamond truncation,
including DC.
and the program file should be called obviously compute_diamond_trunc.
Part (b)
In this part, your task will be to compute the Fourier coefficients of the source vector, b(t),
for the mixer circuit in Figure 1, and use them to construct the vector B¯ of the HB balance
problem. The Fourier coefficients of b(t), are denoted by B0 ∈ R
N , BC
(k1,k2) ∈ R
N and
BS
(k1,k2) ∈ R
N . For a diamond truncation with a truncation index K, only elements that
satisfy |k1| + |k2| ≤ K, need be included in the truncated set of indices ΛM, as shown by
ΛM =
(k1, k2) ∈ Z
2
: |k1| ≤ K1, |k1| + |k2| < K, k2 6= 0 if k1 < 0
\ (k1 = k2 = 0)
IMPORTANT NOTE:
The order you choose to stack the vectors B0, BC
(k1,k2)
and BS
(k1,k2)
in the vector
B¯ should be the same order you use in ordering the frequency components in the function developed in the previous part, freq = compute_diamond_trunc(f_1,f_2,K).
The MATLAB function that you will develop in this part should be general enough to
accomodate any truncation index K used in the diamond truncation scheme. Inside this
function, you are free to assume and use prior knowledge specific to the Mixer circuit
2
above, such as the values of the frequencies of the sources used in the circuit, the indices
of the sources in the MNA time-domain vector b(t), the values of the cos vs the sin component, etc.
The calling syntax of the function developed should mirror exactly the following syntax
1 [freq B_bar] = compute_mt_source_coeffs(K)
where
• freq is a vector of frequencies in the truncated spectrum collected by ΛM in addition
to the DC at the top. This should be the same vector of frequencies returned by the
function of part (a) and in the same order used above.
• B_bar This output argument should hold the vector B¯ in the HB equations, ordered
in harmonic-major mode.
Hints The previous assignment should have given you enough information on how to
construct the B¯ vector in a very limited situation, in the sense that you did not consider the
truncation index (or indices). Your task in this assignment is to make the construction of this
vector automatically linked to a general choice of the truncation index K within a diamond
truncation and the sequence that you choose for ordering the elements of the truncated
double indices in ΛM. You must create the entire B¯ vector based on the truncation index
K in the diamond truncation. Notice that the order you select to sequence the frequency
components is impacted by K and that, in turn, impacts the vector B¯.
The corrector of the assignment will run your function for different values of K, and
will compare the B_bar returned by your function against the correct B¯ vector.
Part (c)
In this part you are required to develop a MATLAB function that computes the permutation
matrix PAFM used in the technique of Artificial Frequency Mapping (AFM). PAFM should
permute the Fourier coefficients for a set of two-tones frequencies truncated by a diamond
truncation scheme with truncation index K into a set of Fourier coefficients for frequencies
that are multiple of an artificial frequency λ0.
The calling syntax should follow the syntax shown below
1 P_AFM = compute_permute_AFM(K)
The input to this function K is the truncation index K to be used in the diamond truncation scheme. The output P_AFM should be the permutation matrix PAFM.
IMPROTANT to NOTE.
PAFM ultimately depends on the sequence that you choose to order the diamond-truncated
set. You MUST adopt the same order that you used in developing the function in part (a),
freq = compute_diamond_trunc(f_1,f_2,K).
3
Hint The previous assignment requested that you construct PAFM for specific values
of truncation indices, be it box- or diamond-truncation. This assignment requests that you
make the construction of such a matrix automatically adjusted for a general index K in a
diamond truncation.
Part (d)
In this part you are asked to develop and test the multi-tone HB technique for the circuit
shown in Fig. 1. The Matlab program expected from you is a function, which takes the
following form
1 [freq, X0, Xc, Xs] = compute_mthb_resp(netlist_file,K,node_name)
where netlist_file should provide the path of the file describing the mixer circuit,
e.g., ../netlists/doubly_balanced_mixer.sp, while the input argument K is
similar to the input used in the previous parts, i.e. it defines the bounds of the diamond truncation scheme, and node name is a string argument that defines the name of the node that
we wish to compute its Fourier spectrum. Most likely, this will be nvout1 or nvout2.
The output of the above function are as follows
• freq is a vector of the truncated frequency spectrum obtained from the diamond
truncation (the original not the artificial one) excluding the DC (zero) frequency.
• X0 is a scalar value representing the DC component of the spectrum of the node
node name provided as the input argument,
• Xc and Xs are vector whose sizes are both identical to the size of the vector freq,
and their numerical values are the values of the Fourier coefficients (respectively,
cosines and sines) of the spectrum of the node node name provided as the input
argument.
Hints
• Use the code that you developed in the previous three parts (a), (b) and (c) to develop
the MATLAB function required in this part (d).
• The code in parts (a), (b) and (c) does not need you to use HiSPCE directly. So it can
be developed and invoked independently without the need to call HiSPICE-Matlab
interface functions, except for the function in part (b) which requires the index of
entries of the sources in the circuit to enable computing the vector B¯. However, you
can find out the indices of those entries offline using HiSPICE, or you may use prior
knowledge of those sources that you utilized in the previous assignment, assignment
4.
4
Part (e)
This part of this assignment requires you to develop a function to plot the time-domain
response, x(t), of the output node (e.g. nvout1) constructed through using the Fourier
coefficients computed from the previous part. By visualizing the steady-state response
in the time-domain you can readily verify and demonstrate that your code is functioning
correctly and without any operation or conceptual bugs.
The syntax of the function that you to develop in this part should mirror the syntax
below
1 [x_time, time_points]=compute_td_from_mthb(freq,X0,XC,XS,n_time_points)
The input arguments to this function are as follows
• freq,X0,Xs,Xs are the outputs returned from the function compute_mthb_resp
developed in part (d).
• n_time_points is an integer number defining the number of time samples at
which x(t) is to be computed.
The output arguments of this function are as follows
• x_time is a column vector whose length is equal to the input argument n_time_points.
This vector should hold the values of x(t0), x(t1), x(t2), · · · x(tP ), where
P = n_time_points − 1.
• time_pointsThis is a column vector whose length is equal to the input argument n_time_points. This vector should hold the values of the sampling instants
t0, t1, t2, · · · , tP , where
P = n_time_points − 1.
.
Hints
• In the above, use t0 equal to 0.
• In order to develop this function correctly, it is very important to know and undertand what is the common or global period T0 for a waveform composed multi-tone
periodical waveforms, i.e., quasi-periodic waveforms. Specifically, the common period T0 will define the time range on which the waveform x(t) is to be sampled at
the required number of sampling points. You will need to read the notes carefully to
figure out the common period in this program.
5
Part (f)
The final part of the assignment requires you to summarize the results of running your
programs in a PDF format. The PDF file should demonstrate the following,
(a) Analysis showing the value of, and how you computed, the common or global period
for the waveforms in the mixer circuit.
(b) Graphs showing the time-domain results obtained from your programs for the voltages at nodes nVout1,nVout2,n4,n5 in the circuit.
(c) A graph showing the result obtained at the differential output voltage, that is
v(nVout1) - v(nVout2).
(d) A graph showing the comparison between some of the above results and corresponding results obtained from the commercial simulator HSPICE, which will be released
in due time.
IMPORTANT INSTRUCTIONS. What you need to submit
You are required to submit only the following files (DO NOT compress them in one
zipped file), and you must submit them in the following order,
(a) MATLAB file compute_diamond_trunc.m
(b) MATLAB file compute_mt_source_coeffs.m
(c) MATLAB file compute_permute_AFM.m
(d) MATLAB file compute_mthb_resp.m. This last one must include all of the
above functions defined internally. The assignments corrector will invoke this function and examine its output.
(e) MATLAB file test_bench.m.
This file is only used to call any or all of the above functions. It is NOT a place where
any function should be defined. A simplified way to represent this file may be shown
below:
6
1 % This is a text bench file used to launch the other
2 % programs developed by
3 % Student Name : Emad Gad
4 % Student Number :12345678
5 clear all
6 close all
7 init_globals
9 netlist_file_name = ’../netlists/doubly_balance--...-.sp’
10 K = 5;
11 f_1 = 1e9;
12 f_2 = 0.1e9;
13 node_name = ’nVout1’;
14 n_time_points = 10000;
15 freq = compute_diamond_trunc(f_1,f_2,K);
16 [freq B_bar] = compute_mt_source_coeffs(K);
17 P_AFM = compute_permute_AFM(K);
18 [freq, X0, Xc, Xs] = ...
19 compute_mthb_resp(netlist_file_name,K,node_name);
20 [x_time, time_points]=...
21 compute_td_from_mthb(freq,X0,Xc,Xs,n_time_points);
22 plot(time_points,x_time)
24 % End of file: no more code to go after this points
(f) A PDF file for your report containing all the items described by part (f).
The PDF file should be named using your student ID and last name, e.g. 1234567 Gad.pdf
DO NOT
• DO NOT compress your files or submit a single .zip or .rar archive file.
• NEVER use clear all inside a function, since it wipes all input arguments.
DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of