1
0
mirror of https://github.com/aap/pdp6.git synced 2026-01-14 07:40:30 +00:00

started with IO

This commit is contained in:
aap 2016-04-16 01:32:43 +02:00
parent f41c186d88
commit 692715079e
5 changed files with 162 additions and 39 deletions

View File

@ -2,7 +2,7 @@ SRC=main.c apr.c mem.c io.c
# clang
#CFLAGS= -Wno-shift-op-parentheses -Wno-logical-op-parentheses \
# -Wno-bitwise-op-parentheses
CFLAGS= \
CFLAGS= -g -Os \
-fno-diagnostics-show-caret \
-L/usr/local/lib -I/usr/local/include -lSDL -lSDL_image -lpthread

122
apr.c
View File

@ -1,4 +1,6 @@
#include "pdp6.h"
#include "inst.h"
int dotrace = 1;
Apr apr;
@ -10,7 +12,7 @@ trace(char *fmt, ...)
if(!dotrace)
return;
va_start(ap, fmt);
printf(" ");
print(" ");
vfprintf(stdout, fmt, ap);
va_end(ap);
}
@ -155,6 +157,16 @@ decodeir(Apr *apr)
apr->inst = apr->ir>>9 & 0777;
apr->io_inst = apr->ir & 0700340;
// 5-7
iobus1 &= ~0377770;
iobus1 |= apr->ir & H3 ? IOBUS_IOS3_1 : IOBUS_IOS3_0;
iobus1 |= apr->ir & H4 ? IOBUS_IOS4_1 : IOBUS_IOS4_0;
iobus1 |= apr->ir & H5 ? IOBUS_IOS5_1 : IOBUS_IOS5_0;
iobus1 |= apr->ir & H6 ? IOBUS_IOS6_1 : IOBUS_IOS6_0;
iobus1 |= apr->ir & H7 ? IOBUS_IOS7_1 : IOBUS_IOS7_0;
iobus1 |= apr->ir & H8 ? IOBUS_IOS8_1 : IOBUS_IOS8_0;
iobus1 |= apr->ir & H9 ? IOBUS_IOS9_1 : IOBUS_IOS9_0;
apr->ir_fp = (apr->inst & 0740) == 0140;
/* 2xx */
@ -389,6 +401,7 @@ pulse(at1);
pulse(at3a);
pulse(iat0);
pulse(et4);
pulse(et5);
pulse(et10);
pulse(mc_wr_rs);
pulse(mc_rd_rq_pulse);
@ -457,6 +470,8 @@ pulse(mr_clr){
mp_clr(apr);
// TODO: DS CLR
apr->iot_go = 0; // 8-1
/* sbr flip-flops */
apr->key_rd_wr = 0; // 5-2
apr->if1a = 0; // 5-3
@ -480,7 +495,9 @@ pulse(ex_clr){
pulse(mr_start){
trace("MR START\n");
// IOB RESET
// 8-1
iobus1 |= IOBUS_IOB_RESET;
// 8-5
apr->cpa_iot_user = 0;
@ -520,7 +537,44 @@ pulse(mr_pwr_clr){
* IOT
*/
pulse(iot_t3a){
trace("IOT T3A\n");
// TODO: figure out reset
iobus1 &= ~IOBUS_PULSES;
// we don't actually use T4
}
pulse(iot_t3){
trace("IOT T3\n");
// 8-1
if(IOT_DATAO)
iobus1 |= IOBUS_DATAO_SET;
if(IOT_CONO)
iobus1 |= IOBUS_CONO_SET;
nextpulse(apr, et5); // 5-5
}
pulse(iot_t2){
trace("IOT T2\n");
// 8-1
apr->iot_go = 0;
if(IOT_OUTGOING)
iobus0 |= apr->ar;
if(IOT_DATAO)
iobus1 |= IOBUS_DATAO_CLEAR;
if(IOT_CONO)
iobus1 |= IOBUS_CONO_CLEAR;
if(IOT_STATUS)
iobus1 |= IOBUS_IOB_STATUS;
if(IOT_DATAI)
iobus1 |= IOBUS_IOB_DATAI;
/* order matters */
nextpulse(apr, iot_t3);
nextpulse(apr, iot_t3a);
}
pulse(iot_t0){
trace("IOT T0\n");
}
/*
@ -717,6 +771,7 @@ pulse(pi_sync){
pulse(st7){
trace("ST7\n");
trace("\n");
apr->sf7 = 0; // 5-6
if(apr->run)
nextpulse(apr, apr->key_ex_st || apr->key_dep_st ? kt1 : it0); // 5-1, 5-3
@ -948,10 +1003,10 @@ pulse(et4){
if(FWT_SWAP || IOT_BLK || apr->ir_acbm)
swap(&apr->mb, &apr->ar); // 6-3
if(apr->ir_iot && ~IOT_BLK)
apr->iot_go = 1; // 8-1
if(IOT_BLK)
nextpulse(apr, iot_t0); // 8-1
else if(apr->ir_iot)
apr->iot_go = 1; // 8-1
if(!ET5_INH)
nextpulse(apr, et5); // 5-5
@ -1050,7 +1105,10 @@ pulse(et0){
}
pulse(et0a){
static int gen = 0;
trace("ET0A\n");
if((apr->inst & 0700) != 0700)
print("%d %s\n", gen++, names[apr->inst]);
if(PI_HOLD)
set_pih(apr, apr->pi_req); // 8-3, 8-4
@ -1575,7 +1633,7 @@ void
nextpulse(Apr *apr, Pulse *p)
{
if(apr->nnextpulses >= MAXPULSE){
fprintf(stderr, "error: too many next pulses\n");
fprint(stderr, "error: too many next pulses\n");
exit(1);
}
apr->nlist[apr->nnextpulses++] = p;
@ -1607,6 +1665,7 @@ aprmain(void *p)
/* KEY MANUAL */
if(apr->extpulse & 1){
apr->extpulse &= ~1;
print("KEY MANUAL\n");
nextpulse(apr, key_manual);
}
/* KEY INST STOP */
@ -1616,6 +1675,26 @@ aprmain(void *p)
// cleared after PI SYNC
apr->ia_inh = 1;
}
/* This is simplified, we have no IOT RESET,
* IOT INIT SET UP or IOT FINAL SETUP really */
if(apr->iot_go)
nextpulse(apr, iot_t2);
/* pulse through IO bus */
if(iobus1 & IOBUS_PULSES){
int dev = 0;
if(iobus1 & IOBUS_IOS3_1) dev |= 0100;
if(iobus1 & IOBUS_IOS4_1) dev |= 0040;
if(iobus1 & IOBUS_IOS5_1) dev |= 0020;
if(iobus1 & IOBUS_IOS6_1) dev |= 0010;
if(iobus1 & IOBUS_IOS7_1) dev |= 0004;
if(iobus1 & IOBUS_IOS8_1) dev |= 0002;
if(iobus1 & IOBUS_IOS9_1) dev |= 0001;
print("device %o\n", dev);
}
if(membus0 & MEMBUS_MAI_ADDR_ACK){
membus0 &= ~MEMBUS_MAI_ADDR_ACK;
apr->extpulse &= ~4;
@ -1631,14 +1710,11 @@ aprmain(void *p)
nextpulse(apr, mc_non_exist_mem); // 7-9
}
}
printf("power off\n");
print("power off\n");
return NULL;
}
#include "inst.h"
void
testinst(Apr *apr)
{
@ -1648,25 +1724,25 @@ testinst(Apr *apr)
// for(inst = 0140; inst < 0141; inst++){
apr->ir = inst << 9 | 1 << 5;
decodeir(apr);
printf("%06o %6s ", apr->ir, names[inst]);
print("%06o %6s ", apr->ir, names[inst]);
/*
printf("%s ", FAC_INH ? "FAC_INH" : " ");
printf("%s ", FAC2 ? "FAC2" : " ");
printf("%s ", FC_C_ACRT ? "FC_C_ACRT" : " ");
printf("%s ", FC_C_ACLT ? "FC_C_ACLT" : " ");
printf("%s ", FC_E ? "FC_E" : " ");
print("%s ", FAC_INH ? "FAC_INH" : " ");
print("%s ", FAC2 ? "FAC2" : " ");
print("%s ", FC_C_ACRT ? "FC_C_ACRT" : " ");
print("%s ", FC_C_ACLT ? "FC_C_ACLT" : " ");
print("%s ", FC_E ? "FC_E" : " ");
*/
printf("%s ", FC_E_PSE ? "FC_E_PSE" : " ");
printf("%s ", SC_E ? "SC_E" : " ");
printf("%s ", SAC_INH ? "SAC_INH" : " ");
printf("%s ", SAC2 ? "SAC2" : " ");
printf("\n");
print("%s ", FC_E_PSE ? "FC_E_PSE" : " ");
print("%s ", SC_E ? "SC_E" : " ");
print("%s ", SAC_INH ? "SAC_INH" : " ");
print("%s ", SAC2 ? "SAC2" : " ");
print("\n");
// FC_E_PSE
//printf("FC_E_PSE: %d %d %d %d %d %d %d %d %d %d\n", apr->hwt_10 , apr->hwt_11 , apr->fwt_11 , \
//print("FC_E_PSE: %d %d %d %d %d %d %d %d %d %d\n", apr->hwt_10 , apr->hwt_11 , apr->fwt_11 , \
// IOT_BLK , apr->inst == EXCH , CH_DEP , CH_INC_OP , \
// MEMAC_MEM , apr->boole_as_10 , apr->boole_as_11);
//printf("CH: %d %d %d %d %d\n", CH_INC, CH_INC_OP, CH_N_INC_OP, CH_LOAD, CH_DEP);
//printf("FAC_INH: %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
//print("CH: %d %d %d %d %d\n", CH_INC, CH_INC_OP, CH_N_INC_OP, CH_LOAD, CH_DEP);
//print("FAC_INH: %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
// apr->hwt_11 , apr->fwt_00 , apr->fwt_01 , apr->fwt_11 ,
// apr->inst == XCT , apr->ex_ir_uuo ,
// apr->inst == JSP , apr->inst == JSR ,

9
mem
View File

@ -1,4 +1,5 @@
:1000
240040000005
240040777773
201040001234
1000: 705240000100
1001: 254200000000
1002: 201000000123
1003: 524040000000
1004: 254200000000

31
mem.c
View File

@ -14,17 +14,22 @@ readmem(char *file, word *mem, word size)
FILE *f;
char buf[100], *s;
hword a;
word w;
if(f = fopen(file, "r"), f == nil)
return;
a = 0;
while(s = fgets(buf, 100, f)){
while(*s){
if(*s == ':')
a = strtol(s+1, &s, 8);
else if('0' <= *s && *s <= '7' &&
a < size)
mem[a++] = strtol(s, &s, 8);
else
if(*s == ';')
break;
else if('0' <= *s && *s <= '7'){
w = strtol(s, &s, 8);
if(*s == ':'){
a = w;
s++;
}else
mem[a++] = w;
}else
s++;
}
}
@ -47,9 +52,13 @@ dumpmem(void)
if(f = fopen("memdump", "w"), f == nil)
return;
for(a = 0; a < 16; a++)
fprint(f, ":%02o %012llo\n", a, fmem[a]);
for(a = 0; a < maxmem; a++)
fprint(f, ":%06o %012llo\n", a, memory[a]);
fprint(f, "%02o: %012llo\n", a, fmem[a]);
for(a = 0; a < maxmem; a++){
if(memory[a]){
fprint(f, "%06o: ", a);
fprint(f, "%012llo\n", memory[a]);
}
}
fclose(f);
}
@ -74,13 +83,13 @@ wakemem(void)
membus0 |= MEMBUS_MAI_ADDR_ACK;
hold = membus0 & MEMBUS_MA_FMC_SEL1 ? &fmem[a] : &memory[a];
if(membus0 & MEMBUS_RD_RQ){
membus1 = *hold;
membus1 = *hold & FW;
membus0 |= MEMBUS_MAI_RD_RS;
hold = NULL;
}
}
if(membus0 & MEMBUS_MAI_WR_RS && hold){
*hold = membus1;
*hold = membus1 & FW;
membus0 &= ~MEMBUS_MAI_WR_RS;
hold = NULL;
}

37
pdp6.h
View File

@ -217,4 +217,41 @@ enum {
};
extern word membus0, membus1;
// 7-10
enum {
IOBUS_PI_REQ_7 = F35,
IOBUS_PI_REQ_6 = F34,
IOBUS_PI_REQ_5 = F33,
IOBUS_PI_REQ_4 = F32,
IOBUS_PI_REQ_3 = F31,
IOBUS_PI_REQ_2 = F30,
IOBUS_PI_REQ_1 = F29,
IOBUS_IOB_STATUS = F23,
IOBUS_IOB_DATAI = F22,
IOBUS_CONO_SET = F21,
IOBUS_CONO_CLEAR = F20,
IOBUS_DATAO_SET = F19,
IOBUS_DATAO_CLEAR = F18,
IOBUS_IOS9_1 = F17,
IOBUS_IOS9_0 = F16,
IOBUS_IOS8_1 = F15,
IOBUS_IOS8_0 = F14,
IOBUS_IOS7_1 = F13,
IOBUS_IOS7_0 = F12,
IOBUS_IOS6_1 = F11,
IOBUS_IOS6_0 = F10,
IOBUS_IOS5_1 = F9,
IOBUS_IOS5_0 = F8,
IOBUS_IOS4_1 = F7,
IOBUS_IOS4_0 = F6,
IOBUS_IOS3_1 = F5,
IOBUS_IOS3_0 = F4,
IOBUS_MC_DR_SPLIT = F3,
IOBUS_POWER_ON = F1,
IOBUS_IOB_RESET = F0,
IOBUS_PULSES = IOBUS_IOB_RESET |
IOBUS_IOB_STATUS | IOBUS_IOB_DATAI |
IOBUS_CONO_SET | IOBUS_CONO_CLEAR |
IOBUS_DATAO_SET | IOBUS_DATAO_CLEAR
};
extern word iobus0, iobus1;