Skip to content

Commit 850fd89

Browse files
authored
Merge pull request #1463 from diffblue/ldg
move `--show-ldg` and `--compute-ct` out of `ebmc_baset`
2 parents f4b127e + d57cfc7 commit 850fd89

File tree

5 files changed

+62
-107
lines changed

5 files changed

+62
-107
lines changed

src/ebmc/ebmc_base.cpp

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -61,65 +61,6 @@ int ebmc_baset::get_properties()
6161

6262
/*******************************************************************\
6363
64-
Function: ebmc_baset::show_ldg
65-
66-
Inputs:
67-
68-
Outputs:
69-
70-
Purpose:
71-
72-
\*******************************************************************/
73-
74-
void ebmc_baset::show_ldg(std::ostream &out)
75-
{
76-
netlistt netlist;
77-
78-
if(make_netlist(netlist))
79-
return;
80-
81-
if(!netlist.transition.empty())
82-
out << "WARNING: transition constraint found!" << '\n'
83-
<< '\n';
84-
85-
ldgt ldg;
86-
87-
ldg.compute(netlist);
88-
89-
out << "Latch dependencies:" << '\n';
90-
91-
for(var_mapt::mapt::const_iterator
92-
it=netlist.var_map.map.begin();
93-
it!=netlist.var_map.map.end();
94-
it++)
95-
{
96-
const var_mapt::vart &var=it->second;
97-
98-
for(std::size_t i=0; i<var.bits.size(); i++)
99-
{
100-
if(var.is_latch())
101-
{
102-
literalt::var_not v=var.bits[i].current.var_no();
103-
104-
out << " " << it->first
105-
<< "[" << i << "] = " << v << ":";
106-
107-
const ldg_nodet &node=ldg[v];
108-
109-
for(ldg_nodet::edgest::const_iterator
110-
i_it=node.in.begin();
111-
i_it!=node.in.end();
112-
i_it++)
113-
out << " " << i_it->first;
114-
115-
out << '\n';
116-
}
117-
}
118-
}
119-
}
120-
121-
/*******************************************************************\
122-
12364
Function: ebmc_baset::make_netlist
12465
12566
Inputs:
@@ -153,36 +94,3 @@ bool ebmc_baset::make_netlist(netlistt &netlist)
15394

15495
return false;
15596
}
156-
157-
/*******************************************************************\
158-
159-
Function: ebmc_baset::do_compute_ct
160-
161-
Inputs:
162-
163-
Outputs:
164-
165-
Purpose:
166-
167-
\*******************************************************************/
168-
169-
int ebmc_baset::do_compute_ct()
170-
{
171-
// make net-list
172-
message.status() << "Making Netlist" << messaget::eom;
173-
174-
netlistt netlist;
175-
if(make_netlist(netlist)) return 1;
176-
177-
message.status() << "Latches: " << netlist.var_map.latches.size()
178-
<< ", nodes: " << netlist.number_of_nodes() << messaget::eom;
179-
180-
message.status() << "Making LDG" << messaget::eom;
181-
182-
ldgt ldg;
183-
ldg.compute(netlist);
184-
185-
std::cout << "CT = " << compute_ct(ldg) << '\n';
186-
187-
return 0;
188-
}

src/ebmc/ebmc_base.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class ebmc_baset
3333
virtual ~ebmc_baset() { }
3434

3535
int get_properties();
36-
void show_ldg(std::ostream &out);
3736
bool make_netlist(netlistt &);
3837

3938
transition_systemt transition_system;
@@ -53,9 +52,6 @@ class ebmc_baset
5352
bool typecheck();
5453

5554
std::size_t bound;
56-
57-
public:
58-
int do_compute_ct();
5955
};
6056

6157
#endif

src/ebmc/ebmc_parse_options.cpp

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ Author: Daniel Kroening, kroening@kroening.com
1313
#include <util/help_formatter.h>
1414
#include <util/string2int.h>
1515

16+
#include <trans-netlist/compute_ct.h>
17+
#include <trans-netlist/ldg.h>
1618
#include <trans-netlist/smv_netlist.h>
1719

1820
#include "build_transition_system.h"
1921
#include "diatest.h"
20-
#include "ebmc_base.h"
2122
#include "ebmc_error.h"
2223
#include "ebmc_language.h"
2324
#include "ebmc_version.h"
@@ -270,10 +271,19 @@ int ebmc_parse_optionst::doit()
270271

271272
if(cmdline.isset("show-ldg"))
272273
{
273-
ebmc_baset ebmc_base(cmdline, ui_message_handler);
274-
ebmc_base.transition_system = std::move(transition_system);
275-
ebmc_base.properties = std::move(properties);
276-
ebmc_base.show_ldg(std::cout);
274+
auto netlist =
275+
make_netlist(transition_system, properties, ui_message_handler);
276+
277+
if(!netlist.transition.empty())
278+
{
279+
messaget message(ui_message_handler);
280+
message.warning() << "transition constraint found!" << messaget::eom;
281+
}
282+
283+
ldgt ldg;
284+
ldg.compute(netlist);
285+
std::cout << "Latch dependencies:" << '\n';
286+
ldg.output(netlist, std::cout);
277287
return 0;
278288
}
279289

@@ -321,10 +331,21 @@ int ebmc_parse_optionst::doit()
321331

322332
if(cmdline.isset("compute-ct"))
323333
{
324-
ebmc_baset ebmc_base(cmdline, ui_message_handler);
325-
ebmc_base.transition_system = std::move(transition_system);
326-
ebmc_base.properties = std::move(properties);
327-
return ebmc_base.do_compute_ct();
334+
auto netlist =
335+
make_netlist(transition_system, properties, ui_message_handler);
336+
337+
messaget message{ui_message_handler};
338+
339+
message.status() << "Latches: " << netlist.var_map.latches.size()
340+
<< ", nodes: " << netlist.number_of_nodes()
341+
<< messaget::eom;
342+
343+
message.status() << "Making LDG" << messaget::eom;
344+
345+
ldgt ldg;
346+
ldg.compute(netlist);
347+
std::cout << "CT = " << compute_ct(ldg) << '\n';
348+
return 0;
328349
}
329350

330351
auto checker_result = property_checker(

src/trans-netlist/ldg.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,30 @@ void ldgt::compute(
9898
}
9999
}
100100
}
101+
102+
void ldgt::output(const netlistt &netlist, std::ostream &out) const
103+
{
104+
for(auto var_it : netlist.var_map.sorted())
105+
{
106+
auto &var = var_it->second;
107+
108+
for(std::size_t i = 0; i < var.bits.size(); i++)
109+
{
110+
if(var.is_latch())
111+
{
112+
literalt::var_not v = var.bits[i].current.var_no();
113+
114+
out << " " << var_it->first << "[" << i << "] = " << v << ":";
115+
116+
const ldg_nodet &node = (*this)[v];
117+
118+
for(ldg_nodet::edgest::const_iterator i_it = node.in.begin();
119+
i_it != node.in.end();
120+
i_it++)
121+
out << " " << i_it->first;
122+
123+
out << '\n';
124+
}
125+
}
126+
}
127+
}

src/trans-netlist/ldg.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ Author: Daniel Kroening, kroening@kroening.com
99
#ifndef CPROVER_TRANS_LDG_H
1010
#define CPROVER_TRANS_LDG_H
1111

12-
#include <set>
13-
1412
#include <util/graph.h>
1513

1614
#include "netlist.h"
1715

16+
#include <iosfwd>
17+
#include <set>
18+
1819
struct ldg_nodet:public graph_nodet<>
1920
{
2021
public:
@@ -35,6 +36,8 @@ class ldgt:public grapht<ldg_nodet>
3536
// latches that are to be considered
3637
void compute(const netlistt &netlist,
3738
const latchest &localization);
39+
40+
void output(const netlistt &, std::ostream &) const;
3841
};
3942

4043
#endif

0 commit comments

Comments
 (0)