计算机组成原理课程设计综述Word格式文档下载.docx
《计算机组成原理课程设计综述Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《计算机组成原理课程设计综述Word格式文档下载.docx(39页珍藏版)》请在冰点文库上搜索。
,"
警告"
JOptionPane.WARNING_MESSAGE);
text1.setText(null);
if(m>
3){
您三次口令错误,确定后退出!
JOptionPane.ERROR_MESSAGE);
System.exit(0);
(2)选择主窗体中“定点整数真值还原”时进入下图所示的窗体:
if(e.getSource()==button2){
com=(Component)e.getSource();
e=SwingUtilities.convertMouseEvent(com,e,this);
Strings=text1.getText();
booleanboo=s.startsWith("
0"
0);
if(boo==true){n1=s.length();
s1=s.substring(1,n1);
text2.setText("
+"
+s1);
n1=s.length();
-"
if(e.getSource()==button3){
s=text1.getText();
chara[]=s1.toCharArray();
for(i=0;
i<
=a.length-1;
i++){
if(a[i]=='
0'
)
a[i]='
1'
;
elseif(a[i]=='
if(e.getSource()==button4){
j=s1.lastIndexOf("
1"
)+1;
s1=s.substring(1,j);
在上面的窗体中按“输入”按扭时,将输入焦点设置为最上面的一个文本框上。
输入一个定点整数形式的机器数(如101010或011010)后,按“原真值”、“反真值”、“补真值”或“移真值”按扭中的任一个后,将在第二个文本框中显示对应的真值。
选择“返回”按扭时回到主窗体。
(3)选择主窗体中“定点整数单符号位补码加减法”时进入下图所示的窗体:
if(i1.length!
=i2.length)
data1.setText("
请输入数值位长度相等的数字!
);
out=jia(i1,i2);
output=newString(out);
data2.setText(output);
out=jian(i1,i2);
data3.setText(output);
在上面的窗体中按“输入”按钮时,将输入焦点设置为最上面的两个文本框。
输入第一个、第二个数的补码,按“加法”、“减法”按钮中的任一个,在第三、第四文本框中显示对应的补码结果。
选择“返回”按钮时回到主窗口。
(4)选择主窗体中“定点整数原码乘法”时进入下图所示的窗体:
for(inti=beichengshu.length();
i>
0;
i--)//按照乘数各个位判别
{
if(in2[i]=='
){
str[i]=newString(c)+newString(c);
elseif(in2[i]=='
str[i]=beichengshu+newString(c);
for(inti=1;
=beichengshu.length();
i++)//实现右移操作
intk;
char[]buwei=newchar[i];
for(k=0;
k<
i;
k++)
buwei[k]='
str[i]=newString(buwei)
+str[i].substring(0,str[i].length()-i);
输入一位符号位的被乘数和一位符号位的乘数,按“乘法”按钮,在第三个文本框中显示对应的一位符号位的乘法结果。
(5)选择主窗体中“浮点加减法”时进入下图所示的窗体:
if((sj1.length()!
=sj2.length())||(st1.length()!
=st2.length())){JOptionPane.showMessageDialog(this,"
请输入长度相等的数据!
错误"
JOptionPane.ERROR_MESSAGE);
Strings[]=myAdd(sj1,sj2,st1,st2);
data4.setText(s[0]);
data5.setText(s[1].substring(0,1)+"
0."
+s[1].substring
(1));
temp=st2.substring(0,st2.lastIndexOf("
));
charc[]=temp.toCharArray();
for(inti=0;
c.length;
if(c[i]=='
c[i]='
else
在上面的窗体中按“输入”按钮时,将输入焦点设置为最上面的四个文本框。
分别输入第一个数和第二个数的阶码,按“加法”或者“减法”按钮,在下面四个文本框中显示结果。
4设计小结
这次计算机组成原理课程设计使我的能力得到了很大的提高,此外使我对本学期所学的计算机组成原理的知识得到了提高,加深了对计算机工作原理的认识,我也体会到了作为一个大学生,要想学有所得,就得学习主动,不要什么都希望别人亲自传授,面对问题要自己去努力解决,多问问身边的同学,多动手查查,多上网找找,所以要想成功就得事事做到细心,耐心,恒心。
当然,在这个过程中,也有许多问题与困难出现。
有的经过自己的思考或与他人合作能得以解决,有的也的确费了一些周折。
但无论如何,这次对于课题的能够实现机器数的真值还原(定点整数)、定点整数的单符号位补码加减运算、定点整数乘法运算和浮点数的加减运算的设计总体来说还是比较令人满意的,不仅用到了课堂上所学到的知识,还加入了自己的一些想法与观点,而且在对编程这一方面也有了很多新的感悟与提高。
不得不说是获益良多。
参考文献
[1]白中英.计算机组成原理(第四版)[M].北京:
科学出版社,2010.
[2]黄理,洪亮,曹林有,张勇.JSP高级编程[M].北京:
北京希望电子出版社,2001.
[3]连洪武.EclipseWeb开发从入门到精通(实例版)[M].北京:
清华大学出版社,2007.
[4]王国辉、李立文.JSP数据库系统开发完全手册[M].北京:
人民邮电出版社,2006.
源程序
MainFrame.java
publicclassMainFrame{
publicstaticvoidmain(Stringargs[]){newNewclass(null);
Newclass.javaimportjava.awt.*;
importjava.awt.event.*;
importjavax.swing.JOptionPane;
publicclassNewclassextendsFrameimplementsActionListener{staticinti=0;
staticintm=1;
Labela1,a2,a22;
TextFieldtext1;
Buttonbutton1,m1,m2,m3,m4;
Fontf;
Newclass(Strings){super(s);
setLayout(null);
f=newFont("
楷体"
Font.BOLD,20);
m1=newButton("
机器数的真值还原(定点整数)"
m2=newButton("
定点整数单符号位补码加减运算"
m3=newButton("
定点整数的原码乘法"
m4=newButton("
浮点数的加减运算"
m1.addActionListener(this);
m2.addActionListener(this);
m3.addActionListener(this);
m4.addActionListener(this);
m1.setBounds(10,30,160,25);
m2.setBounds(175,30,190,25);
m3.setBounds(370,30,120,25);
m4.setBounds(495,30,95,25);
add(m1);
add(m2);
add(m3);
add(m4);
a1=newLabel("
计算机组成原理算法实现(五)"
Label.CENTER);
a2=newLabel("
输入口令(000):
a22=newLabel("
登陆成功"
a1.setBounds(150,100,300,40);
a1.setBackground(Color.WHITE);
a1.setFont(f);
a2.setBounds(150,200,90,25);
a2.setBackground(Color.white);
a22.setBounds(200,200,200,25);
a22.setForeground(Color.white);
a22.setBackground(Color.green);
a22.setVisible(false);
text1=newTextField(18);
text1.setEchoChar('
*'
text1.setBounds(240,200,200,25);
button1=newButton("
确认"
button1.setBounds(270,250,70,30);
button1.addActionListener(this);
add(a1);
add(a2);
add(a22);
add(text1);
add(button1);
setBackground(Color.white);
setBounds(100,100,640,400);
setVisible(true);
validate();
addWindowListener(newWindowAdapter(){publicvoidwindowClosing(WindowEvente){
});
publicstaticvoidmain(Stringargs[]){newNewclass("
计算机组成原理"
publicvoidactionPerformed(ActionEvente){
Strings=newString("
000"
if(e.getSource()==button1){
while(i==0&
&
m<
=3&
(!
(text1.getText().equals("
)))){if(text1.getText().equals(s)){
}else{
if(i==1){
if(e.getSource()==m1){Ljyss1=newLjys();
s1.setVisible(true);
}elseif(e.getSource()==m2){
Zhengshujiajianf1=newZhengshujiajian();
f1.setTitle("
f1.setVisible(true);
}elseif(e.getSource()==m3){
Zhengshuchengfaf2=newZhengshuchengfa();
f2.setTitle("
f2.setVisible(true);
}elseif(e.getSource()==m4){Fdysf5=newFdys();
f5.setVisible(true);
Ljys.java
importjavax.swing.*;
importjava.awt.*;
importjava.awt.event.*;
importjavax.swing.SwingUtilities;
importjava.awt.TextField;
classLjysextendsFrameimplementsMouseListener{Buttonbutton1;
Buttonbutton2;
Buttonbutton3;
Buttonbutton4;
Buttonbutton5;
Buttonbutton6;
Labellabel1;
Labellabel2;
Labellabel3;
Labellabel4;
Labellabel5;
Labellabel6;
Labellabel7;
TextFieldtext2;
TextFieldtext3;
Strings,s1,temp;
intn1,i,j;
chara[];
publicLjys(){
setTitle("
button1=newButton("
输入"
button2=newButton("
原-->
真值"
button3=newButton("
反-->
button4=newButton("
补-->
button5=newButton("
移-->
button6=newButton("
返回"
label1=newLabel("
Fontf1=newFont("
Font.TRUETYPE_FONT,25);
label1.setFont(f1);
label2=newLabel("
请输入机器数:
label3=newLabel("
真值还原结果为:
text1=newTextField(8);
text2=newTextField(10);
text2.setEditable(false);
BoxbaseBox,box1,box2,box3,box4,box5;
box1=Box.createHorizontalBox();
box1.add(label1);
box2=Box.createHorizontalBox();
box2.add(label2);
box2.add(Box.createHorizontalStrut(10));
box2.add(text1);
box3=Box.createHorizontalBox();
box3.add(label3);
box3.add(Box.createHorizontalStrut(10));
box3.add(text2);
box4=Box.createHorizontalBox();
box5=Box.createHorizontalBox();
box5.add(button1);
box5.add(Box.createHorizontalStrut(20));
box5.add(button2);
box5.add(Box.createHorizontalStrut(10));
box5.add(button3);
box5.add(button4);
box5.add(button5);
box5.add(button6);
baseBox=Box.createVerticalBox();
baseBox.add(box1);
baseBox.add(Box.createVerticalStrut(10));
baseBox.add(box2);
baseBox.add(Box.createVerticalStrut(10));
baseBox.add(box3);
baseBox.add(box4);
baseBox.add(box5);
setLayout(newFlowLayout());
add(baseBox);
text1.addMouseListener(this);
text2.addMouseListener(this);
button1.addMouseListener(this);
button2.addMouseListener(this);
button3.addMouseListener(this);
button4.addMouseListener(this);
button5.addMouseListener(this);
but