2001-11-06 04:07:21 +01:00
|
|
|
/*
|
2004-12-11 03:31:25 +01:00
|
|
|
* Copyright (c) 2001-2004 Stephen Williams (steve@icarus.com)
|
2001-11-06 04:07:21 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
2002-08-12 03:34:58 +02:00
|
|
|
#ifdef HAVE_CVS_IDENT
|
2004-12-11 03:31:25 +01:00
|
|
|
#ident "$Id: logic.cc,v 1.14 2004/12/11 02:31:29 steve Exp $"
|
2001-11-06 04:07:21 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
# include "logic.h"
|
|
|
|
|
# include "compile.h"
|
|
|
|
|
# include "bufif.h"
|
|
|
|
|
# include "npmos.h"
|
2002-07-05 22:08:44 +02:00
|
|
|
# include "statistics.h"
|
2001-11-06 04:07:21 +01:00
|
|
|
# include <string.h>
|
|
|
|
|
# include <assert.h>
|
2001-11-16 05:22:27 +01:00
|
|
|
# include <stdlib.h>
|
2001-11-06 04:07:21 +01:00
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
|
# include <malloc.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-07-05 22:08:44 +02:00
|
|
|
|
2001-11-06 04:07:21 +01:00
|
|
|
/*
|
|
|
|
|
* Implementation of the table functor, which provides logic with up
|
|
|
|
|
* to 4 inputs.
|
|
|
|
|
*/
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
table_functor_s::table_functor_s(truth_t t)
|
2004-10-04 03:10:51 +02:00
|
|
|
: table(t)
|
2001-12-14 03:04:49 +01:00
|
|
|
{
|
2002-07-05 22:08:44 +02:00
|
|
|
count_functors_table += 1;
|
2001-12-14 03:04:49 +01:00
|
|
|
}
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-10-04 03:10:51 +02:00
|
|
|
table_functor_s::~table_functor_s()
|
2001-11-06 04:07:21 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The parser calls this function to create a logic functor. I allocate a
|
|
|
|
|
* functor, and map the name to the vvp_ipoint_t address for the
|
|
|
|
|
* functor. Also resolve the inputs to the functor.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-12-06 04:31:24 +01:00
|
|
|
void compile_functor(char*label, char*type,
|
2001-12-14 03:04:49 +01:00
|
|
|
vvp_delay_t delay, unsigned ostr0, unsigned ostr1,
|
2001-12-06 04:31:24 +01:00
|
|
|
unsigned argc, struct symb_s*argv)
|
2001-11-06 04:07:21 +01:00
|
|
|
{
|
2004-12-11 03:31:25 +01:00
|
|
|
table_functor_s* obj = 0;
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
if (strcmp(type, "OR") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_OR);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
} else if (strcmp(type, "AND") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_AND);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
} else if (strcmp(type, "BUF") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_BUF);
|
|
|
|
|
#if 0
|
2001-11-06 04:07:21 +01:00
|
|
|
} else if (strcmp(type, "BUFIF0") == 0) {
|
2002-09-06 06:56:28 +02:00
|
|
|
obj = new vvp_bufif_s(true,false, ostr0, ostr1);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
} else if (strcmp(type, "BUFIF1") == 0) {
|
2002-09-06 06:56:28 +02:00
|
|
|
obj = new vvp_bufif_s(false,false, ostr0, ostr1);
|
2004-12-11 03:31:25 +01:00
|
|
|
#endif
|
2002-01-12 05:02:16 +01:00
|
|
|
} else if (strcmp(type, "BUFZ") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_BUFZ);
|
|
|
|
|
#if 0
|
2001-11-06 04:07:21 +01:00
|
|
|
} else if (strcmp(type, "PMOS") == 0) {
|
|
|
|
|
obj = new vvp_pmos_s;
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(type, "NMOS") == 0) {
|
|
|
|
|
obj= new vvp_nmos_s;
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(type, "RPMOS") == 0) {
|
|
|
|
|
obj = new vvp_rpmos_s;
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(type, "RNMOS") == 0) {
|
|
|
|
|
obj = new vvp_rnmos_s;
|
2004-12-11 03:31:25 +01:00
|
|
|
#endif
|
2002-08-29 05:04:01 +02:00
|
|
|
} else if (strcmp(type, "MUXX") == 0) {
|
|
|
|
|
obj = new table_functor_s(ft_MUXX);
|
|
|
|
|
|
2001-11-06 04:07:21 +01:00
|
|
|
} else if (strcmp(type, "MUXZ") == 0) {
|
|
|
|
|
obj = new table_functor_s(ft_MUXZ);
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(type, "EEQ") == 0) {
|
|
|
|
|
obj = new table_functor_s(ft_EEQ);
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(type, "NAND") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_NAND);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
} else if (strcmp(type, "NOR") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_NOR);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
} else if (strcmp(type, "NOT") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_NOT);
|
|
|
|
|
#if 0
|
2001-12-14 07:03:17 +01:00
|
|
|
} else if (strcmp(type, "NOTIF0") == 0) {
|
2002-09-06 06:56:28 +02:00
|
|
|
obj = new vvp_bufif_s(true,true, ostr0, ostr1);
|
2001-12-14 07:03:17 +01:00
|
|
|
|
|
|
|
|
} else if (strcmp(type, "NOTIF1") == 0) {
|
2002-09-06 06:56:28 +02:00
|
|
|
obj = new vvp_bufif_s(false,true, ostr0, ostr1);
|
2004-12-11 03:31:25 +01:00
|
|
|
#endif
|
2001-11-06 04:07:21 +01:00
|
|
|
} else if (strcmp(type, "XNOR") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_XNOR);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
} else if (strcmp(type, "XOR") == 0) {
|
2004-12-11 03:31:25 +01:00
|
|
|
obj = new table_functor_s(ft_XOR);
|
2001-11-06 04:07:21 +01:00
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
yyerror("invalid functor type.");
|
|
|
|
|
free(type);
|
|
|
|
|
free(argv);
|
|
|
|
|
free(label);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(type);
|
|
|
|
|
|
|
|
|
|
assert(argc <= 4);
|
2004-12-11 03:31:25 +01:00
|
|
|
vvp_net_t*net = new vvp_net_t;
|
2001-11-06 04:07:21 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
define_functor_symbol(label, net);
|
|
|
|
|
free(label);
|
2001-12-06 04:31:24 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
inputs_connect(net, argc, argv);
|
2001-11-06 04:07:21 +01:00
|
|
|
free(argv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: logic.cc,v $
|
2004-12-11 03:31:25 +01:00
|
|
|
* Revision 1.14 2004/12/11 02:31:29 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.
|
2001-11-06 04:07:21 +01:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|