]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/polygon/doc/tutorial/extract.cpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / polygon / doc / tutorial / extract.cpp
CommitLineData
7c673cae
FG
1/*
2Copyright 2010 Intel Corporation
3
4Use, modification and distribution are subject to the Boost Software License,
5Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6http://www.boost.org/LICENSE_1_0.txt).
7*/
8#include "schematic_database.hpp"
9#include "layout_pin.hpp"
10#include "layout_rectangle.hpp"
11#include "connectivity_database.hpp"
12#include "compare_schematics.hpp"
13#include "extract_devices.hpp"
14#include "parse_layout.hpp"
15#include "layout_database.hpp"
16#include "device.hpp"
17#include <string>
18#include <fstream>
19#include <iostream>
20
21bool compare_files(std::string layout_file, std::string schematic_file) {
22 std::ifstream sin(schematic_file.c_str());
23 std::ifstream lin(layout_file.c_str());
24
25 std::vector<layout_rectangle> rects;
26 std::vector<layout_pin> pins;
27 parse_layout(rects, pins, lin);
28
29 schematic_database reference_schematic;
30 parse_schematic_database(reference_schematic, sin);
31
32 layout_database layout;
33 populate_layout_database(layout, rects);
34
35 connectivity_database connectivity;
36 populate_connectivity_database(connectivity, pins, layout);
37
38 schematic_database schematic;
39 std::vector<device>& devices = schematic.devices;
40 for(std::size_t i = 0; i < pins.size(); ++i) {
41 devices.push_back(device());
42 devices.back().type = "PIN";
43 devices.back().terminals.push_back(pins[i].net);
44 }
45 extract_devices(devices, connectivity, layout);
46 extract_netlist(schematic.nets, devices);
47
48 return compare_schematics(reference_schematic, schematic);
49}
50
51int main(int argc, char **argv) {
52 if(argc < 3) {
53 std::cout << "usage: " << argv[0] << " <layout_file> <schematic_file>" << std::endl;
54 return -1;
55 }
56 bool result = compare_files(argv[1], argv[2]);
57 if(result == false) {
58 std::cout << "Layout does not match schematic." << std::endl;
59 return 1;
60 }
61 std::cout << "Layout does match schematic." << std::endl;
62 return 0;
63}