mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 07:28:20 -04:00
changed pin naming and function of new RAM component to match real devices
This commit is contained in:
parent
dde20ad9fe
commit
12cea9a026
@ -26,9 +26,9 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface {
|
|||||||
|
|
||||||
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(RAMSinglePortSel.class,
|
public static final ElementTypeDescription DESCRIPTION = new ElementTypeDescription(RAMSinglePortSel.class,
|
||||||
input("A"),
|
input("A"),
|
||||||
input("sel"),
|
input("CS"),
|
||||||
input("C"),
|
input("WE"),
|
||||||
input("W/\u00ACR"))
|
input("OE"))
|
||||||
.addAttribute(Keys.ROTATE)
|
.addAttribute(Keys.ROTATE)
|
||||||
.addAttribute(Keys.BITS)
|
.addAttribute(Keys.BITS)
|
||||||
.addAttribute(Keys.ADDR_BITS)
|
.addAttribute(Keys.ADDR_BITS)
|
||||||
@ -41,15 +41,14 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface {
|
|||||||
private final String label;
|
private final String label;
|
||||||
private final ObservableValue dataOut;
|
private final ObservableValue dataOut;
|
||||||
private ObservableValue addrIn;
|
private ObservableValue addrIn;
|
||||||
private ObservableValue selIn;
|
private ObservableValue csIn;
|
||||||
private ObservableValue clkIn;
|
private ObservableValue weIn;
|
||||||
private ObservableValue wnrIn;
|
private ObservableValue oeIn;
|
||||||
private ObservableValue dataIn;
|
private ObservableValue dataIn;
|
||||||
|
|
||||||
private boolean lastClk = false;
|
private boolean cs;
|
||||||
private boolean sel;
|
|
||||||
private int addr;
|
private int addr;
|
||||||
private boolean write;
|
private boolean oe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance
|
* Creates a new instance
|
||||||
@ -69,30 +68,28 @@ public class RAMSinglePortSel extends Node implements Element, RAMInterface {
|
|||||||
@Override
|
@Override
|
||||||
public void setInputs(ObservableValues inputs) throws NodeException {
|
public void setInputs(ObservableValues inputs) throws NodeException {
|
||||||
addrIn = inputs.get(0).checkBits(addrBits, this).addObserverToValue(this);
|
addrIn = inputs.get(0).checkBits(addrBits, this).addObserverToValue(this);
|
||||||
selIn = inputs.get(1).checkBits(1, this).addObserverToValue(this);
|
csIn = inputs.get(1).checkBits(1, this).addObserverToValue(this);
|
||||||
clkIn = inputs.get(2).checkBits(1, this).addObserverToValue(this);
|
weIn = inputs.get(2).checkBits(1, this).addObserverToValue(this);
|
||||||
wnrIn = inputs.get(3).checkBits(1, this).addObserverToValue(this);
|
oeIn = inputs.get(3).checkBits(1, this).addObserverToValue(this);
|
||||||
dataIn = inputs.get(4).checkBits(bits, this).addObserverToValue(this);
|
dataIn = inputs.get(4).checkBits(bits, this).addObserverToValue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readInputs() throws NodeException {
|
public void readInputs() throws NodeException {
|
||||||
boolean clk = clkIn.getBool();
|
cs = csIn.getBool();
|
||||||
sel = selIn.getBool();
|
if (cs) {
|
||||||
if (sel) {
|
|
||||||
addr = (int) addrIn.getValue();
|
addr = (int) addrIn.getValue();
|
||||||
write = wnrIn.getBool();
|
oe = oeIn.getBool();
|
||||||
if (write && !lastClk && clk) {
|
if (weIn.getBool()) {
|
||||||
long data = dataIn.getValue();
|
long data = dataIn.getValue();
|
||||||
memory.setData(addr, data);
|
memory.setData(addr, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lastClk = clk;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeOutputs() throws NodeException {
|
public void writeOutputs() throws NodeException {
|
||||||
if (sel && !write) {
|
if (cs && oe) {
|
||||||
dataOut.set(memory.getDataWord(addr), false);
|
dataOut.set(memory.getDataWord(addr), false);
|
||||||
} else {
|
} else {
|
||||||
dataOut.setHighZ(true);
|
dataOut.setHighZ(true);
|
||||||
|
@ -19,6 +19,7 @@ public class FileScanner {
|
|||||||
public int scan(File path) throws Exception {
|
public int scan(File path) throws Exception {
|
||||||
errors = new ArrayList<>();
|
errors = new ArrayList<>();
|
||||||
int count = scanIntern(path);
|
int count = scanIntern(path);
|
||||||
|
System.out.println("tested "+count+" examples");
|
||||||
if (errors.isEmpty())
|
if (errors.isEmpty())
|
||||||
return count;
|
return count;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<int>6</int>
|
<int>6</int>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="40" y="380"/>
|
<pos x="60" y="380"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>Out</elementName>
|
<elementName>Out</elementName>
|
||||||
@ -71,20 +71,20 @@
|
|||||||
<elementAttributes>
|
<elementAttributes>
|
||||||
<entry>
|
<entry>
|
||||||
<string>Label</string>
|
<string>Label</string>
|
||||||
<string>C</string>
|
<string>WE</string>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="120" y="440"/>
|
<pos x="60" y="440"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>In</elementName>
|
<elementName>In</elementName>
|
||||||
<elementAttributes>
|
<elementAttributes>
|
||||||
<entry>
|
<entry>
|
||||||
<string>Label</string>
|
<string>Label</string>
|
||||||
<string>W</string>
|
<string>OE</string>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="40" y="460"/>
|
<pos x="60" y="480"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
<visualElement>
|
<visualElement>
|
||||||
<elementName>RAMSinglePortSel</elementName>
|
<elementName>RAMSinglePortSel</elementName>
|
||||||
@ -148,35 +148,35 @@
|
|||||||
<entry>
|
<entry>
|
||||||
<string>Testdata</string>
|
<string>Testdata</string>
|
||||||
<testData>
|
<testData>
|
||||||
<dataString>sel A C W Din Dout
|
<dataString>CS A WE OE Din Dout
|
||||||
|
|
||||||
# write some values
|
# write some values
|
||||||
1 0 C 1 7 X
|
1 0 C 0 7 X
|
||||||
1 10 C 1 8 X
|
1 10 C 0 8 X
|
||||||
1 20 C 1 9 X
|
1 20 C 0 9 X
|
||||||
1 30 C 1 10 X
|
1 30 C 0 10 X
|
||||||
1 40 C 1 11 X
|
1 40 C 0 11 X
|
||||||
1 50 C 1 12 X
|
1 50 C 0 12 X
|
||||||
1 60 C 1 13 X
|
1 60 C 0 13 X
|
||||||
|
|
||||||
# read some values
|
# read some values
|
||||||
1 0 0 0 Z 7
|
1 0 0 1 Z 7
|
||||||
1 10 0 0 Z 8
|
1 10 0 1 Z 8
|
||||||
1 20 0 0 Z 9
|
1 20 0 1 Z 9
|
||||||
1 30 0 0 Z 10
|
1 30 0 1 Z 10
|
||||||
1 40 0 0 Z 11
|
1 40 0 1 Z 11
|
||||||
1 50 0 0 Z 12
|
1 50 0 1 Z 12
|
||||||
1 60 0 0 Z 13
|
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 50 0 0 Z Z
|
||||||
0 60 0 0 Z Z
|
0 60 0 0 Z Z
|
||||||
|
|
||||||
# write with sel=0 does not work
|
# write with CS=0 does not work
|
||||||
0 1 C 1 7 X
|
0 1 C 0 7 X
|
||||||
0 2 C 1 7 X
|
0 2 C 0 7 X
|
||||||
1 1 0 0 Z 0
|
1 1 0 1 Z 0
|
||||||
1 2 0 0 Z 0
|
1 2 0 1 Z 0
|
||||||
</dataString>
|
</dataString>
|
||||||
</testData>
|
</testData>
|
||||||
</entry>
|
</entry>
|
||||||
@ -202,10 +202,10 @@
|
|||||||
<elementAttributes>
|
<elementAttributes>
|
||||||
<entry>
|
<entry>
|
||||||
<string>Label</string>
|
<string>Label</string>
|
||||||
<string>sel</string>
|
<string>CS</string>
|
||||||
</entry>
|
</entry>
|
||||||
</elementAttributes>
|
</elementAttributes>
|
||||||
<pos x="40" y="620"/>
|
<pos x="60" y="620"/>
|
||||||
</visualElement>
|
</visualElement>
|
||||||
</visualElements>
|
</visualElements>
|
||||||
<wires>
|
<wires>
|
||||||
@ -217,6 +217,10 @@
|
|||||||
<p1 x="180" y="640"/>
|
<p1 x="180" y="640"/>
|
||||||
<p2 x="200" y="640"/>
|
<p2 x="200" y="640"/>
|
||||||
</wire>
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="60" y="480"/>
|
||||||
|
<p2 x="260" y="480"/>
|
||||||
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="380" y="420"/>
|
<p1 x="380" y="420"/>
|
||||||
<p2 x="400" y="420"/>
|
<p2 x="400" y="420"/>
|
||||||
@ -249,10 +253,6 @@
|
|||||||
<p1 x="220" y="680"/>
|
<p1 x="220" y="680"/>
|
||||||
<p2 x="320" y="680"/>
|
<p2 x="320" y="680"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
|
||||||
<p1 x="40" y="460"/>
|
|
||||||
<p2 x="260" y="460"/>
|
|
||||||
</wire>
|
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="460"/>
|
<p1 x="260" y="460"/>
|
||||||
<p2 x="320" y="460"/>
|
<p2 x="320" y="460"/>
|
||||||
@ -262,7 +262,7 @@
|
|||||||
<p2 x="220" y="620"/>
|
<p2 x="220" y="620"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="40" y="620"/>
|
<p1 x="60" y="620"/>
|
||||||
<p2 x="140" y="620"/>
|
<p2 x="140" y="620"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
@ -298,7 +298,7 @@
|
|||||||
<p2 x="320" y="820"/>
|
<p2 x="320" y="820"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="120" y="440"/>
|
<p1 x="60" y="440"/>
|
||||||
<p2 x="280" y="440"/>
|
<p2 x="280" y="440"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
@ -318,7 +318,7 @@
|
|||||||
<p2 x="300" y="380"/>
|
<p2 x="300" y="380"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="40" y="380"/>
|
<p1 x="60" y="380"/>
|
||||||
<p2 x="120" y="380"/>
|
<p2 x="120" y="380"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
@ -355,12 +355,16 @@
|
|||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="460"/>
|
<p1 x="260" y="460"/>
|
||||||
<p2 x="260" y="600"/>
|
<p2 x="260" y="480"/>
|
||||||
</wire>
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="600"/>
|
<p1 x="260" y="600"/>
|
||||||
<p2 x="260" y="740"/>
|
<p2 x="260" y="740"/>
|
||||||
</wire>
|
</wire>
|
||||||
|
<wire>
|
||||||
|
<p1 x="260" y="480"/>
|
||||||
|
<p2 x="260" y="600"/>
|
||||||
|
</wire>
|
||||||
<wire>
|
<wire>
|
||||||
<p1 x="260" y="740"/>
|
<p1 x="260" y="740"/>
|
||||||
<p2 x="260" y="880"/>
|
<p2 x="260" y="880"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user