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 21 package org.mythsim.text; 22 23 import org.mythsim.core.*; 24 /*** 25 * Printing Functions. 26 * @author Jason Vroustouris 27 */ 28 public class Text { 29 static public final String[] columnNames = {"ADDR", 30 "r<k>write","Asel","Bsel","RIsel","RJsel","RKsel", 31 "Cin","alusel","mdrsel","marsel","resultsel","ir0sel", 32 "ir1sel","read","write","indexsel","cond","addrT","addrF"}; 33 34 35 36 37 38 39 /* static void ustore(int a[][]) { 40 System.out.println(" r"); 41 System.out.println(" e i"); 42 System.out.println(" s n"); 43 System.out.println(" a m m u d"); 44 System.out.println(" r r r l d a l r r e"); 45 System.out.println(" a b i j k u r r t 0 1 w x"); 46 System.out.println(" r r c"); 47 System.out.println(" s s s s s c s s s s s s e i s o"); 48 System.out.println(" r<k>write e e e e e i e e e e e e a t e n addr addr"); 49 System.out.println("addr 7654 3210 l l l l l n l l l l l l d e l d true false"); 50 System.out.println("---------------------------------------------------------------------------"); 51 for (int i=0; i<a.length; i++) { 52 if (i % 5 == 0 && i != 0) System.out.println(""); 53 if (i < 10) System.out.print("0"); 54 if (i < 100) System.out.print("0"); 55 if (i < 1000) System.out.print("0"); 56 System.out.print(i); 57 System.out.print(" "); 58 System.out.print(a[i][ControlWord.R7_WRITE]); 59 System.out.print(a[i][ControlWord.R6_WRITE]); 60 System.out.print(a[i][ControlWord.R5_WRITE]); 61 System.out.print(a[i][ControlWord.R4_WRITE]); 62 System.out.print(" "); 63 System.out.print(a[i][ControlWord.R3_WRITE]); 64 System.out.print(a[i][ControlWord.R2_WRITE]); 65 System.out.print(a[i][ControlWord.R1_WRITE]); 66 System.out.print(a[i][ControlWord.R0_WRITE]); 67 System.out.print(" "); 68 System.out.print(a[i][ControlWord.A_SEL]); 69 System.out.print(" "); 70 System.out.print(a[i][ControlWord.B_SEL]); 71 System.out.print(" "); 72 System.out.print(a[i][ControlWord.RI_SEL]); 73 System.out.print(" "); 74 System.out.print(a[i][ControlWord.RJ_SEL]); 75 System.out.print(" "); 76 System.out.print(a[i][ControlWord.RK_SEL]); 77 System.out.print(" "); 78 System.out.print(a[i][ControlWord.C_IN]); 79 System.out.print(" "); 80 System.out.print(a[i][ControlWord.ALU_SEL]); 81 System.out.print(" "); 82 System.out.print(a[i][ControlWord.MDR_SEL]); 83 System.out.print(" "); 84 System.out.print(a[i][ControlWord.MAR_SEL]); 85 System.out.print(" "); 86 System.out.print(a[i][ControlWord.RESULT_SEL]); 87 System.out.print(" "); 88 System.out.print(a[i][ControlWord.IR0_SEL]); 89 System.out.print(" "); 90 System.out.print(a[i][ControlWord.IR1_SEL]); 91 System.out.print(" "); 92 System.out.print(" "); 93 System.out.print(a[i][ControlWord.READ]); 94 System.out.print(" "); 95 System.out.print(a[i][ControlWord.WRITE]); 96 System.out.print(" "); 97 System.out.print(a[i][ControlWord.INDEX_SEL]); 98 System.out.print(" "); 99 System.out.print(a[i][ControlWord.COND]); 100 System.out.print(" "); 101 if (a[i][ControlWord.ADDRESS_TRUE] < 10) System.out.print("0"); 102 if (a[i][ControlWord.ADDRESS_TRUE] < 100) System.out.print("0"); 103 if (a[i][ControlWord.ADDRESS_TRUE] < 1000) System.out.print("0"); 104 System.out.print(a[i][ControlWord.ADDRESS_TRUE]); 105 System.out.print(" "); 106 if (a[i][ControlWord.ADDRESS_FALSE] < 10) System.out.print("0"); 107 if (a[i][ControlWord.ADDRESS_FALSE] < 100) System.out.print("0"); 108 if (a[i][ControlWord.ADDRESS_FALSE] < 1000) System.out.print("0"); 109 System.out.print(a[i][ControlWord.ADDRESS_FALSE]); 110 System.out.println(""); 111 } 112 113 }*/ 114 public static void memory(int a[]) { 115 for (int i=0; i<a.length; i++) { 116 System.out.println(i + ": " + a[i]); 117 } 118 } 119 public static void registers(int a[]) { 120 System.out.print(" r0: " + a[MythSim.R_0]); 121 System.out.print(" r4: " + a[MythSim.R_4]); 122 System.out.println(" ir0: " + a[MythSim.IR_0]); 123 124 System.out.print(" r1: " + a[MythSim.R_1]); 125 System.out.print(" r5: " + a[MythSim.R_5]); 126 System.out.println(" ir1: " + a[MythSim.IR_1]); 127 128 System.out.print(" r2: " + a[MythSim.R_2]); 129 System.out.print(" r6: " + a[MythSim.R_6]); 130 System.out.println(" mdr: " + a[MythSim.MDR]); 131 132 System.out.print(" r3: " + a[MythSim.R_3]); 133 System.out.print(" r7: " + a[MythSim.R_7]); 134 System.out.println(" mar: " + a[MythSim.MAR]); 135 } 136 137 public static void small(int a[]) { 138 139 System.out.print (" CLK:" + tci(a[MythSim.CLOCK])); 140 System.out.print ("ADDR:" + tci(a[MythSim.CURRENT_ADDRESS])); 141 System.out.println(" ir0:" + tci(a[MythSim.IR_0])); 142 143 System.out.print (" r0:" + tci(a[MythSim.R_0])); 144 System.out.print (" r4:" + tci(a[MythSim.R_4])); 145 System.out.println(" ir0:" + tci(a[MythSim.IR_0])); 146 147 System.out.print (" r1:" + tci(a[MythSim.R_1])); 148 System.out.print (" r5:" + tci(a[MythSim.R_5])); 149 System.out.println(" ir1:" + tci(a[MythSim.IR_1])); 150 151 System.out.print (" r2:" + tci(a[MythSim.R_2])); 152 System.out.print (" r6:" + tci(a[MythSim.R_6])); 153 System.out.println(" mdr:" + tci(a[MythSim.MDR])); 154 155 System.out.print (" r3:" + tci(a[MythSim.R_3])); 156 System.out.print (" r7:" + tci(a[MythSim.R_7])); 157 System.out.println(" mar:" + tci(a[MythSim.MAR])); 158 for (int i=18; i<=43; i++) { 159 System.out.println(MythSim.name(i) + ":" + a[i]); 160 } 161 162 163 System.out.println(""); 164 165 166 } 167 168 public static String tci(int i) { 169 String temp = ("" + i); 170 if (i < 0) { 171 if (i > -10) temp += " "; 172 if (i > -100) temp += " "; 173 } else { 174 temp += " "; 175 if (i < 10) temp += " "; 176 if (i < 100) temp += " "; 177 } 178 return temp; 179 } 180 181 public static String address(int value) { 182 String temp = ""; 183 if (value < 10) temp+="0"; 184 if (value < 100) temp+="0"; 185 if (value < 1000) temp+="0"; 186 temp += value; 187 return temp; 188 } 189 190 191 public static String binString(int i) { 192 String temp = new String(); 193 int a = i; 194 if (a < 0) {temp+="1"; a+=128;} else {temp+="0";} 195 if (a >= 64) {temp+="1"; a-=64; } else {temp+="0";} 196 if (a >= 32) {temp+="1"; a-=32; } else {temp+="0";} 197 if (a >= 16) {temp+="1"; a-=16; } else {temp+="0";} 198 temp+=" "; 199 if (a >= 8) {temp+="1"; a-=8; } else {temp+="0";} 200 if (a >= 4) {temp+="1"; a-=4; } else {temp+="0";} 201 if (a >= 2) {temp+="1"; a-=2; } else {temp+="0";} 202 if (a >= 1) {temp+="1"; a-=1; } else {temp+="0";} 203 if (a == 0) {return temp;} else {return "(invalid " + i + ")";} 204 } 205 206 public static String int2bin(int i) { 207 String temp = new String(); 208 int a = i; 209 if (a < 0) {temp+="1"; a+=128;} else {temp+="0";} 210 if (a >= 64) {temp+="1"; a-=64; } else {temp+="0";} 211 if (a >= 32) {temp+="1"; a-=32; } else {temp+="0";} 212 if (a >= 16) {temp+="1"; a-=16; } else {temp+="0";} 213 temp+=" "; 214 if (a >= 8) {temp+="1"; a-=8; } else {temp+="0";} 215 if (a >= 4) {temp+="1"; a-=4; } else {temp+="0";} 216 if (a >= 2) {temp+="1"; a-=2; } else {temp+="0";} 217 if (a >= 1) {temp+="1"; a-=1; } else {temp+="0";} 218 if (a == 0) {return temp;} else {return "(invalid " + i + ")";} 219 } 220 221 222 }

This page was automatically generated by Maven