⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph.h

📁 circuit calculation program
💻 H
字号:
#ifndef __GRAPH_H__
#define __GRAPH_H__

#include "component.h"
/*
 * Nodes in the graph
 *    A node attachs a set of pins
 */

typedef struct node_def { 
	VA_value_t value;
	int n_pins;	
	int *pin_gid;  /* pins attached              */
	int equiv_next;/* non-0 if two nodes shorted */ 
	char flag;     /* VCC/GND                    */
	char name[1];  /* nodes name                 */
} node_t;

#define NODE_FCCS       1        /*this node is a CCS */
#define NODE_FCVS       0x2      /*this node is a CVS */ 
#define NODE_FGND       0x4      /*this node is a CVS */ 
#define NODE_FSOURCE    0x7      /*CCS/CVS            */ 

#define NODE_FPROCESSED 0x10     /*processed by alg   */    

#define CHECK_NODEFLAG(a,b) (nodes[a]->flag & NODE_F##b)
#define SET_NODEFLAG(a,b)   (nodes[a]->flag |= NODE_F##b)

#define GET_EQUIV(a)        (nodes[a]->equiv_next)
#define NODE_PINS(a)        (nodes[a]->n_pins)
#define NODE_PIN(a)         (nodes[a]->pin_gid)

extern node_t **nodes;
extern int n_nodes;

/*
 * Pins:
 *   A pin belongs to a component, attachs to a node
 */
 
 typedef struct pin_def {
 	int node_id;
 	comp_t *comp;
 	VA_value_t value;   /* ampere */
} pin_t;


#define COMP(a) (pins[a].comp)
#define NODE(a) (pins[a].node_id)
#define COMPCLASS(a) (pins[a].comp->class)

extern pin_t *pins;
extern char *pin_flag;

#define PIN_FPROCESSED 0x1


#define CHECK_PINFLAG(a,b) (pin_flag[a] & PIN_F##b)
#define SET_PINFLAG(a,b)   (pin_flag[a] |= PIN_F##b)

int pin_init();
/*
 *  sub-network : unit for equation
 */

typedef struct network_ctx {
	int node_id;
	int node_id_next;
	int pin_next;
} network_ctx; 	

int network_first ( network_ctx *ctx );
int network_next ( network_ctx *ctx );
void network_closure (int pin_gid );
/*
 * link in the network
 * if there are more than 1 links between two nodes,
 * only one is kept. Others are converted to KVL
 */
typedef struct link_def {
	struct link_def *next;            /* horizontal next */
	int pin_from;                     /* from which pin  */
	int pin_to;                       /* to which pin    */
	int node_id;                      /* to which node   */
} link_t;

#endif /*  __GRAPH_H__  */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -