comments are allowed in hex files

This commit is contained in:
hneemann 2017-06-20 10:51:08 +02:00
parent 39d5c68716
commit 9c64d2d568
3 changed files with 24 additions and 5 deletions

View File

@ -7,6 +7,8 @@ planned as v0.13
CAUTION: All default values are lost! If you have built a circuit that contains
test cases that depend on a non-null default value, this tests will fail. To
resolve this issue, reset the default value.
- A warning message shows up if a circuit with unnamed inputs/outputs is analysed.
- Comments are allowed in hex files.
v0.12.1, released on 05. Jun 2016
- added a fuse to simulate a PROM or PAL.

View File

@ -72,11 +72,18 @@ public class DataField {
int pos = 0;
while ((line = br.readLine()) != null) {
try {
long v = Long.parseLong(line, 16);
if (pos == data.length)
data = Arrays.copyOf(data, data.length * 2);
data[pos] = v;
pos++;
int p = line.indexOf('#');
if (p >= 0)
line = line.substring(0, p).trim();
else
line = line.trim();
if (line.length() > 0) {
long v = Long.parseLong(line, 16);
if (pos == data.length)
data = Arrays.copyOf(data, data.length * 2);
data[pos] = v;
pos++;
}
} catch (NumberFormatException e) {
throw new IOException(e);
}

View File

@ -36,4 +36,14 @@ public class DataFieldTest extends TestCase {
assertEquals(0xAA, df.getDataWord(2));
assertEquals(0xFF, df.getDataWord(3));
}
public void testLoadComments() throws Exception {
String data = "v2.0 raw\n#test1 \n 0 \n#test1\n # test2\n10 # test3\n\n\nAA\nFF #test";
DataField df = new DataField(new StringReader(data));
assertEquals(4, df.size());
assertEquals(0x00, df.getDataWord(0));
assertEquals(0x10, df.getDataWord(1));
assertEquals(0xAA, df.getDataWord(2));
assertEquals(0xFF, df.getDataWord(3));
}
}