diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c94b182 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.tar.gz +*.out +*.log +*.ecpi diff --git a/tp2-obj2-meens/Makefile b/tp2-obj2-meens/Makefile index e59b695..4835536 100644 --- a/tp2-obj2-meens/Makefile +++ b/tp2-obj2-meens/Makefile @@ -6,10 +6,10 @@ all: main a: extern.epi heptc $< -$(OBJ): hs_handler.ept a +b: hs_handler.ept a heptc -target c $< -main: $(OBJ) +main: b gcc -I $(LIB_PATH)/c -I . main.c $(OBJ) clean: diff --git a/tp3-obj1-meens/Makefile b/tp3-obj1-meens/Makefile new file mode 100644 index 0000000..50209fc --- /dev/null +++ b/tp3-obj1-meens/Makefile @@ -0,0 +1,21 @@ +LIB_PATH=$(shell heptc -where) +OBJ=extern.c first_c/first.c first_c/first_types.c + +all: main + +a: extern.epi + heptc $< + +$(OBJ): first.ept a + heptc -target c $< + +main: $(OBJ) + gcc -I $(LIB_PATH)/c -I . main.c $(OBJ) + +clean: + $(RM) *.log + $(RM) *.epci + $(RM) *.mls + $(RM) *.o *.obj *.obc + $(RM) -r *_c + $(RM) *.out diff --git a/tp3-obj1-meens/extern.c b/tp3-obj1-meens/extern.c new file mode 100644 index 0000000..0075006 --- /dev/null +++ b/tp3-obj1-meens/extern.c @@ -0,0 +1,14 @@ +#include "extern.h" +#include + +void Extern__print_fast_step(int x, int y, int idx, Extern__print_fast_out *_out) { + printf("Fast - idx: %d, x: %d, y: %d\n", idx, x, y); +} + +void Extern__print_gnc_step(int x, int y, int idx, Extern__print_gnc_out *_out) { + printf("GNC - idx: %d, x: %d, y: %d\n", idx, x, y); +} + +void Extern__print_thermal_step(int idx, Extern__print_thermal_out *_out) { + printf("Thermal - idx: %d\n", idx); +} diff --git a/tp3-obj1-meens/extern.epi b/tp3-obj1-meens/extern.epi new file mode 100644 index 0000000..0e6a5f9 --- /dev/null +++ b/tp3-obj1-meens/extern.epi @@ -0,0 +1,3 @@ +fun print_fast(x:int; y:int; idx:int) returns () +fun print_gnc(y:int; x:int; idx:int) returns () +fun print_thermal(idx:int) returns () diff --git a/tp3-obj1-meens/extern.h b/tp3-obj1-meens/extern.h new file mode 100644 index 0000000..ae4d9c3 --- /dev/null +++ b/tp3-obj1-meens/extern.h @@ -0,0 +1,25 @@ +#ifndef EXTERN_H +#define EXTERN_H + +typedef struct { + int x; + int y; + int idx; +} Extern__print_fast_out; + +typedef struct { + int y; + int x; + int idx; +} Extern__print_gnc_out; + +typedef struct { + int idx; +} Extern__print_thermal_out; + +void Extern__print_fast_step(int x, int y, int idx, Extern__print_fast_out *_out); +void Extern__print_gnc_step(int y, int x, int idx, Extern__print_gnc_out *_out); +void Extern__print_thermal_step(int idx, Extern__print_thermal_out *_out); + +#endif // EXTERN_H + diff --git a/tp3-obj1-meens/extern_types.h b/tp3-obj1-meens/extern_types.h new file mode 100644 index 0000000..863ab7d --- /dev/null +++ b/tp3-obj1-meens/extern_types.h @@ -0,0 +1,6 @@ +#ifndef EXTERN_TYPES_H +#define EXTERN_TYPES_H + + + +#endif /* EXTERN_TYPES_H */ diff --git a/tp3-obj1-meens/first.ept b/tp3-obj1-meens/first.ept new file mode 100644 index 0000000..43694c5 --- /dev/null +++ b/tp3-obj1-meens/first.ept @@ -0,0 +1,60 @@ +open Extern + +node fast(x: int) returns (y: int) +var idx: int; +let + idx = 0 fby (idx + 1); + y = 2 * x + idx; + () = print_fast(x, y, idx); +tel + +node condact_f<>(c: bool; x: int) returns (y: int) +let + y = merge c + (true -> fast(x when c)) + (false -> (y_init fby y) whenot c); +tel + +node gnc(y: int) returns (x: int) +var idx: int; +let + idx = 0 fby (idx + 1); + x = y - idx; + () = print_gnc(y, x, idx); +tel + +node condact_gnc<>(c:bool; y:int) returns (x:int) +let + x = merge c + (true -> gnc (y when c)) + (false -> (x_init fby x) whenot c) ; +tel + +node thermal() returns () +var idx: int; +let + idx = 0 fby (idx + 1); + () = print_thermal(idx); +tel + +node condact_thermal(c: bool) returns () +let + () = thermal() when c; +tel + +node main() returns () + var + mif_cnt,x,y:int; + clk_f,clk_gnc,clk_thermal:bool; +let + (* Clock computation *) + mif_cnt = 0 fby ((mif_cnt+1)%10) ; + clk_f = true ; + clk_thermal = (mif_cnt = 0) ; + clk_gnc = (mif_cnt = 9) ; + + (* Flot de données *) + y = condact_f<<31>>(clk_f,99 fby x) ; + ()= condact_thermal(true when clk_thermal) ; + x = condact_gnc<<99>>(clk_gnc,y) ; +tel diff --git a/tp3-obj1-meens/main.c b/tp3-obj1-meens/main.c new file mode 100644 index 0000000..61213d7 --- /dev/null +++ b/tp3-obj1-meens/main.c @@ -0,0 +1,17 @@ +#include +#include "first_c/first.h" +#include "first_c/first_types.h" + +int main() { + First__main_out _out; + First__main_mem self; + + First__main_reset(&self); + + while (1) { + First__main_step(&_out, &self); + + usleep(1000000); + } + return 0; +}