From cc78e19aa9e6b7c8ec0e1e5ac26685e57406c69d Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Mon, 11 Nov 2013 17:30:46 +0100 Subject: Added ROM support, coded a 24/60/60 watch with output for 7-bit LCD display --- csim/sim.h | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'csim/sim.h') 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 // 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 -- cgit v1.2.3