View Javadoc
1 /* 2 * MythSim 3 * 4 * Copyright (C) 2002-2004 Jason Vroustouris <jasonv@jasonv.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 package org.mythsim.swing.plugin; 21 22 import java.awt.*; 23 import java.awt.event.*; 24 import javax.swing.*; 25 import org.mythsim.swing.*; 26 import org.mythsim.text.Text; 27 28 /*** 29 * An Animated Datapath Window (Beta). 30 * @author Jason Vroustouris 31 * @todo Change screen to black and wires to white. 32 * @todo Finish and test animation. 33 */ 34 public class DatapathAnimationFrame 35 extends MythPlugInFrame { 36 static final int UP = 0; 37 static final int RIGHT = 1; 38 static final int DOWN = 2; 39 static final int LEFT = 3; 40 static final int HORIZONTAL = 4; 41 static final int VERTICAL = 5; 42 static final int HORIZONTAL_C = 6; 43 static final int VERTICAL_C = 7; 44 public final int[] s = ms.getStatus(); 45 public final int[] p = ms.getPreviousStatus(); 46 int displayBase = 2; 47 48 MythMap map = null; 49 public DatapathAnimationFrame(MythSimSwing a, JFrame owner) { 50 super("Datapath Animation (beta)", 51 false, //resizable 52 true, //closable 53 false, //maximizable 54 true, //iconifiable 55 475, 56 425, 57 0, 58 300, 59 a, 60 owner); 61 map = new MythMap(); 62 map.setSize(460, 390); 63 /*for (int i = 0; i < MythSimSwing.LENGTH; i++) { 64 p[i] = s[i]; 65 s[i] = ms.getStatus(i); 66 }*/ 67 setResizable(false); 68 setContentPane(map); 69 } 70 71 public void setup() { 72 } 73 74 public void step() { 75 /*for (int i = 0; i < MythSimSwing.LENGTH; i++) { 76 p[i] = s[i]; 77 s[i] = ms.getStatus(i); 78 } 79 if (s[MythSimSwing.CLOCK] == 0) { 80 for (int i = 0; i < MythSimSwing.LENGTH; i++) { 81 p[i] = 0; 82 } 83 }*/ 84 repaint(); 85 } 86 87 public void setBase(int a) { 88 displayBase = a; 89 map.repaint(); 90 } 91 92 boolean hasChanged(int index) { 93 //return p[index] != s[index]; 94 if (index >= 0 && index <= 3) { 95 return p[MythSimSwing.VR0_WRITE_BUS + index] == 1; 96 } 97 if (index >= 4 && index <= 7) { 98 return p[MythSimSwing.R0_WRITE + index] == 1; 99 } 100 if (index == MythSimSwing.MAR) { 101 return p[MythSimSwing.MAR_SEL] == 1; 102 } 103 if (index == MythSimSwing.MDR) { 104 return p[MythSimSwing.MDR_SEL] == 1; 105 } 106 if (index == MythSimSwing.IR_0) { 107 return p[MythSimSwing.IR0_SEL] == 1; 108 } 109 if (index == MythSimSwing.IR_1) { 110 return p[MythSimSwing.IR1_SEL] == 1; 111 } 112 return false; 113 } 114 115 void redActive(Graphics g, int index) { 116 g.setColor(Color.LIGHT_GRAY); 117 if (index >= MythSimSwing.R0_WRITE && index < MythSimSwing.R0_WRITE_SET) { 118 if (s[index + (MythSimSwing.CONTROL_WORD_LENGTH / 2)] == 1) { 119 g.setColor(Color.RED); 120 return; 121 } 122 } 123 g.setColor(Color.LIGHT_GRAY); 124 } 125 126 void redActive(Graphics g, int index, int index2) { 127 g.setColor(Color.LIGHT_GRAY); 128 if (index >= MythSimSwing.R0_WRITE && index < MythSimSwing.R0_WRITE_SET) { 129 if (s[index + (MythSimSwing.CONTROL_WORD_LENGTH / 2)] == 1) { 130 g.setColor(Color.RED); 131 return; 132 } 133 } 134 if (index2 >= MythSimSwing.R0_WRITE && index2 < MythSimSwing.R0_WRITE_SET) { 135 if (s[index2 + (MythSimSwing.CONTROL_WORD_LENGTH / 2)] == 1) { 136 g.setColor(Color.RED); 137 return; 138 } 139 } 140 g.setColor(Color.LIGHT_GRAY); 141 } 142 143 /* Draw an Arrow*/ 144 void line(Graphics g, int x, int y, int direction, int length) { 145 //g.setColor(Color.LIGHT_GRAY); 146 int xpts[] = new int[4]; 147 int ypts[] = new int[4]; 148 switch (direction) { 149 case UP: 150 xpts[0] = x - 3; 151 ypts[0] = y + 3; 152 xpts[1] = x; 153 ypts[1] = y; 154 xpts[2] = x + 3; 155 ypts[2] = y + 3; 156 xpts[3] = x - 3; 157 ypts[3] = y + 3; 158 g.fillPolygon(xpts, ypts, 4); 159 g.drawPolygon(xpts, ypts, 4); 160 g.drawLine(x, y, x, y + length); 161 break; 162 case RIGHT: 163 xpts[0] = x - 3; 164 ypts[0] = y + 3; 165 xpts[1] = x; 166 ypts[1] = y; 167 xpts[2] = x - 3; 168 ypts[2] = y - 3; 169 xpts[3] = x - 3; 170 ypts[3] = y + 3; 171 g.fillPolygon(xpts, ypts, 4); 172 g.drawPolygon(xpts, ypts, 4); 173 g.drawLine(x, y, x - 3, y + 3); 174 g.drawLine(x, y, x - 3, y - 3); 175 g.drawLine(x, y, x - length, y); 176 break; 177 case DOWN: 178 xpts[0] = x + 3; 179 ypts[0] = y - 3; 180 xpts[1] = x; 181 ypts[1] = y; 182 xpts[2] = x - 3; 183 ypts[2] = y - 3; 184 xpts[3] = x + 3; 185 ypts[3] = y - 3; 186 g.fillPolygon(xpts, ypts, 4); 187 g.drawPolygon(xpts, ypts, 4); 188 g.drawLine(x, y, x + 3, y - 3); 189 g.drawLine(x, y, x - 3, y - 3); 190 g.drawLine(x, y, x, y - length); 191 break; 192 case LEFT: 193 xpts[0] = x + 3; 194 ypts[0] = y + 3; 195 xpts[1] = x; 196 ypts[1] = y; 197 xpts[2] = x + 3; 198 ypts[2] = y - 3; 199 xpts[3] = x + 3; 200 ypts[3] = y + 3; 201 g.fillPolygon(xpts, ypts, 4); 202 g.drawPolygon(xpts, ypts, 4); 203 g.drawLine(x, y, x + 3, y + 3); 204 g.drawLine(x, y, x + 3, y - 3); 205 g.drawLine(x, y, x + length, y); 206 break; 207 case HORIZONTAL: 208 g.drawLine(x, y, x + length, y); 209 break; 210 case VERTICAL: 211 g.drawLine(x, y, x, y + length); 212 break; 213 case HORIZONTAL_C: 214 g.drawLine(x - length / 2, y, x + length / 2, y); 215 break; 216 case VERTICAL_C: 217 g.drawLine(x, y - length / 2, x, y + length / 2); 218 break; 219 default: 220 break; 221 } 222 //g.setColor(Color.LIGHT_GRAY); 223 return; 224 } 225 226 void line(Graphics g, int x, int y, int direction, int length, int value, 227 boolean show) { 228 switch (direction) { 229 case RIGHT: 230 line(g, x, y, direction, length); 231 if (show) { 232 g.drawString(MythSimSwing.name(value), x - length + 10, y + 12); 233 } 234 g.drawString("" + Text.binString(s[value]), x - length + 10, y - 2); 235 break; 236 case HORIZONTAL: 237 line(g, x, y, direction, length); 238 if (show) { 239 g.drawString(MythSimSwing.name(value), x - length + 10, y + 12); 240 } 241 g.drawString("" + Text.binString(s[value]), x - length + 10, y - 2); 242 break; 243 default: 244 break; 245 } 246 } 247 248 void downInBus(Graphics g, int x, int y, int value) { 249 line(g, x, y, DOWN, 20); 250 g.drawString(MythSimSwing.name(value), x + 6, y - 6); 251 g.drawString("" + s[value], x - 3, y - 22); 252 } 253 254 void downOutBus(Graphics g, int x, int y, int value) { 255 line(g, x, y, DOWN, 20); 256 g.drawString(MythSimSwing.name(value), x + 6, y - 6); 257 g.drawString("" + s[value], x - 3, y + 12); 258 } 259 260 void rightBus(Graphics g, int x, int y, int value) { 261 line(g, x, y, RIGHT, 80); 262 g.drawString(MythSimSwing.name(value), x - 70, y + 12); 263 g.drawString("" + Text.binString(s[value]), x - 70, y - 2); 264 } 265 266 void horizontalBus(Graphics g, int x, int y, int value) { 267 line(g, x, y, HORIZONTAL, -80); 268 g.drawString(MythSimSwing.name(value), x - 70, y + 12); 269 g.drawString("" + Text.binString(s[value]), x - 70, y - 2); 270 } 271 272 void downInRightBus(Graphics g, int x, int y, int value) { 273 line(g, x - 15, y, VERTICAL, -15); 274 line(g, x, y, RIGHT, 15); 275 g.drawString("" + s[value], x - 12, y - 3); 276 g.drawString(MythSimSwing.name(value), x - 25, y - 20); 277 } 278 279 void downInLeftBus(Graphics g, int x, int y, int value) { 280 line(g, x + 15, y, VERTICAL, -15); 281 line(g, x, y, LEFT, 15); 282 g.drawString("" + s[value], x + 6, y - 3); 283 g.drawString(MythSimSwing.name(value), x + 5, y - 20); 284 } 285 286 void upInRightBus(Graphics g, int x, int y, int l, int value) { 287 if (s[value] == 1) { 288 g.setColor(Color.RED); 289 } 290 line(g, x, y, UP, 10); 291 g.drawString("" + s[value], x - 3, y + 22); 292 //g.drawLine(x,y+24,x,y+24+(l*12)); 293 g.drawLine(x, y + 24, x, y + 14 + (l * 12)); 294 //g.drawString(MythSimSwing.name(value),x+8,y+(l*12)+24); 295 g.drawString(MythSimSwing.name(value), x, y + (l * 12) + 24); 296 g.setColor(Color.LIGHT_GRAY); 297 } 298 299 void upInLeftBus(Graphics g, int x, int y, int l, int value) { 300 if (s[value] == 1) { 301 g.setColor(Color.RED); 302 } 303 line(g, x, y, UP, 10); 304 g.drawString("" + s[value], x - 3, y + 22); 305 //g.drawLine(x,y+24,x,y+24+(l*12)); 306 g.drawLine(x, y + 24, x, y + 14 + (l * 12)); 307 //g.drawString(MythSimSwing.name(value),x-50,y+(l*12)+24); 308 g.drawString(MythSimSwing.name(value), x - 42, y + (l * 12) + 24); 309 g.setColor(Color.LIGHT_GRAY); 310 } 311 312 void regBox(Graphics g, int x, int y, int value) { 313 g.drawRect(x, y - 15, 70, 15); 314 if (hasChanged(value)) { 315 g.setColor(Color.BLUE); 316 } 317 switch (displayBase) { 318 //case 2: g.drawString("" + Text.binString(s[value]),x+6,y-2); break; 319 //case 10: g.drawString("" + s[value],x+6,y-2); break; 320 case 2: 321 g.drawString("" + Text.binString(s[value]), x + 2, y - 2); 322 break; 323 case 10: 324 g.drawString("" + s[value], x + 2, y - 2); 325 break; 326 default: 327 break; 328 } 329 g.setColor(Color.LIGHT_GRAY); 330 g.drawString(MythSimSwing.name(value), x + 2, y + 15); 331 } 332 333 void reg(Graphics g, int x, int y, int value, String a) { 334 if (hasChanged(value)) { 335 g.setColor(Color.BLUE); 336 } 337 switch (displayBase) { 338 case 2: 339 g.drawString(a + Text.binString(s[value]), x, y); 340 break; 341 case 10: 342 g.drawString(a + s[value], x, y); 343 break; 344 default: 345 break; 346 } 347 g.setColor(Color.LIGHT_GRAY); 348 } 349 350 void regBoxRight(Graphics g, int x, int y, int value) { 351 int width = 62; 352 int height = -15; 353 int x1 = x; 354 int x2 = x + width; 355 int y1 = y; 356 int y2 = y + height; 357 g.drawRect(x1, y2, width, height); 358 g.drawString("" + Text.binString(s[value]), x + 2, y - 2); 359 g.drawString(MythSimSwing.name(value), x + 2, y + 15); 360 g.drawLine(x2, y2 + height / 2, x2 + 20, y2 + height); 361 } 362 363 void memRight(Graphics g, int x, int y, int value) { 364 line(g, x, y, RIGHT, 60); 365 g.drawString(MythSimSwing.name(value), x - 50, y - 2); 366 g.drawString("" + s[value], x - 15, y - 2); 367 } 368 369 void memLeft(Graphics g, int x, int y, int value) { 370 line(g, x, y, LEFT, 60); 371 g.drawString(MythSimSwing.name(value), x + 10, y - 2); 372 g.drawString("" + s[value], x + 45, y - 2); 373 } 374 375 void grid(Graphics g) { 376 for (int m = 0; m < 500; m += 10) { 377 if (m % 50 == 0) { 378 g.setColor(new Color(180, 180, 255)); 379 } 380 else { 381 g.setColor(new Color(180, 180, 180)); 382 } 383 g.drawLine(0, m, 600, m); 384 g.drawLine(m, 0, m, 600); 385 } 386 } 387 388 void registerfile(Graphics g, int x, int y) { 389 int width = 100; 390 int height = 125; 391 392 int x1 = x; // 90 393 int x2 = x + (width / 2); // 140 394 int x3 = x + width; // 190 395 396 int y1 = y; // 40 397 int y2 = y + (height / 2); // 102 398 int y3 = y + height; // 165 399 400 401 // VA_SEL 402 if (s[MythSimSwing.A_SEL_SET] == 1 || s[MythSimSwing.RJ_SEL_SET] == 1) { 403 g.setColor(Color.RED); 404 } 405 downInBus(g, x2 - 40, y1, MythSimSwing.VA_SEL_BUS); 406 g.setColor(Color.LIGHT_GRAY); 407 408 // VB_SEL 409 if (s[MythSimSwing.B_SEL_SET] == 1 || s[MythSimSwing.RK_SEL_SET] == 1) { 410 g.setColor(Color.RED); 411 } 412 downInBus(g, x2 + 10, y1, MythSimSwing.VB_SEL_BUS); 413 g.setColor(Color.LIGHT_GRAY); 414 415 // A and B busses on right side of register file 416 if (p[MythSimSwing.A_SEL_SET] == 1 || p[MythSimSwing.RJ_SEL_SET] == 1) { 417 g.setColor(Color.BLUE); 418 } 419 line(g, x3 + 80, y1 + 25, RIGHT, 80, MythSimSwing.A_BUS, true); 420 g.setColor(Color.LIGHT_GRAY); 421 if (p[MythSimSwing.B_SEL_SET] == 1 || p[MythSimSwing.RK_SEL_SET] == 1) { 422 g.setColor(Color.BLUE); 423 } 424 line(g, x3 + 80, y1 + 100, RIGHT, 80, MythSimSwing.B_BUS, true); 425 g.setColor(Color.LIGHT_GRAY); 426 427 // Write Lines on Bottom of Register File 428 upInLeftBus(g, x2 - 40, y3, 1, MythSimSwing.VR0_WRITE_BUS); 429 upInLeftBus(g, x2 - 30, y3, 2, MythSimSwing.VR1_WRITE_BUS); 430 upInLeftBus(g, x2 - 20, y3, 3, MythSimSwing.VR2_WRITE_BUS); 431 upInLeftBus(g, x2 - 10, y3, 4, MythSimSwing.VR3_WRITE_BUS); 432 upInRightBus(g, x2 + 10, y3, 4, MythSimSwing.R4_WRITE); 433 upInRightBus(g, x2 + 20, y3, 3, MythSimSwing.R5_WRITE); 434 upInRightBus(g, x2 + 30, y3, 2, MythSimSwing.R6_WRITE); 435 upInRightBus(g, x2 + 40, y3, 1, MythSimSwing.R7_WRITE); 436 437 // Numbers 438 reg(g, x1 + 2, y1 + 40, MythSimSwing.R_0, "R0: "); 439 reg(g, x1 + 2, y1 + 40 + 12, MythSimSwing.R_1, "R1: "); 440 reg(g, x1 + 2, y1 + 40 + 23, MythSimSwing.R_2, "R2: "); 441 reg(g, x1 + 2, y1 + 40 + 34, MythSimSwing.R_3, "R3: "); 442 reg(g, x1 + 2, y1 + 40 + 45, MythSimSwing.R_4, "R4: "); 443 reg(g, x1 + 2, y1 + 40 + 56, MythSimSwing.R_5, "R5: "); 444 reg(g, x1 + 2, y1 + 40 + 67, MythSimSwing.R_6, "R6: "); 445 reg(g, x1 + 2, y1 + 40 + 78, MythSimSwing.R_7, "R7: "); 446 447 // Register File Box 448 g.setColor(Color.BLACK); 449 g.drawRect(x1, y1, width, height); 450 g.drawString("Registers", x1 + 10, y1 + 20); 451 g.setColor(Color.LIGHT_GRAY); 452 } 453 454 void alu(Graphics g, int x, int y) { 455 int width = 100; 456 int height = 125; 457 458 int x1 = x; // 90 459 int x2 = x + (width / 2); // 140 460 int x3 = x + width; // 190 461 462 int y1 = y; // 40 463 int y2 = y + (height / 2); // 102 464 int y3 = y + height; // 165 465 466 // Register File Title 467 g.setColor(Color.BLACK); 468 g.drawString("ALU", 310, 110); 469 g.drawRect(270, 40, 100, 125); 470 g.setColor(Color.BLUE); 471 g.drawString(MythSimSwing.funcName(p[MythSimSwing.ALU_SEL]),330,60); 472 g.drawString("" + p[MythSimSwing.C_IN],290,60); 473 g.setColor(Color.LIGHT_GRAY); 474 475 476 // ALU 477 478 if (s[MythSimSwing.C_IN_SET] == 1) { 479 g.setColor(Color.RED); 480 } 481 downInBus(g, 280, 40, MythSimSwing.C_IN); 482 g.setColor(Color.LIGHT_GRAY); 483 if (s[MythSimSwing.ALU_SEL_SET] == 1) { 484 g.setColor(Color.RED); 485 } 486 downInBus(g, 280 + 50, 40, MythSimSwing.ALU_SEL); 487 g.drawString("(" + MythSimSwing.funcName(s[MythSimSwing.ALU_SEL]) + ")", 488 338, 18); 489 g.setColor(Color.LIGHT_GRAY); 490 downOutBus(g, 270 + 5, 40 + 125 + 20, MythSimSwing.C_OUT); 491 downOutBus(g, 270 + 50, 40 + 125 + 20, MythSimSwing.M_7); 492 downOutBus(g, 270 + 95, 40 + 125 + 20, MythSimSwing.V); 493 494 } 495 496 class MythMap 497 extends JPanel { 498 MythMap() {} 499 500 public void paintComponent(Graphics g) { 501 super.paintComponent(g); 502 setBackground(Color.WHITE); 503 //grid(g); 504 505 g.setColor(Color.LIGHT_GRAY); 506 //Write the clock in the top right hand corner. 507 //g.drawString("Clock:" + s[MythSimSwing.CLOCK],20,20); 508 registerfile(g, 90, 40); 509 alu(g, 270, 40); 510 511 // Write Back 512 // MUX 513 g.drawLine(40, 280 - 10, 40, 280 + 10); 514 g.drawLine(50, 280 - 20, 50, 280 + 20); 515 g.drawLine(40, 280 - 10, 50, 280 - 20); 516 g.drawLine(40, 280 + 10, 50, 280 + 20); 517 if (s[MythSimSwing.RESULT_SEL_SET] == 1) { 518 g.setColor(Color.RED); 519 } 520 downInBus(g, 40 + 5, 280 - 15, MythSimSwing.RESULT_SEL); 521 g.setColor(Color.LIGHT_GRAY); 522 523 int baseline = 0; 524 525 // IR1 526 baseline = 340; 527 if (s[MythSimSwing.IR1_SEL_SET] == 1) { 528 g.setColor(Color.RED); 529 } 530 downInRightBus(g, 60, baseline - 7, MythSimSwing.IR1_SEL); 531 g.setColor(Color.LIGHT_GRAY); 532 regBox(g, 60, baseline, MythSimSwing.IR_1); 533 534 // IR0 535 if (s[MythSimSwing.IR0_SEL_SET] == 1) { 536 g.setColor(Color.RED); 537 } 538 downInLeftBus(g, 200, baseline - 7, MythSimSwing.IR0_SEL); 539 g.setColor(Color.LIGHT_GRAY); 540 regBox(g, 130, baseline, MythSimSwing.IR_0); 541 542 // MDR 543 if (s[MythSimSwing.MDR_SEL_SET] == 1) { 544 g.setColor(Color.RED); 545 } 546 downInLeftBus(g, 305, baseline - 7, MythSimSwing.MDR_SEL); 547 g.setColor(Color.LIGHT_GRAY); 548 regBox(g, 235, baseline, MythSimSwing.MDR); 549 550 // MAR 551 if (s[MythSimSwing.MAR_SEL_SET] == 1) { 552 g.setColor(Color.RED); 553 } 554 downInLeftBus(g, 405, baseline - 7, MythSimSwing.MAR_SEL); 555 g.setColor(Color.LIGHT_GRAY); 556 regBox(g, 335, baseline, MythSimSwing.MAR); 557 558 // IR0, IR1 and MDR 559 line(g, 370, baseline + 40, HORIZONTAL, -275); 560 line(g, 450, baseline + 40, RIGHT, 80, MythSimSwing.MEMORY_BUS, false); 561 line(g, 95, baseline, UP, 40); 562 line(g, 165, baseline, UP, 40); 563 line(g, 285, baseline, UP, 40); 564 if(p[MythSimSwing.IR1_SEL] == 1) { 565 g.setColor(Color.BLUE); 566 line(g, 95, baseline, UP, 40); 567 line(g, 370, baseline + 40, HORIZONTAL, -275); 568 line(g, 450, baseline + 40, RIGHT, 80, MythSimSwing.MEMORY_BUS, false); 569 g.setColor(Color.LIGHT_GRAY); 570 } 571 if(p[MythSimSwing.IR0_SEL] == 1) { 572 g.setColor(Color.BLUE); 573 line(g, 165, baseline, UP, 40); 574 line(g, 370, baseline + 40, HORIZONTAL, -205); 575 line(g, 450, baseline + 40, RIGHT, 80, MythSimSwing.MEMORY_BUS, false); 576 g.setColor(Color.LIGHT_GRAY); 577 } 578 if(p[MythSimSwing.MDR_SEL] == 1) { 579 g.setColor(Color.BLUE); 580 line(g, 285, baseline, UP, 40); 581 line(g, 370, baseline + 40, HORIZONTAL, -85); 582 line(g, 450, baseline + 40, RIGHT, 80, MythSimSwing.MEMORY_BUS, false); 583 g.setColor(Color.LIGHT_GRAY); 584 } 585 586 // MAR 587 588 line(g, 370, baseline, VERTICAL, 20); 589 line(g, 450, 360, RIGHT, 65); 590 line(g, 450, baseline + 20, RIGHT, 80, MythSimSwing.MAR, false); 591 if(s[MythSimSwing.READ] == 1 || s[MythSimSwing.WRITE] == 1) { 592 g.setColor(Color.RED); 593 line(g, 370, baseline, VERTICAL, 20); 594 line(g, 450, 360, RIGHT, 65); 595 line(g, 450, baseline + 20, RIGHT, 80, MythSimSwing.MAR, false); 596 g.setColor(Color.LIGHT_GRAY); 597 } 598 599 // ==================================================================== 600 // WRITE BACK 601 // ==================================================================== 602 // Result Bus 603 baseline = 280; 604 605 g.setColor(Color.LIGHT_GRAY); 606 line(g, 10, 110, VERTICAL, 170); 607 line(g, 40, 280, HORIZONTAL, -30); 608 line(g, 90, 110, RIGHT, 80, MythSimSwing.RESULT_BUS, true); 609 610 // 1 ALU to Memory Interface 611 g.setColor(Color.LIGHT_GRAY); 612 horizontalBus(g, 370 + 80, 110, MythSimSwing.ALU_BUS); 613 line(g, 450, 110, VERTICAL, 155); 614 line(g, 50, baseline - 15, LEFT, 400); 615 line(g, 280, baseline + 45, DOWN, 60); 616 line(g, 370, baseline + 45, DOWN, 60); 617 g.setColor(Color.LIGHT_GRAY); 618 619 // 2 620 line(g, 50, baseline - 5, LEFT, 210); 621 line(g, 260, baseline + 45, VERTICAL, -50); 622 623 // 3 624 line(g, 50, baseline + 5, LEFT, 132); 625 line(g, 182, baseline + 35, VERTICAL, -30); 626 line(g, 170, baseline + 35, HORIZONTAL, 25); 627 628 // 4 629 line(g, 50, baseline + 15, LEFT, 115); 630 line(g, 165, baseline + 40, VERTICAL, -25); 631 line(g, 165, baseline + 40, HORIZONTAL_C, 70); 632 633 634 g.setColor(Color.LIGHT_GRAY); 635 if ( 636 p[MythSimSwing.VR0_WRITE_BUS] == 1 || 637 p[MythSimSwing.VR1_WRITE_BUS] == 1 || 638 p[MythSimSwing.VR2_WRITE_BUS] == 1 || 639 p[MythSimSwing.VR3_WRITE_BUS] == 1 || 640 p[MythSimSwing.R4_WRITE] == 1 || 641 p[MythSimSwing.R5_WRITE] == 1 || 642 p[MythSimSwing.R6_WRITE] == 1 || 643 p[MythSimSwing.R7_WRITE] == 1 644 ) { 645 g.setColor(Color.BLUE); 646 line(g, 10, 110, VERTICAL, 170); 647 line(g, 40, 280, HORIZONTAL, -30); 648 line(g, 90, 110, RIGHT, 80, MythSimSwing.RESULT_BUS, true); 649 baseline = 280; 650 switch (p[MythSimSwing.RESULT_SEL]) { 651 case MythSimSwing.RESULT_ALU: 652 horizontalBus(g, 370 + 80, 110, MythSimSwing.ALU_BUS); 653 line(g, 450, 110, VERTICAL, 155); 654 line(g, 50, baseline - 15, LEFT, 400); 655 break; 656 case MythSimSwing.RESULT_MDR: 657 line(g, 50, baseline - 5, LEFT, 210); 658 line(g, 260, baseline + 45, VERTICAL, -50); 659 break; 660 case MythSimSwing.RESULT_IR_CONST4: 661 line(g, 50, baseline + 5, LEFT, 132); 662 line(g, 182, baseline + 35, VERTICAL, -30); 663 line(g, 170, baseline + 35, HORIZONTAL, 25); 664 break; 665 case MythSimSwing.RESULT_IR_CONST8: 666 line(g, 50, baseline + 15, LEFT, 115); 667 line(g, 165, baseline + 40, VERTICAL, -25); 668 line(g, 165, baseline + 40, HORIZONTAL_C, 70); 669 break; 670 default: 671 System.out.print("This should never happen."); 672 break; 673 } 674 g.setColor(Color.LIGHT_GRAY); 675 } 676 677 // 1 678 if (p[MythSimSwing.MAR_SEL] == 1) { 679 g.setColor(Color.BLUE); 680 horizontalBus(g, 370 + 80, 110, MythSimSwing.ALU_BUS); 681 line(g, 450, 110, VERTICAL, 155); 682 //line(g, 50, baseline - 15, LEFT, 400); 683 g.drawLine(370, baseline - 15, 370 + 80, baseline - 15); 684 //line(g, 370, baseline - 15, LEFT, 80); 685 line(g, 370, baseline + 45, DOWN, 60); 686 g.setColor(Color.LIGHT_GRAY); 687 688 } 689 690 691 692 // Memory Lines 693 if (s[MythSimSwing.READ_SET] == 1) { 694 g.setColor(Color.RED); 695 } 696 memRight(g, 450, 40, MythSimSwing.READ); 697 g.setColor(Color.LIGHT_GRAY); 698 if (s[MythSimSwing.WRITE_SET] == 1) { 699 g.setColor(Color.RED); 700 } 701 memRight(g, 450, 60, MythSimSwing.WRITE); 702 g.setColor(Color.LIGHT_GRAY); 703 memLeft(g, 390, 80, MythSimSwing.WAIT); 704 705 } 706 } 707 708 }

This page was automatically generated by Maven