Simple Pin I/O
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.
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)