-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgeneric-model.h
113 lines (88 loc) · 2.56 KB
/
generic-model.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//Elsa Gonsiorowski
//October 7, 2011
//Rensselaer Polytechnic Institute
//General structs, defs, and vars for the model
#ifndef _gates_model_h
#define _gates_model_h
#include "ross.h"
//define logic type and value
typedef int BOOL;
typedef int LOGIC;
#define TRUE (1)
#define FALSE (0)
#define X (-1)
#define Z (2)
#define LOGIC_NOT(x) ((x) + 1) % 2
//message types
#define INIT_MSG (0)
#define SOURCE_MSG (1)
#define SETUP_MSG (2)
#define LOGIC_MSG (3)
#define SINK_MSG (4)
#define WAVE_MSG (5)
//sim settings
#define MESSAGE_PAD (0.4)
//Model structs
typedef struct {
int type;
int id;
int value;
// used for reverse computation of ff/latch
int internal_pin0;
int internal_pin1;
long rng_count;
} message;
typedef struct {
//gate specific information
unsigned int gate_type;
//variables for linking gates
int* inputs;
int* internals;
int output_size;
int* output_gid;
int* output_pin;
int* output_val;
//lp stats
int received_events;
int roll_backs;
//wave stuffs
BOOL wave_print;
char wave_id;
} gate_state;
// Command Line Arguments
// (list here only if needed in multiple files)
//Global vars accessed by main and driver
extern tw_lptype gates_lps[];
extern int wave_gids[];
extern FILE * wave_out_file;
//DRIVER FUNCTIONS: gates-driver.c
void gates_init(gate_state *s, tw_lp *lp);
void gates_event(gate_state *s, tw_bf *bf, message *in_msg, tw_lp *lp);
void gates_event_rc(gate_state *s, tw_bf *bf, message *in_msg, tw_lp *lp);
void gates_final(gate_state *s, tw_lp *lp);
//MAPPING FUNCTIONS: gates-map.c
tw_peid gates_custom_mapping_to_pe(tw_lpid gid);
void gates_custom_mapping_setup();
tw_lp * gates_custom_mapping_to_local(tw_lpid gid);
//RIO FUNCTIONS: gates-rio.c
size_t gate_size(gate_state *s, tw_lp *lp);
void gate_serialize(gate_state *s, void *buffer, tw_lp *lp);
void gate_deserialize(gate_state *s, void *buffer, tw_lp *lp);
//CONTENT GENERATED BY PURGER
// defined in library.c
typedef void (*gate_func)(int input[], int internal[], int output[]);
extern gate_func function_array[];
typedef float (*delay_func)(int in_pin, int out_pin, BOOL rising);
extern delay_func delay_array[];
typedef void (*reverse_func)(int input[], int internal[], int output[]);
extern reverse_func reverse_array[];
extern int gate_input_size[];
extern int gate_internal_size[];
extern int gate_output_size[];
// defined in routing.c
extern int routing_table_lp[];
extern int routing_table_kp[];
typedef int (*intarrptr)[];
extern intarrptr routing_table_mpi;
intarrptr routing_table_mapper(int np);
#endif