打印
[Actel FPGA]

 Debug a microcontroller-to-FPGA interface from the FPGA side

[复制链接]
2442|11
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
金鱼木鱼|  楼主 | 2011-9-14 19:58 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Microcontrollers and FPGAs often work together in embedded systems. As more functions move into the FPGA, however, debugging the interface between the two devices becomes more difficult. The traditional debugging approach comes from the microcontroller side, which relies on a serial-port printout. This approach adds overhead and may cause timing problems. Furthermore, this approach cannot guarantee uninterrupted and exclusive access to certain addresses because of operating-system multitasking. Thus, a serial-port printout doesn’t accurately describe the actions on the microcontroller/FPGA interface.
  Instead, you can approach the problem from the FPGA side using a JTAG (Joint Test Action Group) interface as a communication port. This approach uses the internal logic of the FPGA to capture the read/write transactions on the microcontroller/FPGA interface. This method is nonintrusive because the circuit that captures transactions sits between the microcontroller and the FPGA’s functioning logic and monitors the data without interfering with it. It stores the captured transaction in the FPGA’s RAM resources in real time. You can transfer the data to a PC through the JTAG port’s download cable.
  The debugging tool comprises the data-capture circuit, the JTAG communication circuit, and the GUI (graphical user interface)。 The data-capture circuit uses standard HDL (hardware-description language) and instantiates a FIFO (first-in/first-out) buffer in the FPGA. Whenever you read or write to a register, the debugging tool records the corresponding value of the address and data on the bus and stores it in the FIFO buffer. You can retrieve the data through the JTAG’s download cable to the PC (Listing 1 - all listings are provided on subsequent pages or as a downloadable doc file from the links below)。

相关帖子

沙发
金鱼木鱼|  楼主 | 2011-9-14 20:01 | 只看该作者
Because the FPGA has limited on-chip RAM resources, you must keep the FIFO buffer shallow. To efficiently use the FIFO buffer, the design includes filter and trigger circuits. With inclusive address filtering, the circuit monitors only several discontinuous spans of addresses instead of the whole address space. Exclusive-address filters can filter out several smaller address spans from the inclusive-address spans, enabling finer control of the filter settings (Listing 2)。
  With transaction triggering, the circuit starts when you read from or write to a certain address. You can add certain data values to the triggering condition (Listing 3)。 You can dynamically reconfigure the settings of address filters and transaction triggers through the JTAG’s vendor-supplied, customizable communication circuit without recompilation of the FPGA design (Figure 1)。 The circuit has two interfaces, one of which is written in HDL to form a customized JTAG chain. It communicates with the user logic (listing 1, listing 2, and listing 3)。 The circuit is accessible through specific programming interfaces on the PC and communicates with the user program or GUI (Listing 4)。
  
  The FPGA-based circuit facilitates writing and reading functions from PC to FPGA logic, and it promotes the JTAG interface to a general communication port attached to the FPGA. FPGA manufacturers, including Actel, Altera, Lattice Semiconductor, and Xilinx, respectively, call this circuit UJTAG (user JTAG), Virtual JTAG, ORCAstra, and BScan (references 1 through 4)。
  The GUI for this circuit uses Tcl/Tk (tool-command-language tool kit)。 FPGA manufacturers provide vendor-specific APIs (application-programming interfaces) in Tcl for the PC side of the JTAG-communication circuit. The APIs include basic functions, such as JTAG-chain initialization, selection, and data reading and writing. With the data-read function, you can check the capturing status and get the transaction data from the FIFO buffer. With the data-writing function, you can send the filter and trigger configuration data to the capturing circuit in the FPGA (Listing 4)。 The JTAG-based debugging method provides dynamic visibility and controllability into the microcontroller-to-FPGA interface and the FPGA’s internal logic without the need to recompile and download FPGA code.

使用特权

评论回复
板凳
金鱼木鱼|  楼主 | 2011-9-14 20:02 | 只看该作者
Listing 1
  module virtual_jtag_fifo(clk,wr_en,data_in);
  parameter data_width = 32,
  fifo_depth = 256,
  addr_width = 8,
  al_full_val = 255,
  al_empt_val = 0;
  input clk;
  input wr_en;
  input [data_width-1:0] data_in;
  wire tdi, tck, cdr, cir, e1dr, e2dr, pdr, sdr, udr, uir;
  reg tdo;
  reg [addr_width-1:0] usedw_instr_reg;
  reg reset_instr_reg;
  reg [data_width-1:0] read_instr_reg;
  reg bypass_reg;
  wire [1:0] ir_in;
  wire usedw_instr = ~ir_in[1] & ir_in[0]; // 1
  wire reset_instr = ir_in[1] & ~ir_in[0]; // 2
  wire read_instr = ir_in[1] & ir_in[0]; // 3
  wire reset = reset_instr && e1dr;
  wire [addr_width-1:0] usedw;
  wire [data_width-1:0] data_out;
  wire full;
  wire al_full;
  reg read_instr_d1;
  reg read_instr_d2;
  reg read_instr_d3;
  wire rd_en = read_instr_d2 & !read_instr_d3;
  always @(posedge clk or posedge reset)
  begin
  if (reset)
  begin
  read_instr_d1 《= 1‘b0;
  read_instr_d2 《= 1’b0;
  read_instr_d3 《= 1‘b0;
  end
  else

使用特权

评论回复
地板
金鱼木鱼|  楼主 | 2011-9-14 20:02 | 只看该作者
begin
  read_instr_d1 《= read_instr;
  read_instr_d2 《= read_instr_d1;
  read_instr_d3 《= read_instr_d2;
  end
  end
  scfifo jtag_fifo (
  .aclr (reset),
  .clock (clk),
  .wrreq (wr_en & !al_full),
  .data (data_in),
  .rdreq (rd_en),
  .q (data_out),
  .full (full),
  .almost_full (al_full),
  .empty (),
  .almost_empty (),
  .usedw (usedw),
  .sclr ());
  defparam
  jtag_fifo.lpm_width = data_width,
  jtag_fifo.lpm_numwords = fifo_depth,
  jtag_fifo.lpm_widthu = addr_width,
  jtag_fifo.intended_device_family = “Stratix II”,
  jtag_fifo.almost_full_value = al_full_val,
  jtag_fifo.almost_empty_value = al_empt_val,
  jtag_fifo.lpm_type = “scfifo”,
  jtag_fifo.lpm_showahead = “OFF”,
  jtag_fifo.overflow_checking = “ON”,
  jtag_fifo.underflow_checking = “ON”,
  jtag_fifo.use_eab = “ON”,
  jtag_fifo.add_ram_output_register = “ON”;
  /* usedw_instr Instruction Handler */
  always @ (posedge tck)
  if ( usedw_instr && cdr )
  usedw_instr_reg 《= usedw;
  else if ( usedw_instr && sdr )
  usedw_instr_reg 《= {tdi, usedw_instr_reg[addr_width-1:1]};
  /* reset_instr Instruction Handler */
  always @ (posedge tck)
  if ( reset_instr && sdr )
  reset_instr_reg 《= tdi;//{tdi, reset_instr_reg[data_width-1:1]};
  /* read_instr Instruction Handler */
  always @ (posedge tck)
  if ( read_instr && cdr )
  read_instr_reg 《= data_out;
  else if ( read_instr && sdr )
  read_instr_reg 《= {tdi, read_instr_reg[data_width-1:1]};
  /* Bypass register */
  always @ (posedge tck)
  bypass_reg = tdi;
  /* Node TDO Output */
  always @ ( usedw_instr, reset_instr, read_instr, usedw_instr_reg[0], reset_instr_reg/*[0]*/, read_instr_reg[0], bypass_reg )
  begin
  if (usedw_instr)
  tdo 《= usedw_instr_reg[0];
  else if (reset_instr)
  tdo 《= reset_instr_reg/*[0]*/;
  else if (read_instr)
  tdo 《= read_instr_reg[0];
  else
  tdo 《= bypass_reg; // Used to maintain the continuity of the scan chain.
  end
  sld_virtual_jtag sld_virtual_jtag_component (
  .ir_in (ir_in),
  .ir_out (2’b0),
  .tdo (tdo),
  .tdi (tdi),
  .tms (),

使用特权

评论回复
5
金鱼木鱼|  楼主 | 2011-9-14 20:02 | 只看该作者
 .tck (tck),
  .virtual_state_cir (cir),
  .virtual_state_pdr (pdr),
  .virtual_state_uir (uir),
  .virtual_state_sdr (sdr),
  .virtual_state_cdr (cdr),
  .virtual_state_udr (udr),
  .virtual_state_e1dr (e1dr),
  .virtual_state_e2dr (e2dr),
  .jtag_state_rti (),
  .jtag_state_e1dr (),
  .jtag_state_e2dr (),
  .jtag_state_pir (),
  .jtag_state_tlr (),
  .jtag_state_sir (),
  .jtag_state_cir (),
  .jtag_state_uir (),
  .jtag_state_pdr (),
  .jtag_state_sdrs (),
  .jtag_state_sdr (),
  .jtag_state_cdr (),
  .jtag_state_udr (),
  .jtag_state_sirs (),
  .jtag_state_e1ir (),
  .jtag_state_e2ir ());
  defparam
  sld_virtual_jtag_component.sld_auto_instance_index = “NO”,
  sld_virtual_jtag_component.sld_instance_index = 0,
  sld_virtual_jtag_component.sld_ir_width = 2,
  sld_virtual_jtag_component.sld_sim_action = “((1,1,1,2))”,
  sld_virtual_jtag_component.sld_sim_n_scan = 1,
  sld_virtual_jtag_component.sld_sim_total_length = 2;
  endmodule
  Listing 2
  module virtual_jtag_addr_mask(mask_out0,mask_out1,mask_out2,mask_out3,
  mask_out4,mask_out5,mask_out6,mask_out7,
  mask_out8,mask_out9,mask_out10,mask_out11,
  mask_out12,mask_out13,mask_out14,mask_out15
  );
  parameter addr_width = 32,
  mask_index = 4, //2**mask_index=mask_num
  mask_num = 16;
  output [addr_width-1:0] mask_out0;
  output [addr_width-1:0] mask_out1;
  output [addr_width-1:0] mask_out2;
  output [addr_width-1:0] mask_out3;
  output [addr_width-1:0] mask_out4;
  output [addr_width-1:0] mask_out5;
  output [addr_width-1:0] mask_out6;
  output [addr_width-1:0] mask_out7;
  output [addr_width-1:0] mask_out8;
  output [addr_width-1:0] mask_out9;
  output [addr_width-1:0] mask_out10;
  output [addr_width-1:0] mask_out11;
  output [addr_width-1:0] mask_out12;
  output [addr_width-1:0] mask_out13;
  output [addr_width-1:0] mask_out14;
  output [addr_width-1:0] mask_out15;
  reg [addr_width-1:0] mask_out0;
  reg [addr_width-1:0] mask_out1;
  reg [addr_width-1:0] mask_out2;
  reg [addr_width-1:0] mask_out3;
  reg [addr_width-1:0] mask_out4;
  reg [addr_width-1:0] mask_out5;
  reg [addr_width-1:0] mask_out6;
  reg [addr_width-1:0] mask_out7;
  reg [addr_width-1:0] mask_out8;
  reg [addr_width-1:0] mask_out9;
  reg [addr_width-1:0] mask_out10;
  reg [addr_width-1:0] mask_out11;
  reg [addr_width-1:0] mask_out12;
  reg [addr_width-1:0] mask_out13;
  reg [addr_width-1:0] mask_out14;
  reg [addr_width-1:0] mask_out15;
  wire tdi, tck, cdr, cir, e1dr, e2dr, pdr, sdr, udr, uir;

使用特权

评论回复
6
金鱼木鱼|  楼主 | 2011-9-14 20:02 | 只看该作者
 reg tdo;
  reg [mask_index+addr_width-1:0] mask_instr_reg;
  reg bypass_reg;
  wire [1:0] ir_in;
  wire mask_instr = ~ir_in[1] & ir_in[0]; // 1
  wire [mask_index-1:0] mask_id = mask_instr_reg[(mask_index+addr_width-1):addr_width];
  wire [addr_width-1:0] mask_is = mask_instr_reg[(addr_width-1):0];
  always @(posedge tck)
  begin
  if (mask_instr && e1dr)
  case (mask_id)
  4‘d0 :
  mask_out0 《= mask_is;
  4’d1 :
  mask_out1 《= mask_is;
  4‘d2 :
  mask_out2 《= mask_is;
  4’d3 :
  mask_out3 《= mask_is;
  4‘d4 :
  mask_out4 《= mask_is;
  4’d5 :
  mask_out5 《= mask_is;
  4‘d6 :
  mask_out6 《= mask_is;
  4’d7 :
  mask_out7 《= mask_is;
  4‘d8 :
  mask_out8 《= mask_is;
  4’d9 :
  mask_out9 《= mask_is;
  4‘d10 :
  mask_out10 《= mask_is;
  4’d11 :
  mask_out11 《= mask_is;
  4‘d12 :
  mask_out12 《= mask_is;
  4’d13 :
  mask_out13 《= mask_is;
  4‘d14 :
  mask_out14 《= mask_is;
  4’d15 :
  mask_out15 《= mask_is;
  endcase
  end
  /* mask_instr Instruction Handler */
  always @ (posedge tck)
  if ( mask_instr && cdr )
  mask_instr_reg 《= mask_instr_reg;
  else if ( mask_instr && sdr )
  mask_instr_reg 《= {tdi, mask_instr_reg[mask_index+addr_width-1:1]};
  /* Bypass register */
  always @ (posedge tck)
  bypass_reg = tdi;
  /* Node TDO Output */
  always @ ( mask_instr, mask_instr_reg, bypass_reg )
  begin
  if (mask_instr)
  tdo 《= mask_instr_reg[0];
  else
  tdo 《= bypass_reg;// Used to maintain the continuity of the scan chain.
  end
  sld_virtual_jtag sld_virtual_jtag_component (
  .ir_in (ir_in),
  .ir_out (2‘b0),
  .tdo (tdo),
  .tdi (tdi),
  .tms (),
  .tck (tck),
  .virtual_state_cir (cir),
  .virtual_state_pdr (pdr),
  .virtual_state_uir (uir),
  .virtual_state_sdr (sdr),
  .virtual_state_cdr (cdr),
  .virtual_state_udr (udr),
  .virtual_state_e1dr (e1dr),
  .virtual_state_e2dr (e2dr),
  .jtag_state_rti (),
  .jtag_state_e1dr (),
  .jtag_state_e2dr (),
  .jtag_state_pir (),
  .jtag_state_tlr (),
  .jtag_state_sir (),
  .jtag_state_cir (),
  .jtag_state_uir (),
  .jtag_state_pdr (),
  .jtag_state_sdrs (),
  .jtag_state_sdr (),
  .jtag_state_cdr (),
  .jtag_state_udr (),
  .jtag_state_sirs (),
  .jtag_state_e1ir (),
  .jtag_state_e2ir ());
  defparam
  sld_virtual_jtag_component.sld_auto_instance_index = “NO”,
  sld_virtual_jtag_component.sld_instance_index = 1,
  sld_virtual_jtag_component.sld_ir_width = 2,
  sld_virtual_jtag_component.sld_sim_action = “((1,1,1,2))”,
  sld_virtual_jtag_component.sld_sim_n_scan = 1,
  sld_virtual_jtag_component.sld_sim_total_length = 2;
  endmodule
  Listing 3
  module virtual_jtag_moni_trig(trig_out);
  parameter trig_width = 32;
  output [trig_width-1:0] trig_out;
  reg [trig_width-1:0] trig_out;
  wire tdi, tck, cdr, cir, e1dr, e2dr, pdr, sdr, udr, uir;
  reg tdo;
  reg [trig_width-1:0] trig_instr_reg;
  reg bypass_reg;
  wire [1:0] ir_in;
  wire trig_instr = ~ir_in[1] & ir_in[0]; // 1
  always @(posedge tck)
  begin
  if (trig_instr && e1dr)
  trig_out 《= trig_instr_reg;
  end
  /* trig_instr Instruction Handler */
  always @ (posedge tck)
  if ( trig_instr && cdr )
  trig_instr_reg 《= trig_instr_reg;
  else if ( trig_instr && sdr )
  trig_instr_reg 《= {tdi, trig_instr_reg[trig_width-1:1]};
  /* Bypass register */
  always @ (posedge tck)
  bypass_reg 《= tdi;
  /* Node TDO Output */
  always @ ( trig_instr, trig_instr_reg, bypass_reg )
  begin
  if (trig_instr)
  tdo 《= trig_instr_reg[0];
  else
  tdo 《= bypass_reg;// Used to maintain the continuity of the scan chain.
  end

使用特权

评论回复
7
金鱼木鱼|  楼主 | 2011-9-14 20:03 | 只看该作者
 sld_virtual_jtag sld_virtual_jtag_component (
  .ir_in (ir_in),
  .ir_out (2’b0),
  .tdo (tdo),
  .tdi (tdi),
  .tms (),
  .tck (tck),
  .virtual_state_cir (cir),
  .virtual_state_pdr (pdr),
  .virtual_state_uir (uir),
  .virtual_state_sdr (sdr),
  .virtual_state_cdr (cdr),
  .virtual_state_udr (udr),
  .virtual_state_e1dr (e1dr),
  .virtual_state_e2dr (e2dr),
  .jtag_state_rti (),
  .jtag_state_e1dr (),
  .jtag_state_e2dr (),
  .jtag_state_pir (),
  .jtag_state_tlr (),
  .jtag_state_sir (),
  .jtag_state_cir (),
  .jtag_state_uir (),
  .jtag_state_pdr (),
  .jtag_state_sdrs (),
  .jtag_state_sdr (),
  .jtag_state_cdr (),
  .jtag_state_udr (),
  .jtag_state_sirs (),
  .jtag_state_e1ir (),
  .jtag_state_e2ir ());
  defparam
  sld_virtual_jtag_component.sld_auto_instance_index = “NO”,
  sld_virtual_jtag_component.sld_instance_index = 2,
  sld_virtual_jtag_component.sld_ir_width = 2,
  sld_virtual_jtag_component.sld_sim_action = “((1,1,1,2))”,
  sld_virtual_jtag_component.sld_sim_n_scan = 1,
  sld_virtual_jtag_component.sld_sim_total_length = 2;
  endmodule
  Listing 4
  proc reset_fifo {{jtag_index_0 0}} {
  device_lock -timeout 10000
  device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 2 -no_captured_ir_value
  device_virtual_dr_shift -instance_index $jtag_index_0 -length 32 -dr_value 00000000 -value_in_hex -no_captured_dr_value
  device_unlock
  return 0
  }
  proc query_usedw {{jtag_index_0 0}} {
  global fifoUsedw
  device_lock -timeout 10000
  device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 1 -no_captured_ir_value
  set usedw [device_virtual_dr_shift -instance_index $jtag_index_0 -length 9 -value_in_hex]
  device_unlock
  set tmp 0x
  append tmp $usedw
  set usedw [format “%i” $tmp]
  set fifoUsedw $usedw
  return $usedw
  }
  proc read_fifo {{jtag_index_0 0}} {
  device_lock -timeout 10000
  device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 1 -no_captured_ir_value
  device_virtual_ir_shift -instance_index $jtag_index_0 -ir_value 3 -no_captured_ir_value
  set fifo_data [device_virtual_dr_shift -instance_index $jtag_index_0 -length 48 -value_in_hex]
  device_unlock
  return $fifo_data
  }
  proc config_addr {{jtag_index_1 1} {mask_1 100000000}} {
  device_lock -timeout 10000
  device_virtual_ir_shift -instance_index $jtag_index_1 -ir_value 1 -no_captured_ir_value
  set addr_mask [device_virtual_dr_shift -instance_index $jtag_index_1 -dr_value $mask_1 -length 36 -value_in_hex]
  device_unlock
  return $addr_mask
  }
  proc config_trig {{jtag_index_2 2} {trig_1 0000000000000}} {
  device_lock -timeout 10000
  device_virtual_ir_shift -instance_index $jtag_index_2 -ir_value 1 -no_captured_ir_value
  set addr_trig [device_virtual_dr_shift -instance_index $jtag_index_2 -dr_value $trig_1 -length 50 -value_in_hex]
  device_unlock
  return $addr_trig
  }
  proc open_jtag_device {{test_cable “USB-Blaster [USB-0]”} {test_device “@2: EP2SGX90 (0x020E30DD)”}} {
  open_device -hardware_name $test_cable -device_name $test_device
  # Retrieve device id code.
  device_lock -timeout 10000
  device_ir_shift -ir_value 6 -no_captured_ir_value
  set idcode “0x[device_dr_shift -length 32 -value_in_hex]”
  device_unlock
  return $idcode
  }
  proc close_jtag_device {} {
  close_device
  }
  proc scan_chain {} {
  global log
  $log insert end “JTAG Chain Scanning report:\n”
  $log insert end “****************************************\n”
  set blaster_cables [get_hardware_names]
  set cable_num 0
  foreach blaster_cable $blaster_cables {
  incr cable_num
  $log insert end “@$cable_num: $blaster_cable\n”
  }
  $log insert end “\n****************************************\n”
  global device_list
  set device_list “”
  

使用特权

评论回复
8
金鱼木鱼|  楼主 | 2011-9-14 20:03 | 只看该作者
foreach blaster_cable $blaster_cables {  $log insert end “$blaster_cable:\n”
  lappend device_list $blaster_cable
  if [catch {get_device_names -hardware_name $blaster_cable} error_msg] {
  $log insert end $error_msg
  lappend device_list $error_msg
  } else {
  foreach test_device [get_device_names -hardware_name $blaster_cable] {
  $log insert end “$test_device\n”
  }
  lappend device_list [get_device_names -hardware_name $blaster_cable]
  }
  }
  }
  proc select_device {{cableNum 1} {deviceNum 1}} {
  global log
  global device_list
  $log insert end “\n****************************************\n”
  set test_cable [lindex $device_list [expr 2*$cableNum-2]]
  $log insert end “Selected Cable : $test_cable\n”
  set test_device [lindex [lindex $device_list [expr 2*$cableNum-1]] [expr $deviceNum-1]]
  $log insert end “Selected Device: $test_device\n”
  set jtagIdCode [open_jtag_device $test_cable $test_device]
  $log insert end “Device ID code : $jtagIdCode\n”
  updateAddrConfig
  reset_fifo 0
  query_usedw 0
  }
  proc inclusiveAddrConfig {} {
  global address_span1
  global address_span2
  global address_span3
  global address_span4
  global address_span5
  global address_span6
  global address_span7
  global address_span8
  for {set i 1} {$i《=8} {incr i} {
  set mask [format “%1X” [expr $i-1]]
  append mask [set address_span$i]
  config_addr 1 $mask
  }
  }

使用特权

评论回复
9
金鱼木鱼|  楼主 | 2011-9-14 20:03 | 只看该作者
 proc exclusiveAddrConfig {} {
  global address_span9
  global address_span10
  global address_span11
  global address_span12
  global address_span13
  global address_span14
  global address_span15
  global address_span16
  for {set i 9} {$i《=16} {incr i} {
  set mask [format “%1X” [expr $i-1]]
  append mask [set address_span$i]
  config_addr 1 $mask
  }
  }
  proc updateAddrConfig {} {
  global log
  global address_span1
  global address_span2
  global address_span3
  global address_span4
  global address_span5
  global address_span6
  global address_span7
  global address_span8
  global address_span9
  global address_span10
  global address_span11
  global address_span12
  global address_span13
  global address_span14
  global address_span15
  global address_span16
  for {set i 1} {$i《=8} {incr i} {
  set address_span$i ffff0000
  }
  for {set i 9} {$i《=16} {incr i} {
  set address_span$i 00000000
  }
  }
  proc enableTrigger {} {
  global triggerAddr
  global triggerData
  # enable but stop triggering
  set triggerValue 2
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc disableTrigger {} {
  global triggerAddr
  global triggerData
  # disable and stop triggering
  set triggerValue 0
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc startTrigger {} {
  global triggerAddr
  global triggerData
  # enable and start triggering
  set triggerValue 3
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc stopTrigger {} {
  global triggerAddr
  global triggerData
  # enable and stop triggering
  set triggerValue 2
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc reset_fifo_ptr {} {
  reset_fifo 0
  query_usedw 0
  }
  proc query_fifo_usedw {} {
  query_usedw 0
  }
  proc read_fifo_content {} {
  global log
  global fifoUsedw
  $log insert end “\n****************************************\n”
  for {set i 0} {$i《$fifoUsedw} {incr i} {
  set fifoContent [read_fifo 0]
  $log insert end “wr [string range $fifoContent 0 3] [string range $fifoContent 4 11]\n”
  }
  query_usedw 0
  }
  proc clear_log {} {
  global log
  $log delete insert end
  }
  proc quit {} {
  global exit_console
  destroy .console
  set exit_console 1
  }
  # set the QuartusII special Tk command
  init_tk
  set exit_console 0
  # set the main window
  toplevel .console
  wm title .console “Virtual JTAG: uP transaction monitor”
  pack propagate .console true
  # set the JTAG utility
  frame .console.fig -bg white
  pack .console.fig -expand true -fill both
  button .console.fig.scan -text {Scan JTAG Chain} -command {scan_chain}
  button .console.fig.select -text {Select JTAG Device :} -command {select_device $cableNum $deviceNum}
  button .console.fig.deselect -text {DeSelect JTAG Device} -command {close_jtag_device}
  label .console.fig.cable -text {Cable No.}
  label .console.fig.devic -text {Device No.}
  entry .console.fig.cable_num -textvariable cableNum -width 2
  entry .console.fig.devic_num -textvariable deviceNum -width 2
  pack .console.fig.scan .console.fig.select \
  .console.fig.cable .console.fig.cable_num \
  .console.fig.devic .console.fig.devic_num \
  .console.fig.deselect \
  -side left -ipadx 10
  # set the inclusive address entries
  frame .console.f1 -relief groove -borderwidth 5
  pack .console.f1
  entry .console.f1.address_span1 -textvariable address_span1 -width 5
  entry .console.f1.address_span2 -textvariable address_span2 -width 5
  entry .console.f1.address_span3 -textvariable address_span3 -width 5
  entry .console.f1.address_span4 -textvariable address_span4 -width 5
  entry .console.f1.address_span5 -textvariable address_span5 -width 5
  entry .console.f1.address_span6 -textvariable address_span6 -width 5
  entry .console.f1.address_span7 -textvariable address_span7 -width 5
  entry .console.f1.address_span8 -textvariable address_span8 -width 5
  button .console.f1.config -text {Included Address Filter} -command {inclusiveAddrConfig}
  pack .console.f1.address_span1 .console.f1.address_span2 .console.f1.address_span3 .console.f1.address_span4 \
  .console.f1.address_span5 .console.f1.address_span6 .console.f1.address_span7 .console.f1.address_span8 \
  .console.f1.config -side left -ipadx 10
  # set the exclusive address entries
  frame .console.f2 -relief groove -borderwidth 5
  pack .console.f2
  entry .console.f2.address_span9 -textvariable address_span9 -width 5
  entry .console.f2.address_span10 -textvariable address_span10 -width 5
  entry .console.f2.address_span11 -textvariable address_span11 -width 5
  entry .console.f2.address_span12 -textvariable address_span12 -width 5
  entry .console.f2.address_span13 -textvariable address_span13 -width 5
  entry .console.f2.address_span14 -textvariable address_span14 -width 5
  entry .console.f2.address_span15 -textvariable address_span15 -width 5
  entry .console.f2.address_span16 -textvariable address_span16 -width 5
  button .console.f2.config -text {Excluded Address Filter} -command {exclusiveAddrConfig}
  

使用特权

评论回复
10
金鱼木鱼|  楼主 | 2011-9-14 20:03 | 只看该作者
pack .console.f2.address_span9 .console.f2.address_span10 .console.f2.address_span11 .console.f2.address_span12 \
  .console.f2.address_span13 .console.f2.address_span14 .console.f2.address_span15 .console.f2.address_span16 \
  .console.f2.config -side left -ipadx 10
  # set the transaction trigger controls
  frame .console.f3 -relief groove -borderwidth 5
  pack .console.f3
  button .console.f3.enabletrig -text {Enable Trigger} -command {enableTrigger}
  button .console.f3.disabletrig -text {Disable Trigger} -command {disableTrigger}
  button .console.f3.starttrig -text {Start Trigger} -command {startTrigger}
  button .console.f3.stoptrig -text {Stop Trigger} -command {stopTrigger}
  entry .console.f3.trigvalue_addr -textvar triggerAddr -width 2
  set triggerAddr ffff
  entry .console.f3.trigvalue_data -textvar triggerData -width 6
  set triggerData a5a5a5a5
  label .console.f3.trigaddr -text {@Address :}
  label .console.f3.trigdata -text {@Data :}
  pack .console.f3.enabletrig .console.f3.starttrig .console.f3.trigaddr .console.f3.trigvalue_addr \
  .console.f3.trigdata .console.f3.trigvalue_data .console.f3.stoptrig .console.f3.disabletrig \
  -side left -ipadx 8
  # set the control buttons
  frame .console.f0 -relief groove -borderwidth 5
  pack .console.f0
  button .console.f0.reset -text {Reset FIFO} -command {reset_fifo_ptr}
  button .console.f0.loop -text {Query Used Word} -command {query_fifo_usedw}
  label .console.f0.usedw -textvariable fifoUsedw -relief sunken
  button .console.f0.read -text {Read FIFO} -command {read_fifo_content}
  button .console.f0.clear -text {Clear Log} -command {clear_log}
  button .console.f0.quit -text {Quit} -command {quit}
  pack .console.f0.reset .console.f0.loop .console.f0.usedw .console.f0.read .console.f0.clear .console.f0.quit \
  -side left -ipadx 10
  # set the log window
  frame .console.log -relief groove -borderwidth 5
  set log [text .console.log.text -width 80 -height 40 \
  -borderwidth 2 -relief sunken -setgrid true \
  -yscrollcommand {.console.log.scroll set}]
  scrollbar .console.log.scroll -command {.console.log.text yview}
  pack .console.log.scroll -side right -fill y
  pack .console.log.text -side left -fill both -expand true
  pack .console.log -side top -fill both -expand true
  # make the program wait for exit signal
  vwait exit_console

使用特权

评论回复
11
金鱼木鱼|  楼主 | 2011-9-14 20:04 | 只看该作者
foreach blaster_cable $blaster_cables {  $log insert end “$blaster_cable:\n”
  lappend device_list $blaster_cable
  if [catch {get_device_names -hardware_name $blaster_cable} error_msg] {
  $log insert end $error_msg
  lappend device_list $error_msg
  } else {
  foreach test_device [get_device_names -hardware_name $blaster_cable] {
  $log insert end “$test_device\n”
  }
  lappend device_list [get_device_names -hardware_name $blaster_cable]
  }
  }
  }
  proc select_device {{cableNum 1} {deviceNum 1}} {
  global log
  global device_list
  $log insert end “\n****************************************\n”
  set test_cable [lindex $device_list [expr 2*$cableNum-2]]
  $log insert end “Selected Cable : $test_cable\n”
  set test_device [lindex [lindex $device_list [expr 2*$cableNum-1]] [expr $deviceNum-1]]
  $log insert end “Selected Device: $test_device\n”
  set jtagIdCode [open_jtag_device $test_cable $test_device]
  $log insert end “Device ID code : $jtagIdCode\n”
  updateAddrConfig
  reset_fifo 0
  query_usedw 0
  }
  proc inclusiveAddrConfig {} {
  global address_span1
  global address_span2
  global address_span3
  global address_span4
  global address_span5
  global address_span6
  global address_span7
  global address_span8
  for {set i 1} {$i《=8} {incr i} {
  set mask [format “%1X” [expr $i-1]]
  append mask [set address_span$i]
  config_addr 1 $mask
  }
  }
  proc exclusiveAddrConfig {} {
  global address_span9
  global address_span10
  global address_span11
  global address_span12
  global address_span13
  global address_span14
  global address_span15
  global address_span16
  for {set i 9} {$i《=16} {incr i} {
  set mask [format “%1X” [expr $i-1]]
  append mask [set address_span$i]
  config_addr 1 $mask
  }
  }
  proc updateAddrConfig {} {
  global log
  global address_span1
  global address_span2
  global address_span3
  global address_span4
  global address_span5
  global address_span6
  global address_span7
  global address_span8
  global address_span9
  global address_span10
  global address_span11
  global address_span12
  global address_span13
  global address_span14
  global address_span15
  global address_span16
  for {set i 1} {$i《=8} {incr i} {
  set address_span$i ffff0000
  }
  for {set i 9} {$i《=16} {incr i} {
  set address_span$i 00000000
  }
  }
  proc enableTrigger {} {
  global triggerAddr
  global triggerData
  # enable but stop triggering
  set triggerValue 2
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc disableTrigger {} {
  global triggerAddr
  global triggerData
  # disable and stop triggering
  set triggerValue 0
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc startTrigger {} {
  global triggerAddr
  global triggerData
  # enable and start triggering
  set triggerValue 3
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc stopTrigger {} {
  global triggerAddr
  global triggerData
  # enable and stop triggering
  set triggerValue 2
  append triggerValue $triggerAddr
  append triggerValue $triggerData
  config_trig 2 $triggerValue
  }
  proc reset_fifo_ptr {} {
  reset_fifo 0
  query_usedw 0
  }
  proc query_fifo_usedw {} {
  query_usedw 0
  }
  proc read_fifo_content {} {
  global log
  global fifoUsedw
  $log insert end “\n****************************************\n”
  for {set i 0} {$i《$fifoUsedw} {incr i} {
  set fifoContent [read_fifo 0]
  $log insert end “wr [string range $fifoContent 0 3] [string range $fifoContent 4 11]\n”
  }
  query_usedw 0
  }
  proc clear_log {} {
  global log
  $log delete insert end
  }
  proc quit {} {
  global exit_console
  destroy .console
  set exit_console 1
  }
  # set the QuartusII special Tk command
  init_tk
  set exit_console 0
  # set the main window
  toplevel .console
  wm title .console “Virtual JTAG: uP transaction monitor”
  pack propagate .console true
  # set the JTAG utility
  frame .console.fig -bg white
  pack .console.fig -expand true -fill both
  button .console.fig.scan -text {Scan JTAG Chain} -command {scan_chain}
  button .console.fig.select -text {Select JTAG Device :} -command {select_device $cableNum $deviceNum}

使用特权

评论回复
12
金鱼木鱼|  楼主 | 2011-9-14 20:04 | 只看该作者
button .console.fig.deselect -text {DeSelect JTAG Device} -command {close_jtag_device}
  label .console.fig.cable -text {Cable No.}
  label .console.fig.devic -text {Device No.}
  entry .console.fig.cable_num -textvariable cableNum -width 2
  entry .console.fig.devic_num -textvariable deviceNum -width 2
  pack .console.fig.scan .console.fig.select \
  .console.fig.cable .console.fig.cable_num \
  .console.fig.devic .console.fig.devic_num \
  .console.fig.deselect \
  -side left -ipadx 10
  # set the inclusive address entries
  frame .console.f1 -relief groove -borderwidth 5
  pack .console.f1
  entry .console.f1.address_span1 -textvariable address_span1 -width 5
  entry .console.f1.address_span2 -textvariable address_span2 -width 5
  entry .console.f1.address_span3 -textvariable address_span3 -width 5
  entry .console.f1.address_span4 -textvariable address_span4 -width 5
  entry .console.f1.address_span5 -textvariable address_span5 -width 5
  entry .console.f1.address_span6 -textvariable address_span6 -width 5
  entry .console.f1.address_span7 -textvariable address_span7 -width 5
  entry .console.f1.address_span8 -textvariable address_span8 -width 5
  button .console.f1.config -text {Included Address Filter} -command {inclusiveAddrConfig}
  pack .console.f1.address_span1 .console.f1.address_span2 .console.f1.address_span3 .console.f1.address_span4 \
  .console.f1.address_span5 .console.f1.address_span6 .console.f1.address_span7 .console.f1.address_span8 \
  .console.f1.config -side left -ipadx 10
  # set the exclusive address entries
  frame .console.f2 -relief groove -borderwidth 5
  pack .console.f2
  entry .console.f2.address_span9 -textvariable address_span9 -width 5
  entry .console.f2.address_span10 -textvariable address_span10 -width 5
  entry .console.f2.address_span11 -textvariable address_span11 -width 5
  entry .console.f2.address_span12 -textvariable address_span12 -width 5
  entry .console.f2.address_span13 -textvariable address_span13 -width 5
  entry .console.f2.address_span14 -textvariable address_span14 -width 5
  entry .console.f2.address_span15 -textvariable address_span15 -width 5
  entry .console.f2.address_span16 -textvariable address_span16 -width 5
  button .console.f2.config -text {Excluded Address Filter} -command {exclusiveAddrConfig}
  pack .console.f2.address_span9 .console.f2.address_span10 .console.f2.address_span11 .console.f2.address_span12 \
  .console.f2.address_span13 .console.f2.address_span14 .console.f2.address_span15 .console.f2.address_span16 \
  .console.f2.config -side left -ipadx 10
  # set the transaction trigger controls
  frame .console.f3 -relief groove -borderwidth 5
  pack .console.f3
  button .console.f3.enabletrig -text {Enable Trigger} -command {enableTrigger}
  button .console.f3.disabletrig -text {Disable Trigger} -command {disableTrigger}
  button .console.f3.starttrig -text {Start Trigger} -command {startTrigger}
  button .console.f3.stoptrig -text {Stop Trigger} -command {stopTrigger}
  entry .console.f3.trigvalue_addr -textvar triggerAddr -width 2
  set triggerAddr ffff
  entry .console.f3.trigvalue_data -textvar triggerData -width 6
  set triggerData a5a5a5a5
  label .console.f3.trigaddr -text {@Address :}
  label .console.f3.trigdata -text {@Data :}
  pack .console.f3.enabletrig .console.f3.starttrig .console.f3.trigaddr .console.f3.trigvalue_addr \
  .console.f3.trigdata .console.f3.trigvalue_data .console.f3.stoptrig .console.f3.disabletrig \
  -side left -ipadx 8
  # set the control buttons
  frame .console.f0 -relief groove -borderwidth 5
  pack .console.f0
  button .console.f0.reset -text {Reset FIFO} -command {reset_fifo_ptr}
  button .console.f0.loop -text {Query Used Word} -command {query_fifo_usedw}
  label .console.f0.usedw -textvariable fifoUsedw -relief sunken
  button .console.f0.read -text {Read FIFO} -command {read_fifo_content}
  button .console.f0.clear -text {Clear Log} -command {clear_log}
  button .console.f0.quit -text {Quit} -command {quit}
  pack .console.f0.reset .console.f0.loop .console.f0.usedw .console.f0.read .console.f0.clear .console.f0.quit \
  -side left -ipadx 10
  # set the log window
  frame .console.log -relief groove -borderwidth 5
  set log [text .console.log.text -width 80 -height 40 \
  -borderwidth 2 -relief sunken -setgrid true \
  -yscrollcommand {.console.log.scroll set}]
  scrollbar .console.log.scroll -command {.console.log.text yview}
  pack .console.log.scroll -side right -fill y
  pack .console.log.text -side left -fill both -expand true
  pack .console.log -side top -fill both -expand true
  # make the program wait for exit signal
  vwait exit_console

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

个人签名:http://bbs.srvee.com/forum-104-1.html

346

主题

1551

帖子

2

粉丝