Разработка средства функционального диагностирования вычислительных устройств

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

?т программы, реализующей описание схемы блока контроля БКА.БКв

void __fastcall TForm1: Button1Click (TObject *Sender)

{

int d3b, d3a;

n = StrToInt (Edit1->Text);

k = StrToInt (Edit2->Text);

d3a = n/2 + 3;

d3b = (n n % 2)/2;

StringGrid1->ColCount = d3a;

StringGrid2->ColCount = d3b;

for (int i=1; iColCount; i++)

StringGrid1->Cells[i] [0]=i;

for (int i=1; iColCount; i++)

StringGrid2->Cells[i] [0]=i;

String stroca1 [7]={, 1, 2, 3, 4, 1, 2};

for (int i=0; i<=7; i++)

{

StringGrid1->Cells[0] [i]=stroca1 [i].c_str();

StringGrid2->Cells[0] [i]=stroca1 [i].c_str();

}

StrGr1 ();

StrGr2 ();

}

//

void __fastcall TForm1: Cycle (TStringGrid *tab, int imin, int imax, int iinc, int jmin, int jmax, int jinc)

{

for (int i=imin; i<imax; i=i+iinc) {

for (int j = jmin; j<jmax; j=j+jinc) {

if (n % 2 == 1) {

tab->Cells[i] [1] = tab->Cells [j-1] [6];

tab->Cells[i] [2] = tab->Cells [j-1] [5];

tab->Cells[i] [3] = tab->Cells[j] [6];

tab->Cells[i] [4] = tab->Cells[j] [5];

}

else {

tab->Cells[i] [1] = tab->Cells [j-1] [5];

tab->Cells[i] [2] = tab->Cells [j-1] [6];

tab->Cells[i] [3] = tab->Cells[j] [5];

tab->Cells[i] [4] = tab->Cells[j] [6];

}

}}}

//

void __fastcall TForm1:IF1 (TStringGrid *tab, int head, int tail, int m)

{

if (n % 2 == 1) {

StringGrid1->Cells[head] [1] = StringGrid1->Cells[tail] [5];

StringGrid1->Cells[head] [2] = StringGrid1->Cells[tail] [6];

StringGrid1->Cells[head] [3] = StringGrid1->Cells[m] [5];

StringGrid1->Cells[head] [4] = StringGrid1->Cells[m] [6];

}

else

{

StringGrid1->Cells[head] [1] = StringGrid1->Cells[tail] [6];

StringGrid1->Cells[head] [2] = StringGrid1->Cells[tail] [5];

StringGrid1->Cells[head] [3] = StringGrid1->Cells[m] [6];

StringGrid1->Cells[head] [4] = StringGrid1->Cells[m] [5];

}}

//

void __fastcall TForm1:IF2 (TStringGrid *tab, int head, int tail, int m, int m1)

{

if (n % 2 == 1) {

StringGrid1->Cells[head] [1] = StringGrid1->Cells[tail] [5];

StringGrid1->Cells[head] [2] = StringGrid1->Cells[tail] [6];

StringGrid1->Cells[head] [3] = StringGrid1->Cells[m] [5];

StringGrid1->Cells[head] [4] = StringGrid1->Cells[m] [6];

}

else

{

StringGrid1->Cells[head] [1] = StringGrid1->Cells[tail] [6];

StringGrid1->Cells[head] [2] = StringGrid1->Cells[tail] [5];

StringGrid1->Cells[head] [3] = m;

StringGrid1->Cells[head] [4] = m1;

}}

//

void __fastcall TForm1: StrGr1 ()

{

int L, as1, as2, as3, as4, as5, d2a;

as1 = n/4 + n % 2;

as2 = as1 + L;

as3 = as2/2 + as2% 2;

as4 = as3/2 + as3% 2;

d2a = 4*n-k +5;

L = n-k;

StringGrid1->Cells[1] [5] = d2a;

StringGrid1->Cells[1] [6] = d2a+1;

for (int i=2; iColCount; i++) {

StringGrid1->Cells[i] [5] = StringGrid1->Cells [i-1] [5]+2;

StringGrid1->Cells[i] [6] = StringGrid1->Cells[i] [6]+2;

}

StringGrid1->Cells[as1] [1] = n 3;

StringGrid1->Cells[as1] [2] = n 2;

StringGrid1->Cells[as1] [3] = n 1;

StringGrid1->Cells[as1] [4] = n;

for (int i=(as11); i>=0; i)

for (int j=4; j<=0; j)

StringGrid1->Cells[i] [j] = StringGrid1->Cells [i+1] [j] 4;

if (n % 2 == 1) {

StringGrid1->Cells[1] [1] = 0;

StringGrid1->Cells[1] [2] = 0;

StringGrid1->Cells[1] [3] = 0;

StringGrid1->Cells[1] [4] = 1;

}

Cycle (StringGrid1, as2, (as2-L/2), 1, as1,0, 2);

Cycle (StringGrid1, as3, (as3-L/4), 1, as2,0, 2);

Cycle (StringGrid1, (as1+1), (as2-L/21), 1,0,4,2);

IF1 (StringGrid1, as3+1, as2+1, as2+2);

IF1 (StringGrid1, as5, as3+1, as3+2);

IF2 (StringGrid1, as5+1, as5, n+2, n+1);

}

//

void __fastcall TForm1: StrGr2 ()

{

int d2b, d1, d3, bs1, tail, head, m, m1;

d2b = 8*n-5*k-3;

d1 = (n-k)*2;

d3 = n-k-3;

bs1= n/42;

StringGrid2->Cells[1] [5] = d2b;

StringGrid2->Cells[1] [6] = d2b+1;

for (int i=2; iColCount; i++) {

StringGrid2->Cells[i] [5] = StringGrid2->Cells [i-1] [5]+2;

StringGrid2->Cells[i] [6] = StringGrid2->Cells[i] [6]+2;

}

StringGrid2->Cells[bs1] [1] = n 3;

StringGrid2->Cells[bs1] [2] = n 2;

StringGrid2->Cells[bs1] [3] = n 1;

StringGrid2->Cells[bs1] [4] = n;

for (int i=(bs11); i>d2b; i)

for (int j=0; j<4; j++)

StringGrid2->Cells[i] [j] = StringGrid2->Cells [i+1] [j] 4;

IF1 (StringGrid2, d1+2, d1, d32);

tail+=2;

head+=2;

IF1 (StringGrid2, d1+2, d1, d32);

if (n % 2 == 1) {

StringGrid2->Cells [head+2] [1] = StringGrid2->Cells[head] [6];

StringGrid2->Cells [head+2] [2] = StringGrid2->Cells[head] [5];

StringGrid2->Cells [head+2] [3] = StringGrid2->Cells [d3+1] [6];

StringGrid2->Cells [head+2] [4] = StringGrid2->Cells [d3+1] [5];

}

tail= d3;

m= 4*(k-1);

head = bs1+2;

for (int i=1; i<n-k; i++)

{

IF2 (StringGrid2, head, tail, m, m-1);

tail+=2;

head+=2;

}

IF1 (StringGrid2, head, d1, d1+1);

IF1 (StringGrid2, head, tail, n/42);

IF2 (StringGrid2, head, tail, 2*n+4,2*n+3);

}

 

  1. Результаты работы программы

 

В программе была задана разрядность n = 36 и количество отбрасываемых разрядов k = 31. Разбиение МКП представлено на рис.2.

Блоки контроля БКА и БКБ представлены в приложении 4.

Описание схемы блока контроля БКА приведено в табл. 4.

 

Таблица 4

123456789101112131415Вх1159131721252933118122126128132136Вх22610141822263034119123127129133137Вх137111519232731351201240130134138Вх248121620242832361211250131135139Вых1118120122124126128130132134136138140142144146Вых2119121123125127129131133135137139141143145147

Таблица 4 продолжение

161718192021Вх114014214615015238Вх214114314715115337Вх101441480154157Вх201451490155158Вых1148150152153156159Вых2149151153154157160Описание схемы блока контроля БКБ приведено в табл. 5.

 

Таблица 5

123456789101112131415Вх139435559636771161165171177169177167185Вх240445660646872162166172178170178168186Вх1410576165697316353173511794918347Вх2420586266707416454174521805018448Вых1161163165167169171173175177179181183185187189Вых2162164166168170172174176178180182184186188190

Таблица 5 продолжение

16171819Вх117518919176Вх217619019275Вх118745193195Вх218846197196Вых1191193195197Вых2192194196198

 

Список литературы

 

  1. РабиновичЗ.Л., РаманаускасВ.А.Типовые операции в вычислительных машинах. Киев: Техника, 1980.
  2. СавельевА.Я.Прикладная теория цифровых автоматов. М.: Высш. шк. 1987.