URL
https://opencores.org/ocsvn/qspiflash/qspiflash/trunk
Subversion Repositories qspiflash
Compare Revisions
- This comparison shows the changes necessary to convert path
/qspiflash/trunk/bench
- from Rev 8 to Rev 9
- ↔ Reverse comparison
Rev 8 → Rev 9
/cpp/qspiflashsim.cpp
81,20 → 81,26
memset(m_mem, 0x0ff, MEMBYTES); |
} |
|
void QSPIFLASHSIM::load(const char *fname) { |
void QSPIFLASHSIM::load(const unsigned addr, const char *fname) { |
FILE *fp; |
int nr = 0; |
size_t len; |
|
if (addr >= MEMBYTES) |
return; |
len = MEMBYTES-addr*4; |
|
if (NULL != (fp = fopen(fname, "r"))) { |
nr = fread(m_mem, sizeof(char), MEMBYTES, fp); |
int nr = 0; |
nr = fread(&m_mem[addr], sizeof(char), len, fp); |
fclose(fp); |
if (nr == 0) { |
fprintf(stderr, "SPI-FLASH: Could not read %s\n", fname); |
perror("O/S Err:"); |
} |
} else { |
fprintf(stderr, "SPI-FLASH: Could not open %s\n", fname); |
perror("O/S Err:"); |
} |
|
for(int i=nr; i<MEMBYTES; i++) |
m_mem[i] = 0x0ff; |
} |
|
#define QOREG(A) m_oreg = ((m_oreg & (~0x0ff))|(A&0x0ff)) |
385,8 → 391,8
QOREG(0x0c3); |
assert((m_addr & 0xfc00000)==0); |
} else if ((m_count >= 40)&&(0 == (m_sreg&0x01))) { |
if (m_count == 40) |
printf("DUMMY BYTE COMPLETE ...\n"); |
//if (m_count == 40) |
//printf("DUMMY BYTE COMPLETE ...\n"); |
QOREG(m_mem[m_addr++]); |
// if (m_debug) printf("SPIF[%08x] = %02x\n", m_addr-1, m_oreg); |
} else m_oreg = 0; |
/cpp/qspiflashsim.h
72,7 → 72,8
|
public: |
QSPIFLASHSIM(void); |
void load(const char *fname); |
void load(const char *fname) { load(0, fname); } |
void load(const unsigned addr, const char *fname); |
void debug(const bool dbg) { m_debug = dbg; } |
bool debug(void) const { return m_debug; } |
int operator()(const int csn, const int sck, const int dat); |