Remove most dependencies on vvp_bit4_t encoding.
Remove dependencies on vvp_bit4_encoding outside of the vvp_net core types. The table_functor_s class was the worst offfender and was barely used, so it is now removed completely. There are a few opcodes in vhtread.cc that also make vvvp_bit4_t encoding assumptions (and used casts) and those have been fixed. There were also various VPI interface functions that are fixed.
This commit is contained in:
parent
5e30016910
commit
40fd07d46e
|
|
@ -1444,10 +1444,10 @@ void compile_resolver(char*label, char*type, unsigned argc, struct symb_s*argv)
|
|||
obj = new resolv_functor(vvp_scalar_t(BIT4_1, 5));
|
||||
|
||||
} else if (strcmp(type,"triand") == 0) {
|
||||
obj = new table_functor_s(ft_TRIAND);
|
||||
obj = new resolv_triand;
|
||||
|
||||
} else if (strcmp(type,"trior") == 0) {
|
||||
obj = new table_functor_s(ft_TRIOR);
|
||||
obj = new resolv_trior;
|
||||
|
||||
} else {
|
||||
fprintf(stderr, "invalid resolver type: %s\n", type);
|
||||
|
|
|
|||
710
vvp/draw_tt.c
710
vvp/draw_tt.c
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -16,639 +16,9 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: draw_tt.c,v 1.23 2006/11/28 05:57:20 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
||||
#if 0
|
||||
static void draw_AND(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_AND[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if ((i0 == 0) || (i1 == 0) ||
|
||||
(i2 == 0) || (i3 == 0))
|
||||
val = 0;
|
||||
else if ((i0 == 1) && (i1 == 1) &&
|
||||
(i2 == 1) && (i3 == 1))
|
||||
val = 1;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_NAND(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_NAND[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if ((i0 == 0) || (i1 == 0) ||
|
||||
(i2 == 0) || (i3 == 0))
|
||||
val = 1;
|
||||
else if ((i0 == 1) && (i1 == 1) &&
|
||||
(i2 == 1) && (i3 == 1))
|
||||
val = 0;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_BUF(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_BUF[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i0 == 1)
|
||||
val = 1;
|
||||
else if (i0 == 0)
|
||||
val = 0;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void draw_BUFZ(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_BUFZ[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val = i0;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_BUFIF0(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_BUFIF0[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i2 == 0)
|
||||
val = 3;
|
||||
else if (i0 == 1)
|
||||
val = 1;
|
||||
else if (i0 == 0)
|
||||
val = 0;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_BUFIF1(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_BUFIF1[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i2 == 1)
|
||||
val = 3;
|
||||
else if (i0 == 1)
|
||||
val = 1;
|
||||
else if (i0 == 0)
|
||||
val = 0;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_PMOS(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_PMOS[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i2 == 0 || i0 == 3)
|
||||
val = 3;
|
||||
else if (i0 == 1)
|
||||
val = 1;
|
||||
else if (i0 == 0)
|
||||
val = 0;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_NMOS(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_NMOS[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i2 == 1 || i0 == 3)
|
||||
val = 3;
|
||||
else if (i0 == 1)
|
||||
val = 1;
|
||||
else if (i0 == 0)
|
||||
val = 0;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
static void draw_MUXX(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_MUXX[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i3 == 0)
|
||||
val = 3;
|
||||
else if (i3 == 2)
|
||||
val = 2;
|
||||
else if (i3 == 3)
|
||||
val = 2;
|
||||
else if (i2 >= 2) {
|
||||
val = 2;
|
||||
} else if (i2 == 0)
|
||||
val = i0;
|
||||
else
|
||||
val = i1;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void draw_MUXZ(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_MUXZ[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i3 == 0)
|
||||
val = 3;
|
||||
else if (i3 == 2)
|
||||
val = 2;
|
||||
else if (i3 == 3)
|
||||
val = 2;
|
||||
else if (i2 >= 2) {
|
||||
if (i0 == i1)
|
||||
val = i0;
|
||||
else
|
||||
val = 2;
|
||||
} else if (i2 == 0)
|
||||
val = i0;
|
||||
else
|
||||
val = i1;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_EEQ(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_EEQ[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i3 != i2)
|
||||
val = 0;
|
||||
else if (i1 != i0)
|
||||
val = 0;
|
||||
else
|
||||
val = 1;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_NOR(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_NOR[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if ((i0 == 1) || (i1 == 1) ||
|
||||
(i2 == 1) || (i3 == 1))
|
||||
val = 0;
|
||||
else if ((i0 == 0) && (i1 == 0) &&
|
||||
(i2 == 0) && (i3 == 0))
|
||||
val = 1;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_NOT(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_NOT[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if (i0 == 1)
|
||||
val = 0;
|
||||
else if (i0 == 0)
|
||||
val = 1;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_OR(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_OR[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if ((i0 == 1) || (i1 == 1) ||
|
||||
(i2 == 1) || (i3 == 1))
|
||||
val = 1;
|
||||
else if ((i0 == 0) && (i1 == 0) &&
|
||||
(i2 == 0) && (i3 == 0))
|
||||
val = 0;
|
||||
else
|
||||
val = 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_XNOR(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_XNOR[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
|
||||
if ((i0 > 1) || (i1 > 1)
|
||||
|| (i2 > 1) || (i3 > 1))
|
||||
val = 2;
|
||||
else
|
||||
val = (i0 + i1 + i2 + i3) % 2 ^ 1;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
#if 0
|
||||
static void draw_XOR(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_XOR[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
|
||||
if ((i0 > 1) || (i1 > 1)
|
||||
|| (i2 > 1) || (i3 > 1))
|
||||
val = 2;
|
||||
else
|
||||
val = (i0 + i1 + i2 + i3) % 2;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
static void draw_TRIAND(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_TRIAND[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if ((i0 == 0) || (i1 == 0) ||
|
||||
(i2 == 0) || (i3 == 0))
|
||||
val = 0;
|
||||
else if ((i0 == 2) || (i1 == 2) ||
|
||||
(i2 == 2) || (i3 == 2))
|
||||
val = 2;
|
||||
else if ((i0 == 3) && (i1 == 3) &&
|
||||
(i2 == 3) && (i3 == 3))
|
||||
val = 3;
|
||||
else
|
||||
val = 1;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
static void draw_TRIOR(void)
|
||||
{
|
||||
unsigned i0, i1, i2, i3;
|
||||
|
||||
printf("const unsigned char ft_TRIOR[64] = {");
|
||||
|
||||
for (i3 = 0 ; i3 < 4 ; i3 += 1)
|
||||
for (i2 = 0 ; i2 < 4 ; i2 += 1) {
|
||||
printf("\n ");
|
||||
for (i1 = 0 ; i1 < 4 ; i1 += 1) {
|
||||
unsigned idx = (i3 << 4) | (i2 << 2) | i1;
|
||||
unsigned char byte = 0;
|
||||
|
||||
for (i0 = 0 ; i0 < 4 ; i0 += 1) {
|
||||
unsigned val;
|
||||
if ((i0 == 1) || (i1 == 1) ||
|
||||
(i2 == 1) || (i3 == 1))
|
||||
val = 1;
|
||||
else if ((i0 == 2) || (i1 == 2) ||
|
||||
(i2 == 2) || (i3 == 2))
|
||||
val = 2;
|
||||
else if ((i0 == 3) && (i1 == 3) &&
|
||||
(i2 == 3) && (i3 == 3))
|
||||
val = 3;
|
||||
else
|
||||
val = 0;
|
||||
|
||||
byte |= val << (i0*2);
|
||||
}
|
||||
|
||||
printf("0x%02x, ", byte);
|
||||
}
|
||||
}
|
||||
|
||||
printf("};\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* The hex_digits table is not a functor truth table per say, but a
|
||||
|
|
@ -749,85 +119,7 @@ static void draw_oct_table()
|
|||
|
||||
main()
|
||||
{
|
||||
printf("# include \"logic.h\"\n");
|
||||
draw_MUXX();
|
||||
draw_TRIAND();
|
||||
draw_TRIOR();
|
||||
draw_hex_table();
|
||||
draw_oct_table();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* $Log: draw_tt.c,v $
|
||||
* Revision 1.23 2006/11/28 05:57:20 steve
|
||||
* Use new vvp_fun_XXX in place of old functor table for NAND/NOR/XNOR/EEQ.
|
||||
*
|
||||
* Revision 1.22 2005/09/19 21:45:09 steve
|
||||
* Use lazy eval of BUF/NOT/OR/XOR gates.
|
||||
*
|
||||
* Revision 1.21 2005/06/12 21:56:16 steve
|
||||
* Remove unused ft_MOS truth tables.
|
||||
*
|
||||
* Revision 1.20 2005/02/12 23:05:25 steve
|
||||
* Cleanup unused truth tables.
|
||||
*
|
||||
* Revision 1.19 2005/02/12 22:50:52 steve
|
||||
* Implement the vvp_fun_muxz functor.
|
||||
*
|
||||
* Revision 1.18 2005/01/29 17:52:06 steve
|
||||
* move AND to buitin instead of table.
|
||||
*
|
||||
* Revision 1.17 2004/12/31 05:57:25 steve
|
||||
* No need to draw BUF or BUFZ tables.
|
||||
*
|
||||
* Revision 1.16 2004/10/04 01:10:59 steve
|
||||
* Clean up spurious trailing white space.
|
||||
*
|
||||
* Revision 1.15 2003/07/30 01:13:29 steve
|
||||
* Add support for triand and trior.
|
||||
*
|
||||
* Revision 1.14 2002/08/29 03:04:01 steve
|
||||
* Generate x out for x select on wide muxes.
|
||||
*
|
||||
* Revision 1.13 2002/08/12 01:35:08 steve
|
||||
* conditional ident string using autoconfig.
|
||||
*
|
||||
* Revision 1.12 2002/01/12 04:02:16 steve
|
||||
* Support the BUFZ logic device.
|
||||
*
|
||||
* Revision 1.11 2001/11/06 03:07:22 steve
|
||||
* Code rearrange. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.10 2001/10/09 02:28:17 steve
|
||||
* Add the PMOS and NMOS functor types.
|
||||
*
|
||||
* Revision 1.9 2001/06/19 03:01:10 steve
|
||||
* Add structural EEQ gates (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.8 2001/04/29 23:13:34 steve
|
||||
* Add bufif0 and bufif1 functors.
|
||||
*
|
||||
* Revision 1.7 2001/04/26 05:12:02 steve
|
||||
* Implement simple MUXZ for ?: operators.
|
||||
*
|
||||
* Revision 1.6 2001/04/21 02:04:01 steve
|
||||
* Add NAND and XNOR functors.
|
||||
*
|
||||
* Revision 1.5 2001/04/15 16:37:48 steve
|
||||
* add XOR support.
|
||||
*
|
||||
* Revision 1.4 2001/04/01 21:31:46 steve
|
||||
* Add the buf functor type.
|
||||
*
|
||||
* Revision 1.3 2001/03/25 20:45:09 steve
|
||||
* Add vpiOctStrVal access to signals.
|
||||
*
|
||||
* Revision 1.2 2001/03/25 19:37:26 steve
|
||||
* Calculate NOR and NOT tables, and also the hex_digits table.
|
||||
*
|
||||
* Revision 1.1 2001/03/11 22:42:11 steve
|
||||
* Functor values and propagation.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
49
vvp/logic.cc
49
vvp/logic.cc
|
|
@ -31,52 +31,6 @@
|
|||
# include <malloc.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Implementation of the table functor, which provides logic with up
|
||||
* to 4 inputs.
|
||||
*/
|
||||
|
||||
table_functor_s::table_functor_s(truth_t t)
|
||||
: table(t)
|
||||
{
|
||||
count_functors_logic += 1;
|
||||
}
|
||||
|
||||
table_functor_s::~table_functor_s()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* WARNING: This function assumes that the table generator encodes the
|
||||
* values 0/1/x/z the same as the vvp_bit4_t enumeration values.
|
||||
*/
|
||||
void table_functor_s::recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&val)
|
||||
{
|
||||
input_[ptr.port()] = val;
|
||||
|
||||
vvp_vector4_t result (val.size());
|
||||
|
||||
for (unsigned idx = 0 ; idx < val.size() ; idx += 1) {
|
||||
|
||||
unsigned lookup = 0;
|
||||
for (unsigned pdx = 4 ; pdx > 0 ; pdx -= 1) {
|
||||
lookup <<= 2;
|
||||
if (idx < input_[pdx-1].size())
|
||||
lookup |= input_[pdx-1].value(idx);
|
||||
}
|
||||
|
||||
unsigned off = lookup / 4;
|
||||
unsigned shift = lookup % 4 * 2;
|
||||
|
||||
unsigned bit_val = table[off] >> shift;
|
||||
bit_val &= 3;
|
||||
result.set_bit(idx, (vvp_bit4_t)bit_val);
|
||||
}
|
||||
|
||||
vvp_send_vec4(ptr.ptr()->out, result);
|
||||
}
|
||||
|
||||
vvp_fun_boolean_::vvp_fun_boolean_(unsigned wid)
|
||||
{
|
||||
net_ = 0;
|
||||
|
|
@ -604,9 +558,6 @@ void compile_functor(char*label, char*type, unsigned width,
|
|||
} else if (strcmp(type, "MUXR") == 0) {
|
||||
obj = new vvp_fun_muxr;
|
||||
|
||||
} else if (strcmp(type, "MUXX") == 0) {
|
||||
obj = new table_functor_s(ft_MUXX);
|
||||
|
||||
} else if (strcmp(type, "MUXZ") == 0) {
|
||||
obj = new vvp_fun_muxz(width);
|
||||
|
||||
|
|
|
|||
27
vvp/logic.h
27
vvp/logic.h
|
|
@ -23,26 +23,6 @@
|
|||
# include "schedule.h"
|
||||
# include <stddef.h>
|
||||
|
||||
/*
|
||||
* Table driven functor. This kind of node takes 4 inputs and
|
||||
* generates a single output. The logic is bitwise, and implemented
|
||||
* with a lookup table.
|
||||
*/
|
||||
|
||||
class table_functor_s: public vvp_net_fun_t {
|
||||
|
||||
public:
|
||||
typedef const unsigned char *truth_t;
|
||||
explicit table_functor_s(truth_t t);
|
||||
virtual ~table_functor_s();
|
||||
|
||||
void recv_vec4(vvp_net_ptr_t p, const vvp_vector4_t&bit);
|
||||
|
||||
private:
|
||||
truth_t table;
|
||||
vvp_vector4_t input_[4];
|
||||
};
|
||||
|
||||
/*
|
||||
* vvp_fun_boolean_ is just a common hook for holding operands.
|
||||
*/
|
||||
|
|
@ -210,11 +190,4 @@ class vvp_fun_xor : public vvp_fun_boolean_ {
|
|||
bool invert_;
|
||||
};
|
||||
|
||||
// table functor types
|
||||
|
||||
extern const unsigned char ft_MUXX[];
|
||||
extern const unsigned char ft_EEQ[];
|
||||
extern const unsigned char ft_TRIAND[];
|
||||
extern const unsigned char ft_TRIOR[];
|
||||
|
||||
#endif // __logic_H
|
||||
|
|
|
|||
|
|
@ -93,3 +93,84 @@ void resolv_functor::recv_vec8(vvp_net_ptr_t port, vvp_vector8_t bit)
|
|||
|
||||
vvp_send_vec8(ptr->out, out);
|
||||
}
|
||||
|
||||
resolv_wired_logic::resolv_wired_logic()
|
||||
{
|
||||
}
|
||||
|
||||
resolv_wired_logic::~resolv_wired_logic()
|
||||
{
|
||||
}
|
||||
|
||||
void resolv_wired_logic::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit)
|
||||
{
|
||||
unsigned pdx = port.port();
|
||||
vvp_net_t*ptr = port.ptr();
|
||||
|
||||
if (val_[pdx].eeq(bit))
|
||||
return;
|
||||
|
||||
val_[pdx] = bit;
|
||||
|
||||
vvp_vector4_t out (bit);
|
||||
for (unsigned idx = 0 ; idx < 4 ; idx += 1) {
|
||||
if (idx == pdx)
|
||||
continue;
|
||||
if (val_[idx].size() == 0)
|
||||
continue;
|
||||
|
||||
out = wired_logic_math_(out, val_[idx]);
|
||||
}
|
||||
|
||||
vvp_send_vec4(ptr->out, out);
|
||||
}
|
||||
|
||||
vvp_vector4_t resolv_triand::wired_logic_math_(vvp_vector4_t&a, vvp_vector4_t&b)
|
||||
{
|
||||
assert(a.size() == b.size());
|
||||
|
||||
vvp_vector4_t out (a.size());
|
||||
|
||||
for (unsigned idx = 0 ; idx < out.size() ; idx += 1) {
|
||||
vvp_bit4_t abit = a.value(idx);
|
||||
vvp_bit4_t bbit = b.value(idx);
|
||||
if (abit == BIT4_Z) {
|
||||
out.set_bit(idx, bbit);
|
||||
} else if (bbit == BIT4_Z) {
|
||||
out.set_bit(idx, abit);
|
||||
} else if (abit == BIT4_0 || bbit == BIT4_0) {
|
||||
out.set_bit(idx, BIT4_0);
|
||||
} else if (abit == BIT4_X || bbit == BIT4_X) {
|
||||
out.set_bit(idx, BIT4_X);
|
||||
} else {
|
||||
out.set_bit(idx, BIT4_1);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
vvp_vector4_t resolv_trior::wired_logic_math_(vvp_vector4_t&a, vvp_vector4_t&b)
|
||||
{
|
||||
assert(a.size() == b.size());
|
||||
|
||||
vvp_vector4_t out (a.size());
|
||||
|
||||
for (unsigned idx = 0 ; idx < out.size() ; idx += 1) {
|
||||
vvp_bit4_t abit = a.value(idx);
|
||||
vvp_bit4_t bbit = b.value(idx);
|
||||
if (abit == BIT4_Z) {
|
||||
out.set_bit(idx, bbit);
|
||||
} else if (bbit == BIT4_Z) {
|
||||
out.set_bit(idx, abit);
|
||||
} else if (abit == BIT4_1 || bbit == BIT4_1) {
|
||||
out.set_bit(idx, BIT4_1);
|
||||
} else if (abit == BIT4_X || bbit == BIT4_X) {
|
||||
out.set_bit(idx, BIT4_X);
|
||||
} else {
|
||||
out.set_bit(idx, BIT4_0);
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
|||
68
vvp/resolv.h
68
vvp/resolv.h
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __resolv_H
|
||||
#define __resolv_H
|
||||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -18,9 +18,6 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: resolv.h,v 1.15 2005/06/22 18:30:12 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "config.h"
|
||||
# include "vvp_net.h"
|
||||
|
|
@ -57,32 +54,39 @@ class resolv_functor : public vvp_net_fun_t {
|
|||
const char* debug_label_;
|
||||
};
|
||||
|
||||
/*
|
||||
* $Log: resolv.h,v $
|
||||
* Revision 1.15 2005/06/22 18:30:12 steve
|
||||
* Inline more simple stuff, and more vector4_t by const reference for performance.
|
||||
*
|
||||
* Revision 1.14 2005/06/22 00:04:49 steve
|
||||
* Reduce vvp_vector4 copies by using const references.
|
||||
*
|
||||
* Revision 1.13 2005/03/12 04:27:43 steve
|
||||
* Implement VPI access to signal strengths,
|
||||
* Fix resolution of ambiguous drive pairs,
|
||||
* Fix spelling of scalar.
|
||||
*
|
||||
* Revision 1.12 2005/01/09 20:11:16 steve
|
||||
* Add the .part/pv node and related functionality.
|
||||
*
|
||||
* Revision 1.11 2005/01/01 02:12:34 steve
|
||||
* vvp_fun_signal propagates vvp_vector8_t vectors when appropriate.
|
||||
*
|
||||
* Revision 1.10 2004/12/31 06:00:06 steve
|
||||
* Implement .resolv functors, and stub signals recv_vec8 method.
|
||||
*
|
||||
* Revision 1.9 2004/12/11 02:31:30 steve
|
||||
* Rework of internals to carry vectors through nexus instead
|
||||
* of single bits. Make the ivl, tgt-vvp and vvp initial changes
|
||||
* down this path.
|
||||
*
|
||||
*/
|
||||
class resolv_wired_logic : public vvp_net_fun_t {
|
||||
|
||||
public:
|
||||
explicit resolv_wired_logic(void);
|
||||
~resolv_wired_logic();
|
||||
|
||||
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit);
|
||||
|
||||
protected:
|
||||
virtual vvp_vector4_t wired_logic_math_(vvp_vector4_t&a, vvp_vector4_t&b) =0;
|
||||
|
||||
private:
|
||||
vvp_vector4_t val_[4];
|
||||
};
|
||||
|
||||
class resolv_triand : public resolv_wired_logic {
|
||||
|
||||
public:
|
||||
explicit resolv_triand(void) { }
|
||||
~resolv_triand() { }
|
||||
|
||||
private:
|
||||
virtual vvp_vector4_t wired_logic_math_(vvp_vector4_t&a, vvp_vector4_t&b);
|
||||
};
|
||||
|
||||
class resolv_trior : public resolv_wired_logic {
|
||||
|
||||
public:
|
||||
explicit resolv_trior(void) { }
|
||||
~resolv_trior() { }
|
||||
|
||||
private:
|
||||
virtual vvp_vector4_t wired_logic_math_(vvp_vector4_t&a, vvp_vector4_t&b);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -444,7 +444,20 @@ void vpip_vec4_get_value(const vvp_vector4_t&word_val, unsigned width,
|
|||
rbuf = need_result_buf(width+1, RBUF_VAL);
|
||||
for (unsigned idx = 0 ; idx < width ; idx += 1) {
|
||||
vvp_bit4_t bit = word_val.value(idx);
|
||||
rbuf[width-idx-1] = "01xz"[bit];
|
||||
switch (bit) {
|
||||
case BIT4_0:
|
||||
rbuf[width-idx-1] = '0';
|
||||
break;
|
||||
case BIT4_1:
|
||||
rbuf[width-idx-1] = '1';
|
||||
break;
|
||||
case BIT4_Z:
|
||||
rbuf[width-idx-1] = 'z';
|
||||
break;
|
||||
case BIT4_X:
|
||||
rbuf[width-idx-1] = 'x';
|
||||
break;
|
||||
}
|
||||
}
|
||||
rbuf[width] = 0;
|
||||
vp->value.str = rbuf;
|
||||
|
|
|
|||
|
|
@ -250,7 +250,20 @@ static char *signal_vpiDecStrVal(struct __vpiSignal*rfp, s_vpi_value*vp)
|
|||
unsigned char* bits = new unsigned char[wid];
|
||||
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
bits[idx] = vsig->value(idx);
|
||||
switch (vsig->value(idx)) {
|
||||
case BIT4_0:
|
||||
bits[idx] = 0;
|
||||
break;
|
||||
case BIT4_1:
|
||||
bits[idx] = 1;
|
||||
break;
|
||||
case BIT4_Z:
|
||||
bits[idx] = 3;
|
||||
break;
|
||||
case BIT4_X:
|
||||
bits[idx] = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned hwid = (wid+2) / 3 + 1;
|
||||
|
|
@ -445,7 +458,20 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
|
|||
rbuf = need_result_buf(wid+1, RBUF_VAL);
|
||||
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
rbuf[wid-idx-1] = "01xz"[vsig->value(idx)];
|
||||
switch (vsig->value(idx)) {
|
||||
case BIT4_0:
|
||||
rbuf[wid-idx-1] = '0';
|
||||
break;
|
||||
case BIT4_1:
|
||||
rbuf[wid-idx-1] = '1';
|
||||
break;
|
||||
case BIT4_Z:
|
||||
rbuf[wid-idx-1] = 'z';
|
||||
break;
|
||||
case BIT4_X:
|
||||
rbuf[wid-idx-1] = 'x';
|
||||
break;
|
||||
}
|
||||
}
|
||||
rbuf[wid] = 0;
|
||||
vp->value.str = rbuf;
|
||||
|
|
@ -470,7 +496,22 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
|
|||
rbuf[hwid] = 0;
|
||||
hval = 0;
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
hval = hval | (vsig->value(idx) << 2*(idx % 3));
|
||||
unsigned tmp = 0;
|
||||
switch (vsig->value(idx)) {
|
||||
case BIT4_0:
|
||||
tmp = 0;
|
||||
break;
|
||||
case BIT4_1:
|
||||
tmp = 1;
|
||||
break;
|
||||
case BIT4_Z:
|
||||
tmp = 3;
|
||||
break;
|
||||
case BIT4_X:
|
||||
tmp = 2;
|
||||
break;
|
||||
}
|
||||
hval = hval | (tmp << 2*(idx % 3));
|
||||
|
||||
if (idx%3 == 2) {
|
||||
hwid -= 1;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2008 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
|
|
@ -17,9 +17,6 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: vpi_vthr_vector.cc,v 1.24 2007/02/19 01:45:56 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vpiReg handles are handled here. These objects represent vectors of
|
||||
|
|
@ -118,7 +115,20 @@ static void vthr_vec_DecStrVal(struct __vpiVThrVec*rfp, s_vpi_value*vp)
|
|||
char *rbuf = need_result_buf((rfp->wid+2)/3 + 1, RBUF_VAL);
|
||||
|
||||
for (unsigned idx = 0 ; idx < rfp->wid ; idx += 1)
|
||||
bits[idx] = get_bit(rfp, idx);
|
||||
switch (get_bit(rfp, idx)) {
|
||||
case BIT4_0:
|
||||
bits[idx] = 0;
|
||||
break;
|
||||
case BIT4_1:
|
||||
bits[idx] = 1;
|
||||
break;
|
||||
case BIT4_X:
|
||||
bits[idx] = 2;
|
||||
break;
|
||||
case BIT4_Z:
|
||||
bits[idx] = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
vpip_bits_to_dec_str(bits, rfp->wid, rbuf, rfp->wid+1, rfp->signed_flag);
|
||||
vp->value.str = rbuf;
|
||||
|
|
|
|||
|
|
@ -119,6 +119,9 @@ struct vthread_s {
|
|||
struct vthread_s*scope_next, *scope_prev;
|
||||
};
|
||||
|
||||
// this table maps the thread special index bit addresses to
|
||||
// vvp_bit4_t bit values.
|
||||
static vvp_bit4_t thr_index_to_bit4[4] = { BIT4_0, BIT4_1, BIT4_X, BIT4_Z };
|
||||
|
||||
static inline void thr_check_addr(struct vthread_s*thr, unsigned addr)
|
||||
{
|
||||
|
|
@ -203,7 +206,7 @@ static vvp_vector4_t vthread_bits_to_vector(struct vthread_s*thr,
|
|||
|
||||
} else {
|
||||
vvp_vector4_t value(wid);
|
||||
vvp_bit4_t bit_val = (vvp_bit4_t)bit;
|
||||
vvp_bit4_t bit_val = thr_index_to_bit4[bit];
|
||||
for (unsigned idx = 0; idx < wid; idx +=1) {
|
||||
value.set_bit(idx, bit_val);
|
||||
}
|
||||
|
|
@ -2799,7 +2802,7 @@ bool of_MOD_WR(vthread_t thr, vvp_code_t cp)
|
|||
static bool of_MOV1XZ_(vthread_t thr, vvp_code_t cp)
|
||||
{
|
||||
thr_check_addr(thr, cp->bit_idx[0]+cp->number-1);
|
||||
vvp_vector4_t tmp (cp->number, (vvp_bit4_t)cp->bit_idx[1]);
|
||||
vvp_vector4_t tmp (cp->number, thr_index_to_bit4[cp->bit_idx[1]]);
|
||||
thr->bits4.set_vec(cp->bit_idx[0], tmp);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -3528,9 +3531,8 @@ bool of_SET_VEC(vthread_t thr, vvp_code_t cp)
|
|||
|
||||
} else {
|
||||
/* Make a vector of the desired width. */
|
||||
vvp_bit4_t bit_val = (vvp_bit4_t)bit;
|
||||
vvp_bit4_t bit_val = thr_index_to_bit4[bit];
|
||||
vvp_vector4_t value(wid, bit_val);
|
||||
|
||||
vvp_send_vec4(ptr, value);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue