Horizon
Loading...
Searching...
No Matches
component.hpp
1#pragma once
2#include "common/common.hpp"
3#include "nlohmann/json_fwd.hpp"
4#include "net.hpp"
5#include "util/uuid.hpp"
6#include "util/uuid_path.hpp"
7#include "util/uuid_ptr.hpp"
8#include "util/uuid_vec.hpp"
9#include "util/item_set.hpp"
10#include <map>
11#include <set>
12
13namespace horizon {
14using json = nlohmann::json;
15
17public:
18 Connection(const json &j, class Block *block);
19 Connection(Net *n) : net(n)
20 {
21 }
22 uuid_ptr<Net> net;
23
24 json serialize() const;
25};
26
40class Component {
41public:
42 Component(const UUID &uu, const json &j, class IPool &pool, class Block *block = nullptr);
43 Component(const UUID &uu);
44
45 UUID get_uuid() const;
46
47 UUID uuid;
48 std::shared_ptr<const class Entity> entity = nullptr;
49 std::shared_ptr<const class Part> part = nullptr;
50 std::string refdes;
51 std::string value;
52 UUID group;
53 UUID tag;
54 bool nopopulate = false;
55
56 UUIDVec href;
57
58 enum class NopopulateFromInstance { SET, CLEAR, UNSET };
59 NopopulateFromInstance nopopulate_from_instance = NopopulateFromInstance::UNSET;
60
61 bool get_nopopulate() const;
62
63 const std::string &get_prefix() const;
64
69 std::map<UUIDPath<2>, Connection> connections;
70
74 class AltPinInfo {
75 public:
76 AltPinInfo() = default;
77 AltPinInfo(const json &j, const Pin &pin);
78 std::set<UUID> pin_names;
79 bool use_primary_name = false;
80 bool use_custom_name = false;
81
82 std::string custom_name;
83 Pin::Direction custom_direction = Pin::Direction::BIDIRECTIONAL;
84
85 void update_for_index(int index, const Pin &pin);
86
87 json serialize() const;
88 };
89 std::map<UUIDPath<2>, AltPinInfo> alt_pins;
90
91 static Pin::Direction get_effective_direction(const Component::AltPinInfo &alt, const Pin &pin);
92 Pin::Direction get_effective_direction(const UUIDPath<2> &path) const;
93
94 std::string replace_text(const std::string &t, bool *replaced = nullptr) const;
95
96 ItemSet get_pool_items_used() const;
97
98 json serialize() const;
99 virtual ~Component()
100 {
101 }
102
103private:
104 // void update_refs();
105};
106} // namespace horizon
A block is one level of hierarchy in the netlist.
Definition block.hpp:29
used to select alternate pin names
Definition component.hpp:74
A Component is an instanced Entity in a Block.
Definition component.hpp:40
std::map< UUIDPath< 2 >, Connection > connections
which Nins are connected to which Net the UUIDPath consists of Gate and Pin UUID
Definition component.hpp:69
Definition component.hpp:16
Definition ipool.hpp:15
Definition net.hpp:11
A Pin represents a logical pin of a Unit.
Definition unit.hpp:16
Stores a sequence of up to 3 UUIDs.
Definition uuid_path.hpp:12
This class encapsulates a UUID and allows it to be uses as a value type.
Definition uuid.hpp:16
Definition uuid_ptr.hpp:8
a class to store JSON values
Definition json.hpp:177
basic_json<> json
default JSON class
Definition json_fwd.hpp:62