Skip to content

Commit 7e2df0c

Browse files
committed
add : tests
1 parent 3ada6ae commit 7e2df0c

6 files changed

Lines changed: 184 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ set(STA_SOURCE
114114
liberty/TimingRole.cc
115115
liberty/Units.cc
116116
liberty/Wireload.cc
117+
liberty/GeneratedClock.cc
117118

118119
network/ConcreteLibrary.cc
119120
network/ConcreteNetwork.cc

test/generated_clock.lib

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
library (generated_clock) {
2+
delay_model : "table_lookup";
3+
time_unit : "1ns";
4+
voltage_unit : "1v";
5+
input_threshold_pct_rise : 50;
6+
input_threshold_pct_fall : 50;
7+
output_threshold_pct_rise : 50;
8+
output_threshold_pct_fall : 50;
9+
slew_lower_threshold_pct_rise : 30;
10+
slew_lower_threshold_pct_fall : 30;
11+
slew_upper_threshold_pct_rise : 70;
12+
slew_upper_threshold_pct_fall : 70;
13+
cell (CLK_GEN) {
14+
area : 10.0;
15+
pin (CLK_IN) {
16+
direction : input;
17+
clock : true;
18+
}
19+
pin (CLK_OUT_DIV) {
20+
direction : output;
21+
}
22+
pin (CLK_OUT_MUL) {
23+
direction : output;
24+
}
25+
generated_clock (gen_clk_div2) {
26+
clock_pin : " CLK_OUT_DIV ";
27+
master_pin : CLK_IN ;
28+
divided_by : 2;
29+
}
30+
generated_clock (gen_clk_mul2_inv_dut_80) {
31+
clock_pin : " CLK_OUT_MUL ";
32+
master_pin : CLK_IN ;
33+
multiplied_by : 2;
34+
invert : true; /* inverted duty cycle of 80, so 20 */
35+
duty_cycle : 80.0;
36+
}
37+
timing () {
38+
related_pin : CLK_IN;
39+
timing_type : rising_edge;
40+
intrinsic_rise : 10;
41+
intrinsic_fall : 10;
42+
}
43+
}
44+
cell (CLK_EDGE_SHIFT) {
45+
area : 10.0;
46+
pin (CLK_IN) {
47+
direction : input;
48+
clock : true;
49+
}
50+
pin (CLK_OUT) {
51+
direction : output;
52+
}
53+
generated_clock (shift) {
54+
clock_pin : CLK_OUT ;
55+
master_pin : CLK_IN;
56+
edges (1, 3, 5);
57+
shifts (0, 0, 0)
58+
}
59+
timing () {
60+
related_pin : CLK_IN;
61+
timing_type : rising_edge;
62+
intrinsic_rise : 10;
63+
intrinsic_fall : 10;
64+
}
65+
}
66+
}

test/generated_clock.ok

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Warning: generated_clock.lib line 57, shifts are not supported yet, may cause malformed waveforms.
2+
Number of clocks: 9
3+
clk period: 10.000000
4+
u_second_hierarchy/clk_gen/CLK_OUT_DIV period: 20.000000
5+
u_second_hierarchy/clk_gen2/CLK_OUT_DIV period: 40.000000
6+
u_second_hierarchy/clk_gen3/CLK_OUT_DIV period: 80.000000
7+
u_second_hierarchy/clk_gen3/CLK_OUT_MUL period: 20.000000
8+
u_second_hierarchy/clk_gen2/CLK_OUT_MUL period: 10.000000
9+
u_second_hierarchy/clk_gen/CLK_OUT_MUL period: 5.000000
10+
clk2 period: 100.000000
11+
clk_edge_shift/CLK_OUT period: 200.000000
12+
Number of clocks: 10
13+
Clock Period Waveform
14+
----------------------------------------------------
15+
clk 10.00 0.00 5.00
16+
u_second_hierarchy/clk_gen/CLK_OUT_DIV 20.00 0.00 10.00 (generated)
17+
u_second_hierarchy/clk_gen2/CLK_OUT_DIV 40.00 0.00 20.00 (generated)
18+
u_second_hierarchy/clk_gen3/CLK_OUT_DIV 80.00 0.00 40.00 (generated)
19+
u_second_hierarchy/clk_gen3/CLK_OUT_MUL 20.00 16.00 20.00 (generated)
20+
u_second_hierarchy/clk_gen2/CLK_OUT_MUL 10.00 8.00 10.00 (generated)
21+
u_second_hierarchy/clk_gen/CLK_OUT_MUL 5.00 4.00 5.00 (generated)
22+
clk2 100.00 0.00 50.00
23+
clk_edge_shift/CLK_OUT 200.00 0.00 100.00 (generated)
24+
clk_manual 400.00 0.00 200.00 (generated)

test/generated_clock.tcl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
read_liberty generated_clock.lib
2+
read_verilog generated_clock.v
3+
link_design generated_clock
4+
create_clock -name clk -period 10 [get_ports CLK_IN_1]
5+
create_clock -name clk2 -period 100 [get_ports CLK_IN_2]
6+
7+
# Should see 9 clocks
8+
puts "Number of clocks: [ llength [get_clocks]]"
9+
10+
# Report all clock periods
11+
foreach_in_collection clk [get_clocks] {
12+
puts "[get_object_name $clk] period: [get_attribute $clk period]"
13+
}
14+
15+
# Use TCL command to create a generated clock from generated clock
16+
create_generated_clock \
17+
-name clk_manual \
18+
-source [get_pins clk_edge_shift/CLK_OUT] \
19+
-master_clock clk_edge_shift/CLK_OUT \
20+
-divide_by 2 \
21+
[get_ports CLK_OUT_2]
22+
23+
# Should see 10 clocks
24+
puts "Number of clocks: [ llength [get_clocks]]"
25+
26+
# Use command to validate waveforms
27+
report_clock_properties

test/generated_clock.v

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module generated_clock (
2+
3+
// Test basic test cases
4+
input wire CLK_IN_1,
5+
output wire slow_clk_int,
6+
output wire fast_clk_int,
7+
output wire slow_clk_out2,
8+
output wire fast_clk_out2,
9+
10+
// Test liberty-defined nested clock output
11+
output wire slow_clk_out3,
12+
output wire fast_clk_out3,
13+
14+
// Test edges/shifts (shifts not supported)
15+
input wire CLK_IN_2,
16+
output wire CLK_OUT_2
17+
);
18+
19+
// Give one more level of hierarchy to test names
20+
second_hierarchy u_second_hierarchy (
21+
.clk_in(CLK_IN_1),
22+
.slow_clk_out(slow_clk_int),
23+
.fast_clk_out(fast_clk_int),
24+
.slow_clk_out2(slow_clk_out2),
25+
.fast_clk_out2(fast_clk_out2),
26+
.slow_clk_out3(slow_clk_out3),
27+
.fast_clk_out3(fast_clk_out3)
28+
);
29+
30+
CLK_EDGE_SHIFT clk_edge_shift (
31+
.CLK_IN(CLK_IN_2),
32+
.CLK_OUT(CLK_OUT_2)
33+
);
34+
35+
endmodule
36+
37+
module second_hierarchy (
38+
input wire clk_in,
39+
output wire slow_clk_out,
40+
output wire fast_clk_out,
41+
output wire slow_clk_out2,
42+
output wire fast_clk_out2,
43+
output wire slow_clk_out3,
44+
output wire fast_clk_out3
45+
);
46+
47+
CLK_GEN clk_gen (
48+
.CLK_IN(clk_in),
49+
.CLK_OUT_DIV(slow_clk_out),
50+
.CLK_OUT_MUL(fast_clk_out)
51+
);
52+
53+
CLK_GEN clk_gen2 (
54+
.CLK_IN(slow_clk_out),
55+
.CLK_OUT_DIV(slow_clk_out2),
56+
.CLK_OUT_MUL(fast_clk_out2)
57+
);
58+
59+
CLK_GEN clk_gen3 (
60+
.CLK_IN(slow_clk_out2),
61+
.CLK_OUT_DIV(slow_clk_out3),
62+
.CLK_OUT_MUL(fast_clk_out3)
63+
);
64+
65+
endmodule

test/regression_vars.tcl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ record_public_tests {
151151
get_lib_pins_of_objects
152152
get_noargs
153153
get_objrefs
154+
generated_clock
154155
liberty_arcs_one2one_1
155156
liberty_arcs_one2one_2
156157
liberty_backslash_eol

0 commit comments

Comments
 (0)