iverilog/vvp/functor.h

88 lines
2.8 KiB
C

#ifndef __functor_H
#define __functor_H
/*
* Copyright (c) 2000 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
* 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
*/
#if !defined(WINNT)
#ident "$Id: functor.h,v 1.1 2001/03/11 00:29:38 steve Exp $"
#endif
# include "pointers.h"
# include <stdio.h>
typedef struct vvp_truth_s*vvp_truth_t;
/*
* The vvp_ipoint_t is an integral type that is 32bits. The low 2 bits
* select the port of the referenced functor, and the remaining 30
* index the functor itself. All together, the 32 bits can completely
* identify any input of any functor.
*
* Outputs of functors are the heads of a linked list of all the
* inputs that it is connected to. The vvp_ipoint_t in .out points to
* the first port in the list. The .port[x] in turn points to the next
* port, and so on. The last .port[x] contains the null vvp_ipoint_t
* value zero (0). In this way, an output can fan out as wide as the
* original design requires.
*/
struct functor_s {
/* This is the truth table for the device */
vvp_truth_t table;
/* This is the output for the device. */
vvp_ipoint_t out;
/* These are the input ports. */
vvp_ipoint_t port[4];
};
typedef struct functor_s *functor_t;
/*
* Initialize the functors address space. This function must be called
* exactly once before any of the other functor functions may be
* called.
*/
extern void functor_init(void);
/*
* This function allocates a functor and returns the vvp_ipoint_t
* address for it. Every call to functor_allocate is guaranteed to
* return a different vvp_ipoint_t address. The ipoint port bits are 0.
*/
extern vvp_ipoint_t functor_allocate(void);
/*
* Given an ipoint_t pointer, return a C pointer to the functor. This
* is like a pointer dereference. The point parameter must have been
* returned from a previous call to functor_allocate.
*/
extern functor_t functor_index(vvp_ipoint_t point);
/*
* Dump a readable version of the functor address space to the file.
*/
extern void functor_dump(FILE*fd);
/*
* $Log: functor.h,v $
* Revision 1.1 2001/03/11 00:29:38 steve
* Add the vvp engine to cvs.
*
*/
#endif