| 1 | #ifndef _RAM_H
|
|---|
| 2 | #define _RAM_H
|
|---|
| 3 | #include "systemc.h"
|
|---|
| 4 | #include "common_struct.h"
|
|---|
| 5 |
|
|---|
| 6 | using namespace std;
|
|---|
| 7 |
|
|---|
| 8 | #include <iostream>
|
|---|
| 9 | #include <fstream>
|
|---|
| 10 | #include <string>
|
|---|
| 11 |
|
|---|
| 12 | SC_MODULE(ram)
|
|---|
| 13 | {
|
|---|
| 14 | sc_in<sc_uint<32> > addr;
|
|---|
| 15 | sc_out<sc_uint<32> > dout;
|
|---|
| 16 | sc_in<sc_uint<32> > din;
|
|---|
| 17 | sc_in<sc_uint<2> > memrw;
|
|---|
| 18 | sc_in<bool> clk;
|
|---|
| 19 |
|
|---|
| 20 | sc_uint<32> ramContents[100];
|
|---|
| 21 |
|
|---|
| 22 | SC_CTOR(ram)
|
|---|
| 23 | {
|
|---|
| 24 | SC_METHOD(mRead);
|
|---|
| 25 | sensitive << addr << memrw;
|
|---|
| 26 | SC_METHOD(mWrite);
|
|---|
| 27 | sensitive << clk.pos();
|
|---|
| 28 |
|
|---|
| 29 | ramContents[0]=0x20010080;
|
|---|
| 30 | ramContents[1]=0x8C220000;
|
|---|
| 31 | ramContents[2]=0x8C230004;
|
|---|
| 32 | ramContents[32]=0x00000001;
|
|---|
| 33 | ramContents[33]=0x00000002;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | void mRead()
|
|---|
| 37 | {
|
|---|
| 38 | if ((int)memrw.read()==1)
|
|---|
| 39 | {
|
|---|
| 40 | dout.write(ramContents[addr.read()>>2]) ;
|
|---|
| 41 | printf("coucou\n");
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | void mWrite()
|
|---|
| 46 | {
|
|---|
| 47 | if ((int)memrw.read()==2)
|
|---|
| 48 | ramContents[addr.read()>>2]=din.read() ;
|
|---|
| 49 | }
|
|---|
| 50 | };
|
|---|
| 51 | #endif
|
|---|
| 52 |
|
|---|