URL
https://opencores.org/ocsvn/fpga-cf/fpga-cf/trunk
Subversion Repositories fpga-cf
Compare Revisions
- This comparison shows the changes necessary to convert path
/fpga-cf/trunk/java/src
- from Rev 5 to Rev 7
- ↔ Reverse comparison
Rev 5 → Rev 7
/edu/byu/cc/plieber/fpgaenet/modmod/SHA1Widget.java
1,4 → 1,6
package edu.byu.cc.plieber.fpgaenet.modmod; |
import java.io.IOException; |
import java.net.InetAddress; |
import java.util.ArrayList; |
|
import com.trolltech.qt.gui.*; |
9,6 → 11,26
import edu.byu.cc.plieber.util.StringUtil; |
|
public class SHA1Widget extends ModuleControlWidget{ |
|
public static void main(String[] args) { |
QApplication.initialize(args); |
|
FCPProtocol p = null; |
try { |
p = new FCPProtocol(); |
p.connect(InetAddress.getByName("10.0.1.42")); |
while (!p.isConnected()); |
} catch (IOException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
SHA1Widget w = new SHA1Widget(null, p); |
w.setChannelNumber(6); |
w.show(); |
QApplication.exec(); |
p.disconnect(); |
|
} |
|
public SHA1Widget(QWidget parent, FCPProtocol protocol){ |
super(parent); |
/edu/byu/cc/plieber/fpgaenet/modmod/ConnectionWidget.java
45,7 → 45,7
spnSourcePort.setValue(fcpprotocol.getSourceUDPPort()); |
spnDestPort.setValue(fcpprotocol.getDestUDPPort()); |
if (fcpprotocol.getDestIPAddress() != null) |
txtFPGAIP.setText(fcpprotocol.getDestIPAddress().toString()); |
txtFPGAIP.setText(fcpprotocol.getDestIPAddress().getHostAddress()); |
else |
txtFPGAIP.setText("10.0.1.42"); |
textStatus.setText(fcpprotocol.isConnected() ? "Connected" : "Not Connected"); |
121,6 → 121,7
} |
else { |
try { |
//if (fcpprotocol.isConnected()) fcpprotocol.disconnect(); |
fcpprotocol.connect(InetAddress.getByName(this.txtFPGAIP.text()), spnDestPort.value()); |
while (!fcpprotocol.isConnected()); |
this.textStatus.setText("Connected!"); |
/edu/byu/cc/plieber/fpgaenet/modmod/StaticModulesWidget.java
1,7 → 1,11
package edu.byu.cc.plieber.fpgaenet.modmod; |
import java.util.ArrayList; |
|
import com.trolltech.qt.core.Qt; |
import com.trolltech.qt.gui.*; |
|
import edu.byu.cc.plieber.fpgaenet.examples.ClockControl; |
import edu.byu.cc.plieber.fpgaenet.fcp.FCPException; |
import edu.byu.cc.plieber.fpgaenet.fcp.FCPProtocol; |
|
public class StaticModulesWidget extends QWidget{ |
16,19 → 20,23
} |
|
private FCPProtocol fcpprotocol; |
private ClockControl clockControl; |
|
public StaticModulesWidget(QWidget parent, FCPProtocol protocol){ |
super(parent); |
fcpprotocol = protocol; |
clockControl = new ClockControl(protocol, 2); |
createWidgets(); |
createLayout(); |
connectSignalsAndSlots(); |
} |
|
private QGroupBox grpLEDDIP = new QGroupBox("LED / DIP Control"); |
private QGroupBox grpClockControl = new QGroupBox("Clock Control"); |
|
private QLabel labelStaticModules = new QLabel("Static Module Control"); |
private QLabel labelLEDValue = new QLabel("LED Value:"); |
private QLabel labelDIPValue = new QLabel("DIP Value:"); |
private QLabel labelClockControl = new QLabel("Clock Control"); |
private QLabel labelStepClock = new QLabel("Step Clock:"); |
|
private QPushButton btnSetLED = new QPushButton("Set LED"); |
35,6 → 43,7
private QPushButton btnGetDIP = new QPushButton("Get DIP"); |
private QPushButton btnStep = new QPushButton("Step"); |
private QPushButton btnSingleStep = new QPushButton("Single Step"); |
private QPushButton btnFreeRun = new QPushButton("Free Run"); |
private QPushButton btnCCReset = new QPushButton("Reset"); |
|
private QLineEdit txtLEDValue = new QLineEdit(); |
41,12 → 50,15
private QLineEdit txtDIPValue = new QLineEdit(); |
private QLineEdit txtNumCycles = new QLineEdit(); |
|
private int LEDDIPChannel = 1; |
|
private void createWidgets() { |
labelStaticModules.font().setPointSize(labelStaticModules.font().pointSize()+2); |
QFont font =labelStaticModules.font(); |
font.setPointSize(labelStaticModules.font().pointSize()+2); |
labelStaticModules.setFont(font); |
labelLEDValue.setAlignment(Qt.AlignmentFlag.AlignRight); |
labelDIPValue.setAlignment(Qt.AlignmentFlag.AlignRight); |
labelStepClock.setAlignment(Qt.AlignmentFlag.AlignRight); |
labelClockControl.font().setPointSize(labelClockControl.font().pointSize()+2); |
} |
|
private void createLayout() { |
70,17 → 82,86
clockControlLayout.addWidget(labelStepClock, 0, 1); |
clockControlLayout.addWidget(txtNumCycles, 0, 2); |
clockControlLayout.addWidget(btnStep, 0, 3); |
clockControlLayout.addWidget(btnSingleStep, 1, 1); |
clockControlLayout.addWidget(btnFreeRun, 1, 1); |
clockControlLayout.addWidget(btnSingleStep, 1, 2); |
clockControlLayout.addWidget(btnCCReset, 1, 3); |
|
grpLEDDIP.setLayout(leddipLayout); |
grpClockControl.setLayout(clockControlLayout); |
|
mainLayout.addWidget(labelStaticModules); |
mainLayout.addLayout(leddipLayout); |
mainLayout.addWidget(labelClockControl); |
mainLayout.addLayout(clockControlLayout); |
mainLayout.addWidget(grpLEDDIP); |
mainLayout.addWidget(grpClockControl); |
mainLayout.addStretch(); |
} |
|
private void connectSignalsAndSlots() { |
|
btnCCReset.clicked.connect(this, "resetModules()"); |
btnFreeRun.clicked.connect(this, "freeRun()"); |
btnGetDIP.clicked.connect(this, "getDIP()"); |
btnSetLED.clicked.connect(this, "setLED()"); |
btnSingleStep.clicked.connect(this, "singleStep()"); |
btnStep.clicked.connect(this, "stepClock()"); |
} |
|
@SuppressWarnings("unused") |
private void setLED() { |
byte ledVal = Byte.parseByte(txtLEDValue.text()); |
try { |
fcpprotocol.sendData(LEDDIPChannel, ledVal); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
@SuppressWarnings("unused") |
private void getDIP() { |
try { |
fcpprotocol.sendDataRequest(LEDDIPChannel, 1); |
byte[] data = fcpprotocol.getDataResponse(); |
if (data.length > 0) txtDIPValue.setText(String.valueOf(data[0])); |
else txtDIPValue.setText("-error-"); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
@SuppressWarnings("unused") |
private void stepClock() { |
clockControl.runClock(Integer.parseInt(txtNumCycles.text())); |
} |
|
@SuppressWarnings("unused") |
private void freeRun() { |
clockControl.freeRunClock(); |
} |
|
@SuppressWarnings("unused") |
private void singleStep() { |
clockControl.singleStep(); |
} |
|
@SuppressWarnings("unused") |
private void resetModules() { |
clockControl.assertReset(); |
clockControl.deassertAll(); |
} |
|
public void setChannels(int LEDDIP, int ClockControl) { |
this.LEDDIPChannel = LEDDIP; |
clockControl.setChannel(ClockControl); |
} |
|
public int getLEDDIPChannel() { |
return LEDDIPChannel; |
} |
|
public int getClockControlChannel() { |
return clockControl.getChannel(); |
} |
|
|
} |
|
/edu/byu/cc/plieber/fpgaenet/modmod/ModularModules.java
52,13 → 52,6
public ModularModules(QWidget parent) { |
super(parent); |
this.setWindowTitle("Module Modules"); |
createActions(); |
createMenus(); |
// makeConnections(); |
createWidgets(); |
createLayout(); |
connectSignalsAndSlots(); |
|
try { |
fcpProtocol = new FCPProtocol(); |
icapInterface = new IcapInterface(fcpProtocol, 3, 4); |
67,6 → 60,14
e.printStackTrace(); |
QMessageBox.critical(this, "Bind Error", "Could not bind socket."); |
} |
|
createActions(); |
createMenus(); |
// makeConnections(); |
createWidgets(); |
createLayout(); |
connectSignalsAndSlots(); |
|
connectionChanged(); |
} |
|
139,17 → 140,11
|
private void createWidgets() { |
moduleStack = new QStackedWidget(this); |
staticWidget = new StaticModulesWidget(this, null); |
staticWidget = new StaticModulesWidget(this, fcpProtocol); |
availWidget = new AvailableModulesWidget(this); |
configWidget = new ChannelConfigurationWidget(this); |
md5Widget = new MD5Widget(moduleStack, fcpProtocol); |
sha1Widget = new SHA1Widget(moduleStack, fcpProtocol); |
// availWidget.addModule(new AvailableModule("32-bit\nRegister", |
// availWidget)); |
// availWidget.addModule(new AvailableModule("MD5", availWidget, |
// md5Widget)); |
// availWidget.addModule(new AvailableModule("SHA1", availWidget, |
// sha1Widget)); |
} |
|
private void createLayout() { |
/edu/byu/cc/plieber/fpgaenet/fcp/FCPProtocol.java
303,6 → 303,7
fp.len = 0; |
fp.dest = address; |
fp.dstPort = port; |
this.connected = false; |
try { |
sendThread.sendQueue.put(fp); |
} catch (InterruptedException e) { |
/edu/byu/cc/plieber/fpgaenet/icapif/IcapInterface.java
70,14 → 70,10
/** |
* Send a list of bytes to the ICAP. |
* @param bytes |
* @throws FCPException |
*/ |
public void sendIcapData(java.util.List<Byte> bytes) { |
try { |
this.fcpprotocol.send(this.icapWritePort, bytes, bytes.size()); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
public void sendIcapData(java.util.List<Byte> bytes) throws FCPException { |
this.fcpprotocol.send(this.icapWritePort, bytes, bytes.size()); |
} |
|
/** |
113,12 → 109,7
while (offset < file.length() |
&& (numRead = is.read(writereg, 0, 1024)) >= 0) { |
offset += numRead; |
try { |
fcpprotocol.send(3, writereg, numRead); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
fcpprotocol.send(3, writereg, numRead); |
} |
} catch (FileNotFoundException e) { |
throw new FCPException("File not found: " + fileName); |
/edu/byu/cc/plieber/fpgaenet/icapif/IcapTools.java
38,8 → 38,9
/** |
* Writes a packet to the ICAP |
* @param packet |
* @throws FCPException |
*/ |
public void write(edu.byu.ece.bitstreamTools.bitstream.Packet packet) { |
public void write(edu.byu.ece.bitstreamTools.bitstream.Packet packet) throws FCPException { |
this.icapif.sendIcapData(packet.toByteArray()); |
} |
|
46,8 → 47,9
/** |
* Writes a packet list to the ICAP |
* @param packet |
* @throws FCPException |
*/ |
public void write(edu.byu.ece.bitstreamTools.bitstream.PacketList packetList) { |
public void write(edu.byu.ece.bitstreamTools.bitstream.PacketList packetList) throws FCPException { |
this.icapif.sendIcapData(packetList.toByteArray()); |
} |
|
54,12 → 56,13
/** |
* Writes dummy/synch data from a DummySyncData object. |
* @param synchData |
* @throws FCPException |
*/ |
public void write(edu.byu.ece.bitstreamTools.bitstream.DummySyncData synchData) { |
public void write(edu.byu.ece.bitstreamTools.bitstream.DummySyncData synchData) throws FCPException { |
this.icapif.sendIcapData(synchData.getData()); |
} |
|
public void write(edu.byu.ece.bitstreamTools.configuration.Frame frame) throws BitstreamException { |
public void write(edu.byu.ece.bitstreamTools.configuration.Frame frame) throws BitstreamException, FCPException { |
PacketList packets = new PacketList(); |
packets.addAll(PacketUtils.NOP_PACKETS(2)); |
packets.add(PacketUtils.RCRC_CMD_PACKET); |
85,7 → 88,7
this.write(packets); |
} |
|
public void write(edu.byu.ece.bitstreamTools.bitstream.RegisterType regtype, int value) throws BitstreamException { |
public void write(edu.byu.ece.bitstreamTools.bitstream.RegisterType regtype, int value) throws BitstreamException, FCPException { |
PacketList packets = new PacketList(); |
//packets.addAll(PacketUtils.NOP_PACKETS(1)); |
//packets.add(PacketUtils.IDCODE_PACKET(0x2AD6093)); |
113,7 → 116,7
this.write(packets); |
} |
|
public void synchIcap() { |
public void synchIcap() throws FCPException { |
//write(DummySyncData.V5_V6_ICAP_DUMMY_SYNC_DATA); |
write(DummySyncData.V5_V6_STANDARD_DUMMY_SYNC_DATA); |
} |
/edu/byu/cc/plieber/fpgaenet/examples/IcapToolGui.java
102,7 → 102,12
icapTools = new IcapTools(icapif); |
icapReadback = new IcapReadback(icapTools); |
while(!fcpProtocol.isConnected()); |
icapTools.synchIcap(); |
try { |
icapTools.synchIcap(); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
private void createActions() { |
/edu/byu/cc/plieber/fpgaenet/examples/SignalMonitor.java
75,7 → 75,7
private void setupConnections() { |
try { |
fcpProtocol = new FCPProtocol(); |
fcpProtocol.connect(InetAddress.getByName("192.168.1.222"), 0x3001); |
fcpProtocol.connect(InetAddress.getByName("10.0.1.42"), 0x3001); |
} catch (IOException e) { |
return; |
} |
83,7 → 83,12
icapTools = new IcapTools(icapif); |
icapReadback = new IcapReadback(icapTools); |
while(!fcpProtocol.isConnected()); |
icapTools.synchIcap(); |
try { |
icapTools.synchIcap(); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
private void createActions() { |
144,6 → 149,7
protected void openLL() { |
String fName = QFileDialog.getOpenFileName(this, tr("Open LL File"), "", new QFileDialog.Filter( |
tr("LL Files (*.ll *.LL)"))); |
if (fName == null || fName.compareTo("") == 0) return; |
LogicalMapping llMapping = new LogicalMapping(fName); |
netListModel = new NetListModel(llMapping); |
listProxyModel = new QSortFilterProxyModel(this); |
/edu/byu/cc/plieber/fpgaenet/examples/ClockControl.java
0,0 → 1,96
/** |
* |
*/ |
package edu.byu.cc.plieber.fpgaenet.examples; |
|
import java.util.ArrayList; |
|
import edu.byu.cc.plieber.fpgaenet.fcp.FCPException; |
import edu.byu.cc.plieber.fpgaenet.fcp.FCPProtocol; |
|
/** |
* @author Peter Lieber |
* |
*/ |
public class ClockControl { |
|
private FCPProtocol protocol; |
private int channel; |
/** |
* |
*/ |
public ClockControl(FCPProtocol p, int c) { |
protocol = p; |
channel = c; |
} |
|
public void deassertAll() { |
try { |
protocol.sendData(channel, (byte)0); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
public void assertReset() { |
try { |
protocol.sendData(channel, (byte)0); |
protocol.sendData(channel, (byte)0x04); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
public void singleStep() { |
try { |
protocol.sendData(channel, (byte)0); |
ArrayList<Byte> data = new ArrayList<Byte>(); |
data.add((byte)0x00); |
data.add((byte)0x00); |
data.add((byte)0x00); |
data.add((byte)0x01); |
data.add((byte)0x01); |
protocol.sendData(channel, data); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
public void runClock(int numClocks) { |
try { |
protocol.sendData(channel, (byte)0); |
ArrayList<Byte> data = new ArrayList<Byte>(); |
data.add((byte)((numClocks >> 24) & 0xff)); |
data.add((byte)((numClocks >> 16) & 0xff)); |
data.add((byte)((numClocks >> 8) & 0xff)); |
data.add((byte)(numClocks & 0xff)); |
data.add((byte)0x01); |
protocol.sendData(channel, data); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
public void freeRunClock() { |
try { |
protocol.sendData(channel, (byte)0); |
protocol.sendData(channel, (byte)0x02); |
} catch (FCPException e) { |
// TODO Auto-generated catch block |
e.printStackTrace(); |
} |
} |
|
public int getChannel() { |
return channel; |
} |
|
public void setChannel(int channel) { |
this.channel = channel; |
} |
|
} |