#include "stdio.h" #include "string.h" #pragma pack(1) typedef unsigned char __u8; struct JKFF{ __u8 j:1; __u8 k:1; __u8 q:1; __u8 _q:1; }; struct JKFF_FUNC{ __u8 (*jkflipflop)(__u8, __u8, __u8); }; __u8 jkflipflop(__u8 j, __u8 k, __u8 q){ return j*(~q) + (~k)*q; } int main(){ struct JKFF ff; struct JKFF_FUNC ff_func; ff_func.jkflipflop = jkflipflop; memset(&ff, 0x0, sizeof(struct JKFF)); #if 1 //start while - test JK filpflop function ff.q = 1; ff.j = 1; ff.k = 1; ff._q = ff_func.jkflipflop(ff.j, ff.k, ff.q); printf("%d, %d, %d, %d\n", ff.q, ff.j, ff.k, ff._q); #endif return 0; } /* * Reference: http://zeroway2.com.ne.kr/digital/05/0501/03/050103.html * http://bombofmetal.tistory.com/489 * http://donghwada.tistory.com/20 */
[한이음 프로젝트] 나만의 가상 CPU 만들기 - C언어로 JK플립플롭 구현
Posted in 카테고리 없음 by