Guest User

Untitled

a guest
Oct 26th, 2015
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.74 KB | None | 0 0
  1. # (c) Altera
  2.  
  3. # Setup USB hardware  - assumes only USB Blaster is installed and
  4. # and FPGA is the only device in the JTAG chain
  5.  
  6. set usb [lindex [get_hardware_names] 0]
  7. set device_name [lindex [get_device_name -hardware_name $usb] 0]
  8.  
  9. # write procedure : argument value is integer
  10. proc write (value) {
  11.     global device_name usb
  12.     variable full
  13.    
  14.     start_insystem_source_probe -device_name $device_name -hardware-name $usb
  15.     # read full flag
  16.     set full [read_probe_data -instance_index 0]
  17.    
  18.     if {$full == 1} {end_insystem_source_probe
  19.     return "Write Buffer Full"
  20.     }
  21.  
  22.     # toggle select line, drive value onto port, toggle enable
  23.     # bits 7:0 of instance 0 is S_data[7:0]; bit 8 = S_write_reg;
  24.     # bit 9 = Source_write_sel
  25.  
  26.     # int2bits is custom procedure that returns a bitstring from an integer argument
  27.     write_source_data -instance_index 0 -value [int2bit [expr 0x200 | $value]]
  28.     write_source_data -instance_index 0 -value [int2bit [expr 0x200 | $value]]
  29.    
  30.     # clear transaction
  31.     write_source_data -instance_index 0 -value 0
  32.  
  33.     end_insystem_source_probe
  34. }
  35.  
  36. proc read {} {
  37.     global device_name usb
  38.     variable empty
  39.     start_insystem_source_probe -device_name $device_name -hardware_name $usb
  40.    
  41.     # read empty flag : probe  port [7:0] reads FIFO output; bit 8 reads empty_flag
  42.     set empty [read_probe_data -instance_index 1]
  43.    
  44.     if {[regexp {1........} $empty}} {end_insystem_source_probe
  45.     return "FIFO empty" }
  46.  
  47.     # toggle select line for read transaction
  48.     # Source_read_sel = bit 0; s_read_reg = bit 1
  49.     # pulse read enable on DC FIFO
  50.     write_source_data -instance_index 1 -value 0x1 -value_in_hex
  51.     write_source_data -instance_index 1 -value 0x3 -value_in_hex
  52.     set x [read_probe_data -instance_index 1]
  53.  
  54.     end_insystem_source_probe
  55.     return $x
  56. }
Advertisement
Add Comment
Please, Sign In to add comment