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

Subversion Repositories zipcpu

[/] [zipcpu/] [trunk/] [bench/] [cpp/] [memsim.cpp] - Diff between revs 69 and 197

Show entire file | Details | Blame | View Log

Rev 69 Rev 197
Line 45... Line 45...
        unsigned int    nxt;
        unsigned int    nxt;
        for(nxt=1; nxt < nwords; nxt<<=1)
        for(nxt=1; nxt < nwords; nxt<<=1)
                ;
                ;
        m_len = nxt; m_mask = nxt-1;
        m_len = nxt; m_mask = nxt-1;
        m_mem = new BUSW[m_len];
        m_mem = new BUSW[m_len];
 
        m_nxt_ack = 0;
}
}
 
 
MEMSIM::~MEMSIM(void) {
MEMSIM::~MEMSIM(void) {
        delete[]        m_mem;
        delete[]        m_mem;
}
}
Line 81... Line 82...
 
 
void    MEMSIM::apply(const unsigned int clk, const unsigned char wb_cyc,
void    MEMSIM::apply(const unsigned int clk, const unsigned char wb_cyc,
                        const unsigned char wb_stb, const unsigned char wb_we,
                        const unsigned char wb_stb, const unsigned char wb_we,
                        const BUSW wb_addr, const BUSW wb_data,
                        const BUSW wb_addr, const BUSW wb_data,
                        unsigned char &o_ack, unsigned char &o_stall, BUSW &o_data) {
                        unsigned char &o_ack, unsigned char &o_stall, BUSW &o_data) {
 
        o_ack = m_nxt_ack;
 
        o_data= m_nxt_data;
 
        m_nxt_data = wb_data;
 
        o_stall= 0;
        if ((wb_cyc)&&(wb_stb)&&(clk)) {
        if ((wb_cyc)&&(wb_stb)&&(clk)) {
                if (wb_we)
                if (wb_we)
                        m_mem[wb_addr & m_mask] = wb_data;
                        m_mem[wb_addr & m_mask] = wb_data;
                o_ack  = 1;
                m_nxt_ack = 1;
                o_stall= 0;
                m_nxt_data = m_mem[wb_addr & m_mask];
                o_data = m_mem[wb_addr & m_mask];
                // o_ack  = 1;
 
 
 
                {
 
                        extern FILE *gbl_dbgfp;
 
                        if (gbl_dbgfp) {
 
                                if (wb_we) fprintf(gbl_dbgfp, "MEMSIM::MEM[%08x] = %08x\n", wb_addr&m_mask, wb_data);
 
                                else
 
                                        fprintf(gbl_dbgfp, "MEMSIM::BUS = MEM[%08x] = %08x\n", wb_addr&m_mask, m_nxt_data);
 
                        }
 
                }
                /*
                /*
                printf("MEMBUS -- ACK %s 0x%08x - 0x%08x\n",
                printf("MEMBUS -- ACK %s 0x%08x - 0x%08x\n",
                        (wb_we)?"WRITE":"READ",
                        (wb_we)?"WRITE":"READ",
                        wb_addr, o_data);
                        wb_addr, o_data);
                */
                */
        } else if (clk) {
        } else if (clk) {
                o_ack   = 0;
                m_nxt_ack   = 0;
                o_stall = 0;
                o_stall = 0;
        }
        }
}
}
 
 
 
 

powered by: WebSVN 2.1.0

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