Line 1... |
Line 1... |
/*-------------------------------------------------------------------
|
/*-------------------------------------------------------------------
|
-- TITLE: M-lite CPU in software. Executes MIPS(tm) opcodes.
|
-- TITLE: Plasma CPU in software. Executes MIPS(tm) opcodes.
|
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
|
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
|
-- DATE CREATED: 1/31/01
|
-- DATE CREATED: 1/31/01
|
-- FILENAME: mlite.c
|
-- FILENAME: mlite.c
|
-- PROJECT: M-lite CPU core
|
-- PROJECT: Plasma CPU core
|
-- COPYRIGHT: Software placed into the public domain by the author.
|
-- COPYRIGHT: Software placed into the public domain by the author.
|
-- Software 'as is' without warranty. Author liable for nothing.
|
-- Software 'as is' without warranty. Author liable for nothing.
|
-- DESCRIPTION:
|
-- DESCRIPTION:
|
-- M-lite CPU simulator in C code.
|
-- Plasma CPU simulator in C code.
|
-- This file served as the starting point for the VHDL code.
|
-- This file served as the starting point for the VHDL code.
|
--------------------------------------------------------------------*/
|
--------------------------------------------------------------------*/
|
#include <stdio.h>
|
#include <stdio.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <string.h>
|
#include <string.h>
|
Line 140... |
Line 140... |
answer[1]&=0xffff;
|
answer[1]&=0xffff;
|
*hi=answer[2];
|
*hi=answer[2];
|
*lo=(answer[1]<<16)+answer[0];
|
*lo=(answer[1]<<16)+answer[0];
|
}
|
}
|
|
|
//execute one cycle of a M-lite CPU
|
//execute one cycle of a Plasma CPU
|
void cycle(State *s,int show_mode)
|
void cycle(State *s,int show_mode)
|
{
|
{
|
unsigned long opcode;
|
unsigned long opcode;
|
unsigned long op,rs,rt,rd,re,func,imm,target;
|
unsigned long op,rs,rt,rd,re,func,imm,target;
|
long imm_shift,branch=0,lbranch=2;
|
long imm_shift,branch=0,lbranch=2;
|
Line 378... |
Line 378... |
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
{
|
{
|
State state,*s=&state;
|
State state,*s=&state;
|
FILE *in;
|
FILE *in;
|
long bytes,index;
|
long bytes,index;
|
printf("M-lite emulator\n");
|
printf("Plasma emulator\n");
|
memset(s,0,sizeof(State));
|
memset(s,0,sizeof(State));
|
s->big_endian=0;
|
s->big_endian=0;
|
s->mem=malloc(MEM_SIZE);
|
s->mem=malloc(MEM_SIZE);
|
if(argc<=1) {
|
if(argc<=1) {
|
printf(" Usage: mlite file.exe\n");
|
printf(" Usage: mlite file.exe\n");
|