source: liacs/ca/opdr2b/src/sim.c@ 3

Last change on this file since 3 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

  • Property svn:executable set to *
File size: 1.9 KB
RevLine 
[2]1/* Author : Rick van der Zwet
2 * S-number : 0433373
3 * Version : $Id: sim.c 365 2007-12-03 08:54:04Z rick $
4 * Copyright : FreeBSD Licence
5 * Description : MIPS simulator. Main module
6 */
7
8
9#include <stdlib.h>
10#include <stdio.h>
11#include <sysexits.h>
12#include "sim.h"
13#include "alu.h"
14#include "memory.h"
15#include "control.h"
16#include "constant.h"
17
18
19/* Allow printing of diagnostics */
20void
21_print_diag(const int round)
22{
23 fprintf(stderr, "===TAG ROUND %i====\n", round);
24 fprintf(stderr, "a : %u\n", a);
25 fprintf(stderr, "b : %u\n", b);
26 fprintf(stderr, "c : %u\n", c);
27 fprintf(stderr, "temp : %u\n", temp);
28 fprintf(stderr, "temp2 : %u\n", temp2);
29 fprintf(stderr, "pc : %u\n", pc);
30 fprintf(stderr, "mar : %u\n", mar);
31 fprintf(stderr, "mdr : %u\n", mdr);
32 fprintf(stderr, "ir : %u\n", ir);
33 fprintf(stderr, "imm : %u\n", imm);
34 fprintf(stderr, "constant : %u\n", constant);
35 fprintf(stderr, "mpc : %u\n", mpc);
36}
37
38int main ()
39{
40 fprintf(stderr, "===SIMULATION===\n");
41 fprintf(stderr, "===INIT===\n");
42 /* Initiate control */
43 control_init();
44 /* Read memory from stdin */
45 readmem();
46
47 /* Limit calls to 10000 to make debugging possible */
48 int cycles = 0;
49 for (;cycles < 10000; cycles++)
50 {
51 if (mpc == 43) /* Break line, means end */
52 break;
53 /* Disable if you do not want the verbose outpt */
54 _print_diag(cycles);
55 /* execute command */
56 set_signals();
57 find_new_mPC();
58 }
59
60 /* Dump memory and print diag */
61 fprintf(stderr, "===BEGIN MEMORYDUMP===\n");
62 writemem();
63 fprintf(stderr, "====END MEMORYDUMP====\n");
64 fprintf(stderr, "Number of microinstructions : %i\n", cycles);
65 fprintf(stderr, "Student: Rick van der Zwet\n");
66 fprintf(stderr, "StudentNumber: 0433373\n");
67 fprintf(stderr, "===END===\n");
68 return(EX_OK);
69}
Note: See TracBrowser for help on using the repository browser.