Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
sharma53
post_silicon_protocol_lts
Commits
94ec44ea
Commit
94ec44ea
authored
Mar 30, 2017
by
Debjit Pal
Browse files
Adding broadcasting code
parent
b199bbb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
ascode/config_mclock.cfg
View file @
94ec44ea
...
...
@@ -10,11 +10,13 @@ Message_group: {'PIOW_REQ': {'pioheader':1, 'pioreadwrite':1, 'ncucredid':4, 'nc
protocolnodes: [('FAR',), ('NEAR',), ('IN',)]
protocol: {('FAR',): {'APPROACH:iol2clk': [('NEAR',)]}, ('NEAR',): {'ENTER:iol2clk': [('IN',)]}, ('IN',): {'EXIT:iol2clk': [('FAR',)]}}
initstate: [('FAR',)]
broadcast: [('APPROACH',), ('EXIT',)]
[Railroad:Controller]
protocolnodes: [('0',), ('1',), ('2',), ('3',)]
protocol: {('0',): {'APPROACH:iol2clk': [('1',)]}, ('1',): {'LOWER:iol2clk': [('2',)]}, ('2',): {'EXIT:iol2clk': [('3',)]}, ('3',): {'RAISE:iol2clk': [('0',)]}}
initstate: [('0',)]
broadcast: [('LOWER',), ('RAISE',)]
[Railroad:Gate]
protocolnodes: [('UP',), ('DOWN',)]
...
...
ascode/generate_lockstep_state_machine.py
View file @
94ec44ea
...
...
@@ -54,6 +54,7 @@ def common_messages_3(Interleaved_lts_msgs, TempMachine_2_msgs):
def
construct_protocol
(
protocol_config_file
,
protocol_key
):
EmptyList
=
[]
print
"Constructing Protocol: "
,
protocol_key
config_proto
=
ConfigParser
.
RawConfigParser
()
#config_proto.read('Xtended_proto.cfg')
...
...
@@ -62,6 +63,7 @@ def construct_protocol(protocol_config_file, protocol_key):
proto_nodes
=
[]
proto_tran_rel
=
[]
proto_init_state
=
[]
proto_broadcast_msg
=
[]
Protocols
=
ast
.
literal_eval
(
config_proto
.
get
(
'Configuration'
,
'Protocols'
))
Clock_nodes
=
ast
.
literal_eval
(
config_proto
.
get
(
'Configuration'
,
'Clock_Nodes'
))
...
...
@@ -75,6 +77,12 @@ def construct_protocol(protocol_config_file, protocol_key):
proto_nodes
.
append
(
ast
.
literal_eval
(
config_proto
.
get
(
Protocols
[
i
],
'protocolnodes'
)))
proto_tran_rel
.
append
(
ast
.
literal_eval
(
config_proto
.
get
(
Protocols
[
i
],
'protocol'
)))
proto_init_state
.
append
(
ast
.
literal_eval
(
config_proto
.
get
(
Protocols
[
i
],
'initstate'
)))
try
:
proto_broadcast_msg
.
append
(
ast
.
literal_eval
(
config_proto
.
get
(
Protocols
[
i
],
'broadcast'
)))
except
ConfigParser
.
NoOptionError
,
err
:
# We cannot pass it simply. We need to enter an empty list
proto_broadcast_msg
.
append
(
EmptyList
)
pass
#Interleaved_lockstep_lts_file = open('./cfg/Interleaved_lockstep_lts.cfg', 'w')
#Interleaved_lockstep_lts_file.write('[Configuration]\n')
...
...
@@ -84,6 +92,8 @@ def construct_protocol(protocol_config_file, protocol_key):
#print Interleaved_lts_machine
Interleaved_lts_machine_init
=
proto_init_state
[
0
]
#print Interleaved_lts_machine_init
Interleaved_lts_machine_broadcast_msg
=
proto_broadcast_msg
[
0
]
print
"Broadcast Message of Interleaved_lts_machine: "
,
Interleaved_lts_machine_broadcast_msg
for
iter1
in
range
(
1
,
len
(
proto_tran_rel
)):
ListStateMachineNodes
=
[]
...
...
@@ -91,6 +101,8 @@ def construct_protocol(protocol_config_file, protocol_key):
TempMachine_2
=
proto_tran_rel
[
iter1
]
TempMachine_2_init
=
proto_init_state
[
iter1
]
TempMachine_2_broadcast_msg
=
proto_broadcast_msg
[
iter1
]
print
"Broadcast Message of TempMachine_2: "
,
TempMachine_2_broadcast_msg
Interleaved_lts_machine_keys
=
Interleaved_lts_machine
.
keys
()
Msgs_In_Interleaved
=
[]
...
...
@@ -149,7 +161,7 @@ def construct_protocol(protocol_config_file, protocol_key):
EdgeOf_TempMachine_2
=
TempMachine_2
[
tuple
([
TempMachine_2_state
+
':'
+
TempMachine_2_clkstate
])]
#print EdgeOf_TempMachine_2
# TODO: 23rd March 2017
# TODO: How to handle pairwise broadcasting? In case of Railroad protocol, the flow was Train to Controller and then Controller to Gate. And hence it
# TODO: was simple one way flow. But in the case of Mondo, where flow is from DMU to SIU, SIU to NCU and NCU to DMU, we have to be precise about
# TODO: which state machine broadcasts a particular message so that we can construct proper state transition by using handshaking messages.
...
...
@@ -175,6 +187,8 @@ def construct_protocol(protocol_config_file, protocol_key):
else
:
TempMachine_1
[
StateNowExploring
]
=
tempdict
del
(
tempdict
)
if
QStateToExplore
not
in
StatesExplored
and
QStateToExplore
not
in
StatesYetToExplore
:
StatesYetToExplore
.
append
(
QStateToExplore
)
else
:
...
...
@@ -195,12 +209,18 @@ def construct_protocol(protocol_config_file, protocol_key):
else
:
TempMachine_1
[
StateNowExploring
]
=
tempdict
del
(
tempdict
)
if
QStateToExplore
not
in
StatesExplored
and
QStateToExplore
not
in
StatesYetToExplore
:
StatesYetToExplore
.
append
(
QStateToExplore
)
else
:
Handshake_Msg_from_TempMachine_2
.
append
(
msg_t
)
# Case 2 : When the message of the outgoing edge of the Interleaved_lts_machine and the TempMachine_2 is in Handshake_Messages
# TODO: 24th March 2017
# TODO: Verify that the following piece of code works for the broadcasting messages.
Handshake_Msg_from_Interleaved_considered
=
[]
if
Handshake_Msg_from_Interleaved
:
for
msg_h
in
Handshake_Msg_from_Interleaved
:
if
msg_h
in
Handshake_Msg_from_TempMachine_2
:
...
...
@@ -215,9 +235,15 @@ def construct_protocol(protocol_config_file, protocol_key):
else
:
TempMachine_1
[
StateNowExploring
]
=
tempdict
del
(
tempdict
)
if
QStateToExplore
not
in
StatesExplored
and
QStateToExplore
not
in
StatesYetToExplore
:
StatesYetToExplore
.
append
(
QStateToExplore
)
else
:
# Refining the Handshake Messages from TempMachine_2_state
Handshake_Msg_from_TempMachine_2
.
remove
(
msg_h
)
Handshake_Msg_from_Interleaved_considered
.
append
(
msg_h
)
elif
msg_h
in
Interleaved_lts_machine_broadcast_msg
:
NextState_of_Interleaved
=
EdgeOf_Interleaved_lts_machine
[
msg_h
][
0
]
QStateToExplore
=
tuple
([
NextState_of_Interleaved
[:
NextState_of_Interleaved
.
find
(
':'
)]
+
':'
+
TempMachine_2_state
+
':'
+
NextState_of_Interleaved
[
NextState_of_Interleaved
.
find
(
':'
)
+
1
:]])
tempdict
=
{}
...
...
@@ -228,8 +254,44 @@ def construct_protocol(protocol_config_file, protocol_key):
else
:
TempMachine_1
[
StateNowExploring
]
=
tempdict
del
(
tempdict
)
if
QStateToExplore
not
in
StatesExplored
and
QStateToExplore
not
in
StatesYetToExplore
:
StatesYetToExplore
.
append
(
QStateToExplore
)
Handshake_Msg_from_Interleaved_considered
.
append
(
msg_h
)
Handshake_Msg_from_Interleaved
=
[
ele
for
ele
in
Handshake_Msg_from_Interleaved
if
ele
not
in
Handshake_Msg_from_Interleaved_considered
]
try
:
assert
Handshake_Msg_from_TempMachine_2
except
AssertionError
:
print
"No more handshaking messages remaining in TempMachine_2..
\n
"
try
:
assert
Handshake_Msg_from_Interleaved
except
AssertionError
:
print
"No More handshaking messages remaining in Interleaved_lts_machine"
if
Handshake_Msg_from_TempMachine_2
:
for
msg_t
in
Handshake_Msg_from_TempMachine_2
:
if
msg_t
in
TempMachine_2_broadcast_msg
:
NextState_of_TempMachine_2
=
EdgeOf_TempMachine_2
[
msg_t
][
0
]
QStateToExplore
=
tuple
([
Interleaved_lts_machine_state
+
':'
+
NextState_of_TempMachine_2
[:
NextState_of_TempMachine_2
.
find
(
':'
)]
+
':'
+
':'
+
NextState_of_TempMachine_2
[
NextState_of_TempMachine_2
.
find
(
':'
)
+
1
:]])
tempdict
=
{}
tempdict
[
msg_i
]
=
tuple
([
QStateToExplore
[
0
].
replace
(
':'
,
'_'
,
1
)])
if
StateNowExploring
in
TempMachine_1
.
keys
():
TempMachine_1
[
StateNowExploring
].
update
(
tempdict
)
else
:
TempMachine_1
[
StateNowExploring
]
=
tempdict
del
(
tempdict
)
if
QStateToExplore
not
in
StatesExplored
and
QStateToExplore
not
in
StatesYetToExplore
:
StatesYetToExplore
.
append
(
QStateToExplore
)
############################################################################################
#Composition code for Synchornous State Machine with Handshaking for the single clock mode. Following Flavio's suggestion. Has to be two pass
...
...
@@ -279,8 +341,11 @@ def construct_protocol(protocol_config_file, protocol_key):
Interleaved_lts_machine_init
=
[]
Interleaved_lts_machine_init
.
append
(
tuple
([
Initstate
[
0
].
replace
(
':'
,
'_'
,
1
)]))
for
ele
in
TempMachine_2_broadcast_msg
:
Interleaved_lts_machine_broadcast_msg
.
append
(
ele
)
print
"
\n
"
print
"Initial state of the Interleaved state machine now: "
,
Interleaved_lts_machine_init
,
'
\n
'
print
"Broadcast message of the Interleaved state machine now: "
,
Interleaved_lts_machine_broadcast_msg
,
'
\n
'
print
'#'
*
20
,
'Iteration: '
,
(
iter1
-
1
),
' complete '
,
'#'
*
20
,
'
\n
'
draw_dot
(
Interleaved_lts_machine
,
Interleaved_lts_machine_init
,
iter1
,
protocol_key
)
...
...
ascode/generate_ref_clk_state_machine.py
View file @
94ec44ea
...
...
@@ -31,9 +31,10 @@ clock_init_state.append(ast.literal_eval(config_clock.get('clock_state_machine',
proto_nodes
=
{}
proto_tran_rel
=
{}
proto_init_state
=
{}
proto_broadcast_msg
=
{}
Protocols
=
ast
.
literal_eval
(
config_proto
.
get
(
'Configuration'
,
'Protocols'
))
print
Protocols
.
keys
()
#
print Protocols.keys()
for
key
in
Protocols
.
keys
():
for
comp
in
Protocols
[
key
]:
...
...
@@ -41,7 +42,15 @@ for key in Protocols.keys():
proto_nodes
[
protocol_name
]
=
ast
.
literal_eval
(
config_proto
.
get
(
protocol_name
,
'protocolnodes'
))
proto_tran_rel
[
protocol_name
]
=
ast
.
literal_eval
(
config_proto
.
get
(
protocol_name
,
'protocol'
))
proto_init_state
[
protocol_name
]
=
ast
.
literal_eval
(
config_proto
.
get
(
protocol_name
,
'initstate'
))
try
:
proto_broadcast_msg
[
protocol_name
]
=
ast
.
literal_eval
(
config_proto
.
get
(
protocol_name
,
'broadcast'
))
except
ConfigParser
.
NoOptionError
,
err
:
pass
#print str(err)
#print proto_broadcast_msg
#ss.exit(0)
#print proto_nodes
#print proto_init_state
...
...
@@ -169,7 +178,11 @@ for key in Protocols.keys():
protocol_states
=
", "
.
join
(
str
(
tuple
([
i
]))
for
i
in
ListStateMachineNodes
)
Intermediate_proto_cfg_file
.
write
(
'protocolnodes: ['
+
protocol_states
+
']
\n
'
)
Intermediate_proto_cfg_file
.
write
(
'protocol:'
+
str
(
Intermediate_proto_state_machine
)
+
'
\n
'
)
Intermediate_proto_cfg_file
.
write
(
'initstate: ['
+
str
(
tuple
([
InitState
[
0
]]))
+
']'
)
Intermediate_proto_cfg_file
.
write
(
'initstate: ['
+
str
(
tuple
([
InitState
[
0
]]))
+
']
\n
'
)
try
:
Intermediate_proto_cfg_file
.
write
(
'broadcast: '
+
str
(
proto_broadcast_msg
[
protocol_name
]))
except
KeyError
:
pass
Intermediate_proto_cfg_file
.
write
(
"
\n\n
"
)
#print Xtended_proto_state_machine.keys()
...
...
@@ -212,7 +225,7 @@ for key in Protocols.keys():
Intermediate_proto_cfg_file
.
close
()
print
"Calling protocol construction routine...
\n
"
Xtended_lts_machine
,
Initstate
=
construct_protocol
(
'./cfg/Intermediate_proto.cfg'
,
key
)
os
.
system
(
"rm -rfv ./cfg/Intermediate_proto.cfg"
)
#
os.system("rm -rfv ./cfg/Intermediate_proto.cfg")
Xtended_lts_states
=
Xtended_lts_machine
.
keys
()
Xtended_lts_machine_init
=
[]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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