aboutsummaryrefslogtreecommitdiffstats
path: root/passes
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2013-11-13 15:46:28 +0100
committerClifford Wolf <clifford@clifford.at>2013-11-13 15:46:28 +0100
commita694324a75275d21a674f0a4a3b3537ea8c19c0e (patch)
tree86e0f42c800986b90e01ab35d2b581159c8534c8 /passes
parent63060dcd2e36b9e0964953214ef01466296f4d29 (diff)
downloadyosys-a694324a75275d21a674f0a4a3b3537ea8c19c0e.tar.gz
yosys-a694324a75275d21a674f0a4a3b3537ea8c19c0e.tar.bz2
yosys-a694324a75275d21a674f0a4a3b3537ea8c19c0e.zip
Fixed abc pass blif parser for constant bits
Diffstat (limited to 'passes')
-rw-r--r--passes/abc/blifparse.cc75
1 files changed, 57 insertions, 18 deletions
diff --git a/passes/abc/blifparse.cc b/passes/abc/blifparse.cc
index 7fe27ce1e..31523ec12 100644
--- a/passes/abc/blifparse.cc
+++ b/passes/abc/blifparse.cc
@@ -22,6 +22,28 @@
#include <stdio.h>
#include <string.h>
+static bool read_next_line(char *buffer, int &line_count, FILE *f)
+{
+ buffer[0] = 0;
+
+ while (1)
+ {
+ int buffer_len = strlen(buffer);
+ while (buffer_len > 0 && (buffer[buffer_len-1] == ' ' || buffer[buffer_len-1] == '\t' ||
+ buffer[buffer_len-1] == '\r' || buffer[buffer_len-1] == '\n'))
+ buffer[--buffer_len] = 0;
+
+ if (buffer_len == 0 || buffer[buffer_len-1] == '\\') {
+ if (buffer[buffer_len-1] == '\\')
+ buffer[--buffer_len] = 0;
+ line_count++;
+ if (fgets(buffer+buffer_len, 4096-buffer_len, f) == NULL)
+ return false;
+ } else
+ return true;
+ }
+}
+
RTLIL::Design *abc_parse_blif(FILE *f)
{
RTLIL::Design *design = new RTLIL::Design;
@@ -39,25 +61,10 @@ RTLIL::Design *abc_parse_blif(FILE *f)
while (1)
{
- buffer[0] = 0;
-
- while (1)
- {
- int buffer_len = strlen(buffer);
- while (buffer_len > 0 && (buffer[buffer_len-1] == ' ' || buffer[buffer_len-1] == '\t' ||
- buffer[buffer_len-1] == '\r' || buffer[buffer_len-1] == '\n'))
- buffer[--buffer_len] = 0;
-
- if (buffer_len == 0 || buffer[buffer_len-1] == '\\') {
- if (buffer[buffer_len-1] == '\\')
- buffer[--buffer_len] = 0;
- line_count++;
- if (fgets(buffer+buffer_len, 4096-buffer_len, f) == NULL)
- goto error;
- } else
- break;
- }
+ if (!read_next_line(buffer, line_count, f))
+ goto error;
+ continue_without_read:
if (buffer[0] == '#')
continue;
@@ -112,6 +119,38 @@ RTLIL::Design *abc_parse_blif(FILE *f)
output_sig = input_sig.extract(input_sig.width-1, 1);
input_sig = input_sig.extract(0, input_sig.width-1);
+ if (input_sig.width == 0) {
+ RTLIL::State state = RTLIL::State::Sa;
+ while (1) {
+ if (!read_next_line(buffer, line_count, f))
+ goto error;
+ for (int i = 0; buffer[i]; i++) {
+ if (buffer[i] == ' ' || buffer[i] == '\t')
+ continue;
+ if (i == 0 && buffer[i] == '.')
+ goto finished_parsing_constval;
+ if (buffer[i] == '0') {
+ if (state == RTLIL::State::S1)
+ goto error;
+ state = RTLIL::State::S0;
+ continue;
+ }
+ if (buffer[i] == '1') {
+ if (state == RTLIL::State::S0)
+ goto error;
+ state = RTLIL::State::S1;
+ continue;
+ }
+ goto error;
+ }
+ }
+ finished_parsing_constval:
+ if (state == RTLIL::State::Sa)
+ state = RTLIL::State::S1;
+ module->connections.push_back(RTLIL::SigSig(output_sig, state));
+ goto continue_without_read;
+ }
+
input_sig.optimize();
output_sig.optimize();