summaryrefslogtreecommitdiff
path: root/csim
diff options
context:
space:
mode:
authorAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-03 12:07:46 +0100
committerAlex AUVOLAT <alex.auvolat@ens.fr>2014-01-03 12:07:46 +0100
commitc46fe12e47c405fbb03f0c93121402d873bc470e (patch)
treebc9cb3f5ffb5f130106e80d2777da41058d81d3a /csim
parentf2b28b4124015718dc4b392e00f4aade4eedc11c (diff)
downloadSystDigit-Projet-c46fe12e47c405fbb03f0c93121402d873bc470e.tar.gz
SystDigit-Projet-c46fe12e47c405fbb03f0c93121402d873bc470e.zip
Implement lw/sw/lwr/swr ; optimize simplification pass order ; add comments in ROM files
Diffstat (limited to 'csim')
-rw-r--r--csim/load.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/csim/load.c b/csim/load.c
index bb77a0e..485a743 100644
--- a/csim/load.c
+++ b/csim/load.c
@@ -13,6 +13,19 @@
t_rom *roms = NULL;
+void eat_comment(FILE *file) {
+ while (1) {
+ char c = fgetc(file);
+ if (isspace(c)) continue;
+ if (c == '#') {
+ while (fgetc(file) != '\n');
+ continue;
+ }
+ ungetc(c, file);
+ break;
+ }
+}
+
void add_rom(const char *prefix, FILE *file) {
int i;
@@ -20,11 +33,12 @@ void add_rom(const char *prefix, FILE *file) {
rom->prefix = prefix;
// Load ROM file
+ eat_comment(file);
fscanf(file, "%d %d\n", &(rom->words_defined), &(rom->word_size));
rom->data = malloc(rom->words_defined * sizeof(t_value));
for (i = 0; i < rom->words_defined; i++) {
- fscanf(file, " ");
+ eat_comment(file);
if (fscanf(file, "/%lu", &(rom->data[i]))) {
// ok, value is read
} else if (fscanf(file, "x%x", &(rom->data[i]))) {