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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_42/] [or1ksim/] [cpu/] [common/] [abstract.c] - Diff between revs 47 and 66

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

Rev 47 Rev 66
Line 15... Line 15...
 
 
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
/* Abstract memory and routines that goes with this. I need to
/* Abstract memory and routines that go with this. I need to
add all sorts of other abstract entities. Currently we have
add all sorts of other abstract entities. Currently we have
only memory. */
only memory. */
 
 
#include <stdio.h>
#include <stdio.h>
#include <ctype.h>
#include <ctype.h>
Line 233... Line 233...
        struct dev_memarea *dev;
        struct dev_memarea *dev;
 
 
        slp_checkaccess(memaddr, SLP_MEMREAD);
        slp_checkaccess(memaddr, SLP_MEMREAD);
        memaddr = simulate_dc_mmu_load(memaddr);
        memaddr = simulate_dc_mmu_load(memaddr);
 
 
 
        return evalsim_mem32(memaddr);
 
}
 
 
 
unsigned long evalsim_mem32(unsigned long memaddr)
 
{
 
        unsigned long temp;
 
        struct dev_memarea *dev;
 
 
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
                temp = mem[memaddr].data << 24;
                temp = mem[memaddr].data << 24;
                temp += mem[memaddr + 1].data << 16;
                temp += mem[memaddr + 1].data << 16;
                temp += mem[memaddr + 2].data << 8;
                temp += mem[memaddr + 2].data << 8;
                temp += mem[memaddr + 3].data;
                temp += mem[memaddr + 3].data;
Line 252... Line 260...
 
 
/* Returns 16-bit values from mem array. Big endian version. */
/* Returns 16-bit values from mem array. Big endian version. */
 
 
unsigned short eval_mem16(unsigned long memaddr)
unsigned short eval_mem16(unsigned long memaddr)
{
{
        unsigned short temp;
 
 
 
        memaddr = simulate_dc_mmu_load(memaddr);
        memaddr = simulate_dc_mmu_load(memaddr);
 
 
 
        return evalsim_mem16(memaddr);
 
}
 
 
 
unsigned short evalsim_mem16(unsigned long memaddr)
 
{
 
        unsigned short temp;
 
 
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
                temp = ((unsigned short)(mem[memaddr].data << 8) & 0xff00);
                temp = ((unsigned short)(mem[memaddr].data << 8) & 0xff00);
                temp += ((unsigned short)mem[memaddr + 1].data & 0x00ff);
                temp += ((unsigned short)mem[memaddr + 1].data & 0x00ff);
        } else {
        } else {
                printf("EXCEPTION: read out of memory (16-bit access to %.8lx)\n", memaddr);
                printf("EXCEPTION: read out of memory (16-bit access to %.8lx)\n", memaddr);
Line 274... Line 287...
 
 
unsigned char eval_mem8(unsigned long memaddr)
unsigned char eval_mem8(unsigned long memaddr)
{
{
        memaddr = simulate_dc_mmu_load(memaddr);
        memaddr = simulate_dc_mmu_load(memaddr);
 
 
 
        return evalsim_mem8(memaddr);
 
}
 
 
 
unsigned char evalsim_mem8(unsigned long memaddr)
 
{
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
                return (unsigned char)mem[memaddr].data;
                return (unsigned char)mem[memaddr].data;
        } else {
        } else {
                printf("EXCEPTION: read out of memory (8-bit access to %.8lx)\n", memaddr);
                printf("EXCEPTION: read out of memory (8-bit access to %.8lx)\n", memaddr);
                cont_run = 0;
                cont_run = 0;
Line 287... Line 305...
 
 
/* Set mem, 32-bit. Big endian version. */
/* Set mem, 32-bit. Big endian version. */
 
 
void set_mem32(unsigned long memaddr, unsigned long value)
void set_mem32(unsigned long memaddr, unsigned long value)
{
{
        struct dev_memarea *dev;
 
 
 
        slp_checkaccess(memaddr, SLP_MEMWRITE);
        slp_checkaccess(memaddr, SLP_MEMWRITE);
        memaddr = simulate_dc_mmu_store(memaddr);
        memaddr = simulate_dc_mmu_store(memaddr);
 
 
 
        setsim_mem32(memaddr, value);
 
        return;
 
}
 
 
 
void setsim_mem32(unsigned long memaddr, unsigned long value)
 
{
 
        struct dev_memarea *dev;
 
 
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
                mem[memaddr].data = (value >> 24);
                mem[memaddr].data = (value >> 24);
                mem[memaddr + 1].data = (char)(value >> 16);
                mem[memaddr + 1].data = (char)(value >> 16);
                mem[memaddr + 2].data = (char)(value >> 8);
                mem[memaddr + 2].data = (char)(value >> 8);
                mem[memaddr + 3].data = (char)(value);
                mem[memaddr + 3].data = (char)(value);
Line 313... Line 337...
 
 
void set_mem16(unsigned long memaddr, unsigned short value)
void set_mem16(unsigned long memaddr, unsigned short value)
{
{
        memaddr = simulate_dc_mmu_store(memaddr);
        memaddr = simulate_dc_mmu_store(memaddr);
 
 
 
        setsim_mem16(memaddr, value);
 
        return;
 
}
 
 
 
void setsim_mem16(unsigned long memaddr, unsigned short value)
 
{
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
                mem[memaddr].data = (value >> 8);
                mem[memaddr].data = (value >> 8);
                mem[memaddr + 1].data = (char)(value);
                mem[memaddr + 1].data = (char)(value);
        } else {
        } else {
                printf("EXCEPTION: write out of memory (16-bit access to %.8lx)\n", memaddr);
                printf("EXCEPTION: write out of memory (16-bit access to %.8lx)\n", memaddr);
Line 330... Line 360...
 
 
void set_mem8(unsigned long memaddr, unsigned char value)
void set_mem8(unsigned long memaddr, unsigned char value)
{
{
        memaddr = simulate_dc_mmu_store(memaddr);
        memaddr = simulate_dc_mmu_store(memaddr);
 
 
 
        setsim_mem8(memaddr, value);
 
        return;
 
}
 
 
 
void setsim_mem8(unsigned long memaddr, unsigned char value)
 
{
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
        if (memaddr < (MEMORY_START + MEMORY_LEN)) {
                mem[memaddr].data = value;
                mem[memaddr].data = value;
        } else {
        } else {
                printf("EXCEPTION: write out of memory (8-bit access to %.8lx)\n", memaddr);
                printf("EXCEPTION: write out of memory (8-bit access to %.8lx)\n", memaddr);
                cont_run = 0;
                cont_run = 0;

powered by: WebSVN 2.1.0

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