def lossy_duplicating_tag_data_channel(name): input_channel = z3p.Array('{}_input_channel'.format(name), z3p.IntSort(), z3p.IntSort()) output_channel = z3p.Array('{}_output_channel'.format(name), z3p.IntSort(), z3p.IntSort()) tag = z3p.Int('{}_channel_tag'.format(name)) data = z3p.Int('{}_channel_data'.format(name)) transitions = [] transitions.append(('t0', 'empty', input_channel, z3p.BoolVal(True), [(tag, input_channel[0]), (data, input_channel[1])], 'full')) transitions.append( ('t1', 'full', output_channel, [tag, data], z3p.BoolVal(True), [], 'empty')) transitions.append( ('t2', 'full', input_channel, z3p.BoolVal(True), [], 'full')) transitions.append(('t_duplication', 'full', output_channel, [tag, data], z3p.BoolVal(True), [], 'full')) transitions.append( ('t_loss', 'empty', input_channel, z3p.BoolVal(True), [], 'empty')) return automaton.SymbolicAutomaton( '{}_tag_data_channel'.format(name), ['empty', 'full'], 'empty', transitions, input_channels=[input_channel], output_channels=[output_channel], variables=[tag, data], initial_values=[z3p.IntVal(0), z3p.IntVal(0)], variable_ranges={ tag: (0, 1), data: (min_value_message, max_value_message) }, compassion=['t1', 't0'])
def receiver(): forward_output_channel = z3p.Array('forward_output_channel', z3p.IntSort(), z3p.IntSort()) backward_input_channel = z3p.Int('backward_input_channel') receive = z3p.Int('receive') input_tag = z3p.Int('receiver_tag') input_data = z3p.Int('receiver_data') expected_tag = z3p.Int('expected_tag') transitions = [] transitions.append( ('t0', 'initial', forward_output_channel, z3p.BoolVal(True), [(input_tag, forward_output_channel[0]), (input_data, forward_output_channel[1])], 'q0')) transitions.append( ('t1', 'q0', receive, [input_data], z3p.Eq(input_tag, expected_tag), [], 'q1')) transitions.append( ('t2', 'q1', backward_input_channel, [expected_tag], z3p.BoolVal(True), [(expected_tag, z3p.If(z3p.Eq(expected_tag, 0), z3p.IntVal(1), z3p.IntVal(0)))], 'initial')) transitions.append(('t3', 'q0', z3p.Neq(input_tag, expected_tag), [], 'q2')) transitions.append( ('t4', 'q2', backward_input_channel, [z3p.If(z3p.Eq(expected_tag, 0), z3p.IntVal(1), z3p.IntVal(0))], z3p.BoolVal(True), [], 'initial')) return automaton.SymbolicAutomaton( 'receiver', ['initial', 'q0', 'q1', 'q2'], 'initial', transitions, input_channels=[forward_output_channel], output_channels=[receive, backward_input_channel], variables=[input_tag, input_data, expected_tag], initial_values=[z3p.IntVal(0), z3p.IntVal(0), z3p.IntVal(0)], variable_ranges={ input_tag: (0, 1), input_data: (min_value_message, max_value_message), expected_tag: (0, 1) }, output_channel_ranges={ receive: (min_value_message, max_value_message), backward_input_channel: (0, 1) }, justice=['t3', 't1'])
def sender(): transitions = [] input_message = z3p.Int('sender_input_message') sender_tag = z3p.Int('sender_tag') ack_tag = z3p.Int('ack_tag') forward_input_channel = z3p.Array('forward_input_channel', z3p.IntSort(), z3p.IntSort()) backward_output_channel = z3p.Int('backward_output_channel') send = z3p.Int('send') timeout = util.new_variable('timeout', 'unit') transitions.append(('t0', 'initial', send, z3p.BoolVal(True), [(input_message, send)], 'q0')) transitions.append( ('t1', 'q0', forward_input_channel, [sender_tag, input_message], z3p.BoolVal(True), [], 'q1')) transitions.append(('t2', 'q1', timeout, z3p.BoolVal(True), [], 'q0')) transitions.append(('t3', 'q1', backward_output_channel, z3p.BoolVal(True), [(ack_tag, backward_output_channel)], 'q2')) transitions.append(('t4', 'q2', z3p.Eq(ack_tag, sender_tag), [ (sender_tag, z3p.If(z3p.Eq(sender_tag, 0), z3p.IntVal(1), z3p.IntVal(0))) ], 'initial')) transitions.append(('t5', 'q2', z3p.Neq(ack_tag, sender_tag), [], 'q0')) return automaton.SymbolicAutomaton( 'sender', ['initial', 'q0', 'q1', 'q2'], 'initial', transitions, variables=[input_message, sender_tag, ack_tag], initial_values=[z3p.IntVal(0), z3p.IntVal(0), z3p.IntVal(0)], input_channels=[send, timeout, backward_output_channel], output_channels=[forward_input_channel], variable_ranges={ input_message: (min_value_message, max_value_message), sender_tag: (0, 1), ack_tag: (0, 1) }, output_channel_ranges={ forward_input_channel[1]: (min_value_message, max_value_message), forward_input_channel[0]: (0, 1) })
def response_channel(address_id, cache_id, directory_id, num_values, num_caches): name = 'response_channel_{}_{}_{}'.format(cache_id, address_id, directory_id) inputs = [] outputs = [] data_ranges = {} number_of_fields = {} suffix = '_{}_{}_{}'.format(cache_id, directory_id, address_id) wbackmsg = 'WBAckMsg' wbackmsg_input = util.new_variable(wbackmsg + suffix, 'unit') wbackmsg_output = util.new_variable(wbackmsg + 'P' + suffix, 'unit') inputs.append(wbackmsg_input) outputs.append(wbackmsg_output) locations = ['empty'] transitions = [] full_state = 'WBAckMsg_full' locations.append(full_state) transitions.append((None, 'empty', wbackmsg_input, TRUE, [], full_state)) transitions.append((None, full_state, wbackmsg_output, [ZERO], TRUE, [], 'empty')) variable_ranges = {} variable_data = z3p.Int('data_{}'.format(name)) variable_num_caches = z3p.Int('num_caches_{}'.format(name)) variable_ranges[variable_data] = (0, num_values - 1) variable_ranges[variable_num_caches] = (0, num_caches) datamsgd2c = 'DataMsgD2C' datamsgd2c_input = z3p.Array(datamsgd2c + suffix, z3p.IntSort(), z3p.IntSort()) datamsgd2c_output = z3p.Array(datamsgd2c + 'P' + suffix, z3p.IntSort(), z3p.IntSort()) inputs.append(datamsgd2c_input) outputs.append(datamsgd2c_output) full_state = 'DataMsgD2C_full' locations.append(full_state) transitions.append((None, 'empty', datamsgd2c_input, TRUE, [(variable_data, datamsgd2c_input[0]), (variable_num_caches, datamsgd2c_input[1])], full_state)) transitions.append((None, full_state, datamsgd2c_output, [variable_data, variable_num_caches], TRUE, [(variable_data, ZERO), (variable_num_caches, ZERO)], 'empty')) datamsgc2c = 'DataMsgC2C' invackmsg = 'InvAckMsg' for other_cache_id in range(num_caches): if other_cache_id != cache_id: suffix2 = '_{}{}'.format(other_cache_id, suffix) datamsgc2c_input = z3p.Int(datamsgc2c + suffix2) datamsgc2c_output = z3p.Int(datamsgc2c + 'P' + suffix2) inputs.append(datamsgc2c_input) outputs.append(datamsgc2c_output) full_state = 'DataMsgC2C_full_{}'.format(other_cache_id) locations.append(full_state) transitions.append((None, 'empty', datamsgc2c_input, TRUE, [(variable_data, datamsgc2c_input)], full_state)) transitions.append((None, full_state, datamsgc2c_output, [variable_data], TRUE, [(variable_data, ZERO)], 'empty')) invackmsg_input = util.new_variable(invackmsg + suffix2, 'unit') invackmsg_output = util.new_variable(invackmsg + 'P' + suffix2, 'unit') inputs.append(invackmsg_input) outputs.append(invackmsg_output) full_state = 'InvAckMsg_full_{}'.format(other_cache_id) locations.append(full_state) transitions.append((None, 'empty', invackmsg_input, TRUE, [], full_state)) transitions.append((None, full_state, invackmsg_output, [ZERO], TRUE, [], 'empty')) return automaton.SymbolicAutomaton(name, locations, 'empty', transitions, variables=[variable_data, variable_num_caches], initial_values=[ZERO, ZERO], input_channels=inputs, output_channels=outputs, variable_ranges=variable_ranges)
UnblockSMsgP[c][d] = {} UnblockEMsgP[c][d] = {} FwdGetXMsg[c][d] = {} FwdGetSMsg[c][d] = {} DataMsgD2C[c][d] = {} WBAckMsg[c][d] = {} for a in range(NUM_ADDRESSES): suffix = '_{}_{}_{}'.format(c, d, a) LDMsg[c][d][a] = util.new_variable('LDMsg' + suffix, 'unit') STMsg[c][d][a] = z3p.Int('STMsg' + suffix) EVMsg[c][d][a] = util.new_variable('EVMsg' + suffix, 'unit') FwdGetXMsgP[c][d][a] = z3p.Int('FwdGetXMsgP' + suffix) FwdGetSMsgP[c][d][a] = z3p.Int('FwdGetSMsgP' + suffix) DataMsgD2CP[c][d][a] = z3p.Array('DataMsgD2CP' + suffix, z3p.IntSort(), z3p.IntSort()) WBAckMsgP[c][d][a] = util.new_variable('WBAckMsgP' + suffix, 'unit') LDAckMsg[c][d][a] = z3p.Int('LDAckMsg' + suffix) STAckMsg[c][d][a] = z3p.Int('STAckMsg' + suffix) EVAckMsg[c][d][a] = util.new_variable('EVAckMsg' + suffix, 'unit') UnblockSMsg[c][d][a] = util.new_variable('UnblockSMsg' + suffix, 'unit') UnblockEMsg[c][d][a] = util.new_variable('UnblockEMsg' + suffix, 'unit') GetXMsg[c][d][a] = util.new_variable('GetXMsg' + suffix, 'unit') GetSMsg[c][d][a] = util.new_variable('GetSMsg' + suffix, 'unit') WBMsg[c][d][a] = z3p.Int('WBMsg' + suffix) GetXMsgP[c][d][a] = util.new_variable('GetXMsgP' + suffix, 'unit') GetSMsgP[c][d][a] = util.new_variable('GetSMsgP' + suffix, 'unit')