Skip to content

Commit e30fb54

Browse files
committed
added code related to processing verilog files
1 parent 994f2eb commit e30fb54

File tree

8 files changed

+100
-12
lines changed

8 files changed

+100
-12
lines changed

src/ic3/ebmc_ic3_interface.hh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
typedef std::vector<std::string> GateNames;
22
typedef std::map<int,int> LatchVal;
3+
typedef std::map<int,int> NondetVars;
34
//
45
class ic3_enginet:public ebmc_baset
56
{
@@ -15,6 +16,7 @@ public:
1516
GateNames Gn;
1617
literalt prop_l;
1718
LatchVal Latch_val;
19+
NondetVars Nondet_vars;
1820
bool const0,const1;
1921
bool orig_names;
2022

@@ -54,7 +56,7 @@ public:
5456
void form_init_constr_lits();
5557
void store_constraints(const std::string &fname);
5658
void read_constraints(const std::string &fname);
57-
59+
void add_pseudo_inps(Circuit *N);
5860
protected:
5961
netlistt netlist;
6062

src/ic3/r0ead_input.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,17 @@ void ic3_enginet::form_circ_from_ebmc()
7575
find_prop_lit();
7676

7777
form_latched_gates();
78-
79-
form_gates();
8078

79+
form_gates();
80+
8181
CDNF Out_names;
8282
form_outp_buf(Out_names);
8383
form_invs();
8484
Ci.form_consts(N);
8585

8686
add_spec_buffs(N);
8787

88+
add_pseudo_inps(N);
8889

8990
fill_fanout_lists(N);
9091
assign_gate_type(N,Out_names,true);
@@ -115,7 +116,8 @@ void ic3_enginet::form_inputs()
115116
if (var.is_input() == false) continue;
116117
for (size_t j=0; j < var.bits.size(); j++) {
117118
literalt lit =var.bits[j].current;
118-
int lit_val = lit.get();
119+
int lit_val = lit.get();
120+
// printf("lit_val = %d\n",lit_val);
119121
CCUBE Name;
120122
if (orig_names) {
121123
bool ok = form_orig_name(Name,lit);

src/ic3/r1ead_input.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ void ic3_enginet::form_latched_gates()
105105
literalt lit =var.bits[j].current;
106106
int init_val = Latch_val[lit.var_no()];
107107
literalt next_lit = var.bits[j].next;
108+
// int lit_val = next_lit.get();
109+
// printf("next st. var: %d\n",lit_val);
108110
add_new_latch(Latches,init_val,lit,next_lit);
109111
}
110112
}

src/ic3/r3ead_input.cc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ void ic3_enginet::form_gate_pin_names(CDNF &Pin_names,CUBE &Pol,
147147
literalt gt_lit(node_ind,false);
148148

149149
add_gate_out_name(Pin_names[2],gt_lit,Pol);
150-
150+
// print_name1(Pin_names[2]);
151+
// printf(": "); print_name1(Pin_names[0]);
152+
// printf(" "); print_name1(Pin_names[1],true);
153+
// printf(" Pin_names[0].size() = %d, Pin_names[1].size() = %d\n",(int) Pin_names[0].size(),
154+
// (int) Pin_names[1].size());
151155
} /* end of function from_gate_pin_names */
152156

153157
/*===============================
@@ -160,10 +164,17 @@ void ic3_enginet::form_gates()
160164

161165
Circuit *N = Ci.N;
162166
aigt::nodest &Nodes = netlist.nodes;
163-
167+
164168
for (size_t i=0; i < Nodes.size(); i++) {
165169
aigt::nodet &Nd = Nodes[i];
166-
if (Nd.is_var()) continue;
170+
if (Nd.is_var()) {
171+
// printf("skipping a var node\n");
172+
// literalt gt_lit(i,false);
173+
// unsigned lit_val = gt_lit.get();
174+
// printf("lit_val = %u\n",lit_val);
175+
// printf("i = %zu\n",i);
176+
continue;
177+
}
167178
CDNF Pin_names;
168179
CUBE Pol;
169180
form_gate_pin_names(Pin_names,Pol,i);

src/ic3/r4ead_input.cc

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,24 +165,50 @@ void ic3_enginet::ebmc_form_latches()
165165

166166
for(var_mapt::mapt::const_iterator it=vm.map.begin();
167167
it!=vm.map.end(); it++) {
168-
const var_mapt::vart &var=it->second;
168+
const var_mapt::vart &var=it->second;
169+
170+
if (var.vartype ==var_mapt::vart::vartypet::NONDET) {
171+
assert(var.bits.size() > 0);
172+
int val = (var.bits.size() == 1)?1:2;
173+
for (size_t i=0; i < var.bits.size(); i++) {
174+
literalt lit = var.bits[i].current;
175+
int var_num = lit.var_no();
176+
Nondet_vars[var_num] = val;
177+
}
178+
continue;
179+
}
180+
169181
if (var.vartype !=var_mapt::vart::vartypet::LATCH)
170182
continue;
171183

172184
for (size_t j=0; j < var.bits.size(); j++) {
173185
literalt lit =var.bits[j].current;
174-
Latch_val[lit.var_no()] = 2; // set the value of the latch to a don't care
186+
int var_num = lit.var_no();
187+
Latch_val[var_num] = 2; // set the value of the latch to a don't care
188+
// printf("latch val: %d\n",var_num);
175189
}
176190
}
177191

192+
if (Latch_val.size() == 0) {
193+
printf("there are no latches\n");
194+
// printf("Nondet_vars.size() = %d\n",(int) Nondet_vars.size());
195+
exit(100);
196+
}
178197
// set initial values
179198
bvt Ist_lits;
180199
gen_ist_lits(Ist_lits);
181200

182201
for (size_t i=0; i < Ist_lits.size(); i++) {
183202
literalt &lit = Ist_lits[i];
184203
int var_num = lit.var_no();
185-
assert(Latch_val.find(var_num) != Latch_val.end());
204+
if (Latch_val.find(var_num) == Latch_val.end()) {
205+
p();
206+
printf("Latch %d is not found\n",var_num);
207+
printf("Latch_val.size() = %zu\n",Latch_val.size());
208+
printf("Ist_lits.size() = %zu\n",Ist_lits.size());
209+
printf("i = %zu\n",i);
210+
exit(100);
211+
}
186212
if (lit.sign()) Latch_val[var_num] = 0;
187213
else Latch_val[var_num] = 1;
188214
}
@@ -208,15 +234,24 @@ void ic3_enginet::gen_ist_lits(bvt &Ist_lits)
208234
while (stack.size() > 0) {
209235

210236
literalt lit = stack.back();
237+
assert(lit.is_constant() == false);
211238
size_t var_num = lit.var_no();
212239
stack.pop_back();
213240
if (Visited.find(lit) != Visited.end())
214241
continue;
215-
assert(var_num < Nodes.size());
242+
if (var_num >= Nodes.size()) {
243+
p();
244+
printf("var_num = %d\n",var_num);
245+
printf("Nodes.size() = %zu\n",Nodes.size());
246+
exit(100);
247+
}
216248
aigt::nodet &Nd = Nodes[var_num];
217249

218250
if (Nd.is_var()) {
219251
Ist_lits.push_back(lit);
252+
// literalt gt_lit(var_num,false);
253+
// unsigned lit_val = gt_lit.get();
254+
// printf("init st: lit_val = %u\n",lit_val);
220255
continue;
221256
}
222257

src/ic3/r6ead_input.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bool ic3_enginet::find_prop(propertyt &Prop)
8787

8888
assert(properties.size() > 0);
8989

90-
if ((properties.size() == 1) && (Ci.prop_name.size() == 0)) {
90+
if ((properties.size() >= 1) && (Ci.prop_name.size() == 0)) {
9191
Prop = properties.front();
9292
Ci.prop_name = id2string(Prop.name);
9393
return(true);

src/ic3/r7ead_input.cc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,41 @@ Author: Eugene Goldberg, [email protected]
2323
#include <ebmc/ebmc_base.h>
2424
#include "ebmc_ic3_interface.hh"
2525

26+
/*=========================================
27+
28+
A D D _ P S E U D O _ I N P S
29+
30+
==========================================*/
31+
void ic3_enginet::add_pseudo_inps(Circuit *N)
32+
{
33+
34+
35+
GCUBE &Gate_list = N->Gate_list;
36+
for (size_t i=0; i < Gate_list.size();i++) {
37+
Gate &G=Gate_list[i];
38+
if (G.flags.active) continue;
39+
// printf("inactive gate: ");
40+
// print_name1(G.Gate_name,true);
41+
42+
G.func_type = BUFFER;
43+
G.gate_type = INPUT;
44+
G.flags.active = 1; // mark this input as active
45+
G.flags.output = 0;
46+
G.flags.transition = 0;
47+
G.flags.output_function = 0;
48+
G.flags.feeds_latch = 0;
49+
G.level_from_inputs = 0; // set the topological level to 0
50+
G.inp_feeds_latch = false;
51+
52+
// Add it to the circuit
53+
54+
N->Inputs.push_back(i);
55+
N->ninputs++; // increment the number of inputs
56+
57+
}
58+
59+
} /*end of function add_pseudo_inps */
60+
2661
/*=========================================
2762
2863
F O R M _ I N I T _ C O N S T R _ L I T S

src/ic3/seq_circ/a2dd_gate.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ int assign_input_pin_number1(std::map<CCUBE,int> &pin_list,
4040
pin_list[name] = pin_num;
4141
G.flags.active = 0;
4242
G.gate_type = UNDEFINED;
43+
G.Gate_name = name;
4344
gate_list.push_back(G); // add one more gate
4445
}
4546
else /* an 'old' pin */

0 commit comments

Comments
 (0)