public void drawPanel2() {
		
		panel2 = new JPanel();
		panel2.setLayout(new BoxLayout(panel2, BoxLayout.Y_AXIS));
		
		registerPanel = new JPanel();
		registerPanel.setMaximumSize(new Dimension(400, 400));
		registerPanel.setAlignmentX(CENTER_ALIGNMENT);
		registerPanel.setAlignmentY(TOP_ALIGNMENT);
		registerPanel.setBorder(BorderFactory.createTitledBorder(" CPU Registers "));
		registerPanel.setLayout(new BoxLayout(registerPanel, BoxLayout.Y_AXIS));		
				
		JPanel topRegisterPanel = new JPanel();
		topRegisterPanel.setLayout(new BoxLayout(topRegisterPanel, BoxLayout.X_AXIS));
		
		JPanel controlRegistersPanel1 = new JPanel();		
		controlRegistersPanel1.setLayout(new BoxLayout(controlRegistersPanel1, BoxLayout.Y_AXIS));
		
		pcField = new JTextField(9);		
		pcField.setEditable(false);
		pcField.setAlignmentX(CENTER_ALIGNMENT);
		pcField.setAlignmentY(CENTER_ALIGNMENT);
		JPanel pcPanel = new JPanel();
		pcPanel.setMaximumSize(new Dimension(155, 60));
		pcPanel.add(pcField);
		pcPanel.setBorder(BorderFactory.createTitledBorder(" PC "));
		
		controlUnit.getPC().registerListener(new UpdateListener(this));
		
		JPanel irPanel = new JPanel();
		
		if (!pipeliningEnabled) { //In standard mode, just a single IR
			irRegisters = new JTextField[1];
			irRegisters[0] = new JTextField(8);
			irRegisters[0].setEditable(false);
			irPanel.setMaximumSize(new Dimension(155, 60));
			irPanel.add(irRegisters[0]);
			irPanel.setBorder(BorderFactory.createTitledBorder(" IR "));
		}
		
		else { //Pipelined mode requires an IRfile
			irPanel.setLayout(new BoxLayout(irPanel, BoxLayout.Y_AXIS));			
			irRegisters = new JTextField[3];
			
			JPanel ir0Panel = new JPanel();
			ir0Panel.setBorder(BorderFactory.createEmptyBorder(5, 0, 2, 0));
			irRegisters[0] = new JTextField(9);
			irRegisters[0].setEditable(false);
			JLabel ir0Label = new JLabel("F/D  ");
			ir0Panel.setMaximumSize(new Dimension(155, 50));
			ir0Panel.setLayout(new BoxLayout(ir0Panel, BoxLayout.X_AXIS));
			ir0Panel.add(ir0Label);
			ir0Panel.add(irRegisters[0]);
			
			JPanel ir1Panel = new JPanel();
			irRegisters[1] = new JTextField(9);
			irRegisters[1].setEditable(false);
			JLabel ir1Label = new JLabel("Ex.   ");
			ir1Panel.setMaximumSize(new Dimension(155, 50));
			ir1Panel.setLayout(new BoxLayout(ir1Panel, BoxLayout.X_AXIS));
			ir1Panel.add(ir1Label);
			ir1Panel.add(irRegisters[1]);
			
			JPanel ir2Panel = new JPanel();
			ir2Panel.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 2));
			irRegisters[2] = new JTextField(9);
			irRegisters[2].setEditable(false);
			JLabel ir2Label = new JLabel("WB   ");
			ir2Panel.setMaximumSize(new Dimension(155, 50));
			ir2Panel.setLayout(new BoxLayout(ir2Panel, BoxLayout.X_AXIS));
			ir2Panel.add(ir2Label);
			ir2Panel.add(irRegisters[2]);			
			
			
			irPanel.setBorder(BorderFactory.createTitledBorder(" IR File "));
			irPanel.setMaximumSize(new Dimension(155, 115));
			
			
			irPanel.add(ir0Panel);
			irPanel.add(ir1Panel);
			irPanel.add(ir2Panel);
			
		}
		
		controlUnit.getIR().registerListener(new UpdateListener(this));
		
		//Add PC and IR displays
		controlRegistersPanel1.add(pcPanel);
		controlRegistersPanel1.add(irPanel);
		controlRegistersPanel1.setBorder(BorderFactory.createEmptyBorder(0, 10, 30, 20));
		
		//MAR, MBR and CC displays
		JPanel controlRegistersPanel2 = new JPanel();
		controlRegistersPanel2.setLayout(new BoxLayout(controlRegistersPanel2, BoxLayout.Y_AXIS));
		
		marField = new JTextField(8);
		marField.setEditable(false);		
		JPanel marPanel = new JPanel();
		marPanel.setMaximumSize(new Dimension(150, 60));
		marPanel.add(marField);
		cyanLine = BorderFactory.createLineBorder(Color.blue);
		marPanel.setBorder(BorderFactory.createTitledBorder(cyanLine, " MAR "));
		controlUnit.getMAR().registerListener(new UpdateListener(this));
		
		mbrField = new JTextField(8);
		mbrField.setEditable(false);
		JPanel mbrPanel = new JPanel();
		mbrPanel.setMaximumSize(new Dimension(150, 60));
		mbrPanel.add(mbrField);
		magentaLine = BorderFactory.createLineBorder(Color.magenta);
		mbrPanel.setBorder(BorderFactory.createTitledBorder(magentaLine, " MBR "));
		controlUnit.getMBR().registerListener(new UpdateListener(this));
		
		conditionField = new JTextField(8);
		conditionField.setEditable(false);
		JPanel conditionPanel = new JPanel();
		conditionPanel.setMaximumSize(new Dimension(150, 60));
		conditionPanel.add(conditionField);
		conditionPanel.setBorder(BorderFactory.createTitledBorder(" CC "));
		
		controlUnit.getConditionCodeRegister().registerListener(new UpdateListener(this));
		
		controlRegistersPanel2.add(marPanel);
		controlRegistersPanel2.add(mbrPanel);
		controlRegistersPanel2.add(conditionPanel);
		controlRegistersPanel2.setBorder(BorderFactory.createEmptyBorder(0, 15, 30, 0));
		
		topRegisterPanel.add(controlRegistersPanel1);
		topRegisterPanel.add(controlRegistersPanel2);
		
		registerPanel.add(topRegisterPanel);
		
		
		//General purpose registers
		JPanel generalPurposePanel = new JPanel();
		generalPurposePanel.setLayout(new BoxLayout(generalPurposePanel, BoxLayout.X_AXIS));
		generalPurposePanel.setMaximumSize(new Dimension(400, 300));
		generalPurposePanel.setBorder(BorderFactory.createTitledBorder(" General Purpose Registers "));
		
		JPanel individualPanel1 = new JPanel();
		individualPanel1.setLayout(new BoxLayout(individualPanel1, BoxLayout.Y_AXIS));
		
		JLabel r0label = new JLabel("r0");
		genRegisters[0] = new JTextField(4);
		genRegisters[0].setEditable(false);
		JPanel genReg0panel = new JPanel();
		genReg0panel.add(r0label);
		genReg0panel.add(genRegisters[0]);
		individualPanel1.add(genReg0panel);
		
		JLabel r1label = new JLabel("r1");
		genRegisters[1] = new JTextField(4);
		genRegisters[1].setEditable(false);
		JPanel genReg1panel = new JPanel();
		genReg1panel.add(r1label);
		genReg1panel.add(genRegisters[1]);
		individualPanel1.add(genReg1panel);
		
		JLabel r2label = new JLabel("r2");
		genRegisters[2] = new JTextField(4);
		genRegisters[2].setEditable(false);
		JPanel genReg2panel = new JPanel();
		genReg2panel.add(r2label);
		genReg2panel.add(genRegisters[2]);
		individualPanel1.add(genReg2panel);
		
		JLabel r3label = new JLabel("r3");
		genRegisters[3] = new JTextField(4);
		genRegisters[3].setEditable(false);
		JPanel genReg3panel = new JPanel();
		genReg3panel.add(r3label);
		genReg3panel.add(genRegisters[3]);
		individualPanel1.add(genReg3panel);
		
		generalPurposePanel.add(individualPanel1);
		
		
		
		JPanel individualPanel2 = new JPanel();
		individualPanel2.setLayout(new BoxLayout(individualPanel2, BoxLayout.Y_AXIS));
		
		JLabel r4label = new JLabel("r4");
		genRegisters[4] = new JTextField(4);
		genRegisters[4].setEditable(false);
		JPanel genReg4panel = new JPanel();
		genReg4panel.add(r4label);
		genReg4panel.add(genRegisters[4]);
		individualPanel2.add(genReg4panel);
		
		JLabel r5label = new JLabel("r5");
		genRegisters[5] = new JTextField(4);
		genRegisters[5].setEditable(false);
		JPanel genReg5panel = new JPanel();
		genReg5panel.add(r5label);
		genReg5panel.add(genRegisters[5]);
		individualPanel2.add(genReg5panel);
		
		JLabel r6label = new JLabel("r6");
		genRegisters[6] = new JTextField(4);
		genRegisters[6].setEditable(false);
		JPanel genReg6panel = new JPanel();
		genReg6panel.add(r6label);
		genReg6panel.add(genRegisters[6]);
		individualPanel2.add(genReg6panel);
		
		JLabel r7label = new JLabel("r7");
		genRegisters[7] = new JTextField(4);
		genRegisters[7].setEditable(false);
		JPanel genReg7panel = new JPanel();
		genReg7panel.add(r7label);
		genReg7panel.add(genRegisters[7]);
		individualPanel2.add(genReg7panel);
		
		
		generalPurposePanel.add(individualPanel2);
		
		JPanel individualPanel3 = new JPanel();
		individualPanel3.setLayout(new BoxLayout(individualPanel3, BoxLayout.Y_AXIS));
		
		JLabel r8label = new JLabel("r8");
		genRegisters[8] = new JTextField(4);
		genRegisters[8].setEditable(false);
		JPanel genReg8panel = new JPanel();
		genReg8panel.add(r8label);
		genReg8panel.add(genRegisters[8]);
		individualPanel3.add(genReg8panel);
		
		JLabel r9label = new JLabel("r9");
		genRegisters[9] = new JTextField(4);
		genRegisters[9].setEditable(false);
		JPanel genReg9panel = new JPanel();
		genReg9panel.add(r9label);
		genReg9panel.add(genRegisters[9]);
		individualPanel3.add(genReg9panel);
		
		JLabel r10label = new JLabel("r10");
		genRegisters[10] = new JTextField(4);
		genRegisters[10].setEditable(false);
		JPanel genReg10panel = new JPanel();
		genReg10panel.add(r10label);
		genReg10panel.add(genRegisters[10]);
		individualPanel3.add(genReg10panel);
		
		JLabel r11label = new JLabel("r11");
		genRegisters[11] = new JTextField(4);
		genRegisters[11].setEditable(false);
		JPanel genReg11panel = new JPanel();
		genReg11panel.add(r11label);
		genReg11panel.add(genRegisters[11]);
		individualPanel3.add(genReg11panel);
		

		
		generalPurposePanel.add(individualPanel3);
		
		JPanel individualPanel4 = new JPanel();
		individualPanel4.setLayout(new BoxLayout(individualPanel4, BoxLayout.Y_AXIS));
		
		JLabel r12label = new JLabel("r12");
		genRegisters[12] = new JTextField(4);
		genRegisters[12].setEditable(false);
		JPanel genReg12panel = new JPanel();
		genReg12panel.add(r12label);
		genReg12panel.add(genRegisters[12]);
		individualPanel4.add(genReg12panel);
		
		JLabel r13label = new JLabel("r13");
		genRegisters[13] = new JTextField(4);
		genRegisters[13].setEditable(false);
		JPanel genReg13panel = new JPanel();
		genReg13panel.add(r13label);
		genReg13panel.add(genRegisters[13]);
		individualPanel4.add(genReg13panel);
		
		JLabel r14label = new JLabel("r14");
		genRegisters[14] = new JTextField(4);
		genRegisters[14].setEditable(false);
		JPanel genReg14panel = new JPanel();
		genReg14panel.add(r14label);
		genReg14panel.add(genRegisters[14]);
		individualPanel4.add(genReg14panel);
		
		JLabel r15label = new JLabel("r15");
		genRegisters[15] = new JTextField(4);
		genRegisters[15].setEditable(false);
		JPanel genReg15panel = new JPanel();
		genReg15panel.add(r15label);
		genReg15panel.add(genRegisters[15]);
		individualPanel4.add(genReg15panel);
		
		generalPurposePanel.add(individualPanel4);
		
		
		
		registerPanel.add(generalPurposePanel);
		
		panel2.add(registerPanel);
		
		controlUnit.getRegisters().registerListener(new UpdateListener(this));
		
		
		/*
		 * ALU display
		 */		
		JPanel aluPanel = new JPanel(); //Panel to encase the two subpanels
		aluPanel.setLayout(new BoxLayout(aluPanel, BoxLayout.X_AXIS));
		aluPanel.setBorder(BorderFactory.createTitledBorder(" ALU "));
		
		JPanel aluSubPanel1 = new JPanel();
		aluSubPanel1.setLayout(new BoxLayout(aluSubPanel1, BoxLayout.Y_AXIS));
		
		JLabel addOperand1Label = new JLabel("Operand 1:");
		addOperand1 = new JTextField(4);
		addOperand1.setEditable(false);
		JPanel adderOperand1Panel = new JPanel();
		adderOperand1Panel.setLayout(new BoxLayout(adderOperand1Panel, BoxLayout.X_AXIS));
		adderOperand1Panel.add(addOperand1Label);
		adderOperand1Panel.add(addOperand1);

		
		JLabel addOperand2Label = new JLabel("Operand 2:");
		addOperand2 = new JTextField(4);

		addOperand2.setEditable(false);
		JPanel adderOperand2Panel = new JPanel();
		adderOperand2Panel.setLayout(new BoxLayout(adderOperand2Panel, BoxLayout.X_AXIS));
		adderOperand2Panel.add(addOperand2Label);
		adderOperand2Panel.add(addOperand2);
		
		JLabel addResultLabel = new JLabel("Result:       ");
		addResult = new JTextField(4);
		addResult.setEditable(false);
		JPanel adderResultPanel = new JPanel();
		adderResultPanel.setLayout(new BoxLayout(adderResultPanel, BoxLayout.X_AXIS));
		adderResultPanel.add(addResultLabel);
		adderResultPanel.add(addResult);		
		
		JPanel aluAdderPanel = new JPanel();
		aluAdderPanel.setLayout(new BoxLayout(aluAdderPanel, BoxLayout.Y_AXIS));
		aluAdderPanel.add(adderOperand1Panel);
		aluAdderPanel.add(adderOperand2Panel);
		aluAdderPanel.add(adderResultPanel);
		aluAdderPanel.setBorder(BorderFactory.createTitledBorder("Add. Unit"));
		
		aluSubPanel1.add(aluAdderPanel);
		
		/*
		 * Sub unit
		 */
		JLabel subOperand1Label = new JLabel("Operand 1:");
		subOperand1 = new JTextField(4);
		subOperand1.setEditable(false);
		JPanel subOperand1Panel = new JPanel();
		subOperand1Panel.setLayout(new BoxLayout(subOperand1Panel, BoxLayout.X_AXIS));
		subOperand1Panel.add(subOperand1Label);
		subOperand1Panel.add(subOperand1);

		
		JLabel subOperand2Label = new JLabel("Operand 2:");
		subOperand2 = new JTextField(4);
		subOperand2.setEditable(false);
		JPanel subOperand2Panel = new JPanel();
		subOperand2Panel.setLayout(new BoxLayout(subOperand2Panel, BoxLayout.X_AXIS));
		subOperand2Panel.add(subOperand2Label);
		subOperand2Panel.add(subOperand2);
		
		JLabel subResultLabel = new JLabel("Result:       ");
		subResult = new JTextField(4);
		subResult.setEditable(false);
		JPanel subResultPanel = new JPanel();
		subResultPanel.setLayout(new BoxLayout(subResultPanel, BoxLayout.X_AXIS));
		subResultPanel.add(subResultLabel);
		subResultPanel.add(subResult);		
		
		JPanel aluSubtractorPanel = new JPanel();
		aluSubtractorPanel.setLayout(new BoxLayout(aluSubtractorPanel, BoxLayout.Y_AXIS));
		aluSubtractorPanel.add(subOperand1Panel);
		aluSubtractorPanel.add(subOperand2Panel);
		aluSubtractorPanel.add(subResultPanel);
		aluSubtractorPanel.setBorder(BorderFactory.createTitledBorder("Sub. Unit"));
		
		aluSubPanel1.add(aluAdderPanel);
		aluSubPanel1.add(aluSubtractorPanel);
		
		
		/*
		 * For aluSubPanel2, containing mul and div units
		 */
		
		JPanel aluSubPanel2 = new JPanel();
		aluSubPanel2.setLayout(new BoxLayout(aluSubPanel2, BoxLayout.Y_AXIS));			

		JLabel divOperand1Label = new JLabel("Operand 1:");
		divOperand1 = new JTextField(4);
		divOperand1.setEditable(false);
		JPanel divOperand1Panel = new JPanel();
		divOperand1Panel.setLayout(new BoxLayout(divOperand1Panel, BoxLayout.X_AXIS));
		divOperand1Panel.add(divOperand1Label);
		divOperand1Panel.add(divOperand1);

		
		JLabel divOperand2Label = new JLabel("Operand 2:");
		divOperand2 = new JTextField(4);
		divOperand2.setEditable(false);
		JPanel divOperand2Panel = new JPanel();
		divOperand2Panel.setLayout(new BoxLayout(divOperand2Panel, BoxLayout.X_AXIS));
		divOperand2Panel.add(divOperand2Label);
		divOperand2Panel.add(divOperand2);
		
		JLabel divResultLabel = new JLabel("Result:       ");
		divResult = new JTextField(4);
		divResult.setEditable(false);
		JPanel divResultPanel = new JPanel();
		divResultPanel.setLayout(new BoxLayout(divResultPanel, BoxLayout.X_AXIS));
		divResultPanel.add(divResultLabel);
		divResultPanel.add(divResult);		
		
		JPanel aluDivPanel = new JPanel();
		aluDivPanel.setLayout(new BoxLayout(aluDivPanel, BoxLayout.Y_AXIS));
		aluDivPanel.add(divOperand1Panel);
		aluDivPanel.add(divOperand2Panel);
		aluDivPanel.add(divResultPanel);
		aluDivPanel.setBorder(BorderFactory.createTitledBorder("Div. Unit"));
		
		
		/*
		 * Mul unit
		 */
		JLabel mulOperand1Label = new JLabel("Operand 1:");
		mulOperand1 = new JTextField(4);
		mulOperand1.setEditable(false);
		JPanel mulOperand1Panel = new JPanel();
		mulOperand1Panel.setLayout(new BoxLayout(mulOperand1Panel, BoxLayout.X_AXIS));
		mulOperand1Panel.add(mulOperand1Label);
		mulOperand1Panel.add(mulOperand1);

		
		JLabel mulOperand2Label = new JLabel("Operand 2:");
		mulOperand2 = new JTextField(4);
		mulOperand2.setEditable(false);
		JPanel mulOperand2Panel = new JPanel();
		mulOperand2Panel.setLayout(new BoxLayout(mulOperand2Panel, BoxLayout.X_AXIS));
		mulOperand2Panel.add(mulOperand2Label);
		mulOperand2Panel.add(mulOperand2);
		
		JLabel mulResultLabel = new JLabel("Result:       ");
		mulResult = new JTextField(4);
		mulResult.setEditable(false);
		JPanel mulResultPanel = new JPanel();
		mulResultPanel.setLayout(new BoxLayout(mulResultPanel, BoxLayout.X_AXIS));
		mulResultPanel.add(mulResultLabel);
		mulResultPanel.add(mulResult);		
		
		JPanel aluMulPanel = new JPanel();
		aluMulPanel.setLayout(new BoxLayout(aluMulPanel, BoxLayout.Y_AXIS));
		aluMulPanel.add(mulOperand1Panel);
		aluMulPanel.add(mulOperand2Panel);
		aluMulPanel.add(mulResultPanel);
		aluMulPanel.setBorder(BorderFactory.createTitledBorder("Mul. Unit"));
		
		aluSubPanel2.add(aluDivPanel);
		aluSubPanel2.add(aluMulPanel);
		
		aluPanel.add(aluSubPanel1);
		aluPanel.add(aluSubPanel2);
		aluPanel.setPreferredSize(new Dimension(400, 290));
		aluPanel.setMaximumSize(new Dimension(400, 290));
		
		JPanel bufferPanel = new JPanel(); //To separate registers from ALU with some empty space
		bufferPanel.setPreferredSize(new Dimension(400, 35));
		bufferPanel.setMaximumSize(new Dimension(400, 35));
		
		panel2.add(bufferPanel);		
		panel2.add(aluPanel);		
		
		panel2.setBorder(BorderFactory.createEmptyBorder(15, 5, 20, 5));
		
		ALU.registerListener(new UpdateListener(this));
		
		this.getContentPane().add(panel2);
		
	}