Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mbe-tools
TTool
Commits
14dd1056
Commit
14dd1056
authored
Mar 13, 2019
by
apvrille
Browse files
Adding NoC
parent
9043a11d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/main/java/tmltranslator/HwNoC.java
0 → 100755
View file @
14dd1056
/* 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
tmltranslator
;
import
myutil.TraceManager
;
import
java.awt.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
/**
* Class HwNoC
* Creation: 07/01/2019
* @version 1.0 07/01/2019
* @author Ludovic APVRILLE
*/
public
class
HwNoC
extends
HwCommunicationNode
{
public
static
final
int
DEFAULT_BUFFER_BYTE_DATA_SIZE
=
4
;
public
int
latency
=
0
;
public
int
bufferByteSize
=
DEFAULT_BUFFER_BYTE_DATA_SIZE
;
// In bytes. Should more than 0
public
int
size
=
2
;
//2x2 by default
public
HashMap
<
String
,
Point
>
placementMap
;
public
HwNoC
(
String
_name
)
{
super
(
_name
);
}
public
String
toXML
()
{
String
s
=
"<ROUTER name=\""
+
name
+
"\" clockRatio=\""
+
clockRatio
+
"\" bufferByteSize=\""
+
bufferByteSize
+
"\" />\n"
;
return
s
;
}
public
boolean
makePlacement
(
String
placement
,
int
size
)
{
return
(
placementMap
=
makePlacementMap
(
placement
,
size
))
!=
null
;
}
// Find a free place for a node
public
boolean
map
(
String
name
)
{
if
(
placementMap
==
null
)
{
return
false
;
}
boolean
[][]
mapB
=
new
boolean
[
size
][
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
mapB
[
i
][
j
]
=
false
;
}
}
for
(
Point
p:
placementMap
.
values
())
{
mapB
[
p
.
x
][
p
.
y
]
=
true
;
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
if
(
mapB
[
i
][
j
]
==
false
)
{
placementMap
.
put
(
name
,
new
Point
(
i
,
j
));
return
true
;
}
}
}
return
false
;
}
public
String
toString
()
{
String
ret
=
""
;
if
(
placementMap
==
null
)
{
return
ret
;
}
String
[][]
mapS
=
new
String
[
size
][
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
mapS
[
i
][
j
]
=
" "
;
}
}
for
(
String
s:
placementMap
.
keySet
())
{
Point
p
=
placementMap
.
get
(
s
);
mapS
[
p
.
x
][
p
.
y
]
=
s
;
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
ret
+=
mapS
[
i
][
j
]
+
"\t"
;
}
ret
+=
"\n"
;
}
return
ret
;
}
public
static
HashMap
<
String
,
Point
>
makePlacementMap
(
String
placement
,
int
size
)
{
if
(
placement
==
null
)
{
return
null
;
}
HashMap
<
String
,
Point
>
map
=
new
HashMap
<>();
placement
=
placement
.
trim
();
if
(
placement
.
length
()
==
0
)
{
return
map
;
}
String
[]
byElt
=
placement
.
split
(
";"
);
for
(
String
tmp:
byElt
)
{
tmp
=
tmp
.
trim
();
String
[]
elt
=
tmp
.
split
(
" "
);
if
(
elt
.
length
!=
3
)
{
return
null
;
}
try
{
int
x
=
Integer
.
decode
(
elt
[
1
]);
int
y
=
Integer
.
decode
(
elt
[
2
]);
if
((
x
>
size
)
||
(
y
>
size
))
{
return
null
;
}
map
.
put
(
elt
[
0
],
new
Point
(
x
,
y
));
}
catch
(
Exception
e
)
{
TraceManager
.
addDev
(
"Invalid number in "
+
tmp
);
return
null
;
}
}
// Must now verify that two nodes are not mapped at the same coordinate
boolean
[][]
mapB
=
new
boolean
[
size
][
size
];
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
for
(
int
j
=
0
;
j
<
size
;
j
++)
{
mapB
[
i
][
j
]
=
false
;
}
}
for
(
Point
p:
map
.
values
())
{
if
(
mapB
[
p
.
x
][
p
.
y
]
==
true
)
{
return
null
;
}
mapB
[
p
.
x
][
p
.
y
]
=
true
;
}
return
map
;
}
}
src/main/java/tmltranslator/tonetwork/TMAP2Network.java
View file @
14dd1056
...
...
@@ -203,7 +203,7 @@ public class TMAP2Network<E> {
// A bridge is put with the same position as the router as to allow classical paths not to use the router
return
null
;
// all ok
}
...
...
src/main/java/ui/tmlcompd/TMLCPrimitivePort.java
View file @
14dd1056
...
...
@@ -159,6 +159,9 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
protected
String
dataFlowType
=
"VOID"
;
protected
String
associatedEvent
=
"VOID"
;
// Network
protected
int
vc
;
public
int
verification
;
public
String
oldName
;
...
...
@@ -600,7 +603,12 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
}
}
JDialogTMLCompositePort
jda
=
new
JDialogTMLCompositePort
(
commName
,
typep
,
list
[
0
],
list
[
1
],
list
[
2
],
list
[
3
],
list
[
4
],
isOrigin
,
isFinite
,
isBlocking
,
""
+
maxSamples
,
""
+
widthSamples
,
isLossy
,
lossPercentage
,
maxNbOfLoss
,
frame
,
"Port properties"
,
otherTypes
,
dataFlowType
,
associatedEvent
,
isPrex
,
isPostex
,
checkConf
,
checkAuth
,
reference
,
refs
);
JDialogTMLCompositePort
jda
=
new
JDialogTMLCompositePort
(
commName
,
typep
,
list
[
0
],
list
[
1
],
list
[
2
],
list
[
3
],
list
[
4
],
isOrigin
,
isFinite
,
isBlocking
,
""
+
maxSamples
,
""
+
widthSamples
,
isLossy
,
lossPercentage
,
maxNbOfLoss
,
frame
,
"Port properties"
,
otherTypes
,
dataFlowType
,
associatedEvent
,
isPrex
,
isPostex
,
checkConf
,
checkAuth
,
reference
,
refs
,
vc
);
// jda.setSize(350, 700);
GraphicLib
.
centerOnParent
(
jda
,
350
,
700
);
// jda.show(); // blocked until dialog has been closed
...
...
@@ -688,6 +696,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
list
[
i
].
setType
(
jda
.
getStringType
(
i
));
//TraceManager.addDev("Recorded type: " + list[i].getTypeOther());
}
vc
=
jda
.
getVC
();
}
catch
(
Exception
e
)
{
JOptionPane
.
showMessageDialog
(
frame
,
"Non valid value: "
+
e
.
getMessage
(),
"Error"
,
JOptionPane
.
INFORMATION_MESSAGE
);
return
false
;
...
...
@@ -785,6 +794,7 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
sb
.
append
(
"\" checkAuth=\""
+
checkAuth
);
sb
.
append
(
"\" checkWeakAuthStatus=\""
+
checkWeakAuthStatus
);
sb
.
append
(
"\" checkStrongAuthStatus=\""
+
checkStrongAuthStatus
);
sb
.
append
(
"\" vc=\""
+
vc
);
sb
.
append
(
"\" />\n"
);
for
(
int
i
=
0
;
i
<
nbMaxAttribute
;
i
++)
{
//
...
...
@@ -897,6 +907,13 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
}
catch
(
Exception
e
)
{}
try
{
vc
=
Integer
.
decode
(
elt
.
getAttribute
(
"vc"
));
}
catch
(
Exception
e
)
{
vc
=
0
;
}
}
makeValue
();
...
...
@@ -969,6 +986,10 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
return
TGComponentManager
.
CONNECTOR_PORT_TMLC
;
}
public
int
getVC
()
{
return
vc
;
}
public
String
getAttributes
()
{
String
attr
=
""
;
...
...
@@ -1031,9 +1052,11 @@ public abstract class TMLCPrimitivePort extends TGCScalableWithInternalComponent
}
if
(
conflict
)
{
attr
+=
"Error in path="
+
conflictMessage
;
attr
+=
"Error in path="
+
conflictMessage
+
"\n"
;
}
attr
+=
"vc="
+
vc
;
return
attr
;
}
...
...
src/main/java/ui/window/JDialogTMLCompositePort.java
View file @
14dd1056
...
...
@@ -75,11 +75,13 @@ public class JDialogTMLCompositePort extends JDialogBase implements ActionListen
private
int
lossPercentage
;
private
int
maxNbOfLoss
;
//-1 means no max
private
int
vc
;
public
boolean
data
;
public
boolean
checkConf
;
public
boolean
checkAuth
;
// Panel1
private
JTextField
nameText
,
maxText
,
widthText
,
associatedEventJT
;
private
JTextField
nameText
,
maxText
,
widthText
,
associatedEventJT
,
vcText
;
private
JComboBox
<
String
>
typePort
,
typeList1
,
typeList2
,
typeList3
,
typeList4
,
typeList5
;
private
JComboBox
<
String
>
origin
,
finite
,
blocking
,
dfType
;
private
JComboBox
<
TGComponent
>
refReq
;
...
...
@@ -102,7 +104,8 @@ public class JDialogTMLCompositePort extends JDialogBase implements ActionListen
String
title
,
Vector
<
String
>
_types
,
String
_dataFlowType
,
String
_associatedEvent
,
boolean
_isPrex
,
boolean
_isPostex
,
boolean
_checkConf
,
boolean
_checkAuth
,
TGComponent
_reference
,
Vector
<
TGComponent
>
_refs
)
{
boolean
_checkAuth
,
TGComponent
_reference
,
Vector
<
TGComponent
>
_refs
,
int
_vc
)
{
super
(
f
,
title
,
true
);
frame
=
f
;
...
...
@@ -134,6 +137,7 @@ public class JDialogTMLCompositePort extends JDialogBase implements ActionListen
checkConf
=
_checkConf
;
checkAuth
=
_checkAuth
;
refs
=
_refs
;
vc
=
_vc
;
reference
=
_reference
;
myInitComponents
();
initComponents
();
...
...
@@ -216,6 +220,8 @@ public class JDialogTMLCompositePort extends JDialogBase implements ActionListen
GridBagConstraints
c3
=
new
GridBagConstraints
();
GridBagConstraints
c4
=
new
GridBagConstraints
();
GridBagLayout
gridbag4
=
new
GridBagLayout
();
GridBagConstraints
c5
=
new
GridBagConstraints
();
GridBagLayout
gridbag5
=
new
GridBagLayout
();
setFont
(
new
Font
(
"Helvetica"
,
Font
.
PLAIN
,
14
));
c
.
setLayout
(
gridbag0
);
...
...
@@ -552,6 +558,29 @@ public class JDialogTMLCompositePort extends JDialogBase implements ActionListen
maxNbOfLossText
=
new
JTextField
(
""
+
maxNbOfLoss
);
panel3
.
add
(
maxNbOfLossText
,
c3
);
JPanel
panel5
=
new
JPanel
();
panel5
.
setLayout
(
gridbag5
);
panel5
.
setBorder
(
new
javax
.
swing
.
border
.
TitledBorder
(
"Network"
));
panel5
.
setPreferredSize
(
new
Dimension
(
300
,
300
));
c5
.
gridwidth
=
1
;
c5
.
gridheight
=
1
;
c5
.
weighty
=
1.0
;
c5
.
weightx
=
1.0
;
c5
.
gridwidth
=
GridBagConstraints
.
REMAINDER
;
//end row
c5
.
fill
=
GridBagConstraints
.
BOTH
;
c5
.
gridheight
=
5
;
panel5
.
add
(
new
JLabel
(
" "
),
c5
);
c5
.
gridwidth
=
1
;
lossPercentageLabel
=
new
JLabel
(
"VC:"
);
panel5
.
add
(
lossPercentageLabel
,
c5
);
c5
.
gridwidth
=
GridBagConstraints
.
REMAINDER
;
//end row
vcText
=
new
JTextField
(
""
+
vc
);
panel5
.
add
(
lossPercentageText
,
c5
);
// main panel;
c0
.
gridwidth
=
1
;
...
...
@@ -565,6 +594,7 @@ public class JDialogTMLCompositePort extends JDialogBase implements ActionListen
c
.
add
(
panel2
,
c0
);
c
.
add
(
panel4
,
c0
);
c
.
add
(
panel3
,
c0
);
c
.
add
(
panel5
,
c0
);
c0
.
gridheight
=
1
;
...
...
@@ -808,4 +838,12 @@ public class JDialogTMLCompositePort extends JDialogBase implements ActionListen
return
-
1
;
}
}
public
int
getVC
()
{
try
{
return
Integer
.
decode
(
vcText
.
getText
().
trim
());
}
catch
(
Exception
e
)
{
return
-
1
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment