imiaDPd (780151), страница 2
Текст из файла (страница 2)
С трех входных X1, X2, X3 и трех инвертированных Y1, Y2, Y3 цепей сигналы поступают на три логические устройства первого уровня типа
И (AND) и ИЛИ (OR) с двумя входами. Варианты наборов устройств первого уровня задаются Таблицей 1 (8 вариантов).
Коммутация трех логических устройств первого уровня с входными X1, X2, X3 и инвертированными Y1, Y2, Y3 цепями задается Таблицей 2 (6 вариантов).
С выходов трех логических устройств первого уровня двоичные сигналы подаются на три логические устройства второго уровня типа
И (AND) и ИЛИ (OR) с двумя входами. Варианты наборов устройств второго уровня также задаются Таблицей 1 (8 вариантов).
Коммутация трех логических устройств второго уровня с тремя выходными цепями первого уровня задается Таблицей 3 (3 варианта).
С выходов трех логических устройств второго уровня снимаются выходные сигналы имитируемой схемы Z.
Количество возможных заданий на учебное проектирование:
K= 8*6*8*3 = 1152.
Таблица N1.
| Вариант набора | Логическое устройство | ||
| N | 1 | 2 | 3 |
| 0 | AND | AND | AND |
| 1 | AND | AND | OR |
| 2 | AND | OR | AND |
| 3 | AND | OR | OR |
| 4 | OR | AND | AND |
| 5 | OR | AND | OR |
| 6 | OR | OR | AND |
| 7 | OR | OR | OR |
Таблица N2.
| Коммутация логических устройств первого уровня. | ||||||||||||
| N | X1 | X2 | X3 | Y1 | Y2 | Y3 | X1 | X2 | X3 | Y1 | Y2 | Y3 |
| 0 | ||||||||||||
| 1 | ||||||||||||
| 2 | ||||||||||||
| 3 | ||||||||||||
| 4 | ||||||||||||
| 5 | ||||||||||||
Таблица N3.
| Коммутация логических устройств второго уровня. | ||||||
| N | 1 | 2 | 3 | 1 | 2 | 3 |
| 0 | ||||||
| 1 | ||||||
| 2 | ||||||
Пример.
Создать программный имитатор двоичной цифровой системы управления, имеющий следующую схему (см. Приложение 2):
1. Три логические устройства первого уровня:
Таблица. 1, N = 5.
2. Коммутация трех логических устройств первого уровня с входными X1, X2, X3 и инвертированными Y1, Y2, Y3 цепями:
Таблица. 2, N = 1.
3. Три логические устройства второго уровня:
Таблица. 1, N = 3.
4. Коммутация трех логических устройств второго уровня с тремя выходными цепями первого уровня:
Таблица. 3, N = 0.
Решение.
1. Таблица. 1, N = 5: OR1, AND1, OR2
2. Таблица. 2, N = 1: X2, X3; Y1, Y2; Y3, X1.
Входы OR1: X2, X3.
Входы AND1: Y1, Y2.
Входы OR2: Y3, X1.
3. Таблица. 1, N = 3: AND2, OR3, OR4.
4. Таблица. 3, N = 0: 1, 2; 3, 1; 2, 3.
Входы AND2: OR1, AND1.
Входы OR3: OR2, OR1.
Входы OR4: AND1, OR2.
Написание уравнений логической схемы программного имитатора начинается с выходов Z.
Z1=AND2=OR1*AND1=(X2+X3)*(Y1*Y2);
Z2=OR3=OR2+OR1=(Y3+X1)+(X2+X3);
Z3=OR4=AND1+OR2=(Y1*Y2)+(Y3+X1)
8. Исходный текст программы на языке Си.
/*#####################################################*/
/*Copyright (C) 2003-2004 by A.E.Stefanovich tel. 939-4182, 236-2729
Moscow Town Palace Creation of the Children and Youth
Departement Astronomy
*/
/*#####################################################*/
/* File: imiaDP.c
Imitator automatic of the schemes electronics
*/
/*############################################# LEGEND */
/* <=### CHANGE ###
Moscow Town Palace of the Creation of the Children and Youth
Department Astronomy
---------------
Pupil: L.V. Doronina
School: 45
Class: 9
Tel.: 125-1719
Discipline: Programming and bases of algorithms
Group: 1
Teacher: A.E. Stefanovich
---------------
Year: 2003-2004
---------------
DEVICE LVD
Entrances: X1,X2,X3;
Or1=Y2Y1X3+Y1Y3X2+Y3Y2X1+X1X2X3
Or2=X3X2+X3X1+X2X1
Exits:Z1, Z2
*/
/*############################################## PROGRAMME */
/*============================= Includes */
#include <c:\turboc.3_0\include\stdio.h>
#include <c:\turboc.3_0\include\conio.h>
#include <c:\turboc.3_0\include\stdlib.h>
#include <c:\turboc.3_0\include\graphics.h>
#include <c:\turboc.3_0\include\dos.h>
#include <c:\turboc.3_0\include\string.h>
#include <c:\turboc.3_0\include\time.h>
#include <c:\turboc.3_0\include\ctype.h>
/*============================= Declarations */
int graph_regime();
int text_regime();
int title_sheet(); /* <=### CHANGE ### */
int choice_regime_work(); /* <=### CHANGE ### */
/* */
int draft(); /* <=### CHANGE ### */
/* */
int logic_0(); /* <=### CHANGE ### */
int device_0(); /* <=### CHANGE ### */
int bit(int x,int y,int bit); /* 0 or 1 on the wire */
int all_bit_0(); /* <=### CHANGE ### */
/* */
int hand_order_var0(); /* <=### CHANGE ### */
int hand_order_var1(); /* <=### CHANGE ### */
int hand_order_var2(); /* <=### CHANGE ### */
int hand_order_var5(); /* <=### CHANGE ### */
/* */
int openfile_entry(); /* <=### CHANGE ### */
int openfile_exit();
/* */
int file_order_var2(); /* <=### CHANGE ### */
int file_order_var3(); /* <=### CHANGE ### */
int file_order_var4(); /* <=### CHANGE ### */
/* */
int get_date_pc_counted();
int get_time_pc_counted();
/* */
int display_time_pc_counted(); /* Max: 4 294 967 295 s */
int display_date_pc_counted(int f);
int display_time_ordered(); /* Max: 4 294 967 295 s */
int display_next_entrance();
int display_interval_counted(int f); /* Max: 4 294 967 295 s */
int display_interval_ordered(int f); /* Max: 4 294 967 295 s */
int display_counter_commands(int f); /* Max: 4 294 967 295 s */
int display_regime_work();
/* */
int file_control();
/* */
int end_programm();
/*============================= Global constants */
#define LF cprintf("\n")
#define CR cprintf("\r")
#define HT cprintf("\t")
#define VT cprintf("\v")
#define BS cprintf("\b")
#define BELL cprintf("\a")
/* */
#define STOP getch()
#define STOP_DRAFT bioskey(0)
#define ALERT_SIGNAL cprintf("\a\a\a")
#define ROW 25
#define COL 80
#define ROW_D 36
#define COL_D 50
#define NOT_DELETE 1 /* <=### CHANGE ### */
#define DELETE 0 /* <=### CHANGE ### */
/*============================= Global variables */
/*----------------------------- Device */ /* <=### CHANGE ### */
unsigned int X1,X2,X3; /* Entrances */
unsigned int Y1,Y2,Y3; /* Invert. Entrances */
unsigned int And1,And2,And3,And4,And5,And6,And7; /* 1 range */
unsigned int Or1,Or2; /* 2 range */
/*-----------------------------*/
char Regime_work=0; /* Regime of the work */
/* Counter of the commands Max: 4 294 967 295 s */
unsigned long Counter_commands=0;
/* */
/* Hand or file ordered interval between the commands */
unsigned long Interval_ordered=0; /* */
/* Counter of the intervals Max: 4 294 967 295 s */
unsigned long Interval_counted=0;
/* Hand max. interval between the commands for case: 5 (Random) */
unsigned int Interval_hand_max=0; /* */
/* */
struct date Date_now;
char Str_date_pc_counted[80];
/* */
struct time Time_now;
unsigned int Ho,Mo,So; /* Order of the times */
unsigned int H,M,S; /* Count of the times */
/* Time ordered Max: 4 294 967 295 s */
unsigned long Time_ordered=0;
unsigned int Flag_time_ordered_print=0;
/* Time personal computer Max: 4 294 967 295 s */
unsigned long Time_pc_counted=0;
unsigned int Flag_time_pc_counted_print=0;
unsigned int Flag_bit=0;
/* void* Draft_buffer; */
/* */
/*------------------------------ Global graphic variables */
int Font[8]; /* NN user characters */
int Maxx,Maxy; /* Max. dimensions of the screen in the pixels */
/*------------------------------ Files */
FILE *Fp1,*Fp2;
/* Buffer for name of the file order */
char Fname_entry[80];
/* Buffer for name of the file register */
char Fname_exit[80];
/*============================= Text */ /* <=### CHANGE ### */
char *title_1=
" Moscow Town Palace Creation of the Children and Youth ";
char *title_2=
" I M I T A T O R - LVD ";
char *title_3=
" Pupil: L.V. Doronina ";
char *title_4=
" School: 45; Class: 9; Tel.: 125-1719 ";
char *title_5=
" Discipline: Programming and bases of algorithms ";
char *title_6=
" Group: 1 ";
char *title_7=
" Department Astronomy ";
char *title_8=
" Teacher: A.E. Stefanovich ";
char *title_9=
" Year: 2003-2004 ";
/*------------- Text (device) */
char *title_10=
" Z1=Y2Y1X3+Y1Y3X2+Y3Y2X1+X1X2X3 ";
char *title_11=
" Z2=X3X2+X3X1+X2X1 ";
/*############################################# MAIN */
main()
{
title_sheet(); /* Graph. reg. */
choice_regime_work(); /* Text. reg. */
/*----------------------------- Switch of the variants */
graph_regime();
switch(Regime_work) /* <=### CHANGE ### */
{
/* Hand Command: */
case '0': draft();
display_regime_work();
display_next_entrance();















