- #include <iostream>
- #include <stdio.h>
- #include <string>
- #include <cstring>
- #include <cassert>
- #include <cstdlib>
- #include <cstdio>
- #include <math.h>
- using namespace std;
- double HALF_48MHz_PERIOD = 10416.7;
- double BAUD_OUT_PERIOD = 104167000;
- double time_ps = 0;
- unsigned int number_of_baud_clocks_passed = 0;
- bool finished=false;
- void update_clk(void) {
- time_ps = time_ps + HALF_48MHz_PERIOD/2;
- /*******************************************/
- time_ps = time_ps + HALF_48MHz_PERIOD;
- /*******************************************/
- time_ps = time_ps + HALF_48MHz_PERIOD/2;
- }
- int main()
- {
- while(!finished){
- update_clk();
- number_of_baud_clocks_passed = (unsigned int)(time_ps/BAUD_OUT_PERIOD);
- if ( (number_of_baud_clocks_passed == 974979) && ((time_ps-(double)number_of_baud_clocks_passed*BAUD_OUT_PERIOD <= BAUD_OUT_PERIOD/2+HALF_48MHz_PERIOD) && (time_ps-(double)number_of_baud_clocks_passed*BAUD_OUT_PERIOD >= BAUD_OUT_PERIOD/2-HALF_48MHz_PERIOD)) ) {
- cout << "number_of_baud_clocks_passed = " << number_of_baud_clocks_passed << "\ttime_ps = " << time_ps << endl;
- cout << "(double)number_of_baud_clocks_passed = " << (double)number_of_baud_clocks_passed << endl;
- cout << "(double)BAUD_OUT_PERIOD = " << BAUD_OUT_PERIOD << endl;
- cout << "time_ps-(double)number_of_baud_clocks_passed*(double)BAUD_OUT_PERIOD = " << time_ps-(double)number_of_baud_clocks_passed*BAUD_OUT_PERIOD << endl;
- cout << "(double)BAUD_OUT_PERIOD/2+(double)HALF_48MHz_PERIOD = " << BAUD_OUT_PERIOD/2+HALF_48MHz_PERIOD << endl;
- cout << "(double)BAUD_OUT_PERIOD/2-(double)HALF_48MHz_PERIOD = " << BAUD_OUT_PERIOD/2-HALF_48MHz_PERIOD << endl;
- finished=true;
- }
- }
- }