Вы находитесь на странице: 1из 6

unit Unit1;

interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart, Buttons, StdCtrls,
Mask,Math;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
TimeDiagram: TSpeedButton;
Chart2: TChart;
LineSeries1: TLineSeries;
Chart1: TChart;
LineSeries2: TLineSeries;
LineSeries3: TLineSeries;
Chart4: TChart;
LineSeries4: TLineSeries;
Chart6: TChart;
LineSeries5: TLineSeries;
Chart8: TChart;
LineSeries6: TLineSeries;
Chart5: TChart;
LineSeries7: TLineSeries;
Chart7: TChart;
LineSeries8: TLineSeries;
Chart9: TChart;
LineSeries9: TLineSeries;
Chart10: TChart;
LineSeries10: TLineSeries;
StaticText1: TStaticText;
pausebutton: TSpeedButton;
Chart3: TChart;
StaticText2: TStaticText;
Label1: TLabel;
//

procedure wClick(Sender: TObject);


procedure TimeDiagramClick(Sender: TObject);
procedure delay(lama:real);
procedure pause;
procedure pausebuttonClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }

end;
var
Form1: TForm1;
//input
inA : array[1..128] of integer = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);
inB : array[1..128] of integer = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,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] of integer;

//output

th2 : integer = 2;
th3 : integer = 3;
th6 : integer = 6;
th0 : integer = 0;
w_in : integer = 2;
c_in : integer = -1;
tambah : integer;
pausestat : integer;
N1,N2,N3,nd1,nd2,nd3,nd4,nd5,nd6,nd7,nd8,nd9,nd10,nd11,or1,or2,or3,X1,X2,X3,X4
,X5,X6,X7,X8,X9,X10,XNOR : integer; //variabel untuk penghitungan
implementation

{$R *.dfm}
procedure TFORM1.delay(lama:real); //prosedur delay untuk grafik
var ref:longint;
begin
ref:=gettickcount;
repeat application.processmessages;
until ((gettickcount-ref)>=lama);
end;
procedure TForm1.pause;
begin
repeat
application.processmessages;
until pausebutton.caption='Pause';
end;

procedure hitung;
begin
nd1:= X1*c_in + X2*c_in
if nd1<th2
then nd1:=0
else nd1:=1;
nd2:= X1*c_in + X2*w_in
if nd2<th2
then nd2:=0
else nd2:=1;
nd3:= X1*w_in + X2*c_in
if nd3<th2
then nd3:=0
else nd3:=1;
nd4:= X1*w_in + X2*w_in
if nd4<th6
then nd4:=0
else nd4:=1;

+ X3*w_in;

//mencari /A+/B+C

+ X3*c_in;

//mencari /A+B+/C

+ X3*c_in;

//mencari A+/B+/C

+ X3*w_in;

//mencari A+B+C

or1:= nd1*w_in + nd2*w_in + nd3*w_in + nd4*w_in; //mencari nd1 + nd2 + nd3


+ nd4
if or1<th2
then or1:=0
else or1:=1;
end;
procedure hitung2;
begin
nd5:= X4*c_in + X5*c_in + X6*w_in;
if nd5<th2
then nd5:=0
else nd5:=1;
nd6:= X4*c_in + X5*w_in + X6*c_in;
if nd6<th2
then nd6:=0
else nd6:=1;
nd7:= X4*w_in + X5*c_in + X6*c_in;
if nd7<th2
then nd7:=0
else nd7:=1;

//mencari /D+/E+F

//mencari /D+E+/F

//mencari D+/E+/F

nd8:= X4*w_in + X5*w_in + X6*w_in;


if nd8<th6
then nd8:=0
else nd8:=1;

//mencari D+E+F

or2:= nd5*w_in + nd6*w_in + nd7*w_in + nd8*w_in; //mencari nd5 + nd6 + nd7


+ nd8
if or2<th2
then or2:=0
else or2:=1;
end;
procedure hitung3;
begin
nd9:= X8*w_in + X9*c_in;
if nd9<th2
then nd9:=0
else nd9:=1;
nd10:= X8*c_in + X9*w_in;
if nd10<th2
then nd10:=0
else nd10:=1;
or3:= nd9*w_in + nd10*w_in;
if or3<th2
then or3:=0
else or3:=1;
end;
procedure hitung4;
begin
nd11:= X10*-1;
if nd11<th0
then nd11:=0
else nd11:=1;
end;
procedure TForm1.TimeDiagramClick(Sender: TObject);
var i:integer;
begin
if TimeDiagram.Caption='START' then TimeDiagram.Caption:='STOP'
else
if TimeDiagram.Caption='STOP' then TimeDiagram.Caption:='START';
repeat
for i:=1 to 128 do
begin
X1:=InA[i]; X2:=InB[i]; X3:=InC[i];
hitung;
X4:=InD[i]; X5:=InE[i]; X6:=InF[i];
hitung2;
X8:=or1; X9:=or2;
hitung3;
X8:=or3; X9:=InG[i];
hitung3;
X10:=or3;
hitung4;
XNOR:= nd11;

out_y[i]:=XNOR;
end;
out_y[1]:=out_y[128];
lineseries1.Clear;
lineseries2.Clear;
lineseries3.Clear;
lineseries4.Clear;
lineseries5.Clear;
lineseries6.Clear;
lineseries7.Clear;
lineseries8.Clear;
lineseries9.Clear;
lineseries10.Clear;
for i:=1 to 256 do
begin

lineseries1.AddXY(i,InA[i]);
lineseries2.AddXY(i,InB[i]);
lineseries3.AddXY(i,InC[i]);
lineseries4.AddXY(i,InD[i]);
lineseries5.AddXY(i,InE[i]);
lineseries6.AddXY(i,InF[i]);
lineseries7.AddXY(i,InG[i]);
lineseries8.AddXY(i,out_y[i+1]);
lineseries9.AddXY(i,out_y[i]);
lineseries10.AddXY(i,clk[i]);
delay (10) ;
lineseries10.AddXY(i,clk[i]);

end;

until TimeDiagram.Caption='START'
end;
procedure TForm1.pausebuttonClick(Sender: TObject);
begin
if pausebutton.Caption='Pause' then
begin
pausebutton.Caption:='Continue'; pause;
end;
if pausebutton.Caption='Continue' then pausebutton.Caption:='Pause';
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
close;
end;

end.