UINT16 i8x9x_device::io_r16(UINT8 adr) { switch(adr) { case 0x00: return 0x0000; case 0x02: return ad_result; case 0x04: logerror("%s: read hsi time (%04x)\n", tag(), PPC); return 0x0000; case 0x0a: return timer_value(1, get_cycle()); case 0x0c: logerror("%s: read timer2 (%04x)\n", tag(), PPC); return timer_value(2, get_cycle()); default: return io_r8(adr) | (io_r8(adr+1) << 8); } }
static void return_addr_stack(struct prog_arg *p, struct thread_data *a) { int max_depth = 32; int md, li, n = p->nloop; time_init(); for (md=1; md<max_depth; md++) { long long tb = get_cycle(), te; for (li=0; li<n; li++) { recfuncs[md](1); } te = get_cycle(); printf("depth %d: %f\n", md, (te-tb)/(double)(n*md)); } time_end(); }
void i8x9x_device::commit_hso_cam() { for(int i=0; i<8; i++) if(!hso_info[i].active) { if(hso_command != 0x18 && hso_command != 0x19) logerror("%s: hso cam %02x %04x in slot %d (%04x)\n", tag(), hso_command, hso_time, i, PPC); hso_info[i].active = true; hso_info[i].command = hso_command; hso_info[i].time = hso_time; internal_update(get_cycle()); return; } hso_cam_hold.active = true; hso_cam_hold.command = hso_command; hso_cam_hold.time = hso_time; }
/** Initialize CPUs * * Initialize kernel CPUs support. * */ void cpu_init(void) { #ifdef CONFIG_SMP if (config.cpu_active == 1) { #endif /* CONFIG_SMP */ cpus = (cpu_t *) malloc(sizeof(cpu_t) * config.cpu_count, FRAME_ATOMIC); if (!cpus) panic("Cannot allocate CPU structures."); /* Initialize everything */ memsetb(cpus, sizeof(cpu_t) * config.cpu_count, 0); size_t i; for (i = 0; i < config.cpu_count; i++) { cpus[i].stack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_LOWMEM | FRAME_KA | FRAME_ATOMIC); cpus[i].id = i; irq_spinlock_initialize(&cpus[i].lock, "cpus[].lock"); unsigned int j; for (j = 0; j < RQ_COUNT; j++) { irq_spinlock_initialize(&cpus[i].rq[j].lock, "cpus[].rq[].lock"); list_initialize(&cpus[i].rq[j].rq); } } #ifdef CONFIG_SMP } #endif /* CONFIG_SMP */ CPU = &cpus[config.cpu_active - 1]; CPU->active = true; CPU->tlb_active = true; CPU->idle = false; CPU->last_cycle = get_cycle(); CPU->idle_cycles = 0; CPU->busy_cycles = 0; cpu_identify(); cpu_arch_init(); }
void test_nong0() { const int CYCLE = 10; const int CONTACT_INHIB_TICKS = 10; char_array * id_temp; //initialise(); calcium_level = 0.1; // add agent with 1 bonds in x-y plane, no z bonds, not on edge of substrate id_temp = init_char_array(); add_char(id_temp, '1'); add_keratinocyte_agent(id_temp, K_TYPE_STEM, 10, 10, 0, 0, 0, 0, 1, 0, 0, CYCLE, 0, CONTACT_INHIB_TICKS, 0, 0, 0, 0); current_xmachine = *p_xmachine; cycle(); CU_ASSERT_EQUAL(get_cycle(), CYCLE+1); CU_ASSERT_EQUAL(get_contact_inhibited_ticks(), 0); }
/* compute_bary_positions - This function computes all positions of the nodes in baricentric way. It finds a cycle in the graph of a given number. It places the cycle in a circle and compute the rest of the nodes in baricentric way inside of the circle. inputs gf - Graph Structure cycle_len - Length of the Cycle returns 0 - No problem in computing circular positions of nodes RESIZE_WINDOW - The Drawing Area was resized. WINDOW_FULL - The window can not hold more nodes. NO_CYCLE - There is not cycle of cycle_len in the graph. MEMORY_MATRIX - There is not memory for the matrix. side effects The hash table of vertices changes completely. notes If a vertex can not be located in the circle, the vertex is placed in a empty location of the window. If two or more vertices are in the same location, it finds a near spot and place all vertices in different positions. */ int compute_bary_positions(GraphFrame *gf, int cycle_len) { int mes = 0; enumerate_vertices(gf); reset_mark_pick_vertices(gf); reset_level_vertices(gf); if(!gf->the_cycle) gf->the_cycle = init_linked_list(); if(!gf->list_visited_vertex) gf->list_visited_vertex = init_linked_list(); if(!gf->the_rest) gf->the_rest = init_linked_list(); get_cycle(gf, cycle_len); /*printing_linked_list(gf->the_cycle);*/ if(!is_empty_list(gf->the_cycle)) { Delete_hash_table(gf->HV); circularize(gf,gf->the_cycle, cycle_len); get_rest(gf); /*printing_linked_list(gf->the_rest);*/ if(!is_empty_list(gf->the_rest)) mes = layout_rest(gf, gf->the_rest, gf->count_vertex-cycle_len); } else mes = NO_CYCLE; Delete_all_list(gf->the_cycle); Delete_all_list(gf->list_visited_vertex); Delete_all_list(gf->the_rest); gf->the_cycle = init_linked_list(); gf->list_visited_vertex = init_linked_list(); gf->the_rest = init_linked_list(); return mes; }
UINT8 i8x9x_device::io_r8(UINT8 adr) { switch(adr) { case 0x00: return 0x00; case 0x01: return 0x00; case 0x02: return ad_result; case 0x03: return ad_result >> 8; case 0x04: logerror("%s: read hsi time l (%04x)\n", tag(), PPC); return 0x00; case 0x05: logerror("%s: read hsi time h (%04x)\n", tag(), PPC); return 0x00; case 0x06: logerror("%s: read hsi status (%04x)\n", tag(), PPC); return 0x00; case 0x07: logerror("%s: read sbuf %02x (%04x)\n", tag(), sbuf, PPC); return sbuf; case 0x08: return PSW; case 0x09: logerror("%s: read int pending (%04x)\n", tag(), PPC); return pending_irq; case 0x0a: logerror("%s: read timer1 l (%04x)\n", tag(), PPC); return timer_value(1, get_cycle()); case 0x0b: logerror("%s: read timer1 h (%04x)\n", tag(), PPC); return timer_value(1, get_cycle()) >> 8; case 0x0c: logerror("%s: read timer2 l (%04x)\n", tag(), PPC); return timer_value(2, get_cycle()); case 0x0d: logerror("%s: read timer2 h (%04x)\n", tag(), PPC); return timer_value(2, get_cycle()) >> 8; case 0x0e: { static int last = -1; if(io->read_word(P0*2) != last) { last = io->read_word(P0*2); logerror("%s: read p0 %02x\n", tag(), io->read_word(P0*2)); } return io->read_word(P0*2); } case 0x0f: return io->read_word(P1*2); case 0x10: return io->read_word(P2*2); case 0x11: { UINT8 res = sp_stat; sp_stat &= 0x80; logerror("%s: read sp stat %02x (%04x)\n", tag(), res, PPC); return res; } case 0x15: logerror("%s: read ios 0 %02x (%04x)\n", tag(), ios0, PPC); return ios0; case 0x16: { UINT8 res = ios1; ios1 = ios1 & 0xc0; return res; } default: logerror("%s: io_r8 %02x (%04x)\n", tag(), adr, PPC); return 0x00; } }
void i8x9x_device::io_w8(UINT8 adr, UINT8 data) { switch(adr) { case 0x02: ad_command = data; if(ad_command & 8) ad_start(get_cycle()); break; case 0x03: logerror("%s: hsi_mode %02x (%04x)\n", tag(), data, PPC); break; case 0x04: hso_time = (hso_time & 0xff00) | data; break; case 0x05: hso_time = (hso_time & 0x00ff) | (data << 8); commit_hso_cam(); break; case 0x06: hso_command = data; break; case 0x07: logerror("%s: sbuf %02x (%04x)\n", tag(), data, PPC); serial_send(data); break; case 0x08: PSW = (PSW & 0xff00) | data; check_irq(); break; case 0x09: pending_irq = data; logerror("%s: int_pending %02x (%04x)\n", tag(), data, PPC); break; case 0x0a: logerror("%s: watchdog %02x (%04x)\n", tag(), data, PPC); break; case 0x0e: logerror("%s: baud rate %02x (%04x)\n", tag(), data, PPC); break; case 0x0f: logerror("%s: io port 1 %02x (%04x)\n", tag(), data, PPC); io->write_word(P1*2, data); break; case 0x10: logerror("%s: io port 2 %02x (%04x)\n", tag(), data, PPC); io->write_word(P2*2, data); break; case 0x11: logerror("%s: sp con %02x (%04x)\n", tag(), data, PPC); break; case 0x15: logerror("%s: ioc0 %02x (%04x)\n", tag(), data, PPC); ioc0 = data; break; case 0x16: logerror("%s: ioc1 %02x (%04x)\n", tag(), data, PPC); ioc1 = data; break; case 0x17: logerror("%s: pwm control %02x (%04x)\n", tag(), data, PPC); break; } return; }
void i8x9x_device::serial_send(UINT8 data) { serial_send_buf = data; serial_send_timer = get_cycle() + 9600; }
static void mem_reorder(struct prog_arg *pa, struct thread_data *ta) { int n = pa->nloop; int i; long long tb; long long te; long long t1, t2; long long niter = 512; volatile unsigned int *ptr0 = (unsigned int*)pa->mem1; unsigned int *ptr1 = (unsigned int*)pa->mem1; asm volatile ("":"+r"(ptr0),"+r"(ptr1)); ptr1 ++; time_init(); tb = get_cycle(); int sum0 = 0; for (i=0; i<n; i++) { long long bi = 0; int j; for (j=0; j<niter; j+=4) { ptr1[(j*4+0)*2] = 0; ptr0[(j*4+0)*2]; ptr1[(j*4+1)*2] = 0; ptr0[(j*4+1)*2]; ptr1[(j*4+2)*2] = 0; ptr0[(j*4+2)*2]; ptr1[(j*4+3)*2] = 0; ptr0[(j*4+3)*2]; } } te = get_cycle(); t1 = te-tb; tb = get_cycle(); for (i=0; i<n; i++) { long long bi = 0; int j; for (j=0; j<niter; j+=4) { ptr1[(j*4+0)*2] = 0; ptr1[(j*4+1)*2] = 0; ptr1[(j*4+2)*2] = 0; ptr1[(j*4+3)*2] = 0; ptr0[(j*4+0)*2]; ptr0[(j*4+1)*2]; ptr0[(j*4+2)*2]; ptr0[(j*4+3)*2]; } } te = get_cycle(); t2 = te-tb; time_end(); double inst_total = n * niter * 2.0; printf("IPC=%f/%f sum=%d\n", (double)inst_total/(double)(t1), (double)inst_total/(double)(t2), sum0); }
int cycle() { xmachine_memory_keratinocyte * xmemory = current_xmachine->xmachine_keratinocyte; char_array id_temp; char buffer[10]; /* find number of contacts/bonds*/ int contacts = get_num_xy_bonds() + get_num_z_bonds(); /* touching a wall counts as two contacts*/ if (get_x() == 0 || get_x() == substrate_width) { contacts += 2; } if (get_y() == 0 || get_y() == substrate_width) { contacts += 2; } if (contacts <= get_max_num_bonds(calcium_level)) { /* cell comes out of G0*/ set_cycle(get_cycle()+1); set_contact_inhibited_ticks(0); } else { /* cell enters G0*/ set_contact_inhibited_ticks(get_contact_inhibited_ticks()+1); } /* check to see if enough time has elapsed as to whether cell can divide*/ if (divide(get_type(), get_cycle())) { int new_cycle = start_new_cycle_postion(); double new_x = get_new_coord(get_x(), FALSE); double new_y = get_new_coord(get_y(), FALSE); double new_z = get_z(); double new_diff_noise_factor = 0.9 + (rnd()*0.2); double new_dir = rnd() * 2 * PI; double new_motility = (0.5 + (rnd() * 0.5)) * get_new_motility(get_type(), calcium_level); last_agent_id ++; /* generate a new ID*/ if (can_stratify(get_type(), calcium_level) && get_num_xy_bonds() >= MAX_NUM_LATERAL_BONDS) { new_z = get_new_coord(get_z(), TRUE); } xmemory->cycle = start_new_cycle_postion(); init_char_array(&id_temp); copy_char_array(&ID_CHAR, &id_temp); add_char(&id_temp, '.'); sprintf(buffer, "%d", SPLITS); add_char(&id_temp, buffer[0]); printf("new cell: %s\n", id_temp.array); add_keratinocyte_agent( /*get_id()+1,*/ ID, &id_temp, /*last_agent_id, id*/ 0, /* splits*/ get_type(), /* type*/ new_x, /* x*/ new_y, /* y*/ new_z, /* z*/ 0, /* force_x*/ 0, /* force_y*/ 0, /* force_z*/ 0, /* num_xy_bonds*/ 0, /* num_z_bonds*/ 0, /* num_stem_bonds*/ new_cycle, /* cycle*/ new_diff_noise_factor, /* diff_noise_factor*/ 0, /* dead_ticks*/ 0, /* contact_inhibited_ticks*/ new_motility, /* motility*/ new_dir, /* dir*/ get_range() /* range */ ); xmemory->splits++; free_char_array(&id_temp); } return 0; }