예제 #1
0
 @Override
 public MemState clone() {
   try {
     MemState ret = (MemState) super.clone();
     ret.contents = contents.clone();
     ret.contents.addHexModelListener(ret);
     return ret;
   } catch (CloneNotSupportedException e) {
     return null;
   }
 }
예제 #2
0
	private void doClear() {
		MemState s = factory.getState(instance, circState);
		boolean isAllZero = s.getContents().isClear();
		if (isAllZero) return;

		int choice = JOptionPane.showConfirmDialog(frame,
				_("ramConfirmClearMsg"),
				_("ramConfirmClearTitle"),
				JOptionPane.YES_NO_OPTION);
		if (choice == JOptionPane.YES_OPTION) {
			s.getContents().clear();
		}
	}
예제 #3
0
	private void doSave() {
		MemState s = factory.getState(instance, circState);

		JFileChooser chooser = proj.createChooser();
		File oldSelected = factory.getCurrentImage(instance);
		if (oldSelected != null) chooser.setSelectedFile(oldSelected);
		chooser.setDialogTitle(_("ramSaveDialogTitle"));
		int choice = chooser.showSaveDialog(frame);
		if (choice == JFileChooser.APPROVE_OPTION) {
			File f = chooser.getSelectedFile();
			try {
				HexFile.save(f, s.getContents());
				factory.setCurrentImage(instance, f);
			} catch (IOException e) {
				JOptionPane.showMessageDialog(frame, e.getMessage(),
					_("ramSaveErrorTitle"), JOptionPane.ERROR_MESSAGE);
			}
		}
	}
예제 #4
0
파일: Rom.java 프로젝트: heisera/logisim
	@Override
	public void propagate(InstanceState state) {
		MemState myState = getState(state);
		BitWidth dataBits = state.getAttributeValue(DATA_ATTR);

		Value addrValue = state.getPort(ADDR);
		boolean chipSelect = state.getPort(CS) != Value.FALSE;
		
		if (!chipSelect) {
			myState.setCurrent(-1);
			state.setPort(DATA, Value.createUnknown(dataBits), DELAY);
			return;
		}

		int addr = addrValue.toIntValue();
		if (!addrValue.isFullyDefined() || addr < 0)
			return;
		if (addr != myState.getCurrent()) {
			myState.setCurrent(addr);
			myState.scrollToShow(addr);
		}

		int val = myState.getContents().get(addr);
		state.setPort(DATA, Value.createKnown(dataBits, val), DELAY);
	}