fixed "broken transistors" test

This commit is contained in:
Michael Steil 2010-10-06 16:53:40 +00:00
parent 217ba8f681
commit 44f7f48a9c
6 changed files with 54 additions and 32 deletions

View File

@ -1,7 +1,8 @@
OBJS=perfect6502.o
#OBJS+=runtime.o runtime_init.o plugin.o console.o emu.o
OBJS+=measure.o
CFLAGS=-Wall -O3
#OBJS+=cbmbasic.o runtime.o runtime_init.o plugin.o console.o emu.o
#OBJS+=measure.o
OBJS+=broken_transistors.o runtime.o runtime_init.o plugin.o console.o emu.o
CFLAGS=-Wall -O3 -DBROKEN_TRANSISTORS
CC=clang
all: cbmbasic

View File

@ -1,3 +1,15 @@
#include <stdio.h>
#include <strings.h>
#include "perfect6502.h"
extern void init_monitor();
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int BOOL;
#define YES 1
#define NO 0
#define MAX_CYCLES 33000
BOOL log_rw[MAX_CYCLES];
@ -6,8 +18,10 @@ uint8_t log_db[MAX_CYCLES];
int
main()
{
setupNodesAndTransistors();
for (int run = -1; run < transistors; run ++) {
initAndResetChip();
printf("%d\n", transistors);
int stransistors = transistors;
for (int run = -1; run < stransistors; run ++) {
#if 0
/* skip a few runs! */
if (run == 0)
@ -26,12 +40,12 @@ main()
for (int c = 0; c < MAX_CYCLES; c++) {
step();
if (run == -1) {
log_rw[c] = isNodeHigh(rw);
log_rw[c] = cycle & 1;
log_ab[c] = readAddressBus();
log_db[c] = readDataBus();
} else {
if (log_rw[c] != isNodeHigh(rw)) {
printf("FAIL, RW %d instead of %d @ %d\n", isNodeHigh(rw), log_rw[c], c);
if (log_rw[c] != (cycle & 1)) {
printf("FAIL, RW %d instead of %d @ %d\n", cycle & 1, log_rw[c], c);
fail = YES;
break;
}

23
cbmbasic.c Normal file
View File

@ -0,0 +1,23 @@
#include "perfect6502.h"
int
main()
{
int clk = 0;
initAndResetChip();
/* set up memory for user program */
init_monitor();
/* emulate the 6502! */
for (;;) {
step();
clk = !clk;
if (clk)
handle_monitor();
//chipStatus();
//if (!(cycle % 1000)) printf("%d\n", cycle);
};
}

View File

@ -34,6 +34,8 @@
#include <stdlib.h>
#include <string.h>
#include "perfect6502.h"
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int BOOL;
@ -428,7 +430,7 @@ getGroupValue()
}
#ifdef BROKEN_TRANSISTORS
transnum_t broken_transistor = (transnum_t)-1;
unsigned int broken_transistor = (unsigned int)-1;
#endif
void
@ -719,7 +721,7 @@ step()
*
************************************************************/
count_t transistors;
unsigned int transistors;
void
setupNodesAndTransistors()
@ -820,7 +822,6 @@ void handle_monitor();
#ifdef TEST
#elif defined(BROKEN_TRANSISTORS)
#include "broken_transistors.c"
#elif defined(COMPARE)
#include "compare.c"
#else

View File

@ -15,4 +15,8 @@ extern unsigned char readIR();
extern unsigned char memory[65536];
extern unsigned int cycle;
extern unsigned int transistors;
#ifdef BROKEN_TRANSISTORS
extern unsigned int broken_transistor;
#endif

View File

@ -96,24 +96,3 @@ handle_monitor()
}
}
int
main()
{
int clk = 0;
initAndResetChip();
/* set up memory for user program */
init_monitor();
/* emulate the 6502! */
for (;;) {
step();
clk = !clk;
if (clk)
handle_monitor();
//chipStatus();
//if (!(cycle % 1000)) printf("%d\n", cycle);
};
}