static set_error_t set_timing_model_attribute(void *dont_care, conf_object_t *obj, attr_value_t *val, attr_value_t *idx) { consistency_controller_object_t *cc = (consistency_controller_object_t *)obj; conf_object_t *next; /* accept nil as input to cancel the next timing model */ if (val->kind == Sim_Val_Nil) { cc->next_level_object = NULL; cc->next_level_timing_interface = NULL; } else { if (val->kind != Sim_Val_Object) return Sim_Set_Need_Object; next = val->u.object; if (SIM_get_pending_exception()) { return Sim_Set_Illegal_Value; } cc->next_level_timing_interface = SIM_get_interface(next, "timing-model"); if (SIM_get_pending_exception()) { return Sim_Set_Illegal_Value; } cc->next_level_object = next; } return Sim_Set_Ok; }
const char *asm_s(instruction_id_t ii) { tuple_int_string_t *tuple; attr_value_t pc; pc = SIM_instruction_read_input_reg(ii, V9_Reg_Id_PC); if (pc.kind != Sim_Val_Integer) { SIM_clear_exception(); return "<unknown pc>"; } SIM_clear_exception(); tuple = SIM_disassemble(SIM_instruction_cpu(ii), (logical_address_t)pc.u.integer, 1); if (SIM_get_pending_exception()) { SIM_clear_exception(); return "<disass error>"; } vtsprintf(tmp_buf, "<0x%016llx> %s", (logical_address_t)pc.u.integer, tuple->string); return (const char *)tmp_buf; }
cycles_t consistency_controller_operate(conf_object_t *obj, conf_object_t *space, map_list_t *map, generic_transaction_t *mem_op) { instruction_id_t current, ii; instr_type_t type; log_object_t *log = (log_object_t *)obj; conf_object_t *cpu = mem_op->ini_ptr; instruction_phase_t phase; consistency_controller_object_t *cc = (consistency_controller_object_t *)obj; if (!SIM_mem_op_is_from_cpu(mem_op) || SIM_mem_op_is_instruction(mem_op)) { if (cc->next_level_timing_interface) { return cc->next_level_timing_interface->operate(cc->next_level_object, space, map, mem_op); } else { return 0; } } if (SIM_instruction_nth_id(cpu, 0)) { if (!(current = SIM_instruction_id_from_mem_op_id(cpu, mem_op->id))) { /* No entry -> dangling transaction - pass on */ SIM_log_info(3, log, 0, "Passing dangling transaction on (id = %d)", mem_op->id); return cc->next_level_timing_interface->operate(cc->next_level_object, space, map, mem_op); } if (SIM_instruction_type(current) & It_Load) { for(ii = SIM_instruction_parent(current); ii; ii = SIM_instruction_parent(ii)) { type = SIM_instruction_type(ii); phase = SIM_instruction_phase(ii); /* if the instruction is retired, skip */ if (phase >= Sim_Phase_Retired) continue; if (((type & It_Store) && cc->store_load && phase < Sim_Phase_Retired) || ((type & It_Load) && cc->load_load && phase < Sim_Phase_Executed)) { if (!mem_op->may_stall) ASSERT_MSG(0,"Must stall but can not."); SIM_log_info(2, log, 0, "Obeying %s#load consistency @ %lld for %s", (type & It_Store) ? "store":"load", SIM_cycle_count(cpu), cpu->name); goto stall; } } } if (SIM_instruction_type(current) & It_Store) { for(ii = SIM_instruction_parent(current); ii; ii = SIM_instruction_parent(ii)) { type = SIM_instruction_type(ii); phase = SIM_instruction_phase(ii); /* if the instruction is executed, skip */ if (phase >= Sim_Phase_Retired) continue; if (((type & It_Load) && cc->load_store && phase < Sim_Phase_Executed) || ((type & It_Store) && cc->store_store && phase < Sim_Phase_Retired)) { if (!mem_op->may_stall) ASSERT_MSG(0,"Must stall but can not."); SIM_log_info(2, log, 0, "Obeying %s#store consistency @ %lld for %s", (type & It_Store) ? "store":"load", SIM_cycle_count(cpu), cpu->name); goto stall; } } } if (SIM_get_pending_exception()) SIM_log_error(log, 0, "*** Exception in consistency_controller_operate *** %lld", SIM_cycle_count(cpu)); } mem_op->ma_no_reissue = 0; if (cc->next_level_timing_interface) { return cc->next_level_timing_interface->operate(cc->next_level_object, space, map, mem_op); } else { return 0; } stall: /* if ma_no_reissue is 0 it is the first time we CC-stall this op, we will only prefetch once */ if (cc->prefetch && !mem_op->ma_no_reissue && cc->next_level_timing_interface) { mem_op_type_t type; cycles_t time; int may_stall; v9_memory_transaction_t *v9_mem_op = 0; uint16 p_fcn = 0; if (SIM_mem_op_is_from_cpu_arch(mem_op, Sim_Initiator_CPU_V9)) { v9_mem_op = (v9_memory_transaction_t *)mem_op; p_fcn = v9_mem_op->prefetch_fcn; v9_mem_op->prefetch_fcn = SIM_mem_op_is_write(mem_op) ? 3 : 1; } type = mem_op->type; mem_op->type = Sim_Trans_Prefetch; may_stall = mem_op->may_stall; mem_op->may_stall = 0; /* Prefetches may not stall */ SIM_log_info(2, log, 0, "Sending prefetch for id %d", (int)mem_op->id); time = cc->next_level_timing_interface->operate(cc->next_level_object, space, map, mem_op); if (v9_mem_op) v9_mem_op->prefetch_fcn = p_fcn; mem_op->type = type; mem_op->may_stall = may_stall; } /* do not reissue if squashed */ mem_op->ma_no_reissue = 1; return 1; }