⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.~pas

📁 动态调度算法实验
💻 ~PAS
📖 第 1 页 / 共 4 页
字号:
        Store[i].Address:='';
        Store[i].Qi.data:='';
    end;
  end;

end;

procedure TForm1.CheckStartCount;
var i:integer;
begin
  for i:=1 to RSSIZE do
  if (RS[i].Busy) and (RS[i].Qj.status=AVAILABLE) and (RS[i].Qk.status=AVAILABLE)
  then
  RS[i].StartCount:=true;
end;

procedure Tform1.RefreshInstrGrid;
var i:integer;
begin
   { Refresh StatusGrid }
  for i:=1 to InstrNum do
  begin
    InstructionGrid.Cells[0,i]:=Instr[i].Name;
    InstructionGrid.Cells[1,i]:=Instr[i].OpDest.data;
    InstructionGrid.Cells[2,i]:=Instr[i].OpSourcej.data;
    InstructionGrid.Cells[3,i]:=Instr[i].OpSourcek.data;
  end;
  InstrNumLabel.Caption:=inttostr(Instrnum);
end;

procedure TForm1.ADDInstrFromInput(opname:string; di,sj,sk:string);
var i:integer;
begin
  inc(InstrNum);
  with Instr[InstrNum] do
  begin
    completed:=false;
    Name:=opname;
    OP:=InstructionType(InputDlg1.OpNameComboBox.ItemIndex);
    ////////////////
    OpDest.data:=di;
    if di[1]='F' then
    begin
       OpDest.Optype:=FUTYPE;
       OpDest.index:=strtoint(copy(di,2,length(di)-1));
       OpDest.value:=FU[OpDest.index].value;
       OpDest.fvalue:=FU[OpDest.index].fvalue;
    end
    else
    if di[1]='R' then
    begin
       OpDest.Optype:=RUTYPE;
       OpDest.index:=strtoint(copy(di,2,length(di)-1));
       OpDest.value:=RU[OpDest.index].value;
    end
    else
    if di[1] in ['0'..'9','+','-','.'] then
    begin
       OpDest.Optype:=IMMTYPE;
       OpDest.value:=strtoint(di);
    end;// else error process;
    //////////////
    OpSourcej.data:=Sj;
    if sj[1]='F' then
    begin
       OpSourcej.Optype:=FUTYPE;
       OpSourcej.index:=strtoint(copy(sj,2,length(sj)-1));
       OpSourcej.value:=FU[OpSourcej.index].value;
       OpSourcej.fvalue:=FU[OpSourcej.index].fvalue;
    end
    else
    if sj[1]='R' then
    begin
       OpSourcej.Optype:=RUTYPE;
       OpSourcej.index:=strtoint(copy(sj,2,length(sj)-1));
       OpSourcej.value:=RU[OpSourcej.index].value;
    end
    else
    if Sj[1] in ['0'..'9','+','-','.'] then
    begin
       OpSourcej.Optype:=IMMTYPE;
       OpSourcej.value:=strtoint(Sj);
       OpSourcej.fvalue:=strtofloat(Sj); //?
    end;// else error process;
    ///////////
    OpSourcek.data:=Sk;
    if sk[1]='F' then
    begin
       OpSourcek.Optype:=FUTYPE;
       OpSourcek.index:=strtoint(copy(sk,2,length(sk)-1));
       OpSourcek.value:=FU[OpSourcek.index].value;
       OpSourcek.fvalue:=FU[OpSourcek.index].fvalue;
    end
    else
    if sk[1]='R' then
    begin
       OpSourcek.Optype:=RUTYPE;
       OpSourcek.index:=strtoint(copy(sk,2,length(sk)-1));
       OpSourcek.value:=RU[OpSourcek.index].value;
       OpSourcek.fvalue:=RU[OpSourcek.index].fvalue;
    end
    else
    if Sk[1] in ['0'..'9','+','-','.'] then
    begin
       OpSourcek.Optype:=IMMTYPE;
       OpSourcek.value:=strtoint(Sk);
       OpSourcek.fvalue:=strtofloat(Sk);
    end;// else error process;
  end;

  RefreshInstrGrid;
end;
{
procedure TForm1.AddInstrClick(Sender: TObject);
begin
  InputDlg1.Show;
end;
}
procedure TForm1.StartClick(Sender: TObject);
begin
  PC:=1;
  NextClockClick(Sender);
end;

procedure TForm1.SetRUMenuClick(Sender: TObject);
begin
  SetValuedlg1.RegSetRadio.Checked:=true;
  SetValuedlg1.MemSetRadio.Checked:=false;
  SetValueDlg1.Show;
end;

procedure TForm1.SetMemMenuClick(Sender: TObject);
begin
  SetValuedlg1.RegSetRadio.Checked:=false;
  SetValuedlg1.MemSetRadio.Checked:=true;
  SetValueDlg1.Show;
end;

procedure Tform1.RefreshRU;
var i:integer;
begin
  { Refresh RU Grid }
  for i:=0 to RUSIZE do
  begin
    RUGrid.Cells[i,1]:=floattostr(RU[i].value);
  end;
end;
procedure Tform1.RefreshFU;
var i:integer;
begin
 { Refresh FU Grid }
  for i:=0 to FUSIZE do
  begin
    FUGrid.Cells[i,0]:='F'+inttostr(i);
    FUGrid.Cells[i,1]:=FU[i].data;
    FUGrid.Cells[i,2]:=floattostr(FU[i].fvalue);
  end;
end;

procedure Tform1.RefreshMem;
var i:integer;
begin
  for i:=1 to MemNum do
  begin
    MemGrid.Cells[i-1,0]:=inttostr(Mem[i].Address);
    MemGrid.Cells[i-1,1]:=floattostr(Mem[i].fvalue);
  end;
end;

procedure TForm1.NoValueMenuClick(Sender: TObject);
begin
  ModeFlag:=NOVALUE;
  NoValueMenu.Checked:=true;
  NoValueMenu.Default:=true;
  ValueMenu.Checked:=false;
  ValueMenu.Default:=false;
end;

procedure TForm1.ValueMenuClick(Sender: TObject);
begin
  ModeFlag:=VALUE;
  ValueMenu.Checked:=true;
  ValueMenu.Default:=true;
  NoValueMenu.Checked:=false;
  NoValueMenu.Default:=false;
end;

procedure TForm1.ClearInstrMenuClick(Sender: TObject);
var i,j:integer;
begin
  for i:=1 to InstrNum do
  begin
    InstructionGrid.Cells[0,i]:='';
    InstructionGrid.Cells[1,i]:='';
    InstructionGrid.Cells[2,i]:='';
    InstructionGrid.Cells[3,i]:='';
    StatusGrid.Cells[0,i]:='';
    StatusGrid.Cells[1,i]:='';
    StatusGrid.Cells[2,i]:='';
    StatusGrid.Cells[3,i]:='';
    Instr[i].completed:=false;
    Instr[i].Name:='';
    Instr[i].Issue:=0;
    Instr[i].ExecutionComplete:=0;
    Instr[i].WriteResult:=0;
  end;
  InstrNum:=0;
  InstrNumLabel.Caption:=inttostr(Instrnum);
  PC:=0;
  Clock.clearclock;
  for i:=1 to LOADSIZE do
  begin
    Load[i].Busy:=false;
    Load[i].Address:='';
    Load[i].AddressValue:=0;
    Load[i].Time:=0;
    Load[i].complete:=false;
    Load[i].AddressValue:=0;
  end;

  for i:=1 to STORESIZE do
  begin
    Store[i].Busy:=false;
    Store[i].Address:='';
    Store[i].complete:=false;
    Store[i].Qi.Status:=AVAILABLE;
  end;

  for i:=1 to RSSIZE do
  begin
    RS[i].Busy:=false;
    RS[i].StartCount:=false;
    RS[i].Vj.data:='';
    RS[i].Vj.Status:=NONAVAILABLE;
    RS[i].Vk.data:='';
    RS[i].Vk.Status:=NONAVAILABLE;
    RS[i].Qj.data:='';
    RS[i].Qk.data:='';
    for j:=0 to 9 do
    ReservationGrid.cells[j,i]:='';
  end;
  for i:=1 to RSSIZE do
  ReservationGrid.cells[1,i]:=RS[i].Name;

  for i:=0 to FUSIZE do
  begin
    FU[i].data:='';
    FU[i].Status:=AVAILABLE;
  end;

  RefreshIssue;
end;

procedure TForm1.DefaulInputClick(Sender: TObject);
var i:integer;
begin
  if (InstrNum>0) then exit;
  with Instr[1] do
  begin
    Completed:=false;
    Name:='LD';
    OP:=LD;
    OpDest.data:='F6';
    OpDest.OpType:=FUTYPE;
    OpDest.index:=6;

    OpSourcej.data:='34';
    OpSourcej.OpType:=IMMTYPE;
    OpSourcej.value:=34;

    OpSourcek.data:='R2';
    OpSourcek.OpType:=RUTYPE;
    OpSourcek.index:=2;
    Issue:=0;
    ExecutionComplete:=0;
    WriteResult:=0;
    InstrGridAdd(1,Name,OpDest.data,OpSourcej.data,OpSourcek.data);
  end;
  with Instr[2] do
  begin
    Completed:=false;
    Name:='LD';
    OP:=LD;
    OpDest.data:='F2';
    OpDest.OpType:=FUTYPE;
    OpDest.index:=2;

    OpSourcej.data:='45';
    OpSourcej.OpType:=IMMTYPE;
    OpSourcej.value:=45;

    OpSourcek.data:='R3';
    OpSourcek.OpType:=RUTYPE;
    OpSourcek.index:=3;

    Issue:=0;
    ExecutionComplete:=0;
    WriteResult:=0;
    InstrGridAdd(2,Name,OpDest.data,OpSourcej.data,OpSourcek.data);
  end;
  with Instr[3] do
  begin
    Completed:=false;
    Name:='MULTID';
    OP:=MULTD;

    OpDest.data:='F0';
    OpDest.OpType:=FUTYPE;
    OpDest.index:=0;

    OpSourcej.data:='F2';
    OpSourcej.OpType:=FUTYPE;
    OpSourcej.index:=2;

    OpSourcek.data:='F4';
    OpSourcek.OpType:=FUTYPE;
    OpSourcek.index:=4;

    Issue:=0;
    ExecutionComplete:=0;
    WriteResult:=0;
    InstrGridAdd(3,Name,OpDest.data,OpSourcej.data,OpSourcek.data);
  end;
  with Instr[4] do
  begin
    Completed:=false;
    Name:='SUBD';
    OP:=SUBD;
    OpDest.data:='F8';
    OpDest.OpType:=FUTYPE;
    OpDest.index:=8;

    OpSourcej.data:='F6';
    OpSourcej.OpType:=FUTYPE;
    OpSourcej.index:=6;

    OpSourcek.data:='F2';
    OpSourcek.OpType:=FUTYPE;
    OpSourcek.index:=2;

    Issue:=0;
    ExecutionComplete:=0;
    WriteResult:=0;
    InstrGridAdd(4,Name,OpDest.data,OpSourcej.data,OpSourcek.data);
  end;
  with Instr[5] do
  begin
    Completed:=false;
    Name:='DIVD';
    OP:=DIVD;
    OpDest.data:='F10';
    OpDest.OpType:=FUTYPE;
    OpDest.index:=10;

    OpSourcej.data:='F0';
    OpSourcej.OpType:=FUTYPE;
    OpSourcej.index:=0;

    OpSourcek.data:='F6';
    OpSourcek.OpType:=FUTYPE;
    OpSourcek.index:=6;

    Issue:=0;
    ExecutionComplete:=0;
    WriteResult:=0;
    InstrGridAdd(5,Name,OpDest.data,OpSourcej.data,OpSourcek.data);
  end;
  with Instr[6] do
  begin
    Completed:=false;
    Name:='ADDD';
    OP:=ADDD;
    OpDest.data:='F6';
    OpDest.OpType:=FUTYPE;
    OpDest.index:=6;
    OpSourcej.data:='F8';
    OpSourcej.OpType:=FUTYPE;
    OpSourcej.index:=8;
    OpSourcek.data:='F2';
    OpSourcek.OpType:=FUTYPE;
    OpSourcek.index:=2;
    Issue:=0;
    ExecutionComplete:=0;
    WriteResult:=0;
    InstrGridAdd(6,Name,OpDest.data,OpSourcej.data,OpSourcek.data);
  end;

  for i:=1 to FUSIZE do
  with FU[i] do
  begin
    status:=AVAILABLE;
    value:=0;
    data:='';
  end;

  InstrNum:=6;
  InstrNumLabel.Caption:=inttostr(Instrnum);
  PC:=0;
  RefreshInstrGrid;
end;

procedure TForm1.ManualInputClick(Sender: TObject);
begin
  InputDlg1.Show;
end;

procedure TForm1.StartRunClick(Sender: TObject);
begin
  if (PC>0) then exit;
  PC:=1;
  NextClockClick(Sender);
end;

procedure TForm1.NextClockClick(Sender: TObject);
var i,j:integer;
    mess:TWMPAINT;
begin
//  form1.Invalidate;
//  form1.Canvas.Handle:=GetWindowDC(form1.Handle);
//  Form1.Canvas.FillRect(NULL);
 // broadcast(mess);
 // InstructionGrid.Repaint;
 // form1.broadcast(mess);
 // form1.Paint;
 // form1.Invalidate;
 // form1.Dispatch(mess);
 // InstructionGrid.Invalidate;
//    form1.Repaint;
//  form1.Invalidate;
//  InstructionGrid.Repaint;


 // paintbox1.Repaint;

  if InstrNum<=0 then exit;
  if (PC>InstrNum) and (CheckAllCompleted) then
  begin
    Timer1.Enabled:=false;
     with Application do
     begin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -