Skip to content

Commit f77c321

Browse files
committed
move estimate.py out of analysis directory, rename
1 parent c111217 commit f77c321

File tree

8 files changed

+29
-36
lines changed

8 files changed

+29
-36
lines changed

docs/analysis.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Estimation
1818
1919
.. .. _estimate-ref:
2020
21-
.. automodule:: pyrtl.analysis.estimate
21+
.. automodule:: pyrtl.analysis
2222
:members:
2323
:show-inheritance:
2424
:special-members:

examples/example7-synth-timing-draft.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99

1010
import pyrtl
11-
from pyrtl.analysis import estimate
1211

1312
# --- Part 1: Timing Analysis ------------------------------------------------
1413

@@ -27,7 +26,7 @@
2726

2827
# Generating timing analysis information
2928
print("Pre Synthesis:")
30-
timing = estimate.TimingAnalysis()
29+
timing = pyrtl.TimingAnalysis()
3130
timing.print_max_length()
3231

3332
# We are also able to print out the critical paths as well as get them
@@ -39,7 +38,7 @@
3938
# PyRTL also provides estimates for the area that would be used up if the
4039
# circuit was printed as an ASIC.
4140

42-
logic_area, mem_area = estimate.area_estimation(tech_in_nm=65)
41+
logic_area, mem_area = pyrtl.area_estimation(tech_in_nm=65)
4342
est_area = logic_area + mem_area
4443
print("Estimated Area of block", est_area, "sq mm")
4544
print()
@@ -58,7 +57,7 @@
5857
pyrtl.synthesize()
5958

6059
print("Pre Optimization:")
61-
timing = estimate.TimingAnalysis()
60+
timing = pyrtl.TimingAnalysis()
6261
timing.print_max_length()
6362
for net in pyrtl.working_block().logic:
6463
print(str(net))
@@ -73,7 +72,7 @@
7372

7473
# Now to see the difference
7574
print("Post Optimization:")
76-
timing = estimate.TimingAnalysis()
75+
timing = pyrtl.TimingAnalysis()
7776
timing.print_max_length()
7877

7978
for net in pyrtl.working_block().logic:

pyrtl/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
from .inputoutput import input_from_blif
9999
from .inputoutput import output_to_firrtl
100100

101-
# different analysis and transform passes
101+
# different transform passes
102102
from .passes import common_subexp_elimination
103103
from .passes import constant_propagation
104104
from .passes import synthesize
@@ -114,3 +114,8 @@
114114
from .transform import clone_wire
115115
from .transform import replace_wires
116116
from .transform import replace_wire_fast
117+
118+
# analysis and estimation functions
119+
from .analysis import area_estimation
120+
from .analysis import TimingAnalysis
121+
from .analysis import yosys_area_delay

pyrtl/analysis/estimate.py renamed to pyrtl/analysis.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
import subprocess
1414
import sys
1515

16-
from ..core import working_block
17-
from ..wire import Input, Const, Register
18-
from ..pyrtlexceptions import PyrtlError, PyrtlInternalError
19-
from ..inputoutput import output_to_verilog
20-
from ..memory import RomBlock
21-
from ..helperfuncs import _currently_in_jupyter_notebook, _print_netlist_latex
16+
from .core import working_block
17+
from .wire import Input, Const, Register
18+
from .pyrtlexceptions import PyrtlError, PyrtlInternalError
19+
from .inputoutput import output_to_verilog
20+
from .memory import RomBlock
21+
from .helperfuncs import _currently_in_jupyter_notebook, _print_netlist_latex
2222

2323

2424
# --------------------------------------------------------------------

pyrtl/analysis/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/test_estimate.py renamed to tests/test_analysis.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
from __future__ import print_function, unicode_literals, absolute_import
2-
from .test_transform import NetWireNumTestCases
3-
from pyrtl.wire import Const, Output
4-
from pyrtl.analysis import estimate
52

63
import unittest
74
import pyrtl
8-
import io
95

106

117
class TestAreaEstimate(unittest.TestCase):
@@ -41,7 +37,7 @@ def test_area_est_unchanged(self):
4137
atimesb <<= a * b
4238
memread <<= mem[0]
4339
mem[1] <<= a
44-
self.assertEquals(estimate.area_estimation(), (0.00734386752, 0.01879779717361501))
40+
self.assertEquals(pyrtl.area_estimation(), (0.00734386752, 0.01879779717361501))
4541

4642
def test_area_est_unchanged_with_rom(self):
4743
a = pyrtl.Const(2, 8)
@@ -70,7 +66,7 @@ def test_area_est_unchanged_with_rom(self):
7066
bminusa <<= a - b
7167
atimesb <<= a * b
7268
memread <<= mem[reg]
73-
self.assertEquals(estimate.area_estimation(), (0.00734386752, 0.001879779717361501))
69+
self.assertEquals(pyrtl.area_estimation(), (0.00734386752, 0.001879779717361501))
7470

7571

7672
class TestTimingEstimate(unittest.TestCase):
@@ -106,7 +102,7 @@ def test_time_est_unchanged(self):
106102
atimesb <<= a * b
107103
memread <<= mem[0]
108104
mem[1] <<= a
109-
timing = estimate.TimingAnalysis()
105+
timing = pyrtl.TimingAnalysis()
110106
self.assertEqual(timing.max_freq(), 610.2770657878676)
111107
self.assertEquals(timing.max_length(), 1255.6000000000001)
112108

tests/test_passes.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
import pyrtl
1010
from pyrtl.wire import Const, Output
11-
from pyrtl.analysis import estimate
1211

1312
from .test_transform import NetWireNumTestCases
1413

@@ -613,7 +612,7 @@ def everything_t_procedure(self, timing_val=None, opt_timing_val=None):
613612
# to make sure that the timing matches
614613
# this is a subprocess to do the synth and timing
615614
block = pyrtl.working_block()
616-
timing = estimate.TimingAnalysis(block)
615+
timing = pyrtl.TimingAnalysis(block)
617616
timing_max_length = timing.max_length()
618617
if timing_val is not None:
619618
self.assertEqual(timing_max_length, timing_val)
@@ -623,7 +622,7 @@ def everything_t_procedure(self, timing_val=None, opt_timing_val=None):
623622
pyrtl.optimize()
624623

625624
block = pyrtl.working_block()
626-
timing = estimate.TimingAnalysis(block)
625+
timing = pyrtl.TimingAnalysis(block)
627626
timing_max_length = timing.max_length()
628627
if opt_timing_val is not None:
629628
self.assertEqual(timing_max_length, opt_timing_val)
@@ -633,7 +632,7 @@ def everything_t_procedure(self, timing_val=None, opt_timing_val=None):
633632
pyrtl.optimize()
634633

635634
block = pyrtl.working_block()
636-
timing = estimate.TimingAnalysis(block)
635+
timing = pyrtl.TimingAnalysis(block)
637636
timing_max_length = timing.max_length()
638637
critical_path = timing.critical_path(print_cp=False)
639638
block = pyrtl.working_block()
@@ -644,7 +643,7 @@ def everything_t_procedure(self, timing_val=None, opt_timing_val=None):
644643
pyrtl.optimize()
645644

646645
block = pyrtl.working_block()
647-
timing = estimate.TimingAnalysis(block)
646+
timing = pyrtl.TimingAnalysis(block)
648647
timing_max_length = timing.max_length()
649648
critical_path = timing.critical_path(print_cp=False)
650649
block.sanity_check()
@@ -687,7 +686,7 @@ def test_timing_error(self):
687686
pyrtl.synthesize()
688687
pyrtl.optimize()
689688
block = pyrtl.working_block()
690-
_timing = estimate.TimingAnalysis(block)
689+
_timing = pyrtl.TimingAnalysis(block)
691690
sys.stdout = sys.__stdout__
692691
self.assertTrue(output.getvalue().startswith("Loop found:"))
693692

@@ -752,7 +751,7 @@ def test_two_way_concat(self):
752751
self.assertEqual(len(concat_nets), 1)
753752
self.assertEqual(concat_nets[0].args, (i, j, k))
754753

755-
pyrtl.passes.two_way_concat()
754+
pyrtl.two_way_concat()
756755

757756
concat_nets = list(block.logic_subset(op='c'))
758757
self.assertEqual(len(concat_nets), 2)
@@ -776,7 +775,7 @@ def test_one_bit_selects(self):
776775
self.assertEqual(len(select_nets), 1)
777776
self.assertEqual(tuple(select_nets[0].op_param), (0, 2, 4, 6, 8, 10))
778777

779-
pyrtl.passes.one_bit_selects()
778+
pyrtl.one_bit_selects()
780779

781780
select_nets = list(block.logic_subset(op='s'))
782781
for net in select_nets:

tests/test_visualization.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import random
33
import io
44
import pyrtl
5-
from pyrtl import analysis
65
from .test_inputoutput import full_adder_blif
76

87

@@ -60,7 +59,7 @@ def test_output_to_graphviz_does_not_throw_error(self):
6059
def test_output_to_graphviz_with_custom_namer_does_not_throw_error(self):
6160
with io.StringIO() as vfile:
6261
pyrtl.input_from_blif(full_adder_blif)
63-
timing = analysis.TimingAnalysis()
62+
timing = pyrtl.TimingAnalysis()
6463
node_fan_in = {net: len(net.args) for net in pyrtl.working_block()}
6564
graph_namer = pyrtl.graphviz_detailed_namer(
6665
extra_node_info=node_fan_in,
@@ -70,15 +69,13 @@ def test_output_to_graphviz_with_custom_namer_does_not_throw_error(self):
7069

7170
@unittest.skip("Need to make Graphviz output order deterministic via sorting")
7271
def test_output_to_graphviz_correct_detailed_output(self):
73-
from pyrtl.analysis.estimate import TimingAnalysis
74-
7572
a = pyrtl.Input(2, 'a')
7673
b = a * 8
7774
c = b[2:]
7875
d = pyrtl.Output(10, 'd')
7976
d <<= c
8077

81-
analysis = TimingAnalysis()
78+
analysis = pyrtl.TimingAnalysis()
8279
_, dst_map = pyrtl.working_block().net_connections()
8380

8481
def get_fanout(n):

0 commit comments

Comments
 (0)