|
JACK WHITHAM PhD MEng Professional Activities - Publications - Software - Articles |
|||
|
|
|
||
| Home -> Software -> Virtual Lab -> Debug Device |
| |||||||||||
| |||||||||||
To solve this problem, many integrated circuits include debugging hardware that is not used during normal operation. It is used only for testing at the factory, and for resolving problems with the design. Such hardware frequently includes a "scan chain": a long shift register that runs near to all of the points of interest in the circuit. At least two signals exist within the design: one to load the scan chain with the current values of the points of interest, and another to shift the contents of the scan chain by one bit. The scan chain contents are usually sent to a workstation for analysis. A model of the integrated circuit is used to match the raw data to the circuit.
Such devices have been used in CPUs since the 1980s at least, because they allow the entire state to be examined at minimal cost. It takes some time to unload a long scan chain because the information is obtained one bit at a time, so scan chains are not useful for real-time inspection of CPU internals. However, a truly synchronous circuit has the same behaviour regardless of the clocking rate. Therefore, the CPU can be "single stepped" through one clock cycle between inspections, allowing a "moving picture" of its activities to be captured, one "frame" at a time. For testing, this can be used to compare hardware against a software or HDL simulator model. JTAG provides similar test functionality, but it's not suitable for use in every environment. In an FPGA, JTAG is often used for downloading bit files, so it may not be straightforward (or even possible) to use a JTAG connection for other debugging. If it is possible to access circuits via JTAG (as in some Xilinx FPGAs), it might still be inconvenient as the JTAG lines may be connected to an FPGA programmer rather than a debugging system. Even if the JTAG lines are connected to a PC, debugging will require a special driver to communicate with them as there is no software standard for a "JTAG interface". It would clearly be better to use a widely-supported communication standard that works on any computer. Since it is based on vlabifhw, this debugging device operates via an RS232 serial connection and can also be controlled using VL2.
The debugging functionality provided by this device is also
available in commercial products such as
Chipscope,
which provide features to make it easier to get started with debugging,
such as a GUI and pre-built components for inspecting specific types
of IP core such as bus controllers. Chipscope is not cheap, but
time-limited evaluation versions are available from Xilinx. Some people
also use the HDL simulator ModelSim to
debug their designs; this has the disadvantages of low speed and
an inability to test your hardware alongside hardware made by others,
but you do not need to change your design to debug it.
Usage
To use the debugging device, you must install the
vlabif module and add the
vlabifhw hardware to your FPGA
design. The debugging device hardware and drivers are included
in these packages. Then:
add(Read(input_name="counter_1", size=16))
add(ReadWrite(input_name="test_in", output_name="test_out", size=8))
add(Read(input_name="counter_2", size=20))
add(Write(output_name="reset_counter_2", size=0))
add(Write(output_name="step", size=20))
The input_name/output_name parameters are the names of VHDL
signals. If the size is greater than 0, the type of the signal is a
std_logic_vector of that size. If the size is 0, the type of the
signal is std_logic.
import vlabif
config = vlabif.DebugConfig(dc_name="Autogen_Debug_Entity",
chain_config_file="chain_config.py")
config.writeVHDL()
You can choose the name of the debugging chain (dc_name) and
the name of the configuration file (chain_config_file). In
this case the output is "Autogen_Debug_Entity.vhd" by default.
use work.vlabifhw_pack.all;
...
architecture rtl of test is
signal dc_out : std_logic;
signal dc_in : std_logic;
signal dc_control : DC_Control_Wires;
...
begin
...
-- The debugging hardware device
vlhw : entity vlabifhw
generic map (
ext_channels => 1 ,
fifo_depth => 1,
clock_freq => clock_freq )
port map (
-- External hardware connections
clk => clk,
reset => '0',
hw_tx => ser_txd,
hw_rx => ser_rxd,
-- Internal connections: not used in this example.
out_channel_data => open,
out_channel_wr => open,
out_channel_rdy => "1",
in_channel_data => x"00",
in_channel_wr => "0",
in_channel_rdy => open,
-- Activation signal: not used
active => open,
-- Controls for device under test
debug_clock => ..., -- These outputs can be
debug_reset => ..., -- controlled from software
breakpoint => '0',
dc_control => dc_control,
dc_out => dc_out,
dc_in => dc_in
);
-- Automatically generated component
dc : entity Autogen_Debug_Entity
port map (
counter_1 => ..., -- Things connected here
test_out => ..., -- can be read/written
test_in => ..., -- from software. The connections
counter_2 => ..., -- match the chain_config.py file.
reset_counter_2 => ...,
step => ...,
dc_control => dc_control,
dc_in => dc_out,
dc_out => dc_in ) ;
You might want to refer to the vlabifhw
hardware documentation for further instructions.
The dbg object (of type DebugDriver) has a number of methods for controlling the hardware, including:1 ip = vlabif.VlabInterfaceProtocol() 2 3 # Connect "ip" to a serial port or to VL2, e.g.: 4 serialport.SerialPort(ip, "/dev/ttyS0", 5 reactor=reactor, baudrate=115200) 6 yield ip.start() 7 8 # load debugging config 9 debug_config = vlabif.DebugConfig(dc_name="Autogen_Debug_Entity", 10 chain_config_file="chain_config.py") 11 12 # create driver 13 dbg = vlabif.DebugDriver(debug_config, debug=False) 14 15 # connect debugger to vlabifhw 16 ip.openChannel(ip.getNumChannels() - 1, dbg) 17 18 # do some debugging... 19 yield dbg.reset() 20 yield dbg.capture() 21 data = yield dbg.downloadChain() 22 yield dbg.clock(1)
A more complicated example is found within the
EMS client, which uses the debug device
to access the status LEDs.
Module Documentation
| vlabif.debug_driver | index /home/jack/vll-26/VL2/client/vlabif/debug_driver.py |
# debug_driver.py
# Virtual Lab Interface - Debug Chain Driver
#
# Author: Jack Whitham
# $Id: debug_driver.py,v 1.9 2008/09/07 09:04:47 jack Exp $
#
#
# Copyright (C) 2008, Jack Whitham
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
| Classes | ||||||||||||||||||||||||||
| ||||||||||||||||||||||||||
|
|
|
||
| Copyright (C) Jack Whitham 1997-2008 | |||