Horizon
block.hpp
1 #pragma once
2 #include "bus.hpp"
3 #include "component.hpp"
4 #include "nlohmann/json_fwd.hpp"
5 #include "net.hpp"
6 #include "net_class.hpp"
7 #include "pool/pool.hpp"
8 #include "util/uuid.hpp"
9 #include <fstream>
10 #include <map>
11 #include <set>
12 #include <vector>
13 
14 namespace horizon {
15 using json = nlohmann::json;
16 
25 class Block {
26 public:
27  Block(const UUID &uu, const json &, Pool &pool);
28  Block(const UUID &uu);
29  static Block new_from_file(const std::string &filename, Pool &pool);
30  Net *get_net(const UUID &uu);
31  UUID uuid;
32  std::string name;
33  std::map<UUID, Net> nets;
34  std::map<UUID, Bus> buses;
35  std::map<UUID, Component> components;
36  std::map<UUID, NetClass> net_classes;
37  uuid_ptr<NetClass> net_class_default = nullptr;
38 
39  Block(const Block &block);
40  void operator=(const Block &block);
41 
42  void merge_nets(Net *net, Net *into);
43 
47  void vacuum_nets();
48 
54  Net *extract_pins(const std::set<UUIDPath<3>> &pins, Net *net = nullptr);
55 
56  void update_connection_count();
57 
58  void update_diffpairs();
59 
64  Net *insert_net();
65 
66  json serialize();
67 
68 private:
69  void update_refs();
70 };
71 } // namespace horizon
a class to store JSON values
Definition: json.hpp:161
Net * extract_pins(const std::set< UUIDPath< 3 >> &pins, Net *net=nullptr)
Takes pins specified by pins and moves them over to net.
Definition: block.cpp:218
Stores a sequence of up to 3 UUIDs.
Definition: uuid_path.hpp:13
Net * insert_net()
creates new net
Definition: block.cpp:97
A block is one level of hierarchy in the netlist.
Definition: block.hpp:25
Definition: uuid_ptr.hpp:9
void vacuum_nets()
deletes unreferenced nets
Definition: block.cpp:136
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:18
Definition: block.cpp:7
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
Definition: net.hpp:16