Search in sources :

Example 1 with Data

use of brunonova.drmips.simulator.Data in project drmips by brunonova.

the class ConstantTest method tComp.

private void tComp(int inValue, int inSize) throws InvalidCPUException, JSONException {
    JSONObject json = new JSONObject().put("x", 0).put("y", 0).put("val", inValue).put("size", inSize).put("out", "out");
    Constant c = new Constant("test", json);
    c.execute();
    assertEquals(new Data(inSize, inValue), c.getOutput().getData());
}
Also used : JSONObject(org.json.JSONObject) Data(brunonova.drmips.simulator.Data)

Example 2 with Data

use of brunonova.drmips.simulator.Data in project drmips by brunonova.

the class ForkTest method tComp.

private void tComp(int size, List<String> outIds, int inValue) throws InvalidCPUException, JSONException {
    JSONObject json = new JSONObject().put("x", 0).put("y", 0).put("in", "in").put("size", size).put("out", new JSONArray(outIds));
    Fork c = new Fork("test", json);
    c.getInput().setValue(inValue);
    c.execute();
    Data expectedData = new Data(size, inValue);
    for (String out : outIds) {
        assertEquals(expectedData, c.getOutput(out).getData());
    }
}
Also used : JSONObject(org.json.JSONObject) JSONArray(org.json.JSONArray) Data(brunonova.drmips.simulator.Data)

Example 3 with Data

use of brunonova.drmips.simulator.Data in project drmips by brunonova.

the class ShiftLeftTest method tComp.

private void tComp(int expected, int inValue, int inSize, int outSize, int amount) throws InvalidCPUException, JSONException {
    JSONObject json = new JSONObject().put("x", 0).put("y", 0).put("amount", amount).put("in", new JSONObject().put("id", "in").put("size", inSize)).put("out", new JSONObject().put("id", "out").put("size", outSize));
    ShiftLeft c = new ShiftLeft("test", json);
    c.getInput().setValue(inValue);
    c.execute();
    assertEquals(new Data(outSize, expected), c.getOutput().getData());
}
Also used : JSONObject(org.json.JSONObject) Data(brunonova.drmips.simulator.Data)

Example 4 with Data

use of brunonova.drmips.simulator.Data in project drmips by brunonova.

the class Distributor method addOutput.

/**
 * Adds an output.
 * @param id The identifier of the output.
 * @param msb The most significant bit of the value to put.
 * @param lsb The less significant bit of the value to put.
 * @throws InvalidCPUException If <tt>id</tt> is empty.
 */
private void addOutput(String id, int msb, int lsb) throws InvalidCPUException {
    OutputParameters param = new OutputParameters(id, msb, lsb, getInput().getSize());
    outParameters.add(param);
    addOutput(id, new Data(param.msb - param.lsb + 1));
}
Also used : Data(brunonova.drmips.simulator.Data)

Example 5 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