summaryrefslogtreecommitdiff
path: root/csim/sim.h
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-11 17:30:46 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2013-11-11 17:30:46 +0100
commitcc78e19aa9e6b7c8ec0e1e5ac26685e57406c69d (patch)
tree1adcf146d6a649e92fe4aa13232d70f143dc448b /csim/sim.h
parentaca9d65df0a04d5161ec3485659bbb974b802fb0 (diff)
downloadSystDigit-Projet-cc78e19aa9e6b7c8ec0e1e5ac26685e57406c69d.tar.gz
SystDigit-Projet-cc78e19aa9e6b7c8ec0e1e5ac26685e57406c69d.zip
Added ROM support, coded a 24/60/60 watch with output for 7-bit LCD display
Diffstat (limited to 'csim/sim.h')
-rw-r--r--csim/sim.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/csim/sim.h b/csim/sim.h
index 8b4a726..27b492d 100644
--- a/csim/sim.h
+++ b/csim/sim.h
@@ -1,8 +1,6 @@
#ifndef DEF_SIM_H
#define DEF_SIM_H
-// TODO implement ROM
-
#include <stdio.h>
// Gate types
@@ -25,6 +23,14 @@
// 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;
+
+typedef struct _s_rom {
+ int addr_size, word_size;
+ t_value *data;
+ const char *prefix;
+ struct _s_rom *next;
+} t_rom;
+
// Identifier for the variables of the circuit.
typedef int t_id;
@@ -62,7 +68,7 @@ typedef struct {
t_id a, b, c;
} Mux;
struct {
- int addr_size, word_size;
+ t_rom *rom;
t_id read_addr;
} Rom;
struct {
@@ -109,11 +115,16 @@ typedef struct {
// The functions for doing stuff with these data structures
t_program *load_dumb_netlist(FILE *stream);
+void add_rom(const char *prefix, FILE *file);
t_machine *init_machine(t_program *p);
void read_inputs(t_machine *m, FILE *stream);
void machine_step(t_machine *m);
void write_outputs(t_machine *m, FILE *stream);
+// util
+int pow2(int exp);
+t_value read_bool(FILE *stream, t_value *mask);
+int is_prefix(char *prefix, char *str);
#endif