inline void pls100_device::parse_fusemap() { jed_data jed; jedbin_parse(machine().region(tag())->base(), machine().region(tag())->bytes(), &jed); UINT32 fusenum = 0; m_xor = 0; for (int term = 0; term < PAL_TERMS; term++) { m_and_comp[term] = 0; m_and_true[term] = 0; m_or[term] = 0; for (int i = 0; i < PAL_INPUTS; i++) { m_and_comp[term] |= jed_get_fuse(&jed, fusenum++) << i; m_and_true[term] |= jed_get_fuse(&jed, fusenum++) << i; } for (int f = 0; f < PAL_OUTPUTS; f++) { m_or[term] |= !jed_get_fuse(&jed, fusenum++) << f; } } for (int f = 0; f < PAL_OUTPUTS; f++) { m_xor |= jed_get_fuse(&jed, fusenum++) << f; } }
void pla_device::parse_fusemap() { memory_region *region = machine().root_device().memregion(tag()); jed_data jed; jedbin_parse(region->base(), region->bytes(), &jed); UINT32 fusenum = 0; for (int p = 0; p < m_terms; p++) { term *term = &m_term[p]; // AND mask term->m_and = 0; for (int i = 0; i < m_inputs; i++) { // complement term->m_and |= (UINT64)jed_get_fuse(&jed, fusenum++) << (i + 32); // true term->m_and |= (UINT64)jed_get_fuse(&jed, fusenum++) << i; } // OR mask term->m_or = 0; for (int f = 0; f < m_outputs; f++) { term->m_or |= !jed_get_fuse(&jed, fusenum++) << f; } term->m_or <<= 32; } // XOR mask m_xor = 0; for (int f = 0; f < m_outputs; f++) { m_xor |= jed_get_fuse(&jed, fusenum++) << f; } m_xor <<= 32; }
void pla_device::parse_fusemap() { jed_data jed; int result = JEDERR_NONE; // read pla file switch (m_format) { case PLA_FMT_JEDBIN: result = jedbin_parse(m_region->base(), m_region->bytes(), &jed); break; case PLA_FMT_BERKELEY: result = pla_parse(m_region->base(), m_region->bytes(), &jed); break; } if (result != JEDERR_NONE) { for (int p = 0; p < m_terms; p++) { m_term[p].and_mask = 0; m_term[p].or_mask = 0; } logerror("%s PLA parse error %d!\n", tag(), result); return; } // parse it UINT32 fusenum = 0; for (int p = 0; p < m_terms; p++) { term *term = &m_term[p]; // AND mask term->and_mask = 0; for (int i = 0; i < m_inputs; i++) { // complement term->and_mask |= (UINT64)jed_get_fuse(&jed, fusenum++) << (i + 32); // true term->and_mask |= (UINT64)jed_get_fuse(&jed, fusenum++) << i; } // OR mask term->or_mask = 0; for (int f = 0; f < m_outputs; f++) { term->or_mask |= !jed_get_fuse(&jed, fusenum++) << f; } term->or_mask <<= 32; } // XOR mask m_xor = 0; for (int f = 0; f < m_outputs; f++) { m_xor |= jed_get_fuse(&jed, fusenum++) << f; } m_xor <<= 32; }
size_t jed_output(const jed_data *data, void *result, size_t length) { UINT8 *curdst = (UINT8 *)result; UINT8 *dstend = curdst + length; int i, zeros, ones; char tempbuf[256]; UINT16 checksum; UINT8 defbyte; UINT8 *temp; /* always start the DST with a standard header and an STX */ tempbuf[0] = 0x02; sprintf(&tempbuf[1], "JEDEC file generated by jedutil*\n"); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); /* append the package information */ sprintf(tempbuf, "QF%d*\n", data->numfuses); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); /* compute the checksum */ checksum = 0; for (i = 0; i < data->numfuses / 8; i++) checksum += data->fusemap[i]; if (data->numfuses % 8 != 0) checksum += data->fusemap[data->numfuses / 8] & ((1 << (data->numfuses % 8)) - 1); /* determine if we are mostly 0's or mostly 1's */ for (i = zeros = ones = 0; i < data->numfuses / 8; i++) if (data->fusemap[i] == 0x00) zeros++; else if (data->fusemap[i] == 0xff) ones++; defbyte = (ones > zeros) ? 0xff : 0x00; /* output the default fuse state */ sprintf(tempbuf, "F%d*\n", defbyte & 1); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); /* now loop over groups of 32 fuses and output non-default groups */ for (i = 0; i < data->numfuses; i += 32) if (data->fusemap[i / 8 + 0] != defbyte || data->fusemap[i / 8 + 1] != defbyte || data->fusemap[i / 8 + 2] != defbyte || data->fusemap[i / 8 + 3] != defbyte) { int stroffs; int j; /* build up a string of 32 fuses */ stroffs = sprintf(tempbuf, "L%05d ", i); for (j = 0; j < 32 && i+j < data->numfuses; j++) tempbuf[stroffs++] = '0' + jed_get_fuse(data, i + j); stroffs += sprintf(&tempbuf[stroffs], "*\n"); /* append to the buffer */ if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); } /* write the checksum */ sprintf(tempbuf, "C%04X*\n", checksum); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); /* now compute the transmission checksum */ checksum = 0; for (temp = (UINT8 *)result; temp < curdst && temp < dstend; temp++) checksum += *temp & 0x7f; checksum += 0x03; /* append the ETX and the transmission checksum */ tempbuf[0] = 0x03; sprintf(&tempbuf[1], "%04X", checksum); if (curdst + strlen(tempbuf) <= dstend) memcpy(curdst, tempbuf, strlen(tempbuf)); curdst += strlen(tempbuf); /* return the final size */ return curdst - (UINT8 *)result; }