From cdbd983b03b8955148405f1e567fbfbab6b779e5 Mon Sep 17 00:00:00 2001 From: Hugo Meens Date: Thu, 27 Mar 2025 12:42:38 +0100 Subject: [PATCH] feat(tp1) --- tp1-obj1-meens/Makefile | 18 ++++++++++++++++++ tp1-obj1-meens/first.ept | 7 +++++++ tp1-obj1-meens/main.c | 15 +++++++++++++++ tp1-obj2-meens/Makefile | 18 ++++++++++++++++++ tp1-obj2-meens/first.ept | 4 ++++ tp1-obj2-meens/main.c | 16 ++++++++++++++++ tp1-obj3-meens/Makefile | 19 +++++++++++++++++++ tp1-obj3-meens/first.ept | 4 ++++ tp1-obj3-meens/main.c | 16 ++++++++++++++++ 9 files changed, 117 insertions(+) create mode 100644 tp1-obj1-meens/Makefile create mode 100644 tp1-obj1-meens/first.ept create mode 100644 tp1-obj1-meens/main.c create mode 100644 tp1-obj2-meens/Makefile create mode 100644 tp1-obj2-meens/first.ept create mode 100644 tp1-obj2-meens/main.c create mode 100644 tp1-obj3-meens/Makefile create mode 100644 tp1-obj3-meens/first.ept create mode 100644 tp1-obj3-meens/main.c diff --git a/tp1-obj1-meens/Makefile b/tp1-obj1-meens/Makefile new file mode 100644 index 0000000..850999d --- /dev/null +++ b/tp1-obj1-meens/Makefile @@ -0,0 +1,18 @@ +LIB_PATH=$(shell heptc -where) +OBJ=first_c/first.c + +all: main + +$(OBJ): first.ept + heptc -target c $< + +main: $(OBJ) + gcc -I $(LIB_PATH)/c -I . main.c $< + +clean: + $(RM) *.log + $(RM) *.epci + $(RM) *.mls + $(RM) *.o *.obj *.obc + $(RM) -r *_c + $(RM) *.out diff --git a/tp1-obj1-meens/first.ept b/tp1-obj1-meens/first.ept new file mode 100644 index 0000000..8f393a0 --- /dev/null +++ b/tp1-obj1-meens/first.ept @@ -0,0 +1,7 @@ +fun myfun (x:int;y:int) returns (z:int;t:int) +var x2 : int; +let + x2 = x*x ; + t = x2 + 3*x ; + z= t + y ; +tel diff --git a/tp1-obj1-meens/main.c b/tp1-obj1-meens/main.c new file mode 100644 index 0000000..c720843 --- /dev/null +++ b/tp1-obj1-meens/main.c @@ -0,0 +1,15 @@ +#include + +#include "first_c/first.h" +#include "first_c/first_types.h" + + +void main() { + int x,y ; /* Allocation des entrées */ + First__myfun_out o ; /* Allocation des sorties */ + for(;;) { /* Boucle infinie */ + printf("Inputs:"); scanf("%d%d",&x,&y) ; /* Lecture des entrées */ + First__myfun_step(x,y,&o) ; /* Calculs */ + printf("Result: z=%d t=%d\n",o.z,o.t) ; /* Ecriture des sorties */ + } +} diff --git a/tp1-obj2-meens/Makefile b/tp1-obj2-meens/Makefile new file mode 100644 index 0000000..850999d --- /dev/null +++ b/tp1-obj2-meens/Makefile @@ -0,0 +1,18 @@ +LIB_PATH=$(shell heptc -where) +OBJ=first_c/first.c + +all: main + +$(OBJ): first.ept + heptc -target c $< + +main: $(OBJ) + gcc -I $(LIB_PATH)/c -I . main.c $< + +clean: + $(RM) *.log + $(RM) *.epci + $(RM) *.mls + $(RM) *.o *.obj *.obc + $(RM) -r *_c + $(RM) *.out diff --git a/tp1-obj2-meens/first.ept b/tp1-obj2-meens/first.ept new file mode 100644 index 0000000..8a4da2c --- /dev/null +++ b/tp1-obj2-meens/first.ept @@ -0,0 +1,4 @@ +node sum2(i:int) returns (o:int) +let + o = i + (0 fby i) ; +tel diff --git a/tp1-obj2-meens/main.c b/tp1-obj2-meens/main.c new file mode 100644 index 0000000..a13515b --- /dev/null +++ b/tp1-obj2-meens/main.c @@ -0,0 +1,16 @@ +#include + +#include "first_c/first.h" +#include "first_c/first_types.h" + +void main() { + int i ; /* Allocation des entrées */ + First__sum2_out o ; /* Allocation des sorties */ + First__sum2_mem s ; /* Allocation d l'état */ + First__sum2_reset(&s) ; /* Initialisation de l'état */ + for(;;) { /* Boucle infinie */ + printf("Inputs:"); scanf("%d",&i) ; /* Lecture des entrées */ + First__sum2_step(i,&o,&s) ; /* Calculs */ + printf("Result: o=%d\n",o.o) ; /* Ecriture des sorties */ + } +} diff --git a/tp1-obj3-meens/Makefile b/tp1-obj3-meens/Makefile new file mode 100644 index 0000000..9a825ed --- /dev/null +++ b/tp1-obj3-meens/Makefile @@ -0,0 +1,19 @@ +LIB_PATH=$(shell heptc -where) +OBJ=first_c/first.c + +all: main + +$(OBJ): first.ept + heptc -target c $< + +main: $(OBJ) + gcc -I $(LIB_PATH)/c -I . main.c $< + +clean: + $(RM) *.log + $(RM) *.epci + $(RM) *.mls + $(RM) *.o *.obj *.obc + $(RM) -r *_c + $(RM) *.out + diff --git a/tp1-obj3-meens/first.ept b/tp1-obj3-meens/first.ept new file mode 100644 index 0000000..c72b292 --- /dev/null +++ b/tp1-obj3-meens/first.ept @@ -0,0 +1,4 @@ +node counter () returns (cnt:int) +let + cnt = 0 fby (cnt+1) ; +tel diff --git a/tp1-obj3-meens/main.c b/tp1-obj3-meens/main.c new file mode 100644 index 0000000..8054274 --- /dev/null +++ b/tp1-obj3-meens/main.c @@ -0,0 +1,16 @@ +#include +#include + +#include "first_c/first.h" +#include "first_c/first_types.h" + +void main() { + First__counter_out o ; /* Allocation des sorties */ + First__counter_mem s ; /* Allocation d l'état */ + First__counter_reset(&s) ; /* Initialisation de l'état */ + for(;;) { /* Boucle infinie */ + usleep(10) ; /* A vous d'en choisir un (timer, input, etc.) */ + First__counter_step(&o,&s) ; + printf(" Result: cnt=%d\n",o.cnt) ; + } +}