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

Subversion Repositories qspiflash

[/] [qspiflash/] [trunk/] [bench/] [cpp/] [eqspiflashsim.cpp] - Diff between revs 12 and 14

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

Rev 12 Rev 14
Line 108... Line 108...
        m_last_sck = 1;
        m_last_sck = 1;
        m_write_count = 0;
        m_write_count = 0;
        m_ireg = m_oreg = 0;
        m_ireg = m_oreg = 0;
        m_sreg = 0x01c;
        m_sreg = 0x01c;
        m_creg = 0x001; // Initial creg on delivery
        m_creg = 0x001; // Initial creg on delivery
        m_config   = 0x7; // Volatile configuration register
        m_vconfig   = 0x7; // Volatile configuration register
        m_nvconfig = 0x0fff; // Nonvolatile configuration register
        m_nvconfig = 0x0fff; // Nonvolatile configuration register
        m_quad_mode = false;
        m_quad_mode = false;
        m_mode_byte = 0;
        m_mode_byte = 0;
        m_flagreg = 0x0a5;
        m_flagreg = 0x0a5;
 
 
Line 429... Line 429...
                        if (m_debug) printf("EQSPI: READING FLAGSTATUS REGISTER: %02x\n", m_flagreg);
                        if (m_debug) printf("EQSPI: READING FLAGSTATUS REGISTER: %02x\n", m_flagreg);
                        QOREG(m_flagreg);
                        QOREG(m_flagreg);
                        break;
                        break;
                case 0x81: // Write volatile config register
                case 0x81: // Write volatile config register
                        m_state = EQSPIF_WRCR;
                        m_state = EQSPIF_WRCR;
                        if (m_debug) printf("EQSPI: WRITING CONFIG REGISTER: %02x\n", m_config);
                        if (m_debug) printf("EQSPI: WRITING VOLATILE CONFIG REGISTER: %02x\n", m_vconfig);
                        break;
                        break;
                case 0x85: // Read volatile config register
                case 0x85: // Read volatile config register
                        m_state = EQSPIF_RDCR;
                        m_state = EQSPIF_RDCR;
                        if (m_debug) printf("EQSPI: READING CONFIG REGISTER: %02x\n", m_config);
                        if (m_debug) printf("EQSPI: READING VOLATILE CONFIG REGISTER: %02x\n", m_vconfig);
                        QOREG(m_config>>8);
                        QOREG(m_vconfig);
                        break;
                        break;
                case 0x9e: // Read ID (fall through)
                case 0x9e: // Read ID (fall through)
                case 0x9f: // Read ID
                case 0x9f: // Read ID
                        m_state = EQSPIF_RDID; m_addr = 0;
                        m_state = EQSPIF_RDID; m_addr = 0;
                        if (m_debug) printf("EQSPI: READING ID\n");
                        if (m_debug) printf("EQSPI: READING ID\n");
Line 506... Line 506...
                                exit(-2);
                                exit(-2);
                                m_state = EQSPIF_IDLE;
                                m_state = EQSPIF_IDLE;
                        }
                        }
                        break;
                        break;
                case EQSPIF_WRCR: // Write volatile config register, 0x81
                case EQSPIF_WRCR: // Write volatile config register, 0x81
                        if (m_count == 8) {
                        if (m_count == 8+8) {
                                m_config = m_ireg & 0x0ff;
                                m_vconfig = m_ireg & 0x0ff;
                                printf("Setting volatile config register to %08x\n", m_config);
                                printf("Setting volatile config register to %08x\n", m_vconfig);
                                assert((m_config & 0xfb)==0x8b);
                                assert((m_vconfig & 0xfb)==0x8b);
                        } break;
                        } break;
                case EQSPIF_WRNVCONFIG: // Write nonvolatile config register
                case EQSPIF_WRNVCONFIG: // Write nonvolatile config register
                        if (m_count == 8) {
                        if (m_count == 8+8) {
                                m_nvconfig = m_ireg & 0x0ffdf;
                                m_nvconfig = m_ireg & 0x0ffdf;
                                printf("Setting nonvolatile config register to %08x\n", m_config);
                                printf("Setting nonvolatile config register to %08x\n", m_nvconfig);
                                assert((m_nvconfig & 0xffc5)==0x8fc5);
                                assert((m_nvconfig & 0xffc5)==0x8fc5);
                        } break;
                        } break;
                case EQSPIF_WREVCONFIG: // Write enhanced volatile config reg
                case EQSPIF_WREVCONFIG: // Write enhanced volatile config reg
                        if (m_count == 8) {
                        if (m_count == 8+8) {
                                m_evconfig = m_ireg & 0x0ff;
                                m_evconfig = m_ireg & 0x0ff;
                                printf("Setting enhanced volatile config register to %08x\n", m_evconfig);
                                printf("Setting enhanced volatile config register to %08x\n", m_evconfig);
                                assert((m_evconfig & 0x0d7)==0xd7);
                                assert((m_evconfig & 0x0d7)==0xd7);
                        } break;
                        } break;
                case EQSPIF_WRLOCK:
                case EQSPIF_WRLOCK:
Line 590... Line 590...
                        // printf("Read SREG = %02x, wait = %08x\n", m_sreg,
                        // printf("Read SREG = %02x, wait = %08x\n", m_sreg,
                                // m_write_count);
                                // m_write_count);
                        QOREG(m_sreg);
                        QOREG(m_sreg);
                        break;
                        break;
                case EQSPIF_RDCR:
                case EQSPIF_RDCR:
                        if (m_debug) printf("Read CREG = %02x\n", m_creg);
                        if (m_debug) printf("Read VCONF = %02x\n", m_vconfig);
                        QOREG(m_creg);
                        QOREG(m_creg);
                        break;
                        break;
                case EQSPIF_FAST_READ:
                case EQSPIF_FAST_READ:
                        if (m_count < 32) {
                        if (m_count < 32) {
                                if (m_debug) printf("FAST READ, WAITING FOR FULL COMMAND (count = %d)\n", m_count);
                                if (m_debug) printf("FAST READ, WAITING FOR FULL COMMAND (count = %d)\n", m_count);
Line 635... Line 635...
                        } else if ((m_count > 32+8)&&(0 == (m_sreg&0x01))) {
                        } else if ((m_count > 32+8)&&(0 == (m_sreg&0x01))) {
                                QOREG(m_mem[m_addr++]);
                                QOREG(m_mem[m_addr++]);
                                // printf("EQSPIF[%08x]/QR = %02x\n",
                                // printf("EQSPIF[%08x]/QR = %02x\n",
                                        // m_addr-1, m_oreg);
                                        // m_addr-1, m_oreg);
                        } else {
                        } else {
                                printf("ERR: EQSPIF--TRYING TO READ WHILE BUSY! (count = %d)\n", m_count);
                                // printf("ERR: EQSPIF--TRYING TO READ WHILE BUSY! (count = %d)\n", m_count);
                                m_oreg = 0;
                                m_oreg = 0;
                        }
                        }
                        break;
                        break;
                case EQSPIF_QUAD_READ:
                case EQSPIF_QUAD_READ:
                        if (m_count == 24+8*4) {// Requires 8 QUAD clocks
                        if (m_count == 24+8*4) {// Requires 8 QUAD clocks

powered by: WebSVN 2.1.0

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