The SetWireInValue and GetWireOutValue methods in the okCFrontPanel class allow you to set and get individual pin values across the entire defined Wire address space (0x00-0x1F for WireIn, 0x20-0x3F for WireOut). You can set the WireIn values by passing in the address of the WireIn and its new value. You can read individual WireOut values by passing the address of the WireOut and a bit mask to extract only the relevant bits. After setting a wire in value and before reading a wire out value, remember to update the WireIns and WireOuts, respectively. Otherwise, the values will not be accurate.

This section contains both software and HDL portions. The software and HDL must work in tandem if FrontPanel is to be used on the PC end to perform tasks on the FPGA. The HDL in this section is designed to be set within the FrontPanel Framework HDL, available on the HDL Framework page for USB 2.0 and USB 3.0. For specific information about the FrontPanel methods or modules, consult the FrontPanel User’s Manual, the FrontPanel API guide, and the samples and README files provided with the FrontPanel download.

C/C++

okCFrontPanel dev;
UINT32 A;
 
dev.OpenBySerial();
dev.ConfigureFPGA("example.bit");
 
// Send value 0x0A to Wire endpoint with address 0x03
dev.SetWireInValue(0x03, 0x0A);
dev.UpdateWireIns();
 
// Retrieve value on Wire endpoint with address 0x20
dev.UpdateWireOuts();
A = dev.GetWireOutValue(0x20);Code language: JavaScript (javascript)

C#

okCFrontPanel dev = new okCFrontPanel();
UInt32 A;
 
dev.OpenBySerial("");
dev.ConfigureFPGA("example.bit");
 
// Send value 0x0A to Wire endpoint with address 0x03
dev.SetWireInValue(0x03, 0x0A);
dev.UpdateWireIns();
 
// Retrieve value on Wire endpoint with address 0x20
dev.UpdateWireOuts();
A = dev.GetWireOutValue(0x20);Code language: JavaScript (javascript)

Python

dev = ok.okCFrontPanel()
 
dev.OpenBySerial("")
dev.ConfigureFPGA("example.bit");
 
# Send value 0x0A to Wire endpoint with address 0x03
dev.SetWireInValue(0x03, 0x0A)
dev.UpdateWireIns()
 
# Retrieve value on Wire endpoint with address 0x20
dev.UpdateWireOuts()
A = dev.GetWireOutValue(0x20)Code language: Python (python)

Java

public class example{
     okCFrontPanel dev;	
     long A;
     okCFrontPanel.ErrorCode error;
 
     public void Initialize(){
          dev = new okCFrontPanel();
          dev.OpenBySerial(“”);
          error = dev.ConfigureFPGA(“example.bit”);
          // It’s a good idea to check for errors here!
     }
 
     public void SetPinValues() {
          // Send value 0x0A to Wire endpoint with address 0x03
          dev.SetWireInValue(0x03, 0x0A);
          dev.UpdateWireIns();
     }
 
     public long GetPinValues() {
          // Retrieve value on Wire endpoint with address 0x20
          dev.UpdateWireIns();
          A = dev.GetWireOutValue(0x20);
          return A;
     }
}Code language: PHP (php)

Verilog

// FrontPanel module instantiation
okWireIn inA(
     .ok1(ok1),
     .ep_addr(8'h03),
     .ep_dataout (dataA)
);
 
okWireOut outA(
     .ok1(ok1),
     .ok2(ok2x[0*17 +: 17]),
     .ep_addr (8'h20),
     .ep_datain (dataA)
);Code language: Verilog (verilog)

VHDL

-- FrontPanel module instantiations
inA  : okWireIn port map(
     ok1=>ok1,
     ep_addr=>x"03",
     ep_dataout=>dataA
);
 
outA : okWireOut port map(
     ok1=>ok1,
     ok2=>ok2s( 1*17-1 downto 0*17 ),
     ep_addr=>x"20",
     ep_datain=>dataA
);Code language: VHDL (vhdl)