diff --git a/src/main/java/de/neemann/digital/core/memory/RAMSinglePortSel.java b/src/main/java/de/neemann/digital/core/memory/RAMSinglePortSel.java index b5e261730..21e52f51d 100644 --- a/src/main/java/de/neemann/digital/core/memory/RAMSinglePortSel.java +++ b/src/main/java/de/neemann/digital/core/memory/RAMSinglePortSel.java @@ -26,9 +26,9 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface { public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(RAMSinglePortSel.class, input("A"), - input("sel"), - input("C"), - input("W/\u00ACR")) + input("CS"), + input("WE"), + input("OE")) .addAttribute(Keys.ROTATE) .addAttribute(Keys.BITS) .addAttribute(Keys.ADDR_BITS) @@ -41,15 +41,14 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface { private final String label; private final ObservableValue dataOut; private ObservableValue addrIn; - private ObservableValue selIn; - private ObservableValue clkIn; - private ObservableValue wnrIn; + private ObservableValue csIn; + private ObservableValue weIn; + private ObservableValue oeIn; private ObservableValue dataIn; - private boolean lastClk = false; - private boolean sel; + private boolean cs; private int addr; - private boolean write; + private boolean oe; /** * Creates a new instance @@ -69,30 +68,28 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface { @Override public void setInputs(ObservableValues inputs) throws NodeException { addrIn = inputs.get(0).checkBits(addrBits, this).addObserverToValue(this); - selIn = inputs.get(1).checkBits(1, this).addObserverToValue(this); - clkIn = inputs.get(2).checkBits(1, this).addObserverToValue(this); - wnrIn = inputs.get(3).checkBits(1, this).addObserverToValue(this); + csIn = inputs.get(1).checkBits(1, this).addObserverToValue(this); + weIn = inputs.get(2).checkBits(1, this).addObserverToValue(this); + oeIn = inputs.get(3).checkBits(1, this).addObserverToValue(this); dataIn = inputs.get(4).checkBits(bits, this).addObserverToValue(this); } @Override public void readInputs() throws NodeException { - boolean clk = clkIn.getBool(); - sel = selIn.getBool(); - if (sel) { + cs = csIn.getBool(); + if (cs) { addr = (int) addrIn.getValue(); - write = wnrIn.getBool(); - if (write && !lastClk && clk) { + oe = oeIn.getBool(); + if (weIn.getBool()) { long data = dataIn.getValue(); memory.setData(addr, data); } } - lastClk = clk; } @Override public void writeOutputs() throws NodeException { - if (sel && !write) { + if (cs && oe) { dataOut.set(memory.getDataWord(addr), false); } else { dataOut.setHighZ(true); diff --git a/src/test/java/de/neemann/digital/integration/FileScanner.java b/src/test/java/de/neemann/digital/integration/FileScanner.java index e451d9314..b90a8b482 100644 --- a/src/test/java/de/neemann/digital/integration/FileScanner.java +++ b/src/test/java/de/neemann/digital/integration/FileScanner.java @@ -19,6 +19,7 @@ public class FileScanner { public int scan(File path) throws Exception { errors = new ArrayList<>(); int count = scanIntern(path); + System.out.println("tested "+count+" examples"); if (errors.isEmpty()) return count; diff --git a/src/test/resources/dig/test/ram.dig b/src/test/resources/dig/test/ram.dig index 7def20901..f8aa14fc0 100644 --- a/src/test/resources/dig/test/ram.dig +++ b/src/test/resources/dig/test/ram.dig @@ -14,7 +14,7 @@ 6 - + Out @@ -71,20 +71,20 @@ Label - C + WE - + In Label - W + OE - + RAMSinglePortSel @@ -148,35 +148,35 @@ Testdata - sel A C W Din Dout + CS A WE OE Din Dout # write some values - 1 0 C 1 7 X - 1 10 C 1 8 X - 1 20 C 1 9 X - 1 30 C 1 10 X - 1 40 C 1 11 X - 1 50 C 1 12 X - 1 60 C 1 13 X + 1 0 C 0 7 X + 1 10 C 0 8 X + 1 20 C 0 9 X + 1 30 C 0 10 X + 1 40 C 0 11 X + 1 50 C 0 12 X + 1 60 C 0 13 X # read some values - 1 0 0 0 Z 7 - 1 10 0 0 Z 8 - 1 20 0 0 Z 9 - 1 30 0 0 Z 10 - 1 40 0 0 Z 11 - 1 50 0 0 Z 12 - 1 60 0 0 Z 13 + 1 0 0 1 Z 7 + 1 10 0 1 Z 8 + 1 20 0 1 Z 9 + 1 30 0 1 Z 10 + 1 40 0 1 Z 11 + 1 50 0 1 Z 12 + 1 60 0 1 Z 13 -# read with sel=0 does not work +# read with CS=0 does not work 0 50 0 0 Z Z 0 60 0 0 Z Z -# write with sel=0 does not work - 0 1 C 1 7 X - 0 2 C 1 7 X - 1 1 0 0 Z 0 - 1 2 0 0 Z 0 +# write with CS=0 does not work + 0 1 C 0 7 X + 0 2 C 0 7 X + 1 1 0 1 Z 0 + 1 2 0 1 Z 0 @@ -202,10 +202,10 @@ Label - sel + CS - + @@ -217,6 +217,10 @@ + + + + @@ -249,10 +253,6 @@ - - - - @@ -262,7 +262,7 @@ - + @@ -298,7 +298,7 @@ - + @@ -318,7 +318,7 @@ - + @@ -355,12 +355,16 @@ - + + + + +