Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //compilacion g++ -std=c++11 -o NombreEjecutable NombreFuente.cpp
- //Ejercicio libre VHDL 4.5
- #include <iostream>
- #include <iomanip>
- using namespace std;
- #define max 0x0F
- int main(){
- //int a(0x1F),b(0x31),dif(0),neg(0);//Condiciones iniciales Hexadecimal
- int a(0b00011111),b(0b00110001),dif(0),neg(0);//Condiciones iniciales binario
- for (int time=0;time <360;time+=50){//incrementa el tiempo de 50ns en 50ns
- //Simula el paso del tiempo
- if (time == 100){b=0b00101011;} // 0x2B wait for 100 ns
- if (time == 200){b=0b00011011;} // 0x1B wait for 100 ns
- if (time == 300){b=0b00001110;} // 0x0E wait for 100 ns
- //BEGIN
- if (a>= b+max) {dif=max ;neg=0;}
- else if (a>=b ){dif=(b-a);neg=0;}
- else if (b <= a+max) {dif =b-a; neg=1;}
- else {dif=max ; neg=1;}
- //END PROCESS
- //if (dif <0){ cout <<"!" ;dif=~dif; dif++;} //muestra numero negativo , complemento a 2 , mas 1
- cout <<"Time = " << std::dec<< time <<std::hex<<"ns \t dif = " << setfill('0') << setw(2)<<(dif & 0xFF)<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement