// This code is released as public domain. It a quick implementation // to apply all inputs to a chip and capture the outputs. Output is sent // out serial port in format to process with espresso -Dso -o eqntott // Capture output to a file. // // Runs on MEGA 2560 board with 28 pin ZIF socket wired // Board Socket // 23 1 // 25 3 // ... // 47 13 // GND 14 // 24 27 // 26 26 // ... // 48 15 // Install chip at bottom of socket to pick up ground. Power needs to be // manually connected with a jumper wire. // From chip perspective. For test board chip inputs are Adruino output bits #define CINPUT 1 #define COUTPUT 0 #define OTHER -1 #if 1 // TI Professional character video U5 PAL16R8 #define NUM_PINS 20 // If defined outputs are also inputs to internal logic #define OUTPUTS_FEEDBACK 1 struct { char *name; int8_t inout; } chip[NUM_PINS] = { {"clk", CINPUT}, {"atsel-", CINPUT}, {"csel-", CINPUT}, {"wr-", CINPUT}, {"rd-", CINPUT}, {"x1s", CINPUT}, {"x2s", CINPUT}, {"x4s", CINPUT}, {"ld-", CINPUT}, {"GND", OTHER}, {"OE-", CINPUT}, {"coe-", COUTPUT}, {"cwe-", COUTPUT}, {"aen-", COUTPUT}, {"aoe-", COUTPUT}, {"ack-", COUTPUT}, {"mie-", COUTPUT}, {"swm-", COUTPUT}, {"wait-", COUTPUT}, {"VCC", OTHER} }; #endif #if 0 // 7400 #define OUTPUTS_FEEDBACK 0 #define NUM_PINS 14 struct { char *name; int8_t inout; } chip[NUM_PINS] = { {"1A", CINPUT}, {"1B", CINPUT}, {"1Y", COUTPUT}, {"2A", CINPUT}, {"2B", CINPUT}, {"2Y", COUTPUT}, {"GND", OTHER}, {"3Y", COUTPUT}, {"3A", CINPUT}, {"3B", CINPUT}, {"4Y", COUTPUT}, {"4A", CINPUT}, {"4B", CINPUT}, {"VCC", OTHER} }; #endif #if 0 // 7404 #define OUTPUTS_FEEDBACK 0 #define NUM_PINS 14 struct { char *name; int8_t inout; } chip[NUM_PINS] = { {"1A", CINPUT}, {"1Y", COUTPUT}, {"2A", CINPUT}, {"2Y", COUTPUT}, {"3A", CINPUT}, {"3Y", COUTPUT}, {"GND", OTHER}, {"4Y", COUTPUT}, {"4A", CINPUT}, {"5Y", COUTPUT}, {"5A", CINPUT}, {"6Y", COUTPUT}, {"6A", CINPUT}, {"VCC", OTHER} }; #endif uint8_t pin_map[28]; uint8_t outputs, inputs; void setup() { uint8_t i; // put your setup code here, to run once: Serial.begin(230400); Serial.println("Hello Computer"); for (i = 0; i < NUM_PINS/2; i++) { pin_map[i] = 23 + (i+14-NUM_PINS/2)*2; pin_map[i+NUM_PINS/2] = 48 - i*2; } for (i = 0; i < NUM_PINS; i++) { if (chip[i].inout == CINPUT) { pinMode(pin_map[i], OUTPUT); inputs++; } else if (chip[i].inout == COUTPUT) { pinMode(pin_map[i], INPUT_PULLUP); outputs++; } } } void setOutput(uint16_t value) { for (uint8_t i = 0; i < NUM_PINS; i++) { if (chip[i].inout == CINPUT) { digitalWrite(pin_map[i], value & 1); // Serial.print("wrote pin "); // Serial.print(pin_map[i]); // Serial.print(" "); // Serial.println(value & 1); value >>= 1; } } } uint16_t getInputs(void) { uint16_t value = 0; uint8_t bit = 0; for (uint8_t i = 0; i < NUM_PINS; i++) { if (chip[i].inout == COUTPUT) { value |= digitalRead(pin_map[i]) << bit++; // Serial.print("read pin "); // Serial.print(pin_map[i]); // Serial.print(" "); // Serial.println(digitalRead(pin_map[i])); } } return value; } void loop() { uint16_t i; uint8_t b; // put your main code here, to run repeatedly: if (Serial.available()) { Serial.read(); #if 1 uint8_t lastIn; // This format is for espresso -Dso -o eqntott Serial.print(".i "); if (OUTPUTS_FEEDBACK) { Serial.println(inputs + outputs); } else { Serial.println(inputs); } // We provide one and zero set. Unspecified don't care Serial.println(".type fr"); Serial.print(".o "); Serial.println(outputs); Serial.print(".ilb "); for (i = 0; i < NUM_PINS; i++) { if (chip[i].inout == CINPUT) { Serial.print(chip[i].name); Serial.print(" "); } } if (OUTPUTS_FEEDBACK) { for (i = 0; i < NUM_PINS; i++) { if (chip[i].inout == COUTPUT) { Serial.print(chip[i].name); Serial.print(" "); } } } Serial.println(); Serial.print(".ob "); for (i = 0; i < NUM_PINS; i++) { if (chip[i].inout == COUTPUT) { Serial.print(chip[i].name); Serial.print(" "); } } Serial.println(); // Phase 1 is on set/1 minimized, 0 is off set/0 Serial.print(".phase "); for (i = 0; i < NUM_PINS; i++) { if (chip[i].inout == COUTPUT) { Serial.print("0"); } } Serial.println(); #if 0 for (i = 0; i < (1 << inputs); i++) { setOutput(i); uint16_t outv = i; #else setOutput(0); setOutput(0 | 1); setOutput(0); setOutput(0 | 1); setOutput(0); delay(1); setOutput(0 | 1); lastIn = getInputs(); for (i = 0; i < 1 << 4; i++) { for (uint8_t state = 0; state < 16; state++) { // Pin order is OE which we want 0, state which LD- is part of, // rest of input, clock uint16_t outv = ((state << 4) | i) << 1; setOutput(outv); delay(1); setOutput(outv | 1); delay(1); #endif uint8_t in = getInputs(); for (b = 0; b < inputs; b++) { if (outv & (1 << b)) { Serial.print("1"); } else { Serial.print("0"); } } if (OUTPUTS_FEEDBACK) { for (b = 0; b < outputs; b++) { if (lastIn & (1 << b)) { Serial.print("1"); } else { Serial.print("0"); } } lastIn = in; } Serial.print(" "); for (b = 0; b < outputs; b++) { if (in & (1 << b)) { Serial.print("1"); } else { Serial.print("0"); } } Serial.println(); } } Serial.println(".e"); } #endif #if 0 for (i = 0; i < 1 << inputs; i++) { setOutput(i); uint8_t in = getInputs(); Serial.print(i, HEX); Serial.print(","); Serial.println(in, HEX); } } #endif //delay(1000); // wait for a second }