-
20140408 (회로도 최적화, 4bit 덧셈, 구조체)부산IT학원/스마트컨트롤러 2014. 4. 8. 16:19
37일차
----------------
회로도 최적화
----------------
- 어제 했던 내용을 이어서
어제는 sum을 계산했고 오늘은 carry를 계산한다.
방식은 같다.
실습
A 1
B 1
Ci 1
인 경우
A 1
B 1
Ci 0
인 경우
A 0
B 1
Ci 0
인 경우
A 0
B 0
Ci 0
인 경우
--- 4bit 덧셈
4bit 덧셈을 하려면 전가산기 3개와 반가산기 1개가 필요하다
--- ATMEL
- 메모리 회사
- cpu사업도 시작했음.
- cpu 시리즈 중에 AVR, AT91.. 등등 있음
- AVR 시리즈 중에 Mega 모델 중 ATMega128을 공부할 예정.
--- ATMega128
- Microcontroller
- 8bit
- 128 Flash Memory
----------------
구 조 체
----------------
- 새로운 타입을 정의.
typedef와 다른점은 아래를 참고하자.
struct (타입이름)
{ (내용) };
- 전역에서 사용해야 하니 전역에 정의.
ex)
#include <stdio.h>
struct smart
{
char Name[7];
char Phone[14];
int Age;
};
int main()
{
struct smart people[3];
int iCnt;
for(iCnt = 0; 3 > iCnt; ++iCnt)
{
printf("이름 : ");
scanf("%s", people[iCnt].Name);
fflush(stdin);
printf("전화번호 : ");
scanf("%s", people[iCnt].Phone);
fflush(stdin);
printf("나이 : ");
scanf("%d", &people[iCnt].Age);
}
for(iCnt = 0; 3 > iCnt; ++iCnt)
{
printf("이름 : [%s], 전화번호 : [%s], 나이 : [%d] \n", people[iCnt].Name, people[iCnt].Phone, people[iCnt].Age);
}
return 0;
}이런식으로 사용.
- 초기화
#include <stdio.h>
struct employee
{
char Name[7];
char Phone[14];
int Age;
};
struct employer
{
char Name[7];
char Phone[14];
int Age;
};
int main()
{
struct employee people[3] = {
{"James", "010-0100-0101", 10000},
{"Ayin", "010-1111-2220", 9999},
{"Watson", "010-1234-5678", 8000}
};
struct employer CEO = {"IamCEO", "000-0000-0000", 40000};
int iCnt;
printf("이름 : [%s], 전화번호 : [%s], 나이 : [%d] \n", CEO.Name, CEO.Phone, CEO.Age);
for(iCnt = 0; 3 > iCnt; ++iCnt)
{
printf("이름 : [%s], 전화번호 : [%s], 나이 : [%d] \n", people[iCnt].Name, people[iCnt].Phone, people[iCnt].Age);
}
return 0;
}출력 화면
'부산IT학원 > 스마트컨트롤러' 카테고리의 다른 글
20140410 (프로그램 실행 구조, AvrStudio4 실행, 구조체 포인터, typedef struct) (0) 2014.04.10 20140409 (CPU, Microcontroller, RAM, ROM, RISC, CISC, 구조체, #pragma pack) (2) 2014.04.09 20140407 (반가산기 XOR없이, 회로도 최적화 공식, typedef, strlen, strcpy, strcat) (0) 2014.04.07 20140404 (Adder, NOT, NAND, puts, fputs, gets, fgets, fflush) (0) 2014.04.04 20140403 (TTL, AND gate, putchar, fputc, getchar, fgetc) (0) 2014.04.03