diff --git a/PDP11/CMakeLists.txt b/PDP11/CMakeLists.txt index 475ec489..17c76de8 100644 --- a/PDP11/CMakeLists.txt +++ b/PDP11/CMakeLists.txt @@ -104,3 +104,64 @@ add_simulator(uc15 LABEL PDP11 PKG_FAMILY pdp11_family TEST uc15) + +add_simulator(pdp11-validator-gen + SOURCES + test.c + pdp11_fp.c + pdp11_cpu.c + pdp11_dz.c + pdp11_cis.c + pdp11_lp.c + pdp11_rk.c + pdp11_rl.c + pdp11_rp.c + pdp11_rx.c + pdp11_stddev.c + pdp11_sys.c + pdp11_tc.c + pdp11_tm.c + pdp11_ts.c + pdp11_io.c + pdp11_rq.c + pdp11_tq.c + pdp11_pclk.c + pdp11_ry.c + pdp11_pt.c + pdp11_hk.c + pdp11_xq.c + pdp11_xu.c + pdp11_vh.c + pdp11_rh.c + pdp11_tu.c + pdp11_cpumod.c + pdp11_cr.c + pdp11_rf.c + pdp11_dl.c + pdp11_ta.c + pdp11_rc.c + pdp11_kg.c + pdp11_ke.c + pdp11_dc.c + pdp11_dmc.c + pdp11_kmc.c + pdp11_dup.c + pdp11_rs.c + pdp11_vt.c + pdp11_td.c + pdp11_io_lib.c + pdp11_rom.c + pdp11_ch.c + pdp11_dh.c + pdp11_ng.c + pdp11_daz.c + pdp11_tv.c + pdp11_mb.c + pdp11_rr.c + INCLUDES + ${CMAKE_CURRENT_SOURCE_DIR} + DEFINES + VM_PDP11 + LABEL PDP11 + PKG_FAMILY pdp11_family + TEST pdp11) diff --git a/PDP11/pdp11_cpu.c b/PDP11/pdp11_cpu.c index c37df8b2..c5cf5d2c 100644 --- a/PDP11/pdp11_cpu.c +++ b/PDP11/pdp11_cpu.c @@ -855,9 +855,9 @@ while (reason == 0) { STACKFILE[cm] = SP; saved_PC = PC & 0177777; pcq_r->qptr = pcq_p; /* update pc q ptr */ - set_r_display (rs, cm); + //set_r_display (rs, cm); - reason = sim_process_event (); /* process events */ + //reason = sim_process_event (); /* process events */ /* restore simh register contents into running variables */ PC = saved_PC; @@ -872,7 +872,8 @@ while (reason == 0) { MMR0 = MMR0 | MMR0_IC; /* usually on */ trap_req = calc_ints (ipl, trap_req); /* recalc int req */ - continue; + //continue; + break; } /* end if sim_interval */ if (trap_req) { /* check traps, ints */ @@ -894,7 +895,8 @@ while (reason == 0) { } /* end else t */ if (trapea == 0) { /* nothing to do? */ trap_req = calc_ints (ipl, 0); /* recalculate */ - continue; /* back to fetch */ + break; + //continue; /* back to fetch */ } /* end if trapea */ /* Process a trap or interrupt @@ -944,7 +946,8 @@ while (reason == 0) { if ((cm == MD_KER) && (SP < (STKLIM + STKL_Y)) && (trapnum != TRAP_V_RED) && (trapnum != TRAP_V_YEL)) set_stack_trap (SP); - continue; /* end if traps */ + break; + //continue; /* end if traps */ } /* Fetch and decode next instruction */ @@ -2433,6 +2436,7 @@ while (reason == 0) { else setTRAP (TRAP_ILL); break; /* end case 017 */ } /* end switch op */ + break; } /* end main loop */ /* Simulation halted */ diff --git a/PDP11/test.c b/PDP11/test.c new file mode 100644 index 00000000..f078e74c --- /dev/null +++ b/PDP11/test.c @@ -0,0 +1,86 @@ +#include +#include + +#include "pdp11_defs.h" +#include "sim_defs.h" + +//extern t_stat sim_brk_init(void); +//extern t_stat sim_brk_set(t_addr loc, int32 sw, int32 ncnt, CONST char *act); +extern t_stat sim_instr(); +//extern uint32 sim_brk_summ; +extern void PWriteW(int32 data, int32 addr); +extern int32 REGFILE[6][2]; +extern int32 STACKFILE[4]; +extern int32 saved_PC; +extern int32 PSW; +extern t_stat cpu_reset(DEVICE *dptr); +extern DEVICE cpu_dev; + +void produce_validation_tests() +{ + json_t *out = json_array(); + + for(int i=0; i<65536; i++) { + json_t *before = json_object(); + + cpu_reset(&cpu_dev); + + saved_PC = 0100; + json_object_set(before, "PC", json_integer(saved_PC)); + + json_t *memory = json_array(); + json_t *mem_i = json_object(); + json_object_set(mem_i, "0100", json_integer(i)); + json_array_append_new(memory, mem_i); + json_object_set(before, "memory", memory); + PWriteW(i, saved_PC); + uint16_t data1 = rand() & 0xffff; + uint16_t data2 = rand() & 0xffff; + json_object_set(mem_i, "0102", json_integer(data1)); + PWriteW(data1, saved_PC + 2); + json_object_set(mem_i, "0104", json_integer(data2)); + PWriteW(data2, saved_PC + 4); + + for(int k=0; k<6; k++) { + char name[16]; + + sprintf(name, "reg-%d.%d", k, 0); + REGFILE[k][0] = rand() & 0xffff; + json_object_set(before, name, json_integer(REGFILE[k][0])); + + sprintf(name, "reg-%d.%d", k, 1); + REGFILE[k][1] = rand() & 0xffff; + json_object_set(before, name, json_integer(REGFILE[k][1])); + } + + json_object_set(before, "PSW", json_integer(PSW)); + + // do + sim_instr(); + + json_t *after = json_object(); + json_object_set(after, "PC", json_integer(saved_PC)); + + for(int k=0; k<6; k++) { + char name[16]; + + sprintf(name, "reg-%d.%d", k, 0); + json_object_set(after, name, json_integer(REGFILE[k][0])); + + sprintf(name, "reg-%d.%d", k, 1); + json_object_set(after, name, json_integer(REGFILE[k][1])); + } + + json_object_set(after, "PSW", json_integer(PSW)); + + json_t *collection = json_object(); + json_object_set(collection, "before", before); + json_object_set(collection, "after", after); + + json_array_append_new(out, collection); + } + + FILE *fh = fopen("testset.json", "w"); + json_dumpf(out, fh, JSON_INDENT(2)); + fclose(fh); +} diff --git a/cmake/add_simulator.cmake b/cmake/add_simulator.cmake index e87ef16c..65612290 100644 --- a/cmake/add_simulator.cmake +++ b/cmake/add_simulator.cmake @@ -102,6 +102,7 @@ function(build_simcore _targ) simh_regexp os_features thread_lib + jansson ) # Ensure that sim_rev.h picks up .git-commit-id.h if the git command is @@ -357,7 +358,7 @@ function(add_unit_test _targ) simh_executable_template(${UNIT_TARGET} "${ARGN}") cmake_parse_arguments(SIMH "FEATURE_INT64;FEATURE_FULL64;BUILDROMS;FEATURE_VIDEO,FEATURE_DISPLAY" "SOURCE_DIR;LABEL" - "DEFINES;INCLUDES;SOURCES" + "DEFINES;INCLUDES;SOURCES" ${ARGN}) target_link_libraries(${UNIT_TARGET} PUBLIC unittest) diff --git a/scp.c b/scp.c index 7d9ea9cf..e4ef75e4 100644 --- a/scp.c +++ b/scp.c @@ -2917,7 +2917,7 @@ if (!sim_quiet) { printf ("\n"); show_version (stdout, NULL, NULL, 0, NULL); } -sim_timer_precalibrate_execution_rate (); +//sim_timer_precalibrate_execution_rate (); show_version (stdnul, NULL, NULL, 1, NULL); /* Quietly set SIM_OSTYPE */ #if defined (HAVE_PCRE_H) setenv ("SIM_REGEX_TYPE", "PCRE", 1); /* Publish regex type */ @@ -2971,8 +2971,10 @@ if (docmdp) { } if (SCPE_BARE_STATUS(stat) == SCPE_OPENERR) /* didn't exist/can't open? */ stat = SCPE_OK; -if (SCPE_BARE_STATUS(stat) != SCPE_EXIT) - process_stdin_commands (SCPE_BARE_STATUS(stat), argv, FALSE); +extern void produce_validation_tests(); +produce_validation_tests(); +//if (SCPE_BARE_STATUS(stat) != SCPE_EXIT) +// process_stdin_commands (SCPE_BARE_STATUS(stat), argv, FALSE); cleanup_and_exit: @@ -7788,6 +7790,7 @@ t_stat ssh_break_one (FILE *st, int32 flg, t_addr lo, int32 cnt, CONST char *apt { if (!sim_brk_types) return sim_messagef (SCPE_NOFNC, "No breakpoint support in this simulator\n"); +printf("%d %d %d %s\n", flg, lo, cnt, aptr); switch (flg) { case SSH_ST: @@ -12496,6 +12499,8 @@ t_stat sim_brk_set (t_addr loc, int32 sw, int32 ncnt, CONST char *act) { BRKTAB *bp; +printf("sim_brk_set: %d, %d, %d, %s\n", loc, sw, ncnt, act); + if ((sw == 0) || (sw == BRK_TYP_DYN_STEPOVER)) sw |= sim_brk_dflt; if (~sim_brk_types & sw) {