use of brunonova.drmips.simulator.Data in project drmips by brunonova.
the class ConcatenatorTest method tComp.
private void tComp(int expectedSize, int expectedValue, int in1Size, int in2Size, int in1Value, int in2Value) throws InvalidCPUException, JSONException {
JSONObject json = new JSONObject().put("x", 0).put("y", 0).put("in1", new JSONObject().put("id", "in1").put("size", in1Size)).put("in2", new JSONObject().put("id", "in2").put("size", in2Size)).put("out", "out");
Concatenator c = new Concatenator("test", json);
c.getInput1().setValue(in1Value);
c.getInput2().setValue(in2Value);
c.execute();
Data expectedData = new Data(expectedSize, expectedValue);
assertEquals(expectedData, c.getOutput().getData());
}
use of brunonova.drmips.simulator.Data in project drmips by brunonova.
the class NotTest method tComp.
private void tComp(int expected, int in) throws InvalidCPUException, JSONException {
JSONObject json = new JSONObject().put("x", 0).put("y", 0).put("in", "in").put("out", "out");
Not c = new Not("test", json);
c.getInput().setValue(in);
c.execute();
assertEquals(new Data(1, expected), c.getOutput().getData());
}
use of brunonova.drmips.simulator.Data in project drmips by brunonova.
the class SignExtendTest method tComp.
private void tComp(int expectedValue, int expectedSize, int inValue, int inSize, int outSize) throws InvalidCPUException, JSONException {
JSONObject json = new JSONObject().put("x", 0).put("y", 0).put("in", new JSONObject().put("id", "in").put("size", inSize)).put("out", new JSONObject().put("id", "out").put("size", outSize));
SignExtend c = new SignExtend("test", json);
c.getInput().setValue(inValue);
c.execute();
assertEquals(new Data(expectedSize, expectedValue), c.getOutput().getData());
}
use of brunonova.drmips.simulator.Data in project drmips by brunonova.
the class ZeroExtendTest method tComp.
private void tComp(int expectedValue, int expectedSize, int inValue, int inSize, int outSize) throws InvalidCPUException, JSONException {
JSONObject json = new JSONObject().put("x", 0).put("y", 0).put("in", new JSONObject().put("id", "in").put("size", inSize)).put("out", new JSONObject().put("id", "out").put("size", outSize));
ZeroExtend c = new ZeroExtend("test", json);
c.getInput().setValue(inValue);
c.execute();
assertEquals(new Data(expectedSize, expectedValue), c.getOutput().getData());
}
use of brunonova.drmips.simulator.Data in project drmips by brunonova.
the class DrMIPSActivity method refreshAssembledCodeTable.
/**
* Refreshes the contents of the code table.
*/
private void refreshAssembledCodeTable() {
while (// remove all rows except header
tblAssembledCode.getChildCount() > 1) tblAssembledCode.removeViewAt(1);
AssembledInstruction instruction;
TableRow row;
TextView address, assembled, code;
String codeLine;
CPU cpu = getCPU();
for (int i = 0; i < cpu.getInstructionMemory().getNumberOfInstructions(); i++) {
instruction = cpu.getInstructionMemory().getInstruction(i);
row = new TableRow(this);
row.setOnClickListener(assembledCodeRowOnClickListener);
address = new TextView(this);
address.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, i * (Data.DATA_SIZE / 8)), cmbAssembledCodeFormat.getSelectedItemPosition()) + " ");
address.setTextAppearance(this, android.R.style.TextAppearance_Medium);
address.setTypeface(Typeface.MONOSPACE);
assembled = new TextView(this);
assembled.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, instruction.getData().getValue()), cmbAssembledCodeFormat.getSelectedItemPosition()) + " ");
assembled.setTextAppearance(this, android.R.style.TextAppearance_Medium);
assembled.setTypeface(Typeface.MONOSPACE);
code = new TextView(this);
codeLine = instruction.getLineNumber() + ": ";
for (String label : instruction.getLabels()) codeLine += label + ": ";
codeLine += instruction.getCodeLine();
code.setText(codeLine);
code.setTextAppearance(this, android.R.style.TextAppearance_Medium);
code.setTypeface(Typeface.MONOSPACE);
row.addView(address);
row.addView(assembled);
row.addView(code);
tblAssembledCode.addView(row);
}
refreshAssembledCodeTableValues();
}
Aggregations