计算机体系结构实验-单功能流水线调度机构模拟

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
if(Integer.parseInt(timeslice) == 1) {
new Painting(200, 380, 25, 20, Color.gray, "ED1", true).draw(g);
}
if(Integer.parseInt(timeslice) == 2) {
new Painting(200, 380, 25, 20, Color.gray, "ED1", true).draw(g);
JOptionPane.showOptionDialog(null, "你的输入存在“”,请按提示输入!", "警告",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
}
timeslice = jtf2.getText();
jta1.append("---------------------Deno the pipline for float point add.---------------------\n");
jta1.append("-----------------We want to execute 5 float poing instructions-----------------\n");
//Label jlabel2;
TextArea jta1;
TextField jtf2;
//TextField jtf3;
Button jb_input;
//Button run;
JScrollPane jsp;
JTable jt;
DefaultTableModel dtm;
static String timeslice;
程序通过模拟单功能流水线调度过程,掌握流水线技术,学会计算流水线的吞吐率、
加速比、效率。
1流水线的表示法有三种:
连接图、时空图、预约表。对于线性流水线,主要考虑前二种。
2流水线的主要特点:
在流水线的每一个功能部件的后面都要有一个缓冲器,称为锁存器、闸门寄存器等,
它的作用是保存本流水段的执行结果。各流水段的时间应尽量相等,否则回引起阻塞、
t源自文库y {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public void paint(Graphics g) {
new Painting(50, 280, 500, 180, Color.orange, "", true).draw(g);
jb_input.setBounds(450, 50, 60, 20);
//run.setBounds(450, 260, 100, 20);
this.add(jlabel1);
//this.add(jlabel2);
this.add(jta1);
this.add(jtf2);
//this.add(jtf3);
public void lauchFrame() {
this.setLayout(null);
this.setBounds(100, 100, 600, 500);
this.setBackground(Color.cyan);
this.setVisible(true);
jlabel1 = new Label("请输入时间t:");
newPainting(225, 380, 25, 20, Color.gray, "ED2",true).draw(g);
newPainting(250, 380, 25, 20, Color.gray, "ED3",true).draw(g);
newPainting(225, 360, 25, 20, Color.gray, "EA1",true).draw(g);
CENTRAL SOUTH UNIVERSITY
计算机体系结构实验报告
题目单功能流水线调度机构模拟
一、实验目的
结合数据结构的相关知识,编写流水线调度模拟程序。
二、实验环境
Eclipse IDE for Java Developers(Version: Kepler Release)
Win7
三、实验内容
new Painting(150, 400, 450, 400, Color.red, "", false).draw(g);
new Painting(200, 300, 200, 430, Color.red, "", false).draw(g);
if(timeslice != null && Integer.parseInt(timeslice) <= 8) {
jlabel1.setBounds(50, 50, 110, 20);
//jlabel2.setBounds(230, 50, 90, 20);
jta1.setBounds(50, 100, 500, 150);
jtf2.setBounds(170, 50, 70, 20);
//jtf3.setBounds(330, 50, 90, 20);
public class waterline extends Frame {
public static void main(String[] args) {
waterline lruc = new waterline();
lruc.lauchFrame();
}
Graphics g;
Label jlabel1;
jta1.append(jtf2.getText() + "\n");
jtf2.setText("");
}
}
class RunActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
new Thread(new TextAreaThread()).start();
//jlabel2 = new Label("请输入设备内容:");
jta1 = new TextArea();
jtf2 = new TextField();
//jtf3 = new TextField();
jb_input = new Button("确定");
//run = new Button("运行通道管理器");
jb_input.addActionListener(new RunActionListener());
jta1.addKeyListener(new TextAreaThread());
g = this.getGraphics();
new Thread(new PaintThread()).start();
}
g.setColor(Color.red);
g.drawString(s, x+2, y+15);
g.setColor(c);
}
}
private class PaintThread implements Runnable {
public void run() {
while(true) {
repaint();
五、运行截图及源代码
输入为空的时候:
输入超出规定范围的时候:
输入正常的范围,比如t=8的时候的流水线时空图:
源代码:
package waterline;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.color = color;
this.s = s;
this.flag = flag;
}
public void draw(Graphics g) {
Color c = g.getColor();
new Painting(200, 380, 25, 20, Color.gray, "ED1", true).draw(g);
new Painting(225, 380, 25, 20, Color.gray, "ED2", true).draw(g);
new Painting(250, 380, 25, 20, Color.gray, "ED3", true).draw(g);
new Painting(225, 380, 25, 20, Color.gray, "ED2", true).draw(g);
new Painting(225, 360, 25, 20, Color.gray, "EA1", true).draw(g);
}
if(Integer.parseInt(timeslice) == 3) {
}
class InputActionListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
if(jtf2.getText().equals("")) {
Object[] options = { "OK" };
断流等。只有连续提供同类任务才能充分发挥流水线的效率。在流水线的每一个流水线
段中都要设置一个流水锁存器。流水线需要有“装入时间”和“排空时间”。只有流水线完
全充满时,整个流水线的效率才能得到充分发挥。
四、关键代码
//构筑主窗体大小颜色:
publicvoidlauchFrame() {
this.setLayout(null);
}
}
class Painting {
int x, y, width, height;
Color color;
String s;
Boolean flag;
public Painting(int x, int y,int width, int height, Color color, String s, Boolean flag) {
this.add(jb_input);
//this.add(run);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
jb_input.addActionListener(new InputActionListener());
g.setColor(color);
if(flag == true) {
g.fillRect(x, y, width, height);
g.setColor(Color.red);
g.drawRect(x, y, width, height);
} else if(flag == false) {
g.drawLine(x, y, width, height);
this.setBounds(100, 100, 600, 500);
this.setBackground(Color.cyan);
this.setVisible(true);
//当输入为3时,显示的是此时的流水线
if(Integer.parseInt(timeslice) == 3) {
newPainting(200, 380, 25, 20, Color.gray, "ED1",true).draw(g);
newPainting(250, 360, 25, 20, Color.gray, "EA2",true).draw(g);
newPainting(250, 340, 25, 20, Color.gray, "MA1",true).draw(g);
}
这个程序运行的流水线的模拟,依靠的是Java对于界面的编写,流水线的时空图并不是由程序得出,而是由预先设计好的时空图通过编程输出为图像。比如这个当输入为3时,时空图中有6块,每块用new Painting输出。
jta1.append("Here, we display all the content in the pipline:\n");
jta1.append("Please input a time slice:\n");
//jta1.append(" " + NL[0] + " " + NL[1] + " " + NL[2]);
相关文档
最新文档