@@ -30,6 +30,212 @@ class BufRemTest3 : public tst::IntegratedFixture
3030 bool debug_ = false ; // Set to true to generate debug output
3131};
3232
33+ TEST_F (BufRemTest3, RemoveBufferCase9)
34+ {
35+ std::string test_name = " TestBufferRemoval3_9" ;
36+ readVerilogAndSetup (test_name + " .v" );
37+
38+ // Netlist before buffer removal:
39+ // (undriven input) -> buf1 -> out
40+
41+ // Dump pre ECO state
42+ if (debug_) {
43+ dumpVerilogAndOdb (test_name + " _pre_eco" );
44+ }
45+
46+ odb::dbDatabase::beginEco (block_);
47+
48+ // Pre sanity check
49+ sta_->updateTiming (true );
50+ // Do not call checkAxioms() because there is an undriven buffer.
51+
52+ // ----------------------------------------------------
53+ // Remove buffer
54+ // ----------------------------------------------------
55+ auto insts = std::make_unique<sta::InstanceSeq>();
56+ odb::dbInst* buf_inst = block_->findInst (" buf1" );
57+ ASSERT_NE (buf_inst, nullptr );
58+ sta::Instance* sta_buf = db_network_->dbToSta (buf_inst);
59+ insts->emplace_back (sta_buf);
60+ resizer_.removeBuffers (*insts);
61+
62+ // Post sanity check
63+ sta_->updateTiming (true );
64+ // Do not call checkAxioms() because there is an undriven buffer.
65+
66+ // Write verilog and check the content after buffer removal
67+ const std::string after_vlog_path = test_name + " _after.v" ;
68+ sta::writeVerilog (after_vlog_path.c_str (), true , false , {}, sta_->network ());
69+
70+ std::ifstream file_after (after_vlog_path);
71+ std::string content_after ((std::istreambuf_iterator<char >(file_after)),
72+ std::istreambuf_iterator<char >());
73+
74+ // Netlist after buffer removal:
75+ // in -> mod_inst/mod_in -> assign -> mod_inst/mod_out -> out
76+ const std::string expected_after_vlog = R"( module top (clk,
77+ in,
78+ out);
79+ input clk;
80+ input in;
81+ output out;
82+
83+
84+ endmodule
85+ )" ;
86+
87+ EXPECT_EQ (content_after, expected_after_vlog);
88+
89+ odb::dbDatabase::undoEco (block_);
90+
91+ // Dump undo ECO state
92+ if (debug_) {
93+ dumpVerilogAndOdb (test_name + " _undo_eco" );
94+ }
95+
96+ // Clean up
97+ removeFile (after_vlog_path);
98+ }
99+
100+ TEST_F (BufRemTest3, RemoveBufferCase8)
101+ {
102+ std::string test_name = " TestBufferRemoval3_8" ;
103+ readVerilogAndSetup (test_name + " .v" );
104+
105+ // Netlist before buffer removal:
106+ // (undriven input) -> buf1 -> out
107+
108+ // Dump pre ECO state
109+ if (debug_) {
110+ dumpVerilogAndOdb (test_name + " _pre_eco" );
111+ }
112+
113+ odb::dbDatabase::beginEco (block_);
114+
115+ // Pre sanity check
116+ sta_->updateTiming (true );
117+ // Do not call checkAxioms() because there is an undriven buffer.
118+
119+ // ----------------------------------------------------
120+ // Remove buffer
121+ // ----------------------------------------------------
122+ auto insts = std::make_unique<sta::InstanceSeq>();
123+ odb::dbInst* buf_inst = block_->findInst (" buf1" );
124+ ASSERT_NE (buf_inst, nullptr );
125+ sta::Instance* sta_buf = db_network_->dbToSta (buf_inst);
126+ insts->emplace_back (sta_buf);
127+ resizer_.removeBuffers (*insts);
128+
129+ // Post sanity check
130+ sta_->updateTiming (true );
131+ // Do not call checkAxioms() because there is an undriven buffer.
132+
133+ // Write verilog and check the content after buffer removal
134+ const std::string after_vlog_path = test_name + " _after.v" ;
135+ sta::writeVerilog (after_vlog_path.c_str (), true , false , {}, sta_->network ());
136+
137+ std::ifstream file_after (after_vlog_path);
138+ std::string content_after ((std::istreambuf_iterator<char >(file_after)),
139+ std::istreambuf_iterator<char >());
140+
141+ // Netlist after buffer removal:
142+ // in -> mod_inst/mod_in -> assign -> mod_inst/mod_out -> out
143+ const std::string expected_after_vlog = R"( module top (clk,
144+ in,
145+ out);
146+ input clk;
147+ input in;
148+ output out;
149+
150+
151+ BUF_X1 buf1 (.Z(out));
152+ endmodule
153+ )" ;
154+
155+ EXPECT_EQ (content_after, expected_after_vlog);
156+
157+ odb::dbDatabase::undoEco (block_);
158+
159+ // Dump undo ECO state
160+ if (debug_) {
161+ dumpVerilogAndOdb (test_name + " _undo_eco" );
162+ }
163+
164+ // Clean up
165+ removeFile (after_vlog_path);
166+ }
167+
168+ TEST_F (BufRemTest3, RemoveBufferCase7)
169+ {
170+ std::string test_name = " TestBufferRemoval3_7" ;
171+ readVerilogAndSetup (test_name + " .v" );
172+
173+ // Netlist before buffer removal:
174+ // (undriven input) -> buf1 -> buf2 -> out
175+
176+ // Dump pre ECO state
177+ if (debug_) {
178+ dumpVerilogAndOdb (test_name + " _pre_eco" );
179+ }
180+
181+ odb::dbDatabase::beginEco (block_);
182+
183+ // Pre sanity check
184+ sta_->updateTiming (true );
185+ // Do not call checkAxioms() because there is an undriven buffer.
186+
187+ // ----------------------------------------------------
188+ // Remove buffer
189+ // ----------------------------------------------------
190+ auto insts = std::make_unique<sta::InstanceSeq>();
191+ odb::dbInst* buf_inst = block_->findInst (" buf1" );
192+ ASSERT_NE (buf_inst, nullptr );
193+ sta::Instance* sta_buf = db_network_->dbToSta (buf_inst);
194+ insts->emplace_back (sta_buf);
195+ resizer_.removeBuffers (*insts);
196+
197+ // Post sanity check
198+ sta_->updateTiming (true );
199+ // Do not call checkAxioms() because there is an undriven buffer.
200+
201+ // Write verilog and check the content after buffer removal
202+ const std::string after_vlog_path = test_name + " _after.v" ;
203+ sta::writeVerilog (after_vlog_path.c_str (), true , false , {}, sta_->network ());
204+
205+ std::ifstream file_after (after_vlog_path);
206+ std::string content_after ((std::istreambuf_iterator<char >(file_after)),
207+ std::istreambuf_iterator<char >());
208+
209+ // Netlist after buffer removal:
210+ // in -> mod_inst/mod_in -> assign -> mod_inst/mod_out -> out
211+ const std::string expected_after_vlog = R"( module top (clk,
212+ in,
213+ out);
214+ input clk;
215+ input in;
216+ output out;
217+
218+ wire n1;
219+
220+ BUF_X1 buf1 (.Z(n1));
221+ BUF_X1 buf2 (.A(n1),
222+ .Z(out));
223+ endmodule
224+ )" ;
225+
226+ EXPECT_EQ (content_after, expected_after_vlog);
227+
228+ odb::dbDatabase::undoEco (block_);
229+
230+ // Dump undo ECO state
231+ if (debug_) {
232+ dumpVerilogAndOdb (test_name + " _undo_eco" );
233+ }
234+
235+ // Clean up
236+ removeFile (after_vlog_path);
237+ }
238+
33239TEST_F (BufRemTest3, RemoveBufferCase6)
34240{
35241 std::string test_name = " TestBufferRemoval3_6" ;
0 commit comments