-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWire.h
100 lines (87 loc) · 2.09 KB
/
Wire.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef HOMEWORK_WIRE_H
#define HOMEWORK_WIRE_H
/**
* @file Wire.h
* @brief Functions and structures related to wiring between nodes
* @version 0.1
* @date 2019-11-05
*
* @copyright Copyright (c) 2019
*
*/
#include "Node.h"
typedef struct Node Node;
/**
* @brief Structure holding information about a connection
*
*/
typedef struct Connection {
int dest; /**< Destination node */
int pin; /**< Destination pin */
ComponentData wireComp; /**< Wire corresponding to the connection */
} Connection;
/**
* @brief Structure holding information about a wire
*
*/
typedef struct Wire {
Node *origin; /**< Origin node */
int originPin; /**< Origin pin */
Connection *connections; /**< Connections */
size_t conCount; /**< Connection count */
size_t conCap; /**< Connection capacity */
} Wire;
/**
* @brief Create wire for a node
*
* @param origin Origin node
* @param originPin Origin pin
* @return Wire Resulting wire
*/
Wire wire_create(Node *origin, int originPin);
/**
* @brief Add connection to wire
*
* @param wire Wire to add to
* @param other Other node
* @param otherPin Other pin
* @param nodes Array of the nodes
*/
void wire_add(Wire *wire, int other, int otherPin, Node *nodes);
/**
* @brief Erase connection from wire
*
* @param wire Wire to erase from
* @param id Index to erase
*/
void wire_erase(Wire *wire, int id);
/**
* @brief Send a value over a wire
*
* @param wire Wire to send through
* @param value Value to send through
*/
void wire_send_value(Wire *wire, bool value, Node *nodes);
/**
* @brief Free wire
*
* @param wire Wire to free
*/
void wire_free(Wire *wire);
/**
* @brief Repositions a connection
*
* @param conn Connection to reposition
* @param origin Origin node
* @param originPon Origin pin
* @param dest Destination node
*/
void connection_reposition(Connection *conn, Node *origin, int originPin, Node *dest);
/**
* @brief Repositions the connections of the wire
*
* @param wire Wire to reposition
* @param nodes Array of the nodes
*/
void wire_reposition(Wire *wire, Node *nodes);
#endif //HOMEWORK_WIRE_H