feat(tp3-obj1)
This commit is contained in:
parent
e4242061c3
commit
bba56ded14
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.tar.gz
|
||||
*.out
|
||||
*.log
|
||||
*.ecpi
|
@ -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:
|
||||
|
21
tp3-obj1-meens/Makefile
Normal file
21
tp3-obj1-meens/Makefile
Normal file
@ -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
|
14
tp3-obj1-meens/extern.c
Normal file
14
tp3-obj1-meens/extern.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include "extern.h"
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
3
tp3-obj1-meens/extern.epi
Normal file
3
tp3-obj1-meens/extern.epi
Normal file
@ -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 ()
|
25
tp3-obj1-meens/extern.h
Normal file
25
tp3-obj1-meens/extern.h
Normal file
@ -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
|
||||
|
6
tp3-obj1-meens/extern_types.h
Normal file
6
tp3-obj1-meens/extern_types.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef EXTERN_TYPES_H
|
||||
#define EXTERN_TYPES_H
|
||||
|
||||
|
||||
|
||||
#endif /* EXTERN_TYPES_H */
|
60
tp3-obj1-meens/first.ept
Normal file
60
tp3-obj1-meens/first.ept
Normal file
@ -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<<y_init: int>>(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<<x_init:int>>(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
|
17
tp3-obj1-meens/main.c
Normal file
17
tp3-obj1-meens/main.c
Normal file
@ -0,0 +1,17 @@
|
||||
#include <unistd.h>
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user