Newer
Older
/* Copyright or (C) or Copr. GET / ENST, Telecom-Paris, Ludovic Apvrille
*
* ludovic.apvrille AT enst.fr
*
* This software is a computer program whose purpose is to allow the
* edition of TURTLE analysis, design and deployment diagrams, to
* allow the generation of RT-LOTOS or Java code from this diagram,
* and at last to allow the analysis of formal validation traces
* obtained from external tools, e.g. RTL from LAAS-CNRS and CADP
* from INRIA Rhone-Alpes.
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited
* liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*/
package ui.window;
import myutil.GraphicLib;
import tmltranslator.modelcompiler.ArchUnitMEC;
import ui.ColorManager;
import ui.util.IconManager;
import ui.interactivesimulation.SimulationTransaction;
import ui.tmldd.TMLArchiCPUNode;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.math.BigDecimal;
import java.util.*;
import java.util.List;
* Class JDialogCPUNode
* Dialog for managing attributes of cpu nodes
* Creation: 19/09/2007
* @version 1.0 19/09/2007
* @author Ludovic APVRILLE
public class JDialogCPUNode extends JDialogBase implements ActionListener {
//private static String[] tracemodeTab = {"vcd trace", "VCI logger", "VCI stats"};
// private static String[] tracemodeTab = {"VCI logger"};
private boolean regularClose;
private JPanel panel2, panel4, panel5;
// private Frame frame;
private TMLArchiCPUNode node;
private ArchUnitMEC MECType;
protected JComboBox<String> tracemode;
// private static int selectedTracemode = 0;
// Panel1
protected JTextField nodeName;
// Panel2
protected JTextField sliceTime, nbOfCores, byteDataSize, pipelineSize, goIdleTime, maxConsecutiveIdleCycles, taskSwitchingTime, branchingPredictionPenalty, cacheMiss, clockRatio, execiTime, execcTime, monitored;
protected JComboBox<String> schedulingPolicy, MECTypeCB, encryption;
// Tabbed pane for panel1 and panel2
private JTabbedPane tabbedPane;
private java.util.List<SimulationTransaction> transactions;
//issue 183
List<JTextArea> instructionHelpList;
List<JButton> buttons;
int index;
/* Creates new form */
public JDialogCPUNode(Frame _frame, String _title, TMLArchiCPUNode _node, ArchUnitMEC _MECType, java.util.List<SimulationTransaction> _transactions) {
super(_frame, _title, true);
// frame = _frame;
node = _node;
MECType = _MECType;
transactions = _transactions;
initComponents();
// myInitComponents();
pack();
}
//
// private void myInitComponents() {
// }
//issue 183
private void setButton(JButton button) {
button.setOpaque(false);
button.setFocusPainted(false);
button.setContentAreaFilled(false);
button.setBorderPainted(false);
}
private void hardwareHelp(){
instructionHelpList = new ArrayList<>();
buttons = new ArrayList<>();
JTextArea jft1 = new JTextArea();
instructionHelpList.add(jft1);
JTextArea jft2 = new JTextArea();
instructionHelpList.add(jft2);
JTextArea jft3 = new JTextArea("Slice time : The maximum time allocated by the OS " +
"scheduler to execute a task");
instructionHelpList.add(jft3);
JTextArea jft4 = new JTextArea("Nb of Cores : The number of cores of the CPU");
instructionHelpList.add(jft4);
JTextArea jft5 = new JTextArea("Data size : The size of an EXECI/EXECC operation, in " +
"number of bytes");
instructionHelpList.add(jft5);
JTextArea jft6 = new JTextArea("Pipeline size : The number of stages of the pipeline");
instructionHelpList.add(jft6);
JTextArea jft7 = new JTextArea("Task switching : The time taken by the OS for a context switch");
instructionHelpList.add(jft7);
JTextArea jft8 = new JTextArea("Mis-branching prediction: The miss percentage of the CPU branch " +
"prediction scheme");
instructionHelpList.add(jft8);
JTextArea jft9 = new JTextArea("cahe-miss : The percentage of cache misses");
instructionHelpList.add(jft9);
JTextArea jft10 = new JTextArea("Go idle time (cycles) : The time taken by the OS and the CPU " +
"hardware to go idle");
instructionHelpList.add(jft10);
JTextArea jft11 = new JTextArea("Max consecutive cycles before idle (cycles) : Number of consecutive cycles of NOPs before the " +
"CPU goes idle");
instructionHelpList.add(jft11);
JTextArea jft12 = new JTextArea("EXECI execution : The number of clock cycles corresponding to an " +
"integer operation");
instructionHelpList.add(jft12);
JTextArea jft13 = new JTextArea("EXECC execution : The number of clock cycles corresponding to an " +
"operation on complex numbers");
instructionHelpList.add(jft13);
JTextArea jft14 = new JTextArea("Clock divider : This number defines the operating clock frequency of the CPU \n" +
"It is expressed via a number that is used to divide the global design\n" +
"frequency, whose default value is 200 MHz. Thus a clock divider equal to 4 means that the CPU\n" +
"operates at 200/4 = 50 MHz");
instructionHelpList.add(jft14);
for(int i = 0; i < instructionHelpList.size(); i++) {
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
JButton but = new JButton(myIcon);
setButton(but);
buttons.add(but);
}
buttons.get(0).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft1);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(0),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(1).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft2);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(1),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(2).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft3);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(2),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(3).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft4);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(3),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(4).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft5);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(4),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(5).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft6);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(5),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(6).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft7);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(6),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(7).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft8);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(7),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(8).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft9);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(8),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(9).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft10);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(9),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(10).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft11);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(10),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(11).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft12);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(11),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(12).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft13);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(12),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
buttons.get(13).addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JPopupMenu helpPopup = new JPopupMenu();
helpPopup.add(jft14);
if (!helpPopup.isVisible()) {
helpPopup.show(buttons.get(13),20,20);
} else {
helpPopup.setVisible(false);
}
}
});
}
private void initComponents() {
Container c = getContentPane();
GridBagLayout gridbag0 = new GridBagLayout();
GridBagLayout gridbag2 = new GridBagLayout();
GridBagLayout gridbag4 = new GridBagLayout();
GridBagConstraints c0 = new GridBagConstraints();
//GridBagConstraints c1 = new GridBagConstraints();
GridBagConstraints c2 = new GridBagConstraints();
GridBagConstraints c4 = new GridBagConstraints();
setFont(new Font("Helvetica", Font.PLAIN, 14));
c.setLayout(gridbag0);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
panel2 = new JPanel();
panel2.setLayout(gridbag2);
panel2.setBorder(new javax.swing.border.TitledBorder("CPU attributes"));
panel2.setPreferredSize(new Dimension(500, 300));
// Issue #41 Ordering of tabbed panes
tabbedPane = GraphicLib.createTabbedPane();//new JTabbedPane();
c2.gridwidth = 1;
c2.gridheight = 1;
c2.weighty = 1.0;
c2.weightx = 1.0;
c2.fill = GridBagConstraints.HORIZONTAL;
panel2.add(new JLabel("CPU name:"), c2);
//-------
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
nodeName = new JTextField(node.getNodeName(), 30);
nodeName.setEditable(true);
nodeName.setFont(new Font("times", Font.PLAIN, 12));
panel2.add(nodeName, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(0),c2);
c2.gridwidth = 1;
c2.gridheight = 1;
c2.weighty = 1.0;
c2.weightx = 1.0;
c2.fill = GridBagConstraints.HORIZONTAL;
panel2.add(new JLabel("Scheduling policy:"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
schedulingPolicy = new JComboBox<String>();
schedulingPolicy.addItem("Round Robin");
schedulingPolicy.addItem("Round Robin - Priority Based");
schedulingPolicy.setSelectedIndex(node.getSchedulingPolicy());
panel2.add(schedulingPolicy, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(1),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Slice time (in microseconds):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
sliceTime = new JTextField(""+node.getSliceTime(), 15);
panel2.add(sliceTime, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(2),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Nb of cores:"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
nbOfCores = new JTextField(""+node.getNbOfCores(), 15);
panel2.add(nbOfCores, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(3),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Data size (in byte):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
byteDataSize = new JTextField(""+node.getByteDataSize(), 15);
panel2.add(byteDataSize, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(4),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Pipeline size (num. stages):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
pipelineSize = new JTextField(""+node.getPipelineSize(), 15);
panel2.add(pipelineSize, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(5),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Task switching time (in cycle):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
taskSwitchingTime = new JTextField(""+node.getTaskSwitchingTime(), 15);
panel2.add(taskSwitchingTime, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(6),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Mis-Branching prediction (in %):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
branchingPredictionPenalty = new JTextField(""+node.getBranchingPredictionPenalty(), 15);
panel2.add(branchingPredictionPenalty, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(7),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Cache-miss (in %):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
cacheMiss = new JTextField(""+node.getCacheMiss(), 15);
panel2.add(cacheMiss, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(8),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Go idle time (in cycle):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
goIdleTime = new JTextField(""+node.getGoIdleTime(), 15);
panel2.add(goIdleTime, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(9),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Max consecutive cycles before idle (in cycle):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
maxConsecutiveIdleCycles = new JTextField(""+node.getMaxConsecutiveIdleCycles(), 15);
panel2.add(maxConsecutiveIdleCycles, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(10),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("EXECI execution time (in cycle):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
execiTime = new JTextField(""+node.getExeciTime(), 15);
panel2.add(execiTime, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(11),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("EXECC execution time (in cycle):"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
execcTime = new JTextField(""+node.getExeccTime(), 15);
panel2.add(execcTime, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(12),c2);
c2.gridwidth = 1;
//issue 183
c2.weighty = 1.0;
c2.weightx = 1.0;
panel2.add(new JLabel("Clock divider:"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
clockRatio = new JTextField(""+node.getClockRatio(), 15);
panel2.add(clockRatio, c2);
//issue 183
c2.weighty = 0.0;
c2.weightx = 0.0;
c2.gridwidth = GridBagConstraints.REMAINDER;
panel2.add(buttons.get(13),c2);
// monitored
/*c2.gridwidth = 1;
panel2.add(new JLabel("Monitored:"), c2);
//c2.gridwidth = GridBagConstraints.REMAINDER; //end row
//monitored = new JTextField(""+node.getMonitored(), 15);//DG 19.04.
tracemode = new JComboBox(tracemodeTab);
tracemode.setSelectedIndex(selectedTracemode);
tracemode.addActionListener(this);
panel2.add(tracemode, c2);
monitored = new JTextField("", 15);
panel2.add(monitored, c2);*/
// Code generation
panel4 = new JPanel();
panel4.setLayout( gridbag4 );
panel4.setBorder( new javax.swing.border.TitledBorder("Code generation") );
panel4.setPreferredSize( new Dimension(500, 300) );
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
c4.gridwidth = 1;
c4.gridheight = 1;
c4.weighty = 1.0;
c4.weightx = 1.0;
c4.fill = GridBagConstraints.HORIZONTAL;
/*c4.fill = GridBagConstraints.BOTH;
c4.gridheight = 3;
panel4.add( new JLabel(" "), c4 );
c4.gridwidth = 1;
c4.fill = GridBagConstraints.HORIZONTAL;
c4.anchor = GridBagConstraints.CENTER;*/
panel4.add(new JLabel("Encryption:"), c4);
c4.gridwidth = GridBagConstraints.REMAINDER;
encryption = new JComboBox<String>();
encryption.addItem("None");
encryption.addItem("Software Encryption");
encryption.addItem("Hardware Security Module");
encryption.setSelectedIndex(node.getEncryption());
panel4.add(encryption, c4);
c4.gridwidth = 1;
panel4.add(new JLabel("CPU Extension Construct:"), c4);
c4.gridwidth = GridBagConstraints.REMAINDER; //end row
MECTypeCB = new JComboBox<String>( ArchUnitMEC.stringTypes );
if( MECType == null ) {
MECTypeCB.setSelectedIndex( 0 );
}
else {
MECTypeCB.setSelectedIndex( MECType.getIndex() );
}
MECTypeCB.addActionListener(this);
panel4.add( MECTypeCB, c4);
if (transactions.size()!=0) {
panel5=new JPanel();
panel5.setPreferredSize(new Dimension(400,300));
MyFrame f =new MyFrame();
f.setPreferredSize(new Dimension(400,300));
panel5.add(f,c4);
tabbedPane.addTab("Simulation Transactions", panel5);
//Draw from transactions
}
else {
tabbedPane.addTab( "Simulation", panel2 );
tabbedPane.addTab( "Code generation", panel4 );
tabbedPane.setSelectedIndex(0);
}
// main panel;
c0.gridheight = 10;
c0.weighty = 1.0;
c0.weightx = 1.0;
c0.gridwidth = GridBagConstraints.REMAINDER; //end row
c0.fill = GridBagConstraints.BOTH;
/*c.add(panel2, c0);
c.add(panel4, c0);*/
c.add( tabbedPane, c0 );
c0.gridwidth = 1;
c0.gridheight = 1;
c0.fill = GridBagConstraints.HORIZONTAL;
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
}
public void actionPerformed(ActionEvent evt) {
/* if (evt.getSource() == typeBox) {
boolean b = ((Boolean)(initValues.elementAt(typeBox.getSelectedIndex()))).booleanValue();
initialValue.setEnabled(b);
return;
}*/
// if (evt.getSource() == tracemode) {
// selectedTracemode = tracemode.getSelectedIndex();
// }
String command = evt.getActionCommand();
// Compare the action command to the known actions.
if (command.equals("Save and Close")) {
closeDialog();
} else if (command.equals("Cancel")) {
cancelDialog();
}
}
public void closeDialog() {
regularClose = true;
MECType = ArchUnitMEC.Types.get( MECTypeCB.getSelectedIndex() );
dispose();
}
public void cancelDialog() {
dispose();
}
public boolean isRegularClose() {
return regularClose;
}
public String getNodeName() {
return nodeName.getText();
}
public String getSliceTime() {
return sliceTime.getText();
}
public String getNbOfCores() {
return nbOfCores.getText();
}
public String getByteDataSize() {
return byteDataSize.getText();
}
public String getPipelineSize(){
return pipelineSize.getText();
}
public String getGoIdleTime(){
return goIdleTime.getText();
}
public String getMaxConsecutiveIdleCycles(){
return maxConsecutiveIdleCycles.getText();
}
public String getExeciTime(){
return execiTime.getText();
}
public String getExeccTime(){
return execcTime.getText();
}
public String getTaskSwitchingTime(){
return taskSwitchingTime.getText();
}
public String getBranchingPredictionPenalty(){
return branchingPredictionPenalty.getText();
}
public String getCacheMiss(){
return cacheMiss.getText();
}
public int getMonitored() {
return tracemode.getSelectedIndex();
//return monitored.getText();
}
public String getClockRatio(){
return clockRatio.getText();
}
public int getSchedulingPolicy() {
return schedulingPolicy.getSelectedIndex();
}
public int getEncryption(){
return encryption.getSelectedIndex();
}
public ArchUnitMEC getMECType() {
return MECType;
}
class Range {
int xi, yi, xf, yf;
public Range(int xa, int ya, int xb, int yb){
xi=xa;
yi=ya;
xf=xb;
yf=yb;
}
public boolean inRange(int x, int y){
if (y>yi && y<yf){
if (x>xi && x<xf){
return true;
}
}
return false;
}
}
class MyFrame extends JPanel implements MouseMotionListener, MouseListener{
Map<Range, String> toolMap = new HashMap<Range, String>();
public MyFrame(){
ToolTipManager.sharedInstance().setInitialDelay(0);
addMouseMotionListener(this);
addMouseListener(this);
}
@Override
public void mouseDragged(MouseEvent e) {
//do something
}
@Override
public void mouseMoved(MouseEvent e){
drawToolTip(e);
}
@Override
public void mouseClicked(MouseEvent e) {
drawToolTip(e);
}
@Override
public void mousePressed(MouseEvent e) {
drawToolTip(e);
}
@Override
public void mouseExited(MouseEvent e){
///
}
@Override
public void mouseReleased(MouseEvent e){
///
}
@Override
public void mouseEntered(MouseEvent e){
}
public void drawToolTip(MouseEvent e){
setToolTipText(null);
for (Range r:toolMap.keySet()){
int x=e.getX();
int y=e.getY();
if (r.inRange(x,y)){
setToolTipText(toolMap.get(r));
break;
}
}
}
public void paint(Graphics g) {
//Draw Axis
g.drawLine(70,0,70,300);
int i=0;
java.util.List<String> tasks=new ArrayList<String>();
Map<String, java.util.List<SimulationTransaction>> tasktrans = new HashMap<String, java.util.List<SimulationTransaction>>();
// double incr=0.0;
BigDecimal maxtime = new BigDecimal("0");
BigDecimal mintime=new BigDecimal("9999999999999999999999999999");
//Colors
//Exec- ColorManager.EXEC
//Channel - TML_PORT_CHANNEL
Collections.sort(transactions, new Comparator<SimulationTransaction>(){
public int compare(SimulationTransaction o1, SimulationTransaction o2){
BigDecimal t1 = new BigDecimal(o1.startTime);
BigDecimal t2 = new BigDecimal(o2.startTime);
return t1.compareTo(t2);
}
});
ArrayList<SimulationTransaction> tranList = new ArrayList<SimulationTransaction>(transactions);
for (SimulationTransaction st: transactions){
if (!tasks.contains(st.taskName)){
tasks.add(st.taskName);
java.util.List<SimulationTransaction> tmp = new ArrayList<SimulationTransaction>();
tasktrans.put(st.taskName, tmp);
}
if (tasktrans.get(st.taskName).size()==0 || !(tasktrans.get(st.taskName).get(tasktrans.get(st.taskName).size()-1).command+tasktrans.get(st.taskName).get(tasktrans.get(st.taskName).size()-1).startTime).equals(st.command+st.startTime)){
tasktrans.get(st.taskName).add(st);
}
else {
tranList.remove(st);
}
BigDecimal start = new BigDecimal(st.startTime);
BigDecimal end = new BigDecimal(st.endTime);
if (start.compareTo(mintime)==-1){
mintime=start;
}
if (end.compareTo(maxtime)==1){
maxtime=end;
}
}
String commandName="";
for (String s:tasks){
i++;
g.drawString(s.split("__")[1],0, i*50+50);
for (SimulationTransaction tran: tasktrans.get(s)){
//Fill rectangle with color
if (tran.command.contains("Read")) {
commandName="RD";
g.setColor(ColorManager.TML_PORT_CHANNEL);
}
else if (tran.command.contains("Write")){
g.setColor(ColorManager.TML_PORT_CHANNEL);
commandName="WR";
}
else if (tran.command.contains("Send")){
g.setColor(ColorManager.TML_PORT_EVENT);
commandName="SND";
}
else if (tran.command.contains("Wait")){
g.setColor(ColorManager.TML_PORT_EVENT);
commandName="WT";
}
else if (tran.command.contains("Request")){
g.setColor(ColorManager.TML_PORT_REQUEST);
commandName="REQ";
}
else {
commandName="EX";
g.setColor(ColorManager.EXEC);
}
int start = 30*tranList.indexOf(tran)+70;
g.fillRect(start, i*50+40, 30, 20);
g.setColor(Color.black);
g.drawRect(start, i*50+40, 30, 20);
g.drawString(commandName, start+2, i*50+55);
toolMap.put(new Range(start, i*50+40, start+30, i*50+40+20), tran.command+ " Time "+ tran.startTime + "-" + tran.endTime);
}
}
//g.drawString(Integer.toString(mintime), 70, 250);
//g.drawString(Integer.toString(maxtime), 350, 250);
// g.setColor(Color.red);
//g.fillRect(10,10,100,100);
}
}
}