summaryrefslogtreecommitdiff
path: root/csim/sim.h
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-04 23:47:56 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-04 23:47:56 +0100
commit7950298bf80fd1d1f311e7bd4f75b442df7c679c (patch)
treeefb935d351a6dd798795641461f63cf17ca9f390 /csim/sim.h
parent62705818bf8227a9a35fff6879306c1b861e9dfd (diff)
downloadSystDigit-Projet-7950298bf80fd1d1f311e7bd4f75b442df7c679c.tar.gz
SystDigit-Projet-7950298bf80fd1d1f311e7bd4f75b442df7c679c.zip
C simulator quite completed.
Diffstat (limited to 'csim/sim.h')
-rw-r--r--csim/sim.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/csim/sim.h b/csim/sim.h
index 75f3502..8e35c45 100644
--- a/csim/sim.h
+++ b/csim/sim.h
@@ -24,7 +24,11 @@
#define OP_NAND 3
// Data structures
+
+
+// Use 64-bit ints as bit arrays. Bit index 0 is bitmask 1, bit index 1 is bitmask 2, etc.
typedef unsigned long long int t_value;
+// Identifier for the variables of the circuit.
typedef int t_id;
typedef struct { // a variable in the simulator
@@ -34,8 +38,11 @@ typedef struct { // a variable in the simulator
} t_variable;
typedef struct {
- t_value val;
- t_id source_var; // if source_var == -1 then it's a direct value, else it's that variable
+ t_value mask; // if direct value, mask = all possible bits. Else mask = 0
+ union {
+ t_value Val;
+ t_id SrcVar; // if source_var == -1 then it's a direct value, else it's that variable
+ };
} t_arg;
typedef struct {
@@ -93,20 +100,23 @@ typedef struct {
// machine = execution instance
typedef union {
- t_value r_val;
- t_value *mem_val;
+ t_value RegVal;
+ t_value *RamData;
} t_mem_reg_data;
typedef struct {
t_program *prog;
- t_value *var_values;
- t_mem_reg_data *mem_data;
+ t_value *var_values; // indexed by variable ID
+ t_mem_reg_data *mem_data; // indexed by equation number
} t_machine;
// The functions for doing stuff with these data structures
+t_value read_bool(FILE *stream, t_value* mask);
+
t_program *load_dumb_netlist(FILE *stream);
+
t_machine *init_machine(t_program *p);
void read_inputs(t_machine *m, FILE *stream);
void machine_step(t_machine *m);