Esempio n. 1
0
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;
	}
}
Esempio n. 2
0
File: pla.c Progetto: Ilgrim/MAMEHub
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;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
int main(int argc, char *argv[])
{
	const char *srcfile, *dstfile;
	int src_is_jed, dst_is_jed;
	int numfuses = 0;
	jed_data jed;
	int len;
	int err;

	/* needs at least two arguments */
	if (argc < 3)
	{
		fprintf(stderr,
			"Usage:\n"
			"  jedutil <source.jed> <target.bin> [fuses] -- convert JED to binary form\n"
			"  jedutil <source.bin> <target.jed> -- convert binary to JED form\n"
		);
		return 0;
	}

	/* extract arguments */
	srcfile = argv[1];
	dstfile = argv[2];
	if (argc >= 4)
		numfuses = atoi(argv[3]);

	/* does the source end in '.jed'? */
	len = strlen(srcfile);
	src_is_jed = (srcfile[len - 4] == '.' &&
	             tolower(srcfile[len - 3]) == 'j' &&
	             tolower(srcfile[len - 2]) == 'e' &&
	             tolower(srcfile[len - 1]) == 'd');

	/* does the destination end in '.jed'? */
	len = strlen(dstfile);
	dst_is_jed = (dstfile[len - 4] == '.' &&
	             tolower(dstfile[len - 3]) == 'j' &&
	             tolower(dstfile[len - 2]) == 'e' &&
	             tolower(dstfile[len - 1]) == 'd');

	/* error if neither or both are .jed */
	if (!src_is_jed && !dst_is_jed)
	{
		fprintf(stderr, "At least one of the filenames must end in .jed!\n");
		return 1;
	}
	if (src_is_jed && dst_is_jed)
	{
		fprintf(stderr, "Both filenames cannot end in .jed!\n");
		return 1;
	}

	/* read the source file */
	err = read_source_file(srcfile);
	if (err != 0)
		return 1;

	/* if the source is JED, convert to binary */
	if (src_is_jed)
	{
		printf("Converting '%s' to binary form '%s'\n", srcfile, dstfile);

		/* read the JEDEC data */
		err = jed_parse(srcbuf, srcbuflen, &jed);
		switch (err)
		{
			case JEDERR_INVALID_DATA:	fprintf(stderr, "Fatal error: Invalid .JED file\n"); return 1;
			case JEDERR_BAD_XMIT_SUM:	fprintf(stderr, "Fatal error: Bad transmission checksum\n"); return 1;
			case JEDERR_BAD_FUSE_SUM:	fprintf(stderr, "Fatal error: Bad fusemap checksum\n"); return 1;
		}

		/* override the number of fuses */
		if (numfuses != 0)
			jed.numfuses = numfuses;

		/* print out data */
		printf("Source file read successfully\n");
		printf("  Total fuses = %d\n", jed.numfuses);

		/* generate the output */
		dstbuflen = jedbin_output(&jed, NULL, 0);
		dstbuf = malloc(dstbuflen);
		if (!dstbuf)
		{
			fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen);
			return 1;
		}
		dstbuflen = jedbin_output(&jed, dstbuf, dstbuflen);
	}

	/* if the source is binary, convert to JED */
	else
	{
		printf("Converting '%s' to JED form '%s'\n", srcfile, dstfile);

		/* read the binary data */
		err = jedbin_parse(srcbuf, srcbuflen, &jed);
		switch (err)
		{
			case JEDERR_INVALID_DATA:	fprintf(stderr, "Fatal error: Invalid binary JEDEC file\n"); return 1;
		}

		/* print out data */
		printf("Source file read successfully\n");
		printf("  Total fuses = %d\n", jed.numfuses);

		/* generate the output */
		dstbuflen = jed_output(&jed, NULL, 0);
		dstbuf = malloc(dstbuflen);
		if (!dstbuf)
		{
			fprintf(stderr, "Unable to allocate %d bytes for the target buffer!\n", (int)dstbuflen);
			return 1;
		}
		dstbuflen = jed_output(&jed, dstbuf, dstbuflen);
	}

	/* write the destination file */
	err = write_dest_file(dstfile);
	if (err != 0)
		return 1;

	printf("Target file written succesfully\n");
	return 0;
}