void set_register(int reg){ struct Lnode *ptr = NULL; if(reg == 7) reg = 3; switch (reg) { case -1: //Store instuctions ptr = key_instructions.str; break; case 0: ptr = key_instructions.write_r0; break; case 1: ptr = key_instructions.write_r1; break; case 2: ptr = key_instructions.write_r2; break; case 3: ptr = key_instructions.Inputs[7-3]; break; } if(ptr != NULL){ process_outputs(ptr, payload->head); write_gadget(ptr); process_inputs(ptr); if(reg >= 0){ state[reg] = 1; } } }
int main(int argc, char *argv[]) { process_args(argc, argv); Camera_Reset(); while (1) { if (glfwGetKey(mainWindow, GLFW_KEY_ESCAPE) == GLFW_PRESS || glfwWindowShouldClose(mainWindow) == 1) { break; } process_inputs(); Engine_UpkeepTime(); /* Updates deltaTime */ Engine_Draw(); /* Render */ Engine_Update(); /* Update anything else */ } Engine_Quit(); printf("\nKa3D is now shutting down!\n"); return 0; }
void write_data(){ struct Lnode *actual_node = NULL; struct Lnode *next_node = NULL; struct Lnode *ptr = NULL; int i, *Outputs; uint32_t value; clear_vector(inputs_vector_state, 14, 0); clear_vector(written, 4, 0); inputs_vector_state[7] = 1; inputs_vector_values[7] = 11; store_count = 0; store_values_r3[0] = 0; store_values_r3[1] = SH_HEX; store_values_r3[2] = BIN_HEX; store_values_r4[0] = key_instructions.r_w_addr + 8; store_values_r4[1] = key_instructions.r_w_addr + 4; store_values_r4[2] = key_instructions.r_w_addr; for(actual_node = payload->tail; actual_node != NULL; actual_node = actual_node->prev){ next_node = actual_node->prev; if(next_node == NULL) break; for(ptr = (GETPOINTER(next_node, payload_gadget_t))->gadget; ptr != NULL && ptr->next != NULL; ptr = ptr->next); //'ret' Outputs = (GETPOINTER(ptr, Gadget_t))->Outputs; if(Outputs[0] && !written[0]){ written[0] = 1; inputs_vector_state[0] = 1; inputs_vector_values[0] = key_instructions.r_w_addr; } if(Outputs[1] && !written[1]){ written[1] = 1; inputs_vector_state[1] = 1; inputs_vector_values[1] = key_instructions.r_w_addr + 8; } if(Outputs[2] && !written[2]){ written[2] = 1; inputs_vector_state[2] = 1; inputs_vector_values[2] = 0; } for(i = 14; i >= 0; i--){ if(Outputs[i]){ value = getValue(i); actual_node = insert_word(value, actual_node); } } if(Outputs[7] && !written[3]){ written[3] = 1; inputs_vector_values[7] = WORD_PADDING; } process_inputs(GETPOINTER(next_node, payload_gadget_t)->gadget); } }
static void run_game() { game_data game; initialize_game(&game, wsi::milliseconds()); running = true; for (;;) { wsi::update(&screen); bool rendering = wsi::should_render(); int64_t millisecond_clock_now = wsi::milliseconds(); unsigned ticks_elapsed = 0; float fractional_ticks = 0; calc_game_elapsed_time(&game, &ticks_elapsed, &fractional_ticks, millisecond_clock_now); game_command action = { 0 }; process_inputs(&action); if (!running) break; update_game(&game, ticks_elapsed, &action, millisecond_clock_now); update_fps(); if (action.toggle_pause) { pause_eviz_dx12(game.paused); } if (rendering) { float dpi = (float)screen.dpi.cx; float x_dips = screen.dimensions.cx * 96.0f / dpi; float y_dips = screen.dimensions.cy * 96.0f / dpi; set_swapchain_options_dx12(&wsi::screen_window, NULL, x_dips, y_dips, dpi, &swapchain_opts); rebuild_hud_string(&game); dx12_render_stats stats; render_game_dx12(hud_string, &game, fractional_ticks, screen.prefs.vsync, &stats); if (stats.latency) { const float alpha = 0.1f; frame_latency = (1-alpha)*frame_latency + alpha*stats.latency; frame_latency_stddev = stats.stddev_jitter; frame_latency_minmaxd = stats.minmax_jitter; current_frametime_cpu = (1 - alpha)*current_frametime_cpu + alpha*stats.cpu_frame_time; current_frametime_gpu = (1 - alpha)*current_frametime_gpu + alpha*stats.gpu_frame_time; } } //wsi::limit_fps(max_fps); } }
void write_stores(){ unsigned char store_writes_r3, store_writes_r4; struct Lnode *store_pop = NULL; int i, j, *Outputs[3], sum[3]; for(i = 0; i < 3; i++){ process_inputs(key_instructions.str); write_gadget(key_instructions.str); process_outputs(key_instructions.str, payload->head); } store_writes_r3 = store_writes_r(3); store_writes_r4 = store_writes_r(4); if(store_writes_r3 | store_writes_r4){ if(store_writes_r3 && store_writes_r4){ for(store_pop = key_instructions.str; store_pop->next != NULL; store_pop = store_pop->next); Outputs[0] = (GETPOINTER(store_pop, Gadget_t))->Outputs; Outputs[1] = (GETPOINTER(key_instructions.Inputs[3-3], Gadget_t))->Outputs; Outputs[2] = (GETPOINTER(key_instructions.Inputs[4-3], Gadget_t))->Outputs; for(j = 0; j < 3; j++){ sum[j] = 0; for(i = 0; i < 14; i++){ if(Outputs[j][i]){ sum[j]++; } } } if( (sum[0] - 1) <= sum[1] + sum[2]){ write_auxiliar_gadget(-1, payload->head); //'pop' of the store } else{ write_auxiliar_gadget(4, payload->head); write_auxiliar_gadget(3, payload->head); } } else if(store_writes_r3){ write_auxiliar_gadget(3, payload->head); } else{ write_auxiliar_gadget(4, payload->head); } } }
void resolve_dependences(){ struct Lnode *payload_node = NULL; payload_gadget_t *payload_node_struct = NULL; /* Local state of pending inputs (previous iteration) */ unsigned char inputs_vector_state_LOCAL[14]; unsigned char looping = 1; int i; while(looping){ copy_vector(inputs_vector_state_LOCAL, inputs_vector_state, 14); clear_vector(inputs_vector_state, 14, 0); inputs_vector_state[7] = 1; inputs_vector_values[7] = 11; inputs_vector_refs[7] = 0; for(payload_node = payload->tail; payload_node != NULL; payload_node = payload_node->prev){ payload_node_struct = GETPOINTER(payload_node, payload_gadget_t); process_outputs(payload_node_struct->gadget, payload_node); process_inputs(payload_node_struct->gadget); for(i = 0; i < 14; i++){ if(inputs_vector_state[i] && inputs_vector_state_LOCAL[i]){ // Input not provided // if(payload_node != payload->head || !store_writes_r(i)){ // Fix it if(check_my_outputs(i)){ // Auxiliar gadget (which writes into i) writes also into another pending input // inputs_vector_refs[i] = payload_node; } else{ payload_node = write_auxiliar_gadget(i, payload_node); } } } } } looping = 0; for(i = 0; i < 14; i++){ if(inputs_vector_state[i] && !store_writes_r(i)){ write_auxiliar_gadget(i, payload_node); looping = 1; } } } }
int main (int argc, char* argv[]) { dat_t<FLEN>* inputA; dat_t<FLEN>* inputB; dat_t<1>* expected_out; dat_t<5>* expected_exceptionFlags; dat_t<1>* actual_out; dat_t<5>* actual_exceptionFlags; dat_t<1>* check; dat_t<1>* pass; dut_t* module = new dut_t(); size_t cnt = 0; size_t error = 0; module->init(); inputA = SIGNAL(FLEN, compareOp, a); inputB = SIGNAL(FLEN, compareOp, b); expected_out = SIGNAL(FLEN, compareOp, expected_out); expected_exceptionFlags = SIGNAL(FLEN, compareOp, expected_exceptionFlags); actual_out = SIGNAL(FLEN, compareOp, actual_out); actual_exceptionFlags = SIGNAL(FLEN, compareOp, actual_exceptionFlags); check = SIGNAL(FLEN, compareOp, check); pass = SIGNAL(FLEN, compareOp, pass); // reset for (size_t i=0; i<10; i++) { module->clock_lo(LIT<1>(1)); module->clock_hi(LIT<1>(1)); } // main operation for (;;) { if ( ! process_inputs(inputA, inputB) || ! process_outputs(expected_out, expected_exceptionFlags) ) { printf("Ran %ld tests.\n", cnt); if (!error) fputs("No errors found.\n", stdout); break; } module->clock_lo(LIT<1>(0)); if (check->to_bool()) { if ((cnt % 10000 == 0) && cnt) printf("Ran %ld tests.\n", cnt); if (!pass->to_bool()) { error++; printf("[%07ld]", cnt); printf( " %s %s", inputA->to_str().c_str(), inputB->to_str().c_str() ); printf( " => %s %s expected: %s %s\n", actual_out->to_str().c_str(), actual_exceptionFlags->to_str().c_str(), expected_out->to_str().c_str(), expected_exceptionFlags->to_str().c_str() ); if (error == 20) { printf("Reached %ld errors. Aborting.\n", error); break; } } cnt++; } module->clock_hi(LIT<1>(0)); } return 0; }
void main(void) { unsigned char n; // // Initialisierung // restart_hw(); DEBUG_SETUP; // Warten bis Bus stabil, nach Busspannungswiederkehr for (n = 0; n < 50; n++) { TR0 = 0; // Timer 0 anhalten TH0 = eeprom[ADDRTAB + 1]; // Timer 0 setzen mit phys. Adr. damit Geräte unterschiedlich beginnen zu senden TL0 = eeprom[ADDRTAB + 2]; TF0 = 0; // Überlauf-Flag zurücksetzen TR0 = 1; // Timer 0 starten while (!TF0) ; } restart_app(); do { // // Hauptverarbeitung // if (APPLICATION_RUN) { process_inputs(); if (RTCCON >= 0x80) timer_event(); } DEBUG_POINT; // // Empfangenes Telegramm bearbeiten // if (tel_arrived) process_tel(); // // Watchdog rücksetzen // EA = 0; WFEED1 = 0xA5; WFEED2 = 0x5A; EA = 1; // // Abfrage des Programmier-Tasters // TASTER = 1; if (!TASTER) { for (n = 0; n < 100; n++) // Entprellen ; while (!TASTER) // Warten bis Taster losgelassen ; status60 ^= 0x81;// Prog-Bit und Parity-Bit im system_state toggeln } TASTER = !(status60 & 0x01);// LED entsprechend Prog-Bit schalten (low=LED an) } while (1); }