{
int M, I, L, O, A;
int B=0, C=0, J=0, F=0; // Optional in AIGER 1.9
- if (!(f >> M >> I >> L >> O >> A)) {
+ if (!(f >> M >> I >> L >> O >> A))
log_error("Invalid AIGER header\n");
- return;
- }
for (auto &i : std::array<std::reference_wrapper<int>,4>{B, C, J, F}) {
if (f.peek() != ' ') break;
- if (!(f >> i)) {
+ if (!(f >> i))
log_error("Invalid AIGER header\n");
- return;
- }
}
std::string line;
// Parse inputs
std::vector<RTLIL::Wire*> inputs;
for (int i = 0; i < I; ++i, ++line_count) {
- if (!(f >> l1)) {
+ if (!(f >> l1))
log_error("Line %d cannot be interpreted as an input!\n", line_count);
- return;
- }
log_debug("%d is an input\n", l1);
log_assert(!(l1 & 1)); // TODO: Inputs can't be inverted?
RTLIL::Wire *wire = createWireIfNotExists(l1);
// Parse latches
std::vector<RTLIL::Wire*> latches;
for (int i = 0; i < L; ++i, ++line_count) {
- if (!(f >> l1 >> l2)) {
+ if (!(f >> l1 >> l2))
log_error("Line %d cannot be interpreted as a latch!\n", line_count);
- return;
- }
log_debug("%d %d is a latch\n", l1, l2);
log_assert(!(l1 & 1)); // TODO: Latch outputs can't be inverted?
RTLIL::Wire *q_wire = createWireIfNotExists(l1);
// Parse outputs
std::vector<RTLIL::Wire*> outputs;
for (int i = 0; i < O; ++i, ++line_count) {
- if (!(f >> l1)) {
+ if (!(f >> l1))
log_error("Line %d cannot be interpreted as an output!\n", line_count);
- return;
- }
log_debug("%d is an output\n", l1);
RTLIL::Wire *wire = createWireIfNotExists(l1);
// Parse AND
for (int i = 0; i < A; ++i, ++line_count) {
- if (!(f >> l1 >> l2 >> l3)) {
+ if (!(f >> l1 >> l2 >> l3))
log_error("Line %d cannot be interpreted as an AND!\n", line_count);
- return;
- }
log_debug("%d %d %d is an AND\n", l1, l2, l3);
log_assert(!(l1 & 1)); // TODO: Output of ANDs can't be inverted?
for (int c = f.peek(); c != EOF; c = f.peek(), ++line_count) {
if (c == 'i' || c == 'o') {
f.ignore(1);
- if (!(f >> l1 >> s)) {
+ if (!(f >> l1 >> s))
log_error("Line %d cannot be interpreted as a symbol entry!\n", line_count);
- return;
- }
- if ((c == 'i' && l1 > inputs.size()) || (c == 'l' && l1 > latches.size()) || (c == 'o' && l1 > outputs.size())) {
+ if ((c == 'i' && l1 > inputs.size()) || (c == 'l' && l1 > latches.size()) || (c == 'o' && l1 > outputs.size()))
log_error("Line %d has invalid symbol position!\n", line_count);
- return;
- }
RTLIL::Wire* wire;
if (c == 'i') wire = inputs[l1];
// Else constraint (TODO)
break;
}
- else {
+ else
log_error("Line %d: cannot interpret first character '%c'!\n", line_count, c);
- return;
- }
std::getline(f, line); // Ignore up to start of next line
}