Skip to content
Snippets Groups Projects
Commit b4baeb66 authored by Roberto Hexsel's avatar Roberto Hexsel
Browse files

now reads from stdin, cMIPS.{h,c}

parent 23eb0ec4
No related branches found
No related tags found
No related merge requests found
#define x_INST_BASE_ADDR 0x00000000
#define x_DATA_BASE_ADDR 0x00020000
#define x_DATA_BASE_ADDR 0x00010000
#define x_IO_BASE_ADDR 0x0F000000
#define x_IO_MEM_SZ 0x00002000
#define x_IO_ADDR_RANGE 0x00000020
......@@ -24,7 +24,7 @@
extern void exit(int);
extern void print(int);
extern void to_stdout(char c);
extern int from_stdin(char *);
extern int from_stdin(void);
extern void writeInt(int);
extern void writeClose(void);
......
......@@ -3,7 +3,7 @@
.set x_INST_BASE_ADDR,0x00000000
.set x_INST_MEM_SZ,0x00004000
.set x_DATA_BASE_ADDR,0x00020000
.set x_DATA_BASE_ADDR,0x00010000
.set x_DATA_MEM_SZ,0x00008000
.set x_IO_BASE_ADDR,0x0F000000
......
......@@ -16,11 +16,12 @@
//=======================================================================
// simulator's STD_INPUT and STD_OUTPUT
//=======================================================================
// write an integer (hex) to VHDL simulator's standard output
void print(int n) {
int *IO = (int *)IO_PRINT_ADDR;
// read a character from VHDL simulator's standard input
int from_stdin(void) {
int *IO = (void *)IO_STDIN_ADDR;
*IO = n;
// gets line line only after receiving a '\n' (line-feed, 0x0a)
return( *IO );
}
// write a character to VHDL simulator's standard output
......@@ -31,21 +32,12 @@ void to_stdout(char c) {
*IO = (unsigned char)c;
}
// read a character from VHDL simulator's standard input
// return value = 1 if EnoOfFile, 0 otherwise
// character read is stored at address provided in argument
int from_stdin(char *c) {
int *IO = (int *)IO_STDIN_ADDR;
int status, value;
value = *IO;
status = *(IO + 1);
// write an integer (hex) to VHDL simulator's standard output
void print(int n) {
int *IO = (int *)IO_PRINT_ADDR;
if (status == 0) {
*c = (unsigned char)value;
*IO = n;
}
return status;
}; //--------------------------------------------------------------------
//=======================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment