Search in sources :

Example 6 with Data

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());
}
Also used : JSONObject(org.json.JSONObject) Data(brunonova.drmips.simulator.Data)

Example 7 with Data

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());
}
Also used : JSONObject(org.json.JSONObject) Data(brunonova.drmips.simulator.Data)

Example 8 with Data

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());
}
Also used : JSONObject(org.json.JSONObject) Data(brunonova.drmips.simulator.Data)

Example 9 with Data

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());
}
Also used : JSONObject(org.json.JSONObject) Data(brunonova.drmips.simulator.Data)

Example 10 with Data

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();
}
Also used : TableRow(android.widget.TableRow) CPU(brunonova.drmips.simulator.CPU) TextView(android.widget.TextView) Data(brunonova.drmips.simulator.Data) AssembledInstruction(brunonova.drmips.simulator.AssembledInstruction)

Aggregations

Data (brunonova.drmips.simulator.Data)11 JSONObject (org.json.JSONObject)7 TableRow (android.widget.TableRow)2 TextView (android.widget.TextView)2 AssembledInstruction (brunonova.drmips.simulator.AssembledInstruction)2 CPU (brunonova.drmips.simulator.CPU)2 JSONArray (org.json.JSONArray)1