forked from OpenTimer/OpenTimer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunit.cpp
77 lines (46 loc) · 1.88 KB
/
unit.cpp
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
// This program demonstrates how to change units for
// dimensional analysis.
//
// Design : unit.v
// SDC : unit.sdc
// SPEF : unit.spef
// Library: osu018_stdcells.lib
#include <ot/timer/timer.hpp>
int main(int argc, char *argv[]) {
ot::Timer timer;
// read the design
timer.read_celllib("osu018_stdcells.lib")
.read_verilog("unit.v")
.read_sdc("unit.sdc")
.read_spef("unit.spef")
.update_timing();
// the default library is at ns and pf scale.
std::cout << timer.time_unit()->value() << " second (time unit)\n"
<< timer.capacitance_unit()->value() << " farad (capacitance unit)\n"
<< "TNS: " << *timer.report_tns() << '\n';
// change to ps and ff.
timer.set_time_unit(ot::second_t(1e-12))
.set_capacitance_unit(ot::farad_t(1e-15))
.update_timing();
// dump the timer details
std::cout << timer.time_unit()->value() << " second (time unit)\n"
<< timer.capacitance_unit()->value() << " farad (capacitance unit)\n"
<< "TNS: " << *timer.report_tns() << '\n';
// change back to ns and pf
timer.set_time_unit(ot::second_t(1e-9))
.set_capacitance_unit(ot::farad_t(1e-12f))
.update_timing();
// dump the timer details
std::cout << timer.time_unit()->value() << " second (time unit)\n"
<< timer.capacitance_unit()->value() << " farad (capacitance unit)\n"
<< "TNS: " << *timer.report_tns() << '\n';
// scale the time unit by half
timer.set_time_unit(ot::second_t(2e-9))
.set_capacitance_unit(ot::farad_t(2e-12f))
.update_timing();
// dump the timer details
std::cout << timer.time_unit()->value() << " second (time unit)\n"
<< timer.capacitance_unit()->value() << " farad (capacitance unit)\n"
<< "TNS: " << *timer.report_tns() << '\n';
return 0;
}