DSP Lab Manual
DSP Lab Manual
DSP Lab Manual
FPGAs are high performance data processing devices. FPGA DSP performance is derived from the
ability they provide to construct highly parallel architectures for processing data. In contrast with a
microprocessor or DSP processor, where performance is tied to the clock rate at which the processor
can run, FPGA performance is tied to the amount of parallelism that can be brought to bear in the
algorithms making up a signal processing system. A combination of increasingly high system clock
rates (current system frequencies of 100-200 MHz are common today) and a highly distributed
memory architecture gives the system designer an ability to exploit parallelism in DSP (and other)
applications that operate on data streams. For example, the raw memory bandwidth of a large FPGA
running at a clock rate of 150 MHz can be hundreds of terabytes per second.
There are many DSP applications (e.g., digital up/down converters) that can be implemented only in
custom integrated circuits (ICs) or in an FPGA; a von Neumann processor lacks both the compute
capability and the memory bandwidth required. Advantages of using an FPGA include significantly
lower non-recurring engineering costs than those associated with a custom IC (FPGAs are commercial
off-the-shelf devices), shorter time to market, and the configurability of an FPGA, which allows a
design to be modified, even after deployment in an end application.
MATLAB is a tool which is best suited for DSP algorithm development. Xilinx ISE tool is used for
implementation of systems in FPGA. But there is a gap between these two tools. This gap can be filled
by Xilinx System Generator Tool. In below block diagram we shows design flow of two different
platforms.
Page 1 of 169
• Algorithm Verification and Implementation Design Flow
System Design
Domain FPGA Design
Domain
Manual design
Algorithm design
entry in HDL
Optimization and
Timing verification
re-verification
MATLAB and Simulink Foundation/Alliance
•
Optimization and
Timing verification
re-verification
MATLAB and Simulink Foundation/Alliance
Our system designer flow confronts signal processing, control, and project management challenges in
the process of developing DSP solutions. The System Generator for DSP design flow encompasses
the entire design process.
Page 2 of 169
can also create microprocessor based control circuits.
You can also bring in your own HDL modules via, or write MATLAB code for combinational control
logic or state machines.
• Algorithm Development
MATLAB is an excellent language for creating complex algorithms such as matrix operations and
linear algebra. With the Xilinx AccelDSP Synthesis tool, you can automatically translate these
algorithms into RTL and export them into a larger Simulink/System Generator system.
You can also create a VHDL testbench and data vectors with System Generator for DSP. These
vectors represent the inputs and expected outputs seen in the Simulink simulation, and allow you to
easily see any discrepancies between Simulink and VHDL results. FPGA Advantage can be used to
conduct simulations of DSP systems prior to implementation. ModelSim is required for HDL co-
simulation.
Xilinx System Generator for DSP manages the entire design flow from a single environment
• .vhd - the top level VHDL file for your project. There are additional VHDL files included when your
design has more hierarchy.
• core - files associated with the generated multiplier core, such as the behavioral simulation models
and EDIF file.
• corework - subdirectory containing the CORE Generator log file.
• .xcf - generated constraints file when XST synthesis is chosen in the System Generator block.
Buses in this file are denoted with angle brackets.
• .ncf - generated constraints file when Synplify or Leonardo Spectrum is chosen as the synthesis
tool. Buses are denoted with parentheses.
• .npl - project file for opening the design in Xilinx ISE 6.2i Project Navigator, using your chosen
synthesis compiler and ModelSim simulator.
• testbench.vhd - the top level VHDL testbench file, associated with the top level VHDL source file
in the project
• <gateways>.dat - stimulus files for inputs to testbenches, or predicted outputs of testbenches. The
.dat files are generated by Simulink simulation and saved for running in Xilinx testbenches to verify
design behavior. In this example, <gateways> refers to the names of the Xilinx gateway blocks,
which collect and save the data.
• VhdlFiles - a list of VHDL files, and their dependency order, needed for synthesis projects. System
Generator's Perl scripts read from this file when creating project files.
• Globals - a file containing the characteristics of the design needed by downstream software tools
in order to synthesize and implement.
Page 3 of 169
• Synplify_fir_filtert.prj - a project file for running this design in Synplify (synthesis tools from
Synplicity) if you have chosen it as your synthesis tool in the System Generator block.
• XST_fir_filtert.prj - a project file for running this design in XST if you have chosen it as your
synthesis tool in the System Generator block.
• Spectrum_fir_filtert.tcl - a project file for running this design in Leonardo Spectrum (synthesis
tools from Mentor Graphics).
• Pn_behavioral.do, pn_posttranslate.do, pn_postmap.do, Pn_postpar.do - compilation and
simulation do files for running this design through simulation at different stages. These 4 files are
associated with ModelSim simulation through the Xilinx ISE 6.2i Project Navigator.
• Vcom.do, vsim.do - default behavioral simulation files for use with ModelSim.
• Sysgen.log - log file. xlRunScripts.log - logfileshowing status of post-processing scripts run by
System Generator.
• Simulation : Verifying the design specifications after design entry is functional simulation. It Saves
the time consumed for physical prototyping
• For locking physical pins with the designed entity user constraint file(UCF) has to specify by the
user.
• Implementation : Is the process of placing the design into the specified target technology.
Implementation tool reads the standard netlist & fits it into the target device.
Following steps are performed by the implementation tool
Ð Mapping:Tool partitions the design into the logic blocks available on the device. Good
partitioning results in better performance.
Ð Placing : After the logic is partitioned, implementation software searches for the best location to
place the logic block among all of the possibilities. Primary goal is to reduce the amount of
routing recourses required.
Page 4 of 169
Ð Routing : Logical nets are assigned to the physical wire segments in the device that
interconnect logic cells.
• Programming:
Ð After the design is Implemented, software creates the bitstream ( binary programming ).
Ð The programmable device is configured for the function by downloading the programming file
into target.
Ð After the device is programmed, you are ready to test the actual system, with real life inputs
and outputs.
• Understanding the Number System
Basis of implementing a DSP system are
• “A-PRIORY KNOWLEDGE”, meaning a prior knowledge of the available hardware and the signals
that, will be applied to the input and are expected at the output.
• It is all about “Assigning Meaning to Numbers”, meaning
Ð The input signals have to be converted properly to the number system being implemented in
hardware
Ð The numbers available at the system output have to be understood and then converted to
analog domain.
System Generator
“System Generator for DSP” ( SysGen) is an EDA tool offered by Xilinx. It acts as a bridge between a
design environment which is Matlab (simulink) and the hardware implementation environment, which
is a Xilinx FPGA.
System generator when loaded with Matlab, adds a Xilinx Blockset in the Simulink Library Browser.
This blockset consists of synthesizable blocks for various applications in Communication and DSP.
The “System Generator” block, allows automatic generation of VHDL code. This code can be
synthesized and implemented in the target device using Xilinx ISE tool.
In this document we the detailed steps to implement a Simple Filter in hardware, using the Matlab
(simulink ) and System Generator for DSP Tools.
The Filter will be implemented using DSP development board from Mechatronics Test Equipment.
HARDWARE DESCRIPTION
The following is the configuration of the DSP development board.
• It has a built-in Signal Generator generates, which generates a Sine wave of amplitude 10V peak
to peak.
• ADC on board has the following specifications
Ð Resolution - 12 bits.
Ð Input range - ±10V.
Ð Output Format - ADC output can be in straight Binary or 2’s complement format.
• DAC on-board has the following specifications
Ð Resolution 12 bits
Ð Output Range - ±10V.
Ð Output Format – Straight Binary.
• Crystal oscillator on board has a freq of 4 MHz.
Page 5 of 169
Inputs to System Generator Block:
• Device Family = Spartan-III (check FPGA device in your DSP PROTOBOARD)
• Target Directory = User defined
• Check in “Create Test bench” option
• Click on “Generate”
• STEPS TO IMPLEMENT THE FILTER IN DSP-PROTOBOARD
Ð Change the device type to XC3S400-4PQ208.
Ð Add source files : lowpass.vhd, adc_7891.vhd.
Ð Change the name of the component in “lowpass.vhd” according to the entity name in the
VHDL file generated by system generator (project name).
Ð Assign the generic number n in “lowpass.vhd” the value equal to the Gateway_out signal’s
bus-width.
Ð Add “UCF” file at the “implement design” step.
Ð Configure FPGA.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity adc_dac_test is
generic (n : natural := 21);
Port (
clk : in std_logic; -- Local clock
reset : in std_logic; -- Local reset signal
----------------------------- For ADC1(7891)---------
adc_clk : out std_logic; --sampling frequency to ADC
cs_ad7891 : out std_logic; --chip select
convst_ad7891 : out std_logic; --conversion start
wr_ad7891 : out std_logic; --write
rd_ad7891 : out std_logic; --read
eoc_ad7891 : in std_logic; --end of conversion
mode_ad7891 : out std_logic; --mode=1 for parallel
db_7891 : inout std_logic_vector(11 downto 0);--ADC bidirectional
input/output
---------------------------------For DAC-----------------
bit_trun : in std_logic_vector( 7 downto 0);
dac_sel : in std_logic_vector(1 downto 0);
--- DAC selection. IL0 and IL1 are used
ch_adc : in std_logic_vector( 1 downto 0);
--- Input channel selection for ADC
--- IL6 and IL7 are used for Ch_adc
--- 00 for ch1,01 for ch2,10 for ch3,11 for ch4
dac_out : out std_logic_vector(11 downto 0); ---Output to DAC
en : out std_logic_vector( 3 downto 0) ---DAC latch enable
);
end adc_dac_test;
Page 6 of 169
signal dacout : std_logic_vector(n downto 0);
signal div_adc : std_logic_vector(15 downto 0 );
---This should be changed as per input on board clock
signal decade : std_logic_vector( 3 downto 0 );
signal sampling_clk, wr_s, clk_s, rd_s, convst_ad7891_s : std_logic;
signal db_7891_s : std_logic_vector( 11 downto 0 );
component lowpass
-- Change the name of the component in “lowpass.vhd” according to the entity
port ( clk : in std_logic;
--Name in the VHDL file generated by system generator (project name).
gateway_in : in std_logic_vector(11 downto 0);
gateway_out : out std_logic_vector(21 downto 0));
end component;
begin
-----------------------------Clk Divider------------------------
--Decade counter is used because on board clock is 20 MHz. It can be 40 MHz
--or 4 MHz.In case of 20/40 MHz we have to use decade counter to get 2/4 MHz.
--In case of 4 MHz bypass decade counter. This arrangement is made so as to
--design filter or any other application irrespective of input clk at
--particular clock frequency. Otherwise every time we will have to change
--frequency of our design. We cannot have similar frequency by direct
--division of input clock 20/40/4 MHz. For example 4 divided
--by 5 FF to have 62.5KHz.if we want this frequency from 20/40 MHz clock
--we get 78.125.
process(clk, reset)
begin
if(reset = '1') then
decade <= (others => '0');
elsif(clk'event and clk = '1') then
if decade="1001" then
decade<=(others=>'0');
else
decade <= decade + 1;
end if;
end if;
end process;
clk_s<='1' when decade="1001" else
'0';
process(clk_s, reset)
begin
if(reset = '1') then
div_adc <= (others => '0');
elsif(clk_s'event and clk_s = '1') then
div_adc <= div_adc + 1;
end if;
end process;
sampling_clk <=div_adc(2) ;
---Input clock is very fast so divided clock is used as sampling clock to FSM. ----
FSM will divide sampling clock
---by four so sampling clock for ADC is 62.5KHz.
Page 7 of 169
ps_1 <= ns_1;
end if;
end process;
-------------------------------------------------------------------------
process(ps_1)
begin
case ps_1 is
when reset_1 => ns_1 <= write_cwr;
when write_cwr => ns_1 <= start_conv;
when start_conv => ns_1 <= read_data;
when read_data => ns_1 <= reset_1;
end case;
end process;
cs_ad7891 <= '0' when (ps_1 = read_data or ps_1 = write_cwr) else
'1';
wr_s <='0' when (ps_1 = write_cwr) else
‘1';
wr_ad7891 <= wr_s;
--------------------------read adc--------------------------
process(reset, clk,rd_s)
begin
if(reset = '1') then
db_7891_s <= (others => '0');
elsif(sampling_clk'event and sampling_clk = '0') then
if(rd_s = '0') then
db_7891_s <= db_7891;
end if;
end if;
end process;
------------------ write ADC Data to DAC -------------------------
dac_out_s <= dacout(n downto n-11) when bit_trun(0)='1' else
dacout(n-1 downto n-12) when bit_trun(1)='1' else
dacout(n-2 downto n-13) when bit_trun(2)='1' else
dacout(n-3 downto n-14) when bit_trun(3)='1' else
dacout(n-4 downto n-15) when bit_trun(4)='1' else
dacout(n-5 downto n-16) when bit_trun(5)='1' else
dacout(n-6 downto n-17) when bit_trun(6)='1' else
dacout(n-7 downto n-12) when bit_trun(7)='1' else
dacout(n-8 downto n-12) ;
dac_out<= (dac_out_s(11)&( not dac_out_s( 10 downto 0))) +'1' when
dac_out_s(11)='0' else
dac_out_s(11)&( not dac_out_s( 10 downto 0));
Page 8 of 169
----------------------DAC selection logic--------------------------
process(dac_sel)
begin
case dac_sel is
when "00" => en<="1000" ;
when "01" => en<="0100";
when "10"=> en <="0010";
when "11"=> en <="0001";
when others=> null;
end case;
end process;
end Behavioral;
module lowpassvlog
(smpclk,dac_out,en,cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891,reset,cl
k,dac_sel, bit_trunc,ch_adc,db_7891);
output smpclk,cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891;
output [11:0] dac_out;
output [3:0] en;
input clk, reset;
input [7:0] bit_trunc;
input [1:0] dac_sel;
input [1:0] ch_adc;
inout [11:0] db_7891;
reg [3:0] en;
reg cs_ad7891,convst_ad7891,wr_ad7891,rd_ad7891,mode_ad7891,convst_ad7891_s;
wire sampling_clk,wr_s,rd_s;
wire [11:0] dac_out_s;
wire [21:0] dacout;
`define reset_1 2'd0
`define write_cwr 2'd1
`define start_conv 2'd2
`define read_data 2'd3
reg [1:0] ps_1;
reg [1:0] ns_1;
reg [3:0] div;
wire [5:0] conc;
wire [11:0] conc1;
reg [15:0] div_adc;
reg [11:0] adcin,db_7891_s;
wire clk_s;
Page 9 of 169
assign clk_s = (div == 4'b1001) ? 1'b1:1'b0;
always @ (ps_1)
begin
case (ps_1)
`reset_1 : ns_1 = `write_cwr;
`write_cwr : begin
cs_ad7891 = 1'b0;
ns_1 = `start_conv;
end
`start_conv : ns_1 = `read_data;
`read_data : begin
cs_ad7891 = 1'b0;
ns_1 = `reset_1;
end
endcase
end
always @ (convst_ad7891_s)
convst_ad7891 = convst_ad7891_s;
always @ (db_7891_s)
adcin = db_7891_s;
Page 10 of 169
always
mode_ad7891 = 1'b1;
always @ (dac_sel)
begin
case (dac_sel)
2'b00 : en = 4'b1000;
2'b01 : en = 4'b0100;
2'b10 : en = 4'b0010;
2'b11 : en = 4'b0001;
default : en = 4'b0000;
endcase
end
lowpass u1(.clk(div_adc[4]),.gateway_in(adcin),.gateway_out(dacout));
Note :
The component name represented in BOLD (e.g. lowpass) letters is required to be changed
according to the entity name in the module generated by user.
The value of n must be equal to the bus-width of the Gateway_out signal in the module generated by
user.
Page 11 of 169
STEPPER MOTOR INTERFACE
A1_COIL 43
A2_COIL 42
B1_COIL 37
B2_COIL 39
RELAY
RELAY0 40
ADC DAC
FPGA pin FPGA pin
Signal Signal
Number Number
"DB0" 45 "DAC0" 81
"DB1" 46 "DAC1" 79
"DB2" 57 "DAC2" 100
"DB3" 58 "DAC3" 97
"DB4" 61 "DAC4" 93
"DB5" 62 "DAC5" 90
"DB6" 63 "DAC6" 94
"DB7" 64 "DAC7" 95
"DB8" 65 "DAC8" 96
"DB9" 67 "DAC9" 102
"DB10" 68 "DAC10" 101
"DB11" 71 "DAC11" 80
"MODE" 72 "EN1" 87
"EOC" 44 "EN2" 85
"\CONVST\
48 "EN3" 86
"
"\CS\" 50 "EN4" 74
"\RD\" 51
"\WR\" 52
USB INTERFACE
FPGA pin FPGA pin
Signal Signal
Number Number
USB_D0 106 USB_D6 114
Page 12 of 169
USB_D1 107 USB_D7 115
USB_D2 108 RD# 116
INPUT SWITCHES
FPGA pin Connecter name and pin
Signal
Number number
"IL0" 141 J1-7
"IL1" 140 J1-8
"IL2" 139 J1-11
KEY SWITCHES
FPGA pin Jumper name and pin
Signal
Number number
"KEY0" 143 J1-6
OUTPUT LEDs
FPGA pin Jumper name and pin
Signal
Number number
Page 13 of 169
“OL0” 161 J2-34
“OL1” 172 J2-24
7 SEGMENT DISPLAY
FPGA pin Jumper name and pin
Signal
Number number
"SEGA" 189 J2-8
"SEGB" 190 J2-7
"SEGC" 187 J2-12
Page 14 of 169
LCD DISPLAY
FPGA pin Jumper name and pin
Signal
Number number
"DL0" 33 J3-32
"DL1" 31 J3-31
"DL2" 29 J3-28
"DL3" 28 J3-27
"DL4" 27 J3-26
"DL5" 26 J3-25
"DL6" 24 J3-24
"DL7" 22 J3-23
"E" 36 J3-33
"R/W" 35 J3-34
"RS" 34 J3-35
USER I/O’S
Type FPGA PIN Number Connector pin Number
I/O1_QS 21 J3-22
I/O2_QS 20 J3-21
I/O3_QS 19 J3-18
I/O4_QS 18 J3-17
I/O5_QS 16 J3-16
I/O6_QS 15 J3-15
I/O7_QS 13 J3-14
I/O8_QS 12 J3-13
I/O9_QS 11 J3-12
I/O10_QS 10 J3-11
I/O11_QS 9 J3-8
I/O12_QS 7 J3-7
I/O13_QS 5 J3-6
I/O14_QS 4 J3-5
I/O15_QS 3 J3-4
I/O16_QS 2 J3-3
I/O17_QS 203 J3-1
I/O18_QS 200 J3-2
I/O19_QS 199 J2-1
I/O20_QS 198 J2-2
Page 15 of 169
I/O21_QS 197 J2-3
I/O22_QS 196 J2-4
I/O23_QS 194 J2-5
I/O24_QS 191 J2-6
Page 16 of 169
LAB 1
Generate Waveforms using DAC
1.1 Introduction
Analog signals represent real physical parameters with accuracy, but it is difficult to process or store
them. It is necessary to translate an Analog signal into a Digital signal. Similarly, a digital signal needs
to be translated into an analog signal to represent a physical quantity.
Quite often it is also necessary to decode any digital signal, the most obvious method is to use D/A
converter for each signal.
Therefore it is necessary to study the behaviour of DAC. For that waveform generation using DAC is
done. Various waveforms such as square, sine, triangular, ramp etc. can be generated.
In this lab ramp waveform is being generated.
DAC:- Digital to analog conversion involves translation of digital signal into equivalent analog signal.
Applications of DACs include digital voltmeters, peak detectors, panel meters, programmable gain and
attenuation, and stepping motor drive.
The two important aspects of the D/A converter are the Resolution & Accuracy of the conversion.
ACCURACY:-Accuracy is a measure of how close the actual output voltage is to the theoretical output
voltage.
RESOLUTION:-Resolution is the smallest increment in output voltage and is determined by the LSB.
n
Ex:-If the full scale Analog voltage is 10V, the smallest unit or the LSB is equivalent to 1/2 of 10V.
This is defined as resolution.
DAC AD7541 used on SP3 DSP Protoboard is 12 bit and the Full scale voltage of the analog output
block is 10V
Hence the resolution of the analog output block is 10V/212
12
LSB = 10/2
MSB= ½ full scale = 5V
Full scale output =(Full scale Value–(1 LSB))
= 10V-(10V/212). ------For 12 bit DAC
= 9.998V.
Figure1 shows a block diagram of a 3-bit DAC and characteristics of digital input vs. analog
output
Page 17 of 169
Figure 1
1.3 Objective
After completing this lab you will be able to
• Perform the basic design flow for generating Counter in VHDL.
• Simulate a VHDL file.
• Synthesize a design using XST.
• Implement a design using the Xilinx implementation tools.
• It will help you to understand behaviour of DAC it should show proper RAMP at the output.
1.4 Design Description
In this lab ramp waveform is being generated, for that you will have to design a counter .Counter
output is mapped to DAC input as shown in figure. This will help you to understand behaviour of DAC
& interfacing of DAC with FPGA to generate waveforms of different amplitude and frequency.
1.5 Experimental Set up
In above figure we can implement 3 bit loadable up /down counter. with asynchronous reset. Counter
output is given to DAC to generate Ramp output waveform.
1.6 Procedure
To design Counter, perform the following steps:
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start Æ
Programs Æ Xilinx ISE 7 Æ Project Navigator
Step 2: In the Project Navigator window go on FILE ÆNew projectÆselect device.
Step 3: Click on FPGA symbol of device and then right clickÆ click on new source ÆVHDL module
give
name countÆDefine portsÆfinish.
Page 18 of 169
Step 4: Generate the Behavioural VHDL Code for the counter.
Step 5: Check syntax, remove errors if present.
Page 19 of 169
Step 4: Double-click on Simulate Behavioral VHDL Model. If the modelsim simulator is used then
Model Technology window pops-up, click
Run ModelSim. The simulation will run. Otherwise on the ISE simulator window waveforms are
displayed.
Step 5: Verify the operation of the counter by looking at the input and output signals in the test
bench named *_tb
Page 20 of 169
Note: It may be easier to view the input and output in decimal. This can be done by highlighting the
appropriate signals in the waveform viewer, then use the pull down menus Format Æ Radix Æ
Decimal.
Step 6: After you verify operation you can close ModelSim .If the counter is not functioning
correctly, verify your VHDL code and re-run the simulation.
1.8 Synthesize the Design Using XST
Now that design has been verified using the ModelSim VHDL behavioural simulator, you can
synthesize your design. We do this by using the Xilinx Synthesis Technology (XST).
To synthesize your design, perform the following steps:
Step 1: Highlight counter.vhd file in the Sources in Project window.
Step 2: To run synthesis, right-click on Synthesize, and choose the Run option, or double-click on
Synthesize in the Processes for Current Source window. Synthesis will run, and a green
check will appear next to Synthesize when it is successfully completed.
A yellow exclamation mark indicates that a warning was generated, and a red cross indicates an error
was generated. Warnings are OK.
Page 21 of 169
Step 3 If there are any errors, you can View Synthesis Report by expanding Synthesis, right-click
and Choose the View option; otherwise continue on to the next step.
Step 1: Right-click Implement Design, and choose the Run option, or double left-click Implement
Design.
Page 22 of 169
This runs the design through Place and Route. You will notice green check marks (or warning
exclamations) next to the processes that means finished successfully.
Step 2: To get the Post Place and Route Timing, run Generate Post-Place & Route Static Timing,
and when finished, expand and open the Text. Based Post-Place & Route Static Timing
Report.
Note: - User constraint file (UCF) is used to lock the input and output which we are going to use.
Page 23 of 169
Step 8: Right-click on Generate Programming File, and choose the Run option, or double left-click
on Generate Programming File. This will generate the Bitstream.
Step 9: Double click on Configure Device to download the bitstream.
Step 10: Connect the CRO probe to the DAC Out terminal to observe “Ramp
waveform” as shown in figure below. Thus the digital input applied through counter is
converted into an analog ramp waveform.
1.11 Conclusion
You should now know the basic design flow for taking VHDL through the design process. You have:
• Realized some challenges in writing the VHDL counter.
• Run a piece of VHDL code through simulation.
• Run synthesis using XST.
• Run a synthesized design through the Xilinx implementation tools.
• After downloading check output of DAC on Four output analog channel.
Page 24 of 169
1. What is the Implementation Result. See the Place and Route
report file and fill in the information below
• Number of slices:_________________________________
• Number of global buffers (BUFGMUXs): _______________
• Number of IOBs: __________________________________
2. Open the Post-Place and Routing Timing report, and fill in the
information requested below
• Maximum clock frequency: ___________________________
• Generate a square and triangular waveform.
(Hint. Change the counter direction according to waveform)
3. Maximum clock frequency: _______________________
4. Design counter which will give Ramp output waveform of
amplitude 2.5V.
(Hint – Refer graph of digital input Vs analog output and
modify the counter.)
5. Modify the design to change the frequency of Ramp wave
6. What will be the change in the functionality if we want an
inverted ramp at the output?
7. How will you change the step size?
8. What will happen if the time scale is changed?
Draw the waveform and write down the observations for two
different time scales.
9. Write a code to generate sine wave, square wave and triangular
wave at the output of the DAC. Try for different values of
frequency and amplitude keeping in mind the specifications of
DAC.
10. How 4MHz clock frequency can be divided to see counter
response on LEDs. If clock is applied directly what would you
observe?
11. Define Resolution Time & Settling Time.
Page 25 of 169
LAB 2
Verification of Sampling Theorem using ADC-DAC
2.1 Introduction
Most signals such as speech, biological signals, various communication signals such as audio
and video signals, are analog. To process analog signals by digital means, it is first necessary
to convert them into digital form. The devices used for this are Analog to Digital converters
(ADCs). In many cases it is desirable to convert the processed digital signals into analog
form. This process is done by Digital-to-Analog converters (DACs).
In this lab, sampling theorem is verified. According to the Sampling theorem, the sampling
frequency should be double or more than double the highest input frequency. The input to
ADC is given through an external source and here sampling frequency is fixed. The input
frequency can be increased to see the aliasing effect at the output. Aliasing is the process
where a sinusoid changes from one frequency to another as a result of sampling or other non-
linear action and usually results in a loss of signal’s information. Increasing the input
frequency to more than half the sampling frequency gives aliased low frequency waveform at
the output.
2.2 Objective
The design example in this lab is to demonstrate
• How to write and execute Matlab Simulink program.
• How to generate VHDL/VERILOG code from the system generator.
• How to modify ADC-DAC program according to your application.
• How to use in build function generator.
• How to adjust sampling frequency.
2.3 Design Description:-
• External/On-Board Analog input can be given to the ADC, it converts applied analog
input to 12-Bit Digital signals. This signal is then given to DAC via FPGA and the output
is checked at the DAC output.
• Five channels of ADC are used, wherein Channel 1 to Channel 4 gets the input from
an external source & Channel 5th is used on board for Thermister.
• Output of ADC is then given to FPGA, Conversion Start, ADC clock and channel
address signals are generated through FPGA. FPGA receives End of conversion
(EOC) from ADC.
• FPGA will map ADC output directly to DAC input.
• Digital to Analog converter accepts input from FPGA, converts digital data to Analog
signal.
• Output of DAC is available on the connector. (Refer connector details given below)
Page 26 of 169
2.4 Experimental Set up:-
Step1: Open the MATLAB command window by double clicking on the MATLAB icon,
which is provided on the desktop.
Step2: Open the Simulink library browser window by typing Simulink on the command
prompt (>> Simulink) or clicking on the Simulink library browser.
Step3: Now open the new model file by >> File >> New >> Model.
Step4: Go to Simulink library browser and click on sources and select the signal
generator block and drag that into new model file.
Step5: Then you click on sinks, here you select the scope and drag that on to the sheet.
Step6: Then you click on Xilinx block set in the library browser and then click on basic
elements and select the system generator block, Gateway In, and Gateway Out
blocks and drag them on to new model file.
Page 27 of 169
Step7: Now interconnect all the blocks. The following figure shows how it looks like.
Fig. shows how to interconnect the different Simulink block.
Step8: Double click on each block, the parameter window will open and select the
parameters. For signal generator choose parameters as waveform as sine wave,
amplitude as 3V, and frequency as 0.135 rad/sec.
Note: Frequency (rad/sec) = 2πFp / Fs.
Fig. shows how to set signal property of signal generator Simulink block
Page 28 of 169
Now double click on Gate Way In block, the parameter window will open and fill the
Step11: After selecting the proper device and proper project directory click on Generate.
Here the pop up window will open that shows the running of system generator as
shown in figure.
Page 29 of 169
Step12: Check the generated code in specified folder.
2.5 Generate, Synthesize, and Place & Route in Xilinx
Step1: Double click on Xilinx project navigator icon, which is provided on the desktop.
Step2: Now go to >> File. >> Open project, here you have to specify the path at which
your design has been stored.
Step3: Now add the ADC_DAC controller VHDL Design to your file. This is done as: Right
click on the source file and click on add new source. The following shows how it
happens.
Page 30 of 169
Step4: After that you have to write user constraint file for the ADC_DAC controller VHDL
Design. This is also done by right clicking on source file
>> new source>>Implement constraint file. >> file name >>next
The following depicts that.
Step5: After writing constraint file you go to processes for source window and run the
synthesize process. The following depicts that.
Step6: After running synthesize process run the implement design. The following depicts
that.
Page 31 of 169
Step7: click on Generate program file. and go to the properties. Then pop up window will
open. In that you go to start up options and select the desired clock. The following
is depicts that.
Step8: The above process will generate the bit file. Now right click on the configure device
and click on the properties. Then pop up window will open. Select the particular
configuration mode. The following figure depicts that.
Page 32 of 169
Step9: After selecting the configuration mode you program your device by downloading
bit file into the FPGA.
Note: System generator generates the code corresponding to the logic in between
Gateway In and Gateway Out. The signal generator and the scope used by the system
generator are just for simulation.
Use onboard function generator for input signal. Observe the results on CRO. This
function generator and CRO are for physical verification.
Repeat same procedure for various ADC sampling frequency by changing the positions of
DIP switches (IL0, IL1, and IL2) and observe the output.
The above procedure should repeat for square wave and triangular wave inputs.
2.7 Assignments
1 Open the place and route tool and fill the following?
• Number of slices consumed:_____________________________
• Number of IOBs:________________________________________
• Number of GBUFs:_______________________________________
2 What would be the effect of change in sampling frequency?
3 Repeat the whole experiment for square & triangular input signal.
4 Change the sampling frequency and input frequency. Observe the
aliasing effect on CRO.
5 How to select the sampling frequency of ADC?
6 Write down the specifications of ADC and DAC.
7 What is the maximum input frequency?
8 If two more channels of ADC are used, what will be the change in
the above code?
9 See the Place & Route report and give the number of global buffers,
LUTs, and IOBs.
10 Change the input frequency and observe the change at the output.
Page 33 of 169
LAB 3
FIR filter using windowing method
3.1 Introduction
In this lab, you can study one way to specify, simulate, and implement a FIR filter using the MATLAB
Filter Design & Analysis Tool (FDA Tool). The FDA Tool is used to define the filter order and
coefficients, and the Xilinx FIR filter Blockset is used for the implementation and Simulink simulation.
The algorithms /system can be verified using MATLAB Simulink blocks. Xilinx system generator tool
is a part of Simulink tool box.
System generator is used to generate VHDL and all supporting files.
Xilinx ISE tool. is used to synthesize, implement and programming of FPGA.
Design a FIR Filter using Windowing method for a given frequency response.
• Sampling frequency (Fs) =20000Hz
• Passband frequency (Fpass) =3000Hz
• Stopband frequency (Fstop) =4500Hz
• Passband attenuation (Apass) =1dB
• Stopband attenuation (Astop) =80dB
To design the filters by using “window” method. Here we have to design the filter in the FDATool
with the desired filter specifications and export the coefficients to the Simulink workspace. Windowing
is one of the method for designing FIR filter. Other method is the “frequency sampling” method.
3.2 Objective
After completing this lab you will be able to write and simulate Simulink program. Understanding the
basics of building in designing a system generator.
Simulate the design in the System Generator. Run the system generator token for generating the
VHDL code. Run the designs through System Generator design flow.
3.3 Procedure
Step1: Open the MATLAB command window by double clicking the MATLAB icon that is provided
on the desktop.
Step2: Open the Simulink window by typing the Simulink at the command prompt (>> Simulink) or
clicking on the Simulink Library Browser. The Simulink window will be as shown below.
Page 34 of 169
Step3: Look at the blocks that are available on the window. The following are the blocks.
• SIMULINK (sources and sinks)
• DSP Block set
• XILINX Block set
Step4: Right click on block on the library browser and choose help from the MATLAB menu
This bring up the details of the block and it also work on the Xilinx block set elements
Step5: Create a new model file Go to file >> new>> model
Page 35 of 169
Step6: Go to sources and select the signal generator and add that to the model file. Go to sinks
and select the Scope and add that to the model file.
Double click on Signal Generator block to set its parameter
Write amplitude of
input signal
Ratio of input
Freq and Sampling freq
Step7: Go to Xilinx Blockset and click on the Basic Elements and select the system generator,
GateWay In and GateWay Out blocks and add them to the new model file.
Step8: Go to the DSP section in the Xilinx block set and right click on the FIR block and add to the
new model file.
Fig shows interconnection of above selected components
Page 36 of 169
Below a Block Diagram of FIR filter is shown
• Coefficients
generated from
FDA tool.
• Latency is
required since FIR
is a synthesizable
xilinx block.
• Easy generation
of cores.
Step9: Now go to MATLAB command window and type FDATool (>> FDATool) _you get will get
window
Step10: Then you enter the following specifications
• Sampling frequency (Fs) =20000Hz.
• Passband frequency (Fpass) =3000Hz.
• Stopband frequency (Fstop) =4500Hz.
• Passband attenuation (Apass) =1 dB.
• Stopband attenuation (Astop) =80 dB.
Ð Select design method as “Kaiser Window”
Ð Select type of filter as “low pass FIR”
Ð Click on design filter.
Page 37 of 169
The FDATool generates the filter with the desired specifications. In the FDA tool you can observe
• magnitude response of the filter
• phase response
• magnitude and phase response
• Group delay response
• impulse response
• step response
• pole zero plot
Step11: Go to file and export the filter coefficients to the workspace. >> File >>Export
The following depicts how it looks like
Page 38 of 169
Select Export to >>Workspace
Export as >>Coefficients >> ok.
Step12: Now come back to your model file where you have designed your design file and double
click on FIR block .Here the parameter window will open and type the Num in the
coefficients and click OK. The parameter window will look like below.
After that double click on the signal generator block and select the waveform, amplitude,
and frequency.
Step13: Set the simulation time 1000 and run the simulation.
Page 39 of 169
Step14: Now double click on the System Generator block, parameter window will open. Here you
select target device in which you want to implement your design and target directory that is
location at which you want to store your VHDL project file. The parameter window looks as
shown below.
After selecting the proper device and proper project directory click on Generate. Here the pop up
window will open that shows the running of system generator as shown in figure
Page 40 of 169
Implementation of Design which is generated by MATLAB in Xilinx ISE tool.
When a System Generator project is created, the software produces VHDL design or cores from the
Xilinx CORE Generator. In addition, many other project files are automatically created.
Step15: Now open the Xilinx project navigator and go to >>file >> open project. Here you need
to provide location at which your generated file has stored.
Step16: Now add ADC-DAC controller design & generated VHDL/VERILOG core to your project
files.
Modify ADC-DAC controller according to your application. Instantiate Core, generated by
MATLAB as a component in ADC-DAC controller design.l
Note – Refer the user constraint file(UCF) which is attached at the end of this manual.
Step18: Then go to the processes for the source in the navigator window and double click on
the“Synthesize”.
Step19: Then right click on “Implement the design” and click on Run.
Page 41 of 169
Step20: Then right click on “Generate programming file” and go to properties and then go to the
start up options. Select the clock as CCLK or JTAG. The figure below depicts that
procedure.
Step21: Then run “Generate programming file”. This will generate the bit file.
Step22: Then go to processes for source window and right click on
“Configure device” >> properties >> slave serial / Boundary-scan mode depending
upon the selection of clock (CCLK, JTAG clock).
Page 42 of 169
t
Now you can verify your design by applying sine wave input to any one of the channels and see the
output waveform on the CRO.
Set the frequency to 60Hz and increase it gradually to cut-off frequency and go beyond the cut-off
frequency and observe the output on the CRO.
You may notice that if the frequency is increased beyond the cut-off frequency the amplitude will
reduce gradually and as you move far away from cut-off frequency the output will become zero.
Download the bit file in the Device.& follow the following procedure
• Give input (Square) to ADC using connector (CH1, CH2, CH3, CH4).
• Using preset PR2 we can adjust the magnitude of input square wave.
• Now set frequency of square wave to minimum possible using preset PR1. Check the output. It
should be same as input square wave since the filter has pass band frequency of 2000Hz.
• If the output shows distorted waveform, adjust the truncation bit using sw2 (input switch). In this
case fix IL3 (SW2) = 1 and rest all zeros.
• Now increase the frequency continuously and check output. As you approach 2000 Hz, the output
will start converting to a sin wave of frequency equal to frequency of square wave
• Above 2000Hz output will remain sine curve but its amplitude will start decreasing.
You can repeat the above procedure for high pass filter, band pass filter, and band reject filter.
Page 43 of 169
3.4 Assignments
1. Open the place and route tool and fill the following information
• Number of slices ____________________________________
• Number of IOBs ____________________________________
• Number of GBUFs ____________________________________
• Maximum clk frquency ____________________________________
2. What should be the cut-off frequency?
3. Describe windowing design method of above filter How it differs
from the Fourier series and frequency sampling method.
4. Draw the waveforms of Different Window functions?
5. What are the different windows available for filter design? What
is the criterion to design a particular window?
6. Use different type of window for design a filter with same
frequency response
Page 44 of 169
LAB 4
Design of FIR filter
4.1 Introduction
This lab is to design low pass FIR filter by using Equiripple Design method.
The filter specifications are as follows
• Sampling frequency : Fs = *****
• Passband frequency : Fpass = 2 KHz
• Stopband frequency : Fstop = 5 KHz
• Passband ripple : Apass = 1dB
• Stopband ripple : Astop = 24
4.2 Procedure
• Drag & Drop the required components from the DSP Blockset.
• Generate Coefficients for the FIR Filter:-
Ð you specify the filter characteristics through the MATLAB FDA Tool, Save the coefficients to the
workspace, and use the coefficients in the Xilinx FIR filter Blockset.
• To analyze the output of the filter, input and output signals are displayed in a spectrum scope and
a transfer scope.
Note-A spectrum scope is used to compare the frequency response of the fixed- point FIR filter, and
the double precision direct form II Transpose filter.
4.3 Filter Design
Fixed- point FIR filter is implemented in the FPGA. while Transpose filter is invoked from the Simulink
Blockset library.
To design the filter using the FDA Tool, perform the following steps:
Step 1: Start the FDA Tool by typing >> fdatool in the MATLAB Command window.
Step 2: Enter the following filter parameters in the Filter Design & Analysis Tool
• Sampling frequency : Fs = *****
• Passband frequency : Fpass = 2 KHz
• Stopband frequency : Fstop = 5 KHz
• Passband ripple : Apass = 1dB
• Stopband ripple : Astop = 24dB
Click on the Design Filter button to find out the filter order
Page 45 of 169
Error!
Page 46 of 169
4.4 Simulate the FIR filter in Simulink
Following steps are needed to implement FIR in Simulink.
Step 1: To simulate the block click on Simulation icon.
Step 2: Select simulation time (i.e. 1000).
Step 3: Click on start simulation.
Step 4: Double click on scopes.
Page 47 of 169
Step 5: Click properties to change the number of axis displayed and the time range value (X-axis).
Step 6: Use Data history to control how many values are stored and displayed on the scope.
Step 7: Click auto scale to configure the display to the correct axis values.
Step 8: Right click on the Y-axis to set its value.
Step 9: Click on play to see response of signals on scope.
An error will be reported regarding the filter latency when you stop simulation:
Error reported by S-function 'xlfir' in block 'filter1/FIR':
To use a core, latency must be increased to at least 13.
Behaviour of the configured block can be simulated.
It is not possible to target it in to hardware as no synthesizable filter code is provided by FDA Tool
Note: At this point, you need to re-open the FIR Filter parameters and set the latency to 13 as
specified in the Error Message.
Page 48 of 169
4.5 Generate Synthesize and Place and Route
In third section, you will observe that what impact of data width, coefficient width, and the number of
taps has on the size and performance of the Filter Implementation.
Step 1: Open the FIR filter Blockset, and verify that all the parameters are set as follows
Step 2: Select the SPARTAN-III family, the XC3S400-4pq208 device, XST and generate the top-
level VHDL code with the System Generator icon.
Step 3: Open Project Navigator by double-clicking the filter1.npl file in Windows Explorer.
Step 4: Synthesize and Implement the design
Step 5: Now, go back to the Simulink filter design example, and decrease the coefficient width to
Fix12_6.
Step 6: Rerun Synthesize and Implement in the Project Navigator.
Step 7: Download Design into FPFA and follow following procedure to verify desired filter on FPGA.
Page 49 of 169
4.7 Assignments
Page 50 of 169
LAB 5
Implementation of aliasing effect
5.1 Introduction
This is an interfacing code for ADC and DAC. Sampling frequency will remain fix here. We
can change our input frequency to observe aliasing effect at output.
According to the Sampling theorem, the sampling frequency should be double or more
than double the highest input frequency. The input to ADC is given through an external
source and here sampling frequency is fixed. The input frequency can be changed to see
the aliasing effect at the output. Aliasing is the process where a sinusoid changes from
one frequency to another as a result of sampling or other non-linear action. Usually results
in a loss of signal’s information. Increase in input frequency more than half the sampling
frequency gives alias low frequency waveform at the output.
5.2 Objective
In this lab we will verify the “Nyquist criteria”. We can change our input frequency to see
aliasing effect at output of DAC (According to Nyquist criteria sampling frequency should
be double / more than double the highest frequency of the input signal).As soon as
increase the input frequency more than half of sampling frequency , we will observe alias
low frequency waveform at output.
5.3 Design Description
Configuration of system for Digital processing of an analog signal
Discrete FPGA
DSP µP ASICs
Logic
Sampling Theorem:-
If the highest frequency of a signal is Fmax then the signal should be sampled at the rate of at
least 2fmax for the samples to describe the signal completely
Fs >=2Fmax( Fs = sampling frequency)
Aliasing :- Sampling does not results in a loss of information nor does it introduce distortion
in the signal if the signal bandwidth is finite In principle, the analog signal can be
reconstructed from the samples, provided that the sampling rate is sufficiently high to avoid
the problem commonly called Aliasing
Anti aliasing filter : Anti-aliasing filter is used to reduce the effect of aliasing. For that
purpose
sharp cut-off. anti-aliasing filters are used to band limit the signal.
Page 51 of 169
The sampling frequency is increased, to widen the separation between the signal and image
spectra.
Any frequency components of the signal above the folding frequency Fs/2 are sufficiently
attenuated by Anti aliasing filter.
Reconstruction filter : Output of the DAC is need to be reconstruct using low pass analog
filter .before giving to the final output .It serves two purpose first reconstruct output of DAC
and second Remove unwanted frequency i.e above Nyquist frequency
5.4 Procedure
• Use reference material of ADC,DAC .
• Study of ADC and DAC data sheets in details.
• Write VHDL code for interfacing ADC and DAC.
• Set sampling frequency through VHDL code
• Download design code in DSP proto board
• So when we apply sin wave/square wave at input and increase its frequency (using PR1
and SW2) we will get same output frequency as input frequency till half the sampling
frequency. As soon as we cross this frequency (in this case 15.625Khz or 19.53125Khz
respectively for 4Mhz and 20Mhz) we will start observing aliased (low frequency)sin wave.
5.5 Simulate the Design Using Modelsim
Follow same procedure as in counter.
5.6 Synthesize the Design Using XST
Follow same procedure as in counter.
5.7 Running Xilinx Implementation tool
Follow same procedure as in counter.
5.8 Assignments
1 Which type of ADC,DAC is used on protoboard?
2 Write down the specifications of ADC,DA.C
3 What is the maximum input frequency?.
4 How to set input frequecny range for function generator?
5 Write VHDL code for programmable sampling frequency.
6 What is the minimum sampling rate available in your protoboard?.
7 How to get desired sampling clock from DSP board to ADC?.
8 What is aliasing.and How to reduce aliasing effect?.
9 What is Quantization, Expain Midtread & Midriser Uniform
Quantization?
Define “Sampling Theorem”.
Page 52 of 169
LAB 6
IMPULSE RESPONSE OF GIVEN FILTER
6.1 Introduction
In this lab, you can study one way to specify, simulate, and implement a impulse response of FIR filter
using the MATLAB Filter Design & Analysis Tool (FDA Tool). The FDA Tool is used to define the
filter order and coefficients, and the Xilinx FIR filter Blockset is used for the implementation and
Simulink simulation.
The impulse response of a linear time-invariant system is defined as the response of the system to
a unit sample excitation. The output of the system is convolution of input signal x(n) and the system
function h(n). The impulse response of a system helps in finding the stability of that system.
System
X(n) h(n) Y(n)
N
y(n) = ∑ [x(k)*h(n-k)]
k=0
In frequency domain the output of a system is multiplication of Fourier transform of input and system
function i.e.
Since Fourier transform of impulse signal (input signal X(w)) is equal to 1, hence output is equal to
H(w) i.e.
Y(w) = H(w)
Multiple manipulations helps you to understand what impact of changing the coefficient and data width
on both the quality of the filter response and the resulting size
The algorithms /system can be verified using MATLAB Simulink blocks. Xilinx system generator tool
is a part of Simulink tool box.
System generator is used to generate VHDL and all supporting files.
Xilinx ISE tool. is used to synthesize, implement and programming of FPGA.
Page 53 of 169
6.2 Design Procedure Using MATLAB:
Step1: Open MATLAB command window ( by double clicking on the MATLAB icon)
Step2: Open the Simulink library browser window by typing Simulink on the command prompt (>>
Simulink) or by clicking on the Simulink library browser.
Step3: Open a new model file by >> File >> New >> Model
Step4: Go to Simulink library browser and click on sources and select the Pulse generator block and
drag that into new model file.
Step5: Click on sinks and select scope. Drag scope on to open sheet.
Step6: Click on Xilinx block set in the library browser, when in it Click on basic elements
and select system generator block, Gateway In block and Gateway Out block. Drag
them on to new model file.
Step7: Now interconnect all the blocks. It will look as shown in Fig-2.
Step8: Double click on each block, the parameter window will open and select the parameters.
Figure 2
The Pulse Generator can emit scalar, vector, or matrix signals of any real data type. To cause the
block to emit a scalar signal, use scalars to specify the waveform parameters. To cause the block to
emit a vector or matrix signal, use vectors or matrices, respectively, to specify the waveform
parameters. Each element of the waveform parameters affects the corresponding element of the
output signal. For example, the first element of a vector amplitude parameter determines the amplitude
of the first element of a vector output pulse.
The data type of the output is the same as the data type of the Amplitude parameter. The block's
Pulse type parameter allows you to specify whether the block's output is time-based or sample-based.
We have to select sample-based, the block computes its outputs at fixed intervals that we specify. This
can result in fewer computations being required to compute the block's output over the simulation time
period. Depending on the pulse's waveform characteristics, the intervals between changes in the
block's output can vary. For this reason, Simulink cannot use a fixed solver to compute the output of a
Page 54 of 169
time-based pulse generator. Simulink allows you to specify a fixed-step solver for models that contain
time-based pulse generators. However, in this case, Simulink computes a fixed sample time for the
time-based pulse generators. It then simulates the time-based pulse generators as sample-based.
Note If you use a fixed-step solver and the Pulse type is time-
based, you must choose the step size such that the period, phase delay, and
pulse width (in seconds) are integer multiples of the step size. For
example, suppose that the period is 4 seconds, the pulse width is 75%
(i.e., 3 s), and the phase delay is 1 s. In this case, the computed sample
time is 1 s. Therefore, you must choose a fixed-step size that is 1 or that
divides 1 exactly (e.g., 0.25). You can guarantee this by setting the
fixed-step solver's step size to auto on the Configuration Parameters
dialog box.
If you select time-based as the block's pulse type, you must specify the pulse's phase delay and period
in units of seconds. If you specify sample-based, you must specify the block's sample time in seconds,
using the Sample Time parameter, then specify the block's phase delay and period as integer
multiples of the sample time. For example, suppose that you specify a sample time of 0.5 second. And
suppose you want the pulse to repeat every two seconds. In this case, you would specify 4 as the
value of the block's Period parameter
Page 55 of 169
LAB 7
Design Of A Bandpass Filter
Design the Bandpass Equiripple filter for given filter specification.
• Sampling frequency(fs) :62500Hz
• Stop band Frequency1 :500Hz
• Pass band Frequency1 :2000Hz
• Stop band Frequency2: 8000Hz
• Pass band Frequency2 :6000 Hz
• Stop1 band ripple (Astop1 = 60 db)
• Pass band ripple (Apass = 1db)
• Stop2 band ripple (Astop2 = 60 db)
7.1 Procedure
Follow the steps taken in LAB 3
7.2 Assignments
1. 1:Open the place and route tool and fill the following
information
• Number of slices consumed____________________________
• Number of IOBs_______________________________________
• Number of GBUFs______________________________________
• Maximum path delay___________________________________
Page 56 of 169
LAB 8
Design Of A Band Reject Filter
Design the Bandreject Equiripple filter for given filter specification.
• Sampling Frequency (fs) 62500 Hz
• Stop band Frequency1 (Fstop1) 3000 Hz
• Stop band Frequency2 (Fstop2) 4000 Hz
• Pass band Frequency1 (Fpass1) 1000 Hz
• Pass band Frequency2 (Fpass2) 6000 Hz
• Apass1 = 5 db
• Apass2 = 1 db
• Astop = 60 db
8.1 Procedure
Follow the all step as taken in LAB 3.
8.2 Assignments
• Open the place and route tool and fill the following
information
Ð Number of slices consumed______________________
Ð Number of IOBs ________________________________
Ð Number of GBUFs ________________________________
Ð Maximum path delay _____________________________
Page 57 of 169
LAB 9
Noise Removal
Page 58 of 169
Fig -1 Block diagram of Filter
Step2: Open the Simulink library browser window by typing Simulink on the command prompt (>>
Simulink) or by clicking on the Simulink library browser.
Step3: Open a new model file by >> File >> New >> Model
Step4: Go to Simulink library browser and click on sources and select the signal generator block and
drag that into new model file.
Step5: Click on sinks and select scope. Drag scope on to open sheet.
Step6: Click on Xilinx block set in the library browser, when in it Click on basic elements and select
system generator block, Gateway In block and Gateway Out block. Drag them on to new model file.
Step7: Now interconnect all the blocks. It will look as shown in Fig-2.
Step8: Double click on each block, the parameter window will open and select the parameters.
Page 59 of 169
Fig-2
9.4 Filter Specifications:
The specifications of the filter that we intended to design are as follows.
9.5 Signal Generator: Signal generator is used to verify your filter design in the Matlab domain. It
applies an stimulus (note – this stimulus is in the digital domain) of your choice to the Filter.
To program the signal generator, Double click on signal generator icon. A window as shown in Fig-3
will pop up.
Signal Generator parameters
• Amplitude: - The amplitude is the peak value of the input wave.
• Frequency: - The frequency of input wave. Is entered as ratio of input frequency to
• Sampling frequency. (2π * Fin / Fc radians /sec).
Page 60 of 169
Ð The cut off frequency of our filter is 2000Hz and the sampling frequency is 250000Hz. Hence
frequencies in the pass band are represented by a value 0.0502 or greater. We have input a
value 0.135 which corresponds to an input frequency of 5370 Hz (a pass band frequency)
9.6 Gateway In Gateway In blocks are the inputs into the Xilinx portion of the user's Simulink design.
These blocks convert Simulinks integer, double and fixed point data types into the System Generator
fixed point type. Each block defines a top-level input port in the HDL design generated by System
Generator.
To set the block parameters of the gateway in block, double click on the gateway in icon, a window as
shown in Fig-3 will pop up.
Page 61 of 169
(refer to the specifications of DSP development board given above)
Also note that the Input to Gateway-In is coming from the on-board ADC,
Output Data type – is chosen as 2’s complement, because the ADC that is how the ADC codes its
output.
Number of Bits: - represents the number of the bits required to represent the applied input.
The on-board ADC is a 12 bit ADC, Hence we choose number of bits as 12.
Binary Point: - It is position of binary point in the input value (from ADC) from the right hand side.
We use a normalized number system (preferred way of doing a design using Matlab), Hence we put
the binary point at 10 positions ( from the RHS), by doing this,
• We have normalized our input between +1 to -1. Since the sign bit is represented by MSB. 0 bit in
MSB represents a positive number and 1 in MSB represents a negative number.
• The next bit (2nd MSB) bit is used to represent the integer value 1 and the remaining 10 bits
represent the fractional value. 10 bits are sufficient to represent maximum fractional value
(0.9999999999….).
Quantization: - We choose the option truncate. It will truncate bits from MSB if our input number is
more than 12 bits from input.
Overflow: - It will wrap the input if our input number is more than 12 bits from input, which means
value greater than +2047 will map as -2048.
Page 62 of 169
9.8 FDA Tool:-
Step 1: Double click on FDA Tool Block and you get window that looks like below.
Step 3: Go to file menu and export the filter coefficients to the workspace. (>> file >>export)
Step 4 Now come back to your model file where you have design your design file and double click on
FIR
Page 63 of 169
Applying Results to DAC.
The results from Filter are as follows
• Form - 2’s compliment
• Number of Bits – 24
• Sign bit – at MSB.
• Position of Decimal point – before the 19th bit
• Maximum value of any output sample is between +1 to -1 (because output is also normalized.)
We also know from our DAC specification that we have a 12 bit DAC and it accepts inputs in straight
binary format.
Hence we take bits 20
Page 64 of 169
LAB 10
Compiling MATLAB into an FPGA
10.1 Introduction
The MCode block applies input values to an M-function for evaluation using Xilinx's fixed-point data
type. The evaluation is done once for each sample period. The block is capable of keeping internal
states with the user of persistent state variables. The input ports of the block are determined by the
input arguments of the specified M-function and the output ports of the block are determined by the
output arguments of the M-function. The block provides a convenient way to build finite state machines
and control logic.
In order to construct a MCode block, an M-function must be written. The M-file must be in the directory
of the model file that is to use the M-file or in a directory in the MATLAB path.
This tutorial provides two examples that use the MCode block.
• Example 1 shows how to implement a function that returns the maximum value of its inputs;
• Example 2 shows how to implement simple arithmetic operations;
The xlmax.m(file and function name ) file should be either saved in the same directory of the model file
or should be in the MATLAB path. Once the xlmax.m has been saved to the appropriate place, you
should drag a MCode block into your model, open the block parameter dialog box, and enter xlmax
into the Mfunction MATLAB Function. After clicking the OK button, the block has two input ports x and
y, and one output port z.
Page 65 of 169
The following figure shows what the block looks like after the model is compiled. You can see that the
block calculates and sets the necessary fixed-point data type to the output port.
This example shows some simple arithmetic operations and type conversions. The following shows
the xlSimpleArith.m file, which specifies the xlSimpleArith M-function.
Page 66 of 169
function [z1, z2, z3, z4] = xlSimpleArith(a, b)
% const1 is Ufix_8_3
const1 = xfix({xlUnsigned, 8, 3}, 1.53);
% const2 is Fix_10_4
const2 = xfix({xlSigned, 10, 4, xlRound, xlWrap}, 5.687);
z1 = a + const1;
z2 = -b - const2;
z3 = z1 - z2;
% convert z3 to Fix_12_8 with saturation for overflow
z3 = xfix({xlSigned, 12, 8, xlTruncate, xlSaturate}, z3);
This M-function uses addition and subtraction operators. The MCode block calculates these
operations in full precision, which means the output precision is sufficient to carry out the operation
without losing information.
Page 67 of 169
One thing worth discussing is the xfix function call. The function requires two arguments: the first for
fixed-point data type precision and the second indicating the value. The precision is specified in a cell
array. The first element of the precision cell array is the type value. It can be one of three different
types: xlUnsigned, xlSigned, or xlBoolean. The second element is the number of bits of the fixed-point
number. The third is the binary point position. If the element is xlBoolean, there is no need to specify
the number of bits and binary point position. The number of bits and binary point position must be
specified in pair. The fourth element is the quantization mode and the fifth element is the overflow
mode. The quantization mode can be one of xlTruncate, xlRound, or xlRoundBanker. The overflow
mode can be one of xlWrap, xlSaturate, or xlThrowOverflow. Quanitization mode and overflow mode
must be specified
as a pair. If the quantization-overflow mode pair is not specified, the xfix function uses xlTruncate and
xlWrap for signed and unsigned numbers. The second argument of the xfix function can be either a
double or a Xilinx fixed-point number. If a constant is an integer number, there is no need to use the
xfix function. The Mcode block converts it to the appropriate fixed-point number automatically.
After setting the dialog box parameter MATLAB Function to xlSimpleArith, the block shows two input
ports a and b, and four output ports z1, z2, z3, and z4.
Page 68 of 169
M-functions using Xilinx data types and functions can be tested in the MATLAB command window. For
example, if you type: [z1, z2, z3, z4] = xlSimpleArith(2, 3) in the MATLAB command window, you'll get
the following lines:
Notice that the two integer arguments (2 and 3) are converted to fixed-point numbers automatically. If
you have a floating-point number as an argument, an xfix call is required.
Page 69 of 169
LAB 11
Design of A High Pass Filter
11.1 Introduction
In this lab, you can study one way to specify, simulate, and implement a FIR filter using the MATLAB
Filter Design & Analysis Tool (FDA Tool). The FDA Tool is used to define the filter order and
coefficients, and the Xilinx FIR filter Blockset is used for the implementation and Simulink simulation.
Multiple manipulations help you to understand what impact of changing the coefficient and data width
on both the quality of the filter response and the resulting size
The algorithms /system can be verified using MATLAB Simulink blocks. Xilinx system generator tool
is a part of Simulink tool box.
System generator is used to generate VHDL and all supporting files.
Xilinx ISE tool. is used to synthesize, implement and programming of FPGA.
11.2 Procedure
Design of FIR filter –
1. Drag & Drop the required components from the DSP Blockset.
2. Generate Coefficients for the FIR Filter:-
• you specify the filter characteristics through the MATLAB FDA Tool, Save the coefficients to
the workspace, and use the coefficients in the Xilinx FIR filter Blockset.
3. To analyze the output of the filter, input and output signals are displayed in a spectrum scope and
a transfer scope.
Note-A spectrum scope is used to compare the frequency response of the fixed- point FIR filter, and
the double precision direct form II Transpose filter.
Page 70 of 169
Sampling.
Frequency
Stop frequency
Pass frequency
Click on the Design Filter button to find out the filter order
Step 3: In the FDA Tool start-up window, choose File → Export
Go analysis ->select full view analysis observe all theoretical filter analysis
• -Magnitude response.
• -Phase response.
• -Magnitude and phase response.
• -Group delay response.
• -Impulse response
• -Step response.
• -Pole /zero plot.
• -Filter coefficient.
• -Noise loading method.
Page 71 of 169
• -Turn quantization on.
Page 72 of 169
Step 4: Click OK to save the coefficients in the Workspace. You now have two new variables in
your MATLAB workspace: Num and Den. For a FIR filter, Den is equal to one, and Num
represents the coefficients that are used in the filter.
Step 5: Type Num from the MATLAB workspace to see the list of coefficients. >> Num
Step 6: Add the FIR filter block from the Xilinx Blockset/DSP library.
Step 7: Double-click the Xilinx FIR Filter block, and specify the variable
Num in the coefficients parameter field as well as the coefficient width of Fix12_6.(or
Fix12_8) Also, in this design, it is possible to deselect the “Provide Valid Ports” option
because there is a continuous and always valid data on the input of the FIR filter.
Page 73 of 169
Simulate the FIR Filter in Simulink
Following steps are needed to implement FIR filter
Step 1: To simulate the block, click on Simulation icon.
Step 2: Select simulation time (i.e. 1000).
Step 3: Click on start simulation.
Step 4: Double click on scopes.
Step 5: Click properties to change the number of axis displayed and the time range value
(X-axis)
Step 6: Use Data history to control, how many values are stored and displayed on the scope
Step 7: Click auto scale to configure the display to the correct axis values
Page 74 of 169
Step 9: Click on play to see response of signals on scope.
Page 75 of 169
Step 2: Select the SPARTAN-III family, the XC3S400-5PQ208 device, XST and generate the top-
level VHDL code with the System Generator icon
Step 3: Open Project Navigator by double-clicking the filter1.npl file in Windows Explorer
Step 4: Synthesize and Implement the design.
Step 5: Now, go back to the Simulink filter design example, and decrease the coefficient width to
Fix8_8.
Step 6: Rerun Synthesize and Implement in the Project Navigator.
Step 7: Download Design into FPGA and follow following procedure to verify desired filter on FPGA.
• Download the bit file in the Device.
• Give input (Square/sin) to ADC using connector
• Using PR2/PR3/PR4 we can adjust the magnitude of input wave.
• Set the frequency of input using PR1 to 4 KHz. Then start decreasing it. Initially you will
• get output same as input. As you go below 3 kHz attenuation starts.
• Below 1 KHz the output will attenuate almost to zero and you will see a DC value with high
frequency noise.
• If you increase value of input frequency above Nyquist criteria (15 kHz) then you will see aliasing
effect (you’ll see low frequency waveform at output).
11.5 Conclusion
After this lab you are able to know,
• How to select and generate filter coefficients using FDA tool.
• How Xilinx system generator can be used to implement DSP applications.
• Complete simulation and block parameter selection of Xilinx system generator block set.
• Complete MATLAB and ISE design flow.
• How to analyse synthesis and implementation report.
• How Filter can be verified on FPGA using MECHATRONICS DSP Board.
Page 76 of 169
11.6 Assignments
1. What is the type of filter used?
• Equiripple filter: Most of the filters designed here are
equiripple filter.
• Equiripple filter mean that in stop band all the lobes
will have equal size or we can say equal gain.
6. How many slices are used, and are the timing constraint
met?What is the actual clock period? Knowing that you
selected the serial implementation, what is the actual
filter sample rate?--- slices. Constraints are met. Actual
period is xx ns or yyy MHz. Sample rate is yyy/xx = ----
MSPS.
Page 77 of 169
input data width? Decreasing the coefficient width results
in a smaller FIR filter. Decreasing the data width impacts
the sample rate in serial implementation. The smaller the
data, the faster the sample rate.
Stop Band
Pass Frequency
Band
Equal
Freq.
Ripples
Page 78 of 169
LAB 12
Multirate Signal Processing
12.1 Introduction
Having discussed the cases of decimation (down sampling by factor D) and interpolation (up sampling
by factor I) we now consider the general case of sampling rate conversion by factor I/D. Basically, we
can achieve this sampling rate conversion by first performing interpolation by factor I and decimating
the output of the interpolator by the factor D. In other words, a sampling rate conversion by the rational
factor I/D is accomplished by cascading an interpolator with a decimator.
This experiment explains multirate signal processing, how to convert Sampling Rate by rational factor
I/D.
12.2 Procedure
Step1: Open the MATLAB command window by double clicking on the MATLAB icon, which is
provided on the desktop.
Step2: Now open the Simulink Library Browser by typing the Simulink at the command prompt (>>
Simulink) or clicking on the Simulink library browser.
Step4: Go to Simulink sources and select the signal generator block and drag it into model file.
Then go to sinks select the scope and drag into model file.
Step5: Go to Xilinx blocks set and click on the basic elements. The Simulink library browser
looks like below fig.
Page 79 of 169
Select the Gateway In, Gateway Out, System Generator, up sample, and FIR blocks and drop them
into new model file. Then interconnect all the blocks as shown below
Step6: In the figure there are two Xilinx block sets up-sampler followed by low pass filter. Now you
can design the filter as described in the previous lab with the same Specifications. And
export the co-efficient to the FIR Xilinx filter block.
Step7: Now double click on the Up-sampler block. The parameter window will open and select the
sampling rate as 2 as shown in figure below.
Page 80 of 169
Now double click on the FIR block. The parameter window will open and fill the parameters like
coefficients with Num and latency should be greater than 14. Click on ok.
.
Step8: Now double click on Gateway In. The parameter window will open and enter the parameters
as shown below
Page 81 of 169
Step9: Now double click on the signal generator block and select the parameters as shown in
below
Step10: Go to simulation parameters and keep the simulation time as 1000.as shown in below
Page 82 of 169
Step11: Run the simulation and observe the output on the scope. It will look like below
Top one is the output and bottom one is the input waveform
Step12: Now double click on the System Generator block. And select the target device and target
directory where you want to save your file.
Page 83 of 169
Step1: Now open the Xilinx project navigator and go to..>>File >> Open Project. Here you need to
specify location at which your generated file is stored.
Step2: Now add ADC-DAC controller design & generated VHDL/VERILOG core to your project
files.
Modify ADC-DAC controller according to your application. Instantiate Core, generated by
MATLAB as a component in ADC-DAC controller design.
Step3: Then you have to provide .ucf file (User Constraint file).
Right click on VHDL file >> new source >> Implementation Constraint File >> specify
constraints for the Design.
Note – Refer the user constraint file (UCF) which is attached at the end of this manual.
Step4: Then go to the processes for the source in the navigator window and double click on the
“synthesize”.
Step5: Then right click on “Implement the design “and click on Run.
Step6: Then right click on “Generate programming file” and go to properties and then go to the
start up options. Select the clock as CCLK or JTAG. The figure below depicts that
procedure.
Page 84 of 169
Step8 Then run “Generate Programming File”. This will generate the bit file.
Step9: Then go to processes for source window and right click on
“Configure device” >> properties >> slave serial / Boundary-scan mode depending
upon the selection of clock (CCLK, JTAG clock).
Page 85 of 169
Step10: Then double click on “Configure device”.
Download bitstream into FPGA and follow the procedure to verify desired filter on FPGA.
Now you can verify your design by applying sine wave input to any one of the channels and see the
output waveform on the CRO. Set the frequency to 60Hz and increase it gradually to cut-off frequency
and go beyond the cut-off frequency and observe the output on the CRO. You may notice that if the
frequency is increased beyond the cut-off frequency the amplitude will reduce gradually and as you
move far away from cut-off frequency the output will become zero.
Note: You can vary the sampling frequency of ADC by changing the positions of DIPs IL0, IL1, IL2
(switch1, switch2, switch3) from all OFFs to all ONs. Refer DSP manual.
12.3 Assignments
1. Open the place and route tool and fill the following information
• Number of slices _________________________________
• Number of IOBs _________________________________
• Number of GBUFs _________________________________
• Maximum clk frq _________________________________
2. What should be the cut-off frequency?
3. What will be the effect of change in sampling frequency on the
output waveform?
4. What impact does decreasing the coefficient width and input data
width on the Filter size
5. What is Decimator, Interpolator & applications of Decimator &
Interpolator?
6. What is Sampling Rate Conversion of Digital signal?
7. Advantages & Disadvantages of Sampling Rate Conversion in the
Digital Domain.
Page 86 of 169
LAB 12-A
Decimator In Multirate Signal Processing
12-A.1 Introduction
The process of reducing the sampling rate by a factor D (Down sampling by D) is called decimation.
For that the input sequence is passed through low pass filter first and then down sampled.
12-A.2 Procedure
Step 1: Follow the Step 1 to step 4 given in LAB 7.
Step 5: Go to Xilinx block set and click on the basic elements. From that select the Gateway In,
Gateway Out, System Generator, down sample, and FIR blocks and drop them into new
model file. Then interconnect all the blocks are as shown below
Step 6: In the figure there are two Xilinx block sets, up-sampler followed by low pass filter. Now
you design the filter as described in the previous lab with the same specifications. And
export the co-efficient to the FIR Xilinx filter block.
Step 7: Now double click on the down-sampler block. The parameter window will open and select
the sampling rate as 2 as shown in fig below.
Page 87 of 169
Now double click on the FIR block. The parameter window will open and fill the parameters like
coefficients with Num and latency should be greater than 14. Click on ok.
Step 8: Now double click on Gateway In. The parameter window will open and enter the parameters
as shown below
Step 9: Now double click on the signal generator block and select the parameters as shown.
Page 88 of 169
.
Step 10: Go to simulation parameters and keep the simulation time as 1000 as shown.
Step11: Run the simulation and observe the output on the scope. It will look as shown below.
Page 89 of 169
Top one is the output and bottom one is the input waveform
Step12: Now double click on the System Generator block. And select the target device and target
directory where you want to save your file. Click on Generate.
Page 90 of 169
Step5: Then right click on “Implement the design” and click on Run.
Step6: Then right click on “Generate programming file” and go to properties and then go to the
start up options. Select the clock as CCLK or JTAG. The figure below depicts that
procedure.
Page 91 of 169
Step7: Then run the “Generate programming file”. This will generate the bit file.
Step8: Then go to processes for source window and right click on
“Configure device” >> properties >> slave serial / Boundary-scan mode depending
upon the selection of clock (CCLK, JTAG clock).
Now you can verify your design by applying sine wave input to any one of the channels and see the
output waveform on the CRO. Set the frequency to 60Hz and increase it gradually to cut-off frequency
and go beyond the cut-off frequency and observe the output on the CRO. You may notice that if the
frequency is increased beyond the cut-off frequency the amplitude will reduce gradually and as you
move far away from cut-off frequency the output will become zero.
Page 92 of 169
12-A.4: Assignments
1. Open the place and route tool and fill the following
information
• Number of slices _______________________________
• Number of IOBs __________________________________
• Number of GBUFs ________________________________
• Maximum clk frq ________________________________
2. What should be the cut-off frequency?
3. What will be the effect of change in sampling frequency on the
output waveform?
4. What impact does decreasing the coefficient width have on the
filter size? What would be the impact of decreasing the input
data width?
5. Based on the defined specifications, what is the minimum
• filter order?
6. What is the multirate signal processing? What is the need to
change sampling frequency?
Page 93 of 169
LAB 12-B
Interpolator In Multirate Signal Processing
12-B .1 Introduction
Interpolation is the process of up sampling followed by low pass filtering. An increase in the sampling
rate by an integer factor of I can be accomplished by interpolating (I-1) new samples between
successive values of the signal. We can describe it by other means as a process that preserves the
spectral shape of the input signal sequence. Let v (m) denote a sequence with a rate Fy = IFx which is
obtained from input sequence by adding (I-1) zeros between successive values of input sequence.
12-B.2 Procedure
Step1: Open the MATLAB command window by double clicking on the MATLAB icon, which is
provided on the desktop.
Step2: Now open the Simulink Library Browser by typing the Simulink at the command prompt (>>
Simulink) or clicking on the Simulink library browser.
Step4: Go to Simulink sources and select the signal generator block and drag it into model file.
Then go to sinks select the scope and drag into model file.
Step5: Go to Xilinx block set and click on the basic elements. The Simulink library browser is as
shown below
Page 94 of 169
Select the Gateway In, Gateway Out, System Generator, up sample, and FIR blocks and drop them
into new model file. Then interconnect all the blocks as shown below.
Step6: In the figure there are two Xilinx block sets up-sampler followed by lowpass filter. Now you
design the filter as described in the previous lab with the same specifications. And export
the co-efficient to the FIR .Xilinx filter block.
Step7: Now double click on the Up-sampler block. The parameter window will open and select the
sampling rate as “2” as shown in the figure below.
Page 95 of 169
Now double click on the FIR block. The parameter window will open and fill the parameters like
coefficients with Num and latency should be greater than 14.Click on ok.
Step8: Now double click on Gateway In. The parameter window will open and enter the parameters
as shown below
Page 96 of 169
Step9: Now double click on the signal generator block and select the parameters as shown below
Step10: Go to simulation parameters and keep the simulation time as 1000.as shown in below
Page 97 of 169
Step11: Run the simulation and observe the output on the scope. It will look as shown below.
Top one is the output and bottom one is the input waveform
Step12: Now double click on the System Generator block and select the target device and target
directory where you want to save your file. Click on Generate.
Page 98 of 169
12-B.3 Implementation of Design which is generated by MATLAB in Xilinx ISE tool.
Step1: Now open the Xilinx project navigator and go to >>File >> Open Project. Here you need to
specify location at which your generated file is stored.
Step2: Now add ADC-DAC controller design & generated VHDL/VERILOG core to your project
files.
Modify ADC-DAC controller according to your application. Instantiate Core, generated by
MATLAB as a component in ADC-DAC controller design.
Step3: Then you have to provide .ucf file (User Constraint file).
Right click on VHDL file >> new source >> Implementation Constraint File >> specify
constraints for the Design.
Step5: Then right click on “Implement the design” and click on Run.
Page 99 of 169
Step6: Then right click on “Generate programming file” and go to properties and then go to the
start up options. Select the clock as CCLK or JTAG. The figure below depicts that
procedure.
Step7: Then run “Generate programming file”. This will generate the bit file.
13.1 Introduction
Most signals such as speech, biological signals, various communication signals such as audio and
video signals, are analog. To process analog signals by digital means, it is first necessary to convert
them into digital form. The devices used for this are Analog to Digital converters (ADCs). To convert
the processed digital signals into analog form.the device used is D/A converters (DAC – AD7541).
After designing different types of filter successfully there is a need of applying filters in application.
Audio (music) signal contains many frequencies like voice, tones, and drums. If we use low pass filter
and select low frequency from Win amp software, it will show selected range of frequencies and we
will listen music of selected frequency. Using different filters we can extract different music frequency
signals.
In this lab, ADC-DAC interface controller can be verified / implemented in the FPGA using the Xilinx
ISE Tool.
The input to ADC (Audio Signal) is given through stereo jack. Audio (music) signal contains many
frequencies like voice, tones, and drums. If we use low pass filter and select low frequency from Win
amp software, it will show selected range of frequencies and we will listen music of selected
frequency. Using different filters we can extract different music frequency signals.
13.2 Objective
After completing this lab you can go for various audio applications like extracting of some frequencies
with the use of filters. Filters limit the bandwidth of the signal. Low pass filter can be designed for all
low frequencies .As we know musical signal contains musical effects(bass, voice, treble) that may
have higher frequencies all the high frequency effects will be attenuated .We can hear the impact on
speakers.
Similarly if we use high pass filter that will pass higher frequencies then all the low frequency
components will be attenuated. Effect can be easily hear on speakers. If we change frequencies on
Winamp software, we can hear different effect on speakers.
Similarly if we use bandpass or bandreject filters then as per selected frequency range we can hear
effect on speakers.
13.3 Design Description
• Five channels of ADC are used, wherein Channel 1 or Channel 2 gets the input from a stereo jack.
• Output of ADC is then given to FPGA, Conversion Start, ADC clock and channel address signals
are generated through FPGA. FPGA receives End of conversion (EOC) from ADC.
• FPGA will map ADC output directly to DAC input.
• Digital to Analog converter accepts input from FPGA, converts digital data to Analog signal.
• Output of DAC is available on the output stereo jack.
• Design description of all filters is similar as in Labs of filters.
13.4 Procedure
Follow the following steps to analyse music system
• Follow the filter design steps to design filter.
• Instead of giving input from Function generator to ADC use audio output port of PC.
• Output of DAC is connected to speakers.
• Open Win amp. Run music and set frequencies in Win amp.
• As per your filter specification it will attenuate unwanted frequency.
• Vary frequencies from Win amp and listen effect on speakers.
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start Æ
Programs Æ Xilinx ISE Æ Project Navigator
If there are any errors, you can View Synthesis Report by expanding Synthesis, right-click and choose
the View option, otherwise continue on to the next step.
Right-click on Generate Programming File, and choose the Run option, or double left-click on
Generate Programming File. This will generate the Bitstream.
Step 10: Instead of giving input from function generator to ADC use audio out port of PC. Connect it
to the input stereo jack. Connect output of DAC to speakers via an output stereo jack
provided on board. Required control signals of ADC are generated through FPGA.
Step 11: Observe and verify all signals on Test Points of Spartan-III Protoboard (Conversion start,
End of Conversion, sampling clock).
14.1 Introduction:-
The stepper motor is an electrical motor, which converts digital electric input into a rotary motion.
Stepper Motor is the one that revolves through a fixed angle for each pulse applied to the logic
sequences. By controlling pulse rate stepper motor speed can be controlled.
Stepper Motor is also called as a Single Stack Variable Reluctance Motor. If the switching is carried
out in a sequence, the rotor will rotate with stepped motion.
Each coil of stepper motor has a centre tap - a wire coming out from the coil is midway in length
between its two terminals. Because of the long length of the wound wire, it has a significant resistance
(and inductance). You can identify the centre tap by measuring resistance with a suitable ohm-meter.
The resistance from a terminal to the centre tap is half the resistance from the two terminals of a coil.
As shown in the figure, the current flowing from the centre tap of winding 1 to terminal A1 causes the
top stator pole to be a north pole while the bottom stator pole is a south pole. This attracts the rotor
into the position shown. If the power to winding 1 is removed and winding 2 is energised, the rotor will
turn 30 degrees, or one step.
The motor cross section shown in Figure is of a 30 degree per step permanent magnet or hybrid
motor. Motor winding number 1 is distributed between the top and bottom stator pole, while motor
winding number 2 is distributed between the left and right motor poles. The rotor is a permanent
magnet with 6 poles, 3 south and 3 north, arranged around its circumference.
14.2 Objective
In this lab, you will be able to
• Implement a Stepper Motor Controller in an FPGA and verify it on Mechatronics make
protoboard.
• Verify & change speed of Stepper Motor by varying input frequency.
• Verify & change the direction of rotation of Motor.
• Use Spartan-III Protoboard for implementation
• Initialize and test Spartan-III Protoboard before using for your application.
Specifications of motor -
• Voltage Rating – 12 V DC
• Step Angle –1.80.
• Steps/Revolution-200
Step 3: Click on symbol of FPGA device and then right clickÆ Click on new source ÆVHDL module
and give name stepper_motor_hsÆDefine portsÆFinish.
Step 4: Generate the Behavioral VHDL Code for the stepper motor controller.
Step 5: Check syntax, and remove errors if present.
Step 6: Synthesize the design using XST.
Highlight stepper_motor_test.vhd file in the Sources in Project window.
To run synthesis, right-click on Synthesize, and choose the Run option, or double-click on
Synthesize in the Processes for Current Source window. Synthesis will run, and a green
check will appear next to Synthesize when it is successfully completed. A yellow
exclamation mark indicates that a warning was generated, and a red cross indicates an
error was generated. Warnings are OK.
14.6 Conclusion: -
Thus stepper motor is implemented in FPGA for different speeds and the direction of the motor is
changed and verified.
15.1 USB
USB (Universal Serial Bus) is used for Data transfer with peripherals and has many advantages:-
• Best way to communicate with many
Ð Input Devices (Mouse, Keyboard, Joysticks .etc).
• Memory Devices like Disk Drives, Memory Cards …etc.
Ð Computer peripherals like, Modems, Printers, Disk drives..etc
Ð Other devices like Digital Cameras, MP3 players, Set Top boxes …etc.
• USB expansion hubs make the bus simultaneously available to dozens of Device.
• USB devices are true plug-n-play i.e. can be plugged in anytime, even when the PC is turned ON.
15.2 USB Interfacing:-
When you plug into USB, the host goes through a Sign ON sequence.
• The host sends a Get Descriptor-Device request to address Zero (all USB device must respond to
address Zero when first attached).
• The Device responds to the request by sending ID data back to the Host to identify itself.
• The Host sends a Set Address request which assigns a unique address to the just attached device.
So it may be distinguished from other devices connected to the Bus
• The Host sends more Get Descriptor request asking for additional device description.
USB devices available in a large variety through a large a number of vendors. The device provided on
our proto-board is FT245BM from FTDI Inc. The FT245BM is their 2nd generation USB FIFO IC.
15.5 General Description of USB-FIFO (FTDI):-To send data from the peripheral to the host
computer, simply write the byte wide data into the module when TXE# is low If the (384-byte) transmit
buffer fills up or is busy storing the previously written byte, the device keeps TXE# high in order to stop
further data from being written until some of the FIFO data has been transferred over USB to the host.
TXE# goes high after every byte written.
When the host sends data to the peripheral over USB, the device will take RXF# low to let the
peripheral know that at least one byte of data is available. The peripheral can read a data byte every
time RXF# goes low. RXF# goes high after every byte read.
• USB Drivers
• Required Drivers and DLL S/W Interface are provided on CD supplied with this proto-board and
are also freely downloadable from the FTDI Website.
• counter_read_write:
A COUNTER is run in 'C' and fed into an array which in turn is passed into the buffer and finally
through FTDI (FT245BM) into FIFO of FPGA (SPARTAN3). When data enters into the FIFO empty
flag of FIFO goes down and data is written into FIFO. When FIFO gets full, the full flag gets high and
then read operation is performed and data transferred is seen as a counter on LEDs.
• File-loopback:
Data is sent from file input (of size 16MB in this case).When data enters into the FIFO, empty flag of
FIFO goes down and data is written into FIFO. When FIFO gets full, the full flag gets high and then
read operation is performed. As reading operation gets over, an output file is created in which data
from f1 is poured. This serves as a Loop back operation.
Data is written in the FIFO in chunks of 4KB and then read from fifo, till the fifo gets empty and then
again same process of writing and reading in chunks of 4KB is done till end of file is reached.
• Keyboard_ASCII:-
Data is input through the keyboard and written into the FIFO and loop back operation is observed.
(Corresponding ASCII) value is returned.
Step 3: Click on symbol of FPGA device and then right clickÆ Click on new source ÆVHDL module
and give name usb_main.vhdÆDefine portsÆFinish.
Step 4: Generate the Behavioural VHDL Code for the USB Interface.
If there are any errors, you can View Synthesis Report by expanding Synthesis,
right-click and choose the View option, otherwise continue on to the next step.
Step 7: Write User Constraint file wherein the FPGA pins are locked as per the Spartan-II hardware.
16.1 Introduction:
The Multiplexer is a combinational circuit that is the most widely used circuit in Digital Design.
Multiplexing means transmitting a large number of information units over a smaller number of channels
or lines. A Digital Multiplexer is a combinational circuit that selects binary information from one of many
input lines and directs it to a single output line. The selection of a particular input line is controlled by a
set of selection lines.
In this lab, you will learn how to implement an 8:1 Multiplexer using Xilinx ISE Tool.
• Write the functionality in the Xilinx project navigator.
• Run a functional HDL simulation.
• Synthesize your design with XST.
• Take the synthesized design through the Xilinx implementation tools.
• Download the bit stream file.
• Check the performance of your design by applying different inputs and verify the outputs.
16.2 Objectives:
In this lab, you will be able to implement the multiplexer in FPGA and verify it on Mechatronics make
Protoboard.
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start Æ
Programs Æ Xilinx ISE Æ Project Navigator.
Step 2: In the Project Navigator window go to FILE ÆNew projectÆSelect Device.
Step 3: Click on the symbol of FPGA device and then right clickÆ Click on new source ÆVHDL
module and give the name 8_1_MultiplexerÆDefine portsÆFinish.
If there are any errors, you can view the error through the console window otherwise
continue on to the next step.
Step 9: Write User Constraint file (UCF) wherein the FPGA pins are locked as per the hardware.
Step 10: Run the Xilinx Implementation Tools.
VHD Code for 8:1 Multiplexer:- Verilog Code for 8:1 Multiplexer
17.1 Introduction:-
Discrete quantities of information are represented in digital systems with binary codes. A binary code
of n bits is capable of representing up to 2n distinct elements of the coded information. A Decoder is a
combinational circuit that converts binary information from n input lines to a maximum of 2n output
lines. Decoder is similar to a Demultiplexer except that there is no data input. The only inputs are the
control inputs A and B.
In this lab, you will learn how to implement a 2:4 Decoder using Xilinx ISE Tool.
• Write the functionality in the Xilinx project navigator.
• Run a functional HDL simulation.
• Synthesize your design with XST.
• Take the synthesized design through the Xilinx implementation tools.
• Download the bit stream file.
• Check the performance of your design by applying binary inputs and verify the outputs.
17.2 Objectives:-
In this lab, you will be able to implement the Decoder in FPGA and verify it on Mechatronics make
Protoboard.
17.3 Design Description:-
The Truth Table of 2:4 decoders is as below.
Step 3: Click on the symbol of FPGA device and then right clickÆ Click on new source ÆVHDL
module and give the name 2_4_DecoderÆDefine portsÆFinish.
Step 4: Generate the Behavioral VHDL Code for the 2_4_Decoder.
Step 5: Check syntax, and remove errors if present.
Step 6: Simulate the design using Modelsim.
Highlight Decoder_tb.vhd file in the Sources in Project window. To run the Functional
Simulation, Click on the symbol of FPGA device and then right clickÆ Click on new
sourceÆClick on test bench waveformÆGive file nameÆSelect entityÆFinishÆGive
inputsÆ Click on simulate behavioral model Æobserve the output.
If there are any errors, you can view the error through the console window otherwise
continue on to the next step.
Step 8: Write User Constraint file wherein the FPGA pins are locked as per the hardware.
Step 9: Run the Xilinx Implementation Tools.
Once synthesis is complete, you can place and route your design to fit into a Xilinx device
(Spartan-III 400k), and you can also get some post place-and-route timing information about
the design. This procedure runs you through the basic flow for implementation.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
Right-click on Generate Programming File, and choose the Run option, or double left-click
on Generate Programming File. This will generate the Bit stream
Step 10: Double click on Configure Device to download the bit stream.
Step 11: Apply input through DIP Switches (IL0 to IL1) and output is displayed on LEDs.
17.6 Conclusion:-
Design of 2:4 Decoder is implemented in Protoboard and is verified according to the truth Table.
17-A .1 Introduction:-
An Encoder is a digital circuit that performs the inverse operation of a decoder. An Encoder has 2n
input lines and n output lines. The output lines generate the binary code corresponding to the input
value.
In this lab, you will learn how to implement a 8:3 Encoder using Xilinx ISE Tool.
Write the functionality in the Xilinx project navigator.
Run a functional HDL simulation.
Synthesize your design with XST.
Take the synthesized design through the Xilinx implementation tools.
Download the bit stream file.
Check the performance of your design by applying eight inputs and verify the binary outputs.
17-A.2 Objectives:
After completing this lab, you will be able to implement the Encoder in FPGA and verify it on
Mechatronics make Protoboard.
If there are any errors, you can view the error through the console window otherwise
continue on to the next step.
Step 8: Write User Constraint file wherein the FPGA pins are locked as per the hardware.
Step 9: Run the Xilinx Implementation Tools.
Once synthesis is complete, you can place and route your design to fit into a Xilinx device
(Spartan-III 400k), and you can also get some post place-and-route timing information about
the design. This procedure runs you through the basic flow for implementation.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
Right-click on Generate Programming File, and choose the Run option, or double left-
click on Generate Programming File. This will generate the Bit stream.
Step 10: Double click on Configure Device to download the bit stream.
Step 11: Apply input through DIP Switches (IL0 to IL7) and output is displayed on LEDs.
17-A.6 Conclusion:-
Design of 8:3 Encoder is implemented in Protoboard and is verified according to the truth Table.
17-A.7 Assignments
1. Design 8:3 Priority encoder with Y7 having highest
priority.
2. Give applications of encoder.
18.1 Introduction:-
An Encoder is a digital circuit that performs the inverse operation of a decoder. An Encoder has 2n
input lines and n output lines. The output lines generate the binary code corresponding to the input
value.
In this lab, you will learn how to implement a 8:3 Encoder using Xilinx ISE Tool.
• Write the functionality in the Xilinx project navigator.
• Run a functional HDL simulation.
• Synthesize your design with XST.
• Take the synthesized design through the Xilinx implementation tools.
• Download the bit stream file.
• Check the performance of your design by applying eight inputs and verify the binary outputs.
18.2 Objectives:-
In this lab, you will be able to implement the Encoder in FPGA and verify it on Mechatronics make
Protoboard.
18.6 Conclusion:-
Design of 8:3 Encoder is implemented in Protoboard and is verified according to the truth Table.
18.7 Assignments
19.1 Introduction:-
The comparison of two numbers is an operation that determines if one number is greater than, less
than or equal to the other number. A magnitude comparator is a combinational circuit that compares
two numbers, A and B, and determines their relative magnitudes. The output of the comparison is
specified by the three binary outputs that indicates whether A is greater than B (A>B), A is less than B
(A<B) or A is equal to B (A=B).
In this lab, you will learn how to implement a 2 Bit Comparator using Xilinx ISE Tool.
• Write the functionality in the Xilinx project navigator.
• Run a functional HDL simulation.
• Synthesize your design with XST.
• Take the synthesized design through the Xilinx implementation tools.
• Download the bit stream file.
• Check the performance of your design by applying inputs and verify the outputs.
19.2 Objectives:-
In this lab, you will be able to implement the 2 Bit Comparator in FPGA and verify it on Mechatronics
make Protoboards.
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start Æ
Programs Æ Xilinx ISE Æ Project Navigator.
Step 2: In the Project Navigator window go to FILE ÆNew projectÆSelect Device.
Step 3: Click on the symbol of FPGA device and then right clickÆ Click on new source ÆVHDL
module and give the name comparatorÆDefine portsÆFinish.
Step 4: Generate the Behavioural VHDL Code for the Comparator.
Step 5: Check syntax and remove errors if present.
Step 6: Simulate the design using ModelSim.
Highlight Comparator_tb.vhd file in the Sources in Project window. To run the Functional
Simulation, Click on the symbol of FPGA device and then right clickÆ Click on new
sourceÆClick on test bench waveformÆGive file nameÆSelect entityÆFinishÆGive
inputsÆ Click on simulate behavioral model Æobserve the output.
If there are any errors, you can view the error through the console window otherwise
continue on to the next step.
Step 8: Write User Constraint file wherein the FPGA pins are locked as per the hardware.
Step 9: Running the Xilinx Implementation Tools.
Once synthesis is complete, you can place and route your design to fit into a Xilinx device
(Spartan-IIII 400k), and you can also get some post place-and-route timing information
about the design. This procedure runs you through the basic flow for implementation.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
Right-click on Generate Programming File, and choose the Run option, or double left-click
on Generate Programming File. This will generate the Bit stream.
Step 10: Double click on Configure Device to download the bit stream.
Step 11: Apply input through DIP Switches (IL0 to IL3) and output is displayed on LEDs.
Further assignments
1. Design Generalized Comparator using Generic statements in
VHDL (Ex. n bit comparator).
2. See the synthesis report and place and route report and
observe the hardware.
Note – Refer the user constraint file(UCF) which is attached at
the end of this manual
20.1 Introduction:-
The availability of a large variety of codes for the same discrete elements of information results in the
use of different codes by different digital systems. It is sometimes necessary to use the output of one
system as a input to another. A conversion circuit must be inserted between the two systems if each
uses different codes for the same information. Thus, a code converter is a circuit that makes the two
systems compatible even though each uses a different binary code. To convert from binary code A to
binary code B, the input lines must supply the bit combination of elements as specified by code A and
the output lines must generate the corresponding bit combination of code B. A combinational circuit
performs this transformation by means of logic gates.
Sometimes it is convenient to use the Gray code to represent the digital data when it is converted from
analog data. The advantage of the Gray code over binary numbers is that only one bit in the code
group changes when going from one number to the next. The gray code is used in applications where
the normal sequence of binary numbers may produce an error or ambiguity during the transition from
one number to the next.
In this lab, you will learn how to implement a Binary to Gray Code Converter using Xilinx ISE Tool.
• Write the functionality in the Xilinx project navigator.
• Run a functional HDL simulation.
• Synthesize your design with XST.
• Take the synthesized design through the Xilinx implementation tools.
• Download the bit stream file.
• Check the performance of your design by applying inputs and verify the outputs.
20.2 Objectives:-
In this lab, you will be able to implement the binary to gray code converter in FPGA and verify it on
Mechatronics make Protoboard.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
Right-click on Generate Programming File, and choose the Run option, or double left-click
on Generate Programming File. This will generate the Bit stream.
Step 10: Double click on Configure Device to download the bit stream.
Step 11 Apply Binary inputs (B3, B2, B1, B0) through DIP Switches (IL0, IL1, IL2, IL3) and 4 bit Gray
Code outputs are observed on Output LEDs (OL0 TO OL3).
20.7 Conclusion:-
Design of Binary to Gray code converter is implemented in Protoboard and is verified according to the
truth Table.
20.8 Assignments
1. Design a gray to binary converter and write the VHDL code
to implement it in FPGA.
2. Design controllable Binary to Gray/Gray to Binary
converter.
3. List the applications wherein gray code is used.
Note – Refer the user constraint file(UCF) which is attached at
the end of this manual
21.1 Introduction:-
The T flip-flop is a single input version of the JK flip-flop. It is obtained from the JK flip-flop when both
the inputs are tied together. The designation T comes from the ability of the flip flop to “toggle” or
complement, its state. Regardless of the present state, the flip-flop complements its output when the
clock pulse occurs while input T=’1’. The characteristic table and characteristic equation shows that
when T=0, Q(t+1) = Q, that is, the next state is the same as the present state and no change occurs.
When T=1, then Q(t+1) = Q’, and the state of the flip-flop is complemented.
In this lab, you will learn how to implement a T Flip Flop using Xilinx ISE Tool.
• Write the functionality in the Xilinx project navigator.
• Run a functional HDL simulation.
• Synthesize your design with XST.
• Take the synthesized design through the Xilinx implementation tools.
• Download the bit stream file.
• Check the performance of your design by applying inputs and verify the outputs.
21 2 Objectives:-
In this lab, you will be able to implement the T Flip Flop in FPGA and verify it on Mechatronics make
Protoboard.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
Right-click on Generate Programming File, and choose the Run option, or double left-click
on Generate Programming File. This will generate the Bit stream.
Step 10: Double click on Configure Device to download the bit stream.
Step 11: Apply input through DIP Switches (IL0) and output is displayed on LEDs.
21.6 Conclusion
Design of T Flip Flop is implemented in Protoboards and is verified according to the truth Table.
22.1 Introduction:-
In this lab we will learn how to interface keyboard, seven-segment display and Input Output LEDs to
FPGA using Xilinx ISE Tool. Write the functionality in Xilinx Project Navigator, synthesize the design
with XST, and take the synthesized design through the Xilinx implementation tools. Download the bit
stream file into FPGA and see the scrolling display using keyboard.
22.2 Objective:-
In this lab, you will be able to
• Use the keyboard, Input / Output LEDs to perform various functions that can be implemented
using FPGA.
• Observe the output on the display / LEDs.
22.4 Procedure:-
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start
ÆPrograms Æ Xilinx ISE Æ Project Navigator.
Step 2: In the Project Navigator window go on FILE ÆNew projectÆSelect
Device.
Step 10: Apply input through SW1 & SW2 switches. Observe input/output LEDs. LEDs should
glow with proper brightness.
Step 11: Observe the scrolling of hexadecimal numbers by pressing respective keys.
Note – Refer the user constraint file (UCF) which is attached at the end of this manual.
23.1 Introduction
In this lab, Design of 4 bit Arithmetic and Logic Unit can be verified / implemented in the FPGA
using the Xilinx ISE Tool.
The Arithmetic Logic Unit is the heart of the microprocessor. It is used to perform certain
arithmetic operations, such as addition, subtraction etc. and logical operations such as AND, OR,
EX-OR, etc.
Accumulator Register For arithmetic operations, such as addition, subtraction, etc. and logical
operations, such as AND, OR, EX-OR etc, one of the operands is in the accumulator. The result
of the operations is also stored in the accumulator.
23.2 Objective
In this lab, you will be able to
• Observe the logical and arithmetic operation output.
• Implement and verify the design using the Mechatronics Make VLSI protoboard.
It has four inputs (A, B, Opcode and Enable) and a single output (Out).
A and B: 4 bit Binary Data inputs.
Opcode: 4 Bit Opcode used to select the operation.
Enable: ALU should pass the result to the output bus when enable line is High, and Tri-state the
output bus when the Enable line is Low.
ALU should use combinational logic to calculate an output based on the four-bit Opcode input.
ALU should decode the 4 Bit Opcode according to the table given below
A and B operand can be applied through input switches. Output can be observed on 7 segment
Display.
Operand A (IL0 to IL3)
Operand B (IL4 to IL7)
Opcode can be applied through (IL8 to IL11)
23.5 Procedure:
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start Æ
Programs Æ Xilinx ISE Æ Project Navigator.
Step 2: In the Project Navigator window go on FILE ÆNew projectÆSelect Device.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
Right-click on Generate Programming File, and choose the Run option, or double left-click
on Generate Programming File. This will generate the Bitstream.
Step 9: Double click on Configure Device to download the bitstream.
23.7 Assignments
1. Design a 6-bit ALU and verify it on the Mechatronics make
Protoboard.
2. Whether latches are inferred for this code? If yes, give
the number of latches inferred
Note – Refer the user constraint file (UCF) which is attached at the end of this manual.
24.1 Introduction:-
Most signals such as speech, biological signals, and various communication signals such as audio
and video signals are analog. To process analog signals by digital means, it is first necessary to
convert them into digital form. The devices used for this are Analog to Digital converters (ADCs). In
many cases it is desirable to convert the processed digital signals into analog form. This is done by
D/A converters (DACs).
In this lab, ADC-DAC interface will be implemented in the FPGA using the Xilinx ISE Tool. The input to
the ADC is given through a thermistor circuit. Thermistor is a thermally sensitive resistor whose
function is to exhibit a large, predictable and precise change in electrical resistance when subjected to
an increase in temperature.
In protoboard, Negative Temperature Coefficient (NTC) thermistor is used. NTC thermistor exhibits a
decrease in electrical resistance when subjected to an increase in body temperature. Resistance
temperature characteristics of an NTC are shown below.
The slope or resistance ratio for thermistor is defined as the ratio of resistance at one temperature
(usually 0°C) to the resistance at a second / higher temperature (usually 70°C).
Slope or resistance ratio provides an introduction to the concept of rate of change of resistance with
temperature and the sensitivity of the resistance of thermistor to temperature change.
24.2 Objective:-
In this lab, ADC-DAC interfacing is implemented and is verified with the help of a temperature sensor
(thermistor). After completing this lab you will be able to observe and verify the characteristics of
thermistor using FPGA.
Digital to Analog converter accepts input from FPGA, converts digital data to Analog signal.
Output of DAC is available on the connector. (Refer connector details given below)
24.5 Procedure:-
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start Æ
Programs Æ Xilinx ISE Æ Project Navigator
Step 2: In the Project Navigator window go on FILE ÆNew projectÆSelect Device.
Step 3: Click on symbol of FPGA device and then right clickÆ Click on new source ÆVHDL module
and give name adcdacmodiÆDefine portsÆFinish.
Step 4: Generate the Behavioral VHDL Code for the ADC-DAC interface.
Step 5: Check syntax, and remove errors if present.
Step 6: Synthesize the design using XST.
Highlight adcdacmodi.vhd file in the Sources in Project window.
If there are any errors, you can View Synthesis Report by expanding Synthesis, right-click
and choose the View option, otherwise continue on to the next step.
Step 7: Write User Constraint file wherein the FPGA pins are locked as per the hardware.
Step 8: Running the Xilinx Implementation Tools.
Once synthesis is complete, you can place and route your design to fit into a Xilinx device
(Spartan3 400K), and you can also get some post place-and-route timing information about
the design. This procedure runs you through the basic flow for implementation.
Right-click on Implement Design, and choose the Run option, or double left-click on
Implement Design.
Right-click on Generate Programming File, and choose the Run option, or double left-click
on Generate Programming File. This will generate the Bitstream.
Step 9: Double click on Configure Device to download the bitstream.
24.6 Assignments
Note – Refer the user constraint file (UCF) which is attached at the end of this manual.
25.1 Introduction
In this lab, 16 characters X 2-line LCD display is interfaced to the protoboard. The data to be
displayed on the LCD can be sent through the FPGA by writing VHDL code using the Xilinx ISE
Tool.
A Liquid Crystal Display is commonly used in systems where low power consumption is necessary. An
LCD display consists of crystal material placed between two plates. The crystal material is arranged
between two segments or in the form of a dot matrix. The crystal material passes or blocks the light
coming on it; so as to create a display. To display the character, certain segments or dots are driven
by square wave pattern, which is supplied by a built in driver.
The driver is interfaced with FPGA using signals such as data lines, control signals (RS-Register
select, R/W-Read/Write, E-Enable).
25.2 Objective:-
After completing this lab, you will be able to
• Observe data on the LCD display.
• Display data in various fashion such as rotating mode, constant display etc.
25.5 Procedure:-
Step 1: Start the Xilinx Project Navigator by using the desktop shortcut or by using the Start Æ
Programs Æ Xilinx ISE Æ Project Navigator.
Step 2: In the Project Navigator window go on FILE ÆNew projectÆSelect Device.
Step 10: Observe the data displayed on LCD. You can see
BITMAPPER in the first row
Cnt – XX A free running counter in the second row.
25.6 Assignments
1. Design LCD Controller to display the name of your college.
2. Do a scrolling display on the LCD.
3. How will you reduce the delay that has been introduced in the
counter of the given functionality?
4. Design a calculator and display the result on LCD.
Note – Refer the user constraint file (UCF) which is attached at the end of this manual.
26.1 Introduction:-
In this lab, an elevator is designed for a three storied building using the system controller
approach. The goal of this lab is to learn more of the capabilities of VHDL and the Xilinx tool as
well as to learn how to debug and build larger Digital design systems.
Figure below shows the block diagram of Lift Controller.
First we shall try to understand the concept of finite state machines (FSM) in brief.
• In layman’s terms all circuits or devices that go through a number of finite distinct states can be
classified as FSM.
• The best possible example that can be illustrated is that of a counter. Since the counter traverses a
number of states before reaching its original state.
• In FSM we see that the circuit in each distinct state has a distinct number of outputs.
We observe that for the FSM to go from state s0 to s1 a particular input has to be ‘1’ else it stays at
s0 (next state logic).
• Also at every state there is an output defined e.g. at s1 the o/p is ‘0’ (output logic).
• Similarly for others we can understand that for the states to change certain conditions must be
satisfied and that every state has its own set of outputs.
• Before the students start coding FSM they should realize that FSM is not the only way of making a
circuit but it is just a way of representing an idea in a well-organized and structured manner. Thus
any circuit that can be constructed using FSM can also be constructed using regular VHDL coding
techniques.
Step 3: Click on symbol of FPGA device and then right clickÆ Click on new source ÆVHDL module
and give name lift controllerÆDefine portsÆFinish.
Step 4: Generate the Behavioral VHDL Code for the Lift Controller.
Step 5: Check syntax, and remove errors if present.
Step 6: Synthesize the design using XST.
Highlight lift_controller.vhd file in the Sources in Project window.
To run synthesis, right-click on Synthesize, and choose the Run option, or double-click on
Synthesize in the Processes for Current Source window. Synthesis will run, and a green
check will appear next to Synthesize when it is successfully completed. A yellow
exclamation mark indicates that a warning was generated, and a red cross indicates an
error was generated. Warnings are OK.
Step 10: The output can be observed on the seven segment displays as well as the output LEDs.
Note – Refer the user constraint file (UCF) which is attached at the end of this manual.
LAB 1 ..............................................................................................................................................17
Generate Waveforms using DAC 17
1.1 Introduction ............................................................................................................................................ 17
1.2 Specifications of DAC AD7541: .............................................................................................................. 17
1.3 Objective ................................................................................................................................................ 18
1.4 Design Description ................................................................................................................................. 18
1.5 Experimental Set up ............................................................................................................................... 18
1.6 Procedure............................................................................................................................................... 18
1.7 Simulate the Design Using ModelSim .................................................................................................... 19
1.8 Synthesize the Design Using XST.......................................................................................................... 21
1.9 Running the Xilinx Implementation Tools ............................................................................................... 22
1.10 Download design into DSP Protoboard ................................................................................................ 23
1.11 Conclusion ........................................................................................................................................... 24
LAB 2 ..............................................................................................................................................26
Verification of Sampling Theorem using ADC-DAC 26
2.1 Introduction ............................................................................................................................................ 26
2.2 Objective ................................................................................................................................................ 26
2.3 Design Description:- ............................................................................................................................... 26
2.4 Experimental Set up:-............................................................................................................................. 27
2.5 Generate, Synthesize, and Place & Route in Xilinx ................................................................................ 30
2.6 For physical verification: ......................................................................................................................... 33
2.7 Assignments........................................................................................................................................... 33
LAB 3 ..............................................................................................................................................34
FIR filter using windowing method 34
3.1 Introduction ............................................................................................................................................ 34
3.2 Objective ................................................................................................................................................ 34
3.3 Procedure............................................................................................................................................... 34
3.4 Assignments........................................................................................................................................... 44
LAB 4 ..............................................................................................................................................45
Design of FIR filter 45
4.1 Introduction ............................................................................................................................................ 45
4.2 Procedure............................................................................................................................................... 45
4.3 Filter Design ........................................................................................................................................... 45
4.4 Simulate the FIR filter in Simulink........................................................................................................... 47
4.5 Generate Synthesize and Place and Route............................................................................................ 49
4.6 Download the bit file in the Device.......................................................................................................... 49
4.7 Assignments........................................................................................................................................... 50
LAB 5 ..............................................................................................................................................51
LAB 6 ..............................................................................................................................................53
IMPULSE RESPONSE OF GIVEN FILTER 53
6.1 Introduction ............................................................................................................................................ 53
6.2 Design Procedure Using MATLAB: ........................................................................................................ 54
6.3 Pulse Generator ..................................................................................................................................... 54
LAB 7 ..............................................................................................................................................56
Design Of A Bandpass Filter 56
7.1 Procedure............................................................................................................................................... 56
7.2 Assignments........................................................................................................................................... 56
LAB 8 ..............................................................................................................................................57
Design Of A Band Reject Filter 57
8.1 Procedure............................................................................................................................................... 57
8.2 Assignments........................................................................................................................................... 57
LAB 9 ..............................................................................................................................................58
Noise Removal 58
9.1 Noise Removal ....................................................................................................................................... 58
9.2 Hardware Description............................................................................................................................. 58
9.3 Filter Design Procedure using MATLAB ................................................................................................. 58
9.4 Filter Specifications: ............................................................................................................................... 60
9.5 Signal Generator: ................................................................................................................................... 60
9.6 Gateway In ............................................................................................................................................. 61
9.7 FIR Filter Design: ................................................................................................................................... 62
9.8 FDA Tool:-.............................................................................................................................................. 63
9.9 GATEWAY Out....................................................................................................................................... 63
LAB 10 ............................................................................................................................................65
Compiling MATLAB into an FPGA 65
10.1 Introduction .......................................................................................................................................... 65
LAB 11 ............................................................................................................................................70
Design of A High Pass Filter 70
11.1 Introduction .......................................................................................................................................... 70
11.2 Procedure............................................................................................................................................. 70
11.3 Filter Design ......................................................................................................................................... 70
11.4 Generate, Synthesize, and Place & Route ........................................................................................... 75
11.5 Conclusion ........................................................................................................................................... 76
11.6 Assignments......................................................................................................................................... 77
LAB 12 ............................................................................................................................................79
Multirate Signal Processing 79
12.1 Introduction .......................................................................................................................................... 79
12.2 Procedure............................................................................................................................................. 79
12.3 Assignments......................................................................................................................................... 86
LAB 13 ..........................................................................................................................................102
Analysis of Audio Signal Using Filters 102
13.1 Introduction ........................................................................................................................................ 102
13.2 Objective ............................................................................................................................................ 102
13.3 Design Description ............................................................................................................................. 102
13.4 Procedure........................................................................................................................................... 102
13.5 Experimental Set up ........................................................................................................................... 104
13.6 Further assignments........................................................................................................................... 104
LAB 14 ..........................................................................................................................................105
Implementation of Stepper Motor Controller 105
14.1 Introduction:- ...................................................................................................................................... 105
14.2 Objective ............................................................................................................................................ 105
14.3 Design Description:- ........................................................................................................................... 105
14.4 Procedure........................................................................................................................................... 107
14.5 Experimental Set up:- ......................................................................................................................... 109
14.6 Conclusion: - ...................................................................................................................................... 109
14.7 Further assignments........................................................................................................................... 109
LAB 15 ..........................................................................................................................................110
USB Controller 110
15.1 USB.................................................................................................................................................... 110
15.2 USB Interfacing:- ................................................................................................................................ 110
15.3 USB Interface Devices:- ..................................................................................................................... 110
15.4 Features of FT245BM ........................................................................................................................ 111
15.5 General Description of USB-FIFO (FTDI):-......................................................................................... 111
15.6 LAB Description.................................................................................................................................. 112
15.7 Design Description ............................................................................................................................. 112
15.8 Procedure:- ........................................................................................................................................ 113
15 .9 Experimental Setup ........................................................................................................................... 115
15.10 Conclusion ....................................................................................................................................... 115
LAB 16 ..........................................................................................................................................116
Implementation of 8:1 Multiplexer 116
16.1 Introduction: ....................................................................................................................................... 116
16.2 Objectives: ......................................................................................................................................... 116
16.3 Design Description: ............................................................................................................................ 116
16.4 Experimental Set up: .......................................................................................................................... 116
16.5 Steps to implement the 8:1 multiplexer in the FPGA .......................................................................... 117
16.6 Conclusion:- ....................................................................................................................................... 120
VHD Code for 8:1 Multiplexer:-................................................................................................................... 120
UCF for 8:1 Multiplexer:- .................................................................................Error! Bookmark not defined.
16.7 Assignments....................................................................................................................................... 121
LAB 17 ..........................................................................................................................................122
Implementation of 2:4 Decoder 122
17.1 Introduction:- ...................................................................................................................................... 122
17.2 Objectives:- ........................................................................................................................................ 122
17.3 Design Description:- ........................................................................................................................... 122
17.4 Experimental Set up:- ......................................................................................................................... 122
17.5 Steps to implement the 2:4 Decoder in the FPGA .............................................................................. 122
LAB 18 ..........................................................................................................................................129
Implementation of 8:3 Encoder 129
18.1 Introduction:- ...................................................................................................................................... 129
18.2 Objectives:- ........................................................................................................................................ 129
18.3 Design Description:- ........................................................................................................................... 129
18.4 Experimental Set up:- ......................................................................................................................... 129
18.5 Steps to implement the 8:3 Encoder in the FPGA .............................................................................. 129
18.6 Conclusion:- ....................................................................................................................................... 132
18.7 Assignments....................................................................................................................................... 132
LAB 19 ..........................................................................................................................................133
Implementation of 2 Bit Comparator 133
19.1 Introduction:- ...................................................................................................................................... 133
19.2 Objectives:- ........................................................................................................................................ 133
19.3 Design Description:- ........................................................................................................................... 133
19.4 Experimental Set up:- ......................................................................................................................... 134
19.5 Steps to implement the 2 Bit Comparator in the FPGA....................................................................... 134
LAB 20 ..........................................................................................................................................136
Implementation Of Binary To Gray Code Converter 136
20.1 Introduction:- ...................................................................................................................................... 136
20.2 Objectives:- ........................................................................................................................................ 136
20.3 Design Description:- ........................................................................................................................... 136
20.4 Truth Table for Binary to Gray Code:.................................................................................................. 137
20.5 Experimental Set up: .......................................................................................................................... 137
20.6 Steps to implement the Binary to Gray code converter....................................................................... 137
20.7 Conclusion:- ....................................................................................................................................... 139
20.8 Assignments....................................................................................................................................... 139
LAB 21 ..........................................................................................................................................140
Implementation of T Flip Flop 140
21.1 Introduction:- ...................................................................................................................................... 140
21 2 Objectives:- ........................................................................................................................................ 140
21.3 Design Description:- ........................................................................................................................... 140
21.4 Experimental Set up: .......................................................................................................................... 140
21.5 Steps to implement the T Flip Flop ..................................................................................................... 140
21.6 Conclusion ......................................................................................................................................... 142
21.7 Further assignments........................................................................................................................... 142
LAB 22 ..........................................................................................................................................143
Scrolling Of Data On Seven-Segment Display Using Keyboard. 143
22.1 Introduction:- ...................................................................................................................................... 143
22.2 Objective:- .......................................................................................................................................... 143
22.3 Experimental Set up:- ......................................................................................................................... 143
22.4 Procedure:- ........................................................................................................................................ 143
22.5 Assignments....................................................................................................................................... 146
LAB 23 ..........................................................................................................................................147
Design Of 4-bit Arithmetic Logic Unit 147
LAB 24 ..........................................................................................................................................151
Temperature Sensing Using ADC-DAC Interfacing. 151
24.1 Introduction:- ...................................................................................................................................... 151
24.2 Objective:- .......................................................................................................................................... 151
24.3 Design Description:- ........................................................................................................................... 151
24.5 Procedure:- ........................................................................................................................................ 152
24.6 Assignments....................................................................................................................................... 154
LAB 25 ..........................................................................................................................................156
Design of LCD Controller 156
25.1 Introduction ........................................................................................................................................ 156
25.2 Objective:- .......................................................................................................................................... 156
25.3 Design Description:- ........................................................................................................................... 156
25.4 Experimental set up:- ......................................................................................................................... 157
25.5 Procedure:- ........................................................................................................................................ 157
25.6 Assignments....................................................................................................................................... 159
LAB 26 ..........................................................................................................................................160
Lift Controller 160
26.1 Introduction:- ...................................................................................................................................... 160
26.2 VHDL Coding ..................................................................................................................................... 161
26.3 Objective ............................................................................................................................................ 161
26.4 Procedure........................................................................................................................................... 162
26.5 Assignments....................................................................................................................................... 164