OpenCores
URL https://opencores.org/ocsvn/s6soc/s6soc/trunk

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [bench/] [cpp/] [qspiflashsim.cpp] - Diff between revs 2 and 10

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 10
Line 44... Line 44...
#include <stdio.h>
#include <stdio.h>
#include <string.h>
#include <string.h>
#include <assert.h>
#include <assert.h>
#include <stdlib.h>
#include <stdlib.h>
 
 
 
#include "regdefs.h"
#include "qspiflashsim.h"
#include "qspiflashsim.h"
 
 
#define MEMBYTES        (1<<22)
#define MEMBYTES        (FLASHWORDS<<2)
 
 
static  const unsigned  DEVID = 0x0115,
static  const unsigned  DEVID = 0x0115,
        DEVESD = 0x014,
        DEVESD = 0x014,
        MICROSECONDS = 100,
        MICROSECONDS = 100,
        MILLISECONDS = MICROSECONDS * 1000,
        MILLISECONDS = MICROSECONDS * 1000,
Line 101... Line 102...
                fprintf(stderr, "SPI-FLASH: Could not open %s\n", fname);
                fprintf(stderr, "SPI-FLASH: Could not open %s\n", fname);
                perror("O/S Err:");
                perror("O/S Err:");
        }
        }
}
}
 
 
 
void    QSPIFLASHSIM::write(const unsigned addr, const unsigned len, const uint32_t *buf) {
 
        char    *ptr;
 
        printf("FLASH: Copying into memory at S6Add4 %08x, my addr %08x, %d values\n",
 
                addr, (addr-SPIFLASH)<<2, len<<2);
 
        ptr = &m_mem[(addr-SPIFLASH)<<2];
 
        memcpy(ptr, buf, len<<2);
 
        printf("%02x %02x %02x %02x\n", ptr[0]&0x0ff, ptr[1]&0x0ff, ptr[2]&0x0ff, ptr[3]&0x0ff);
 
}
 
 
#define QOREG(A)        m_oreg = ((m_oreg & (~0x0ff))|(A&0x0ff))
#define QOREG(A)        m_oreg = ((m_oreg & (~0x0ff))|(A&0x0ff))
 
 
int     QSPIFLASHSIM::operator()(const int csn, const int sck, const int dat) {
int     QSPIFLASHSIM::operator()(const int csn, const int sck, const int dat) {
        // Keep track of a timer to determine when page program and erase
        // Keep track of a timer to determine when page program and erase
        // cycles complete.
        // cycles complete.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.