feat(tp2-obj1)

This commit is contained in:
Hugo Meens 2025-04-03 12:08:22 +02:00
parent cdbd983b03
commit 453e7aea56
3 changed files with 39 additions and 0 deletions

18
tp2-obj1-meens/Makefile Normal file
View File

@ -0,0 +1,18 @@
LIB_PATH=$(shell heptc -where)
OBJ=rcounter_c/rcounter.c rcounter_c/rcounter_types.c
all: main
$(OBJ): rcounter.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

17
tp2-obj1-meens/main.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include "rcounter_c/rcounter.h"
#include "rcounter_c/rcounter_types.h"
void main() {
int o;
Rcounter__rcounter_mem s;
Rcounter__rcounter_out out;
for(;;) { /* Boucle infinie */
printf("Input: ");
scanf("%d", &o);
Rcounter__rcounter_step(o, &out, &s) ; /* Calculs */
printf("%i\n", out);
}
}

View File

@ -0,0 +1,4 @@
node rcounter(rst:bool) returns (cnt:int)
let
cnt = if rst then 0 else (0 fby (cnt+1))
tel