1 / 13

mu0 & algorithm

mu0 & algorithm. SoC Lab. Harvard Architecture. Instruction cycle. Harvard Architecture. D_ADDR. D_DATA. Data Memory. INST_ADDR. INST_DATA. Inst Memory. IR. MUX. PC. +1. +. ALU. MUX. ACC. Harvard Architecture with Index Register. D_ADDR. D_DATA. Data Memory. MUX. INST_ADDR.

Download Presentation

mu0 & algorithm

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. mu0 & algorithm SoC Lab

  2. Harvard Architecture

  3. Instruction cycle

  4. Harvard Architecture D_ADDR D_DATA Data Memory INST_ADDR INST_DATA Inst Memory IR MUX PC +1 + ALU MUX ACC

  5. Harvard Architecture with Index Register D_ADDR D_DATA Data Memory MUX INST_ADDR INST_DATA Inst Memory IR MUX PC +1 + ALU MUX MUX ACC IDX

  6. Harvard Architecture with Index & Link Address Register 1/2 • 추가 명령어 • CALL S // call sub-routine • RET // return • 추가 레지스터 • Link address // or stack point • Reset • Link address를 적절한 번지로 초기화 ( 메모리의 뒷부분에 할당)ex) data mem이 1000번지까지 있다면 900 정도로 설정

  7. Harvard Architecture with Index & Link Address Register 2/2 CALL S // dmem[RA] = PC , IR = imem[S], PC = S+1, RA = RA+1 RET // IR = imem[dmem[RA-1]], PC = dmem[RA-1]+1, RA = RA-1 D_ADDR D_DATA Data Memory MUX INST_ADDR INST_ADDR INST_DATA Inst Memory RA IR MUX MUX PC 1 1 + - +1 D_DATA + ALU MUX MUX ACC IDX

  8. 최대 공약수유클리드호제법 Input = 24 , 16 intFindGcdUmethod(intiFirstIn,intiSecondIn) { intiMaxNum,iMinNum; if(iFirstIn>iSecondIn) { iMaxNum=iFirstIn; iMinNum=iSecondIn; }else{ iMaxNum=iSecondIn; iMinNum=iFirstIn; } if(iMinNum==0) return iMaxNum; else return FindGcdUmethod(iMinNum,iMaxNum%iMinNum); } iMaxNum 24 16 8 8 iMinNum 16 8 8 0

  9. Binary search intbinary_search( int *data, int key, intlenth) { int l = 0; // left int r = lenth -1; //right int mid; while( l <= r) { mid = (l + r); mid = mid >> 1; if( data[mid] == key) return mid; // find key else if(data[mid] < key) l = mid + 1; else if (data[mid] > key) r = mid -1; } return -1; // can't find } lenth = 10, key = 66l = 0 , r = 9, mid = 4, data[mid] = 33 l = 5 , r = 9, mid = 7, data[mid] = 67 l = 5 , r = 6, mid = 5, data[mid] = 55 l = 6 , r = 6, mid = 6, data[mid] = 66

  10. Run-Length Coding void run_lenth(int *data,int *comp,int length) { inti; int code = data[0]; intcode_cnt = 1; intdest_cnt = 0; for(i=1;i<length;i++) { if(code == data[i]) code_cnt = code_cnt + 1; else { comp[dest_cnt] = code; dest_cnt = dest_cnt+1; comp[dest_cnt] = code_cnt; code = data[i]; code_cnt = 1; } } comp[dest_cnt] = code; dest_cnt = dest_cnt+1; comp[dest_cnt] = code_cnt; } data : 44444333233333332223334444 comp : 45 32 21 37 23 33 44 Num of data = 26 Num of comp = 14 Compression Rate = 26/14 = 1.86

  11. Quick Sort void quickSort(int numbers[], intarray_size){ q_sort(numbers, 0, array_size - 1); } void q_sort(int numbers[], int left, int right){ int pivot, l_hold, r_hold; l_hold = left; r_hold = right; pivot = numbers[left]; while (left < right){ while ((numbers[right] >= pivot) && (left < right)) right--; if (left != right){ numbers[left] = numbers[right]; left++; } while ((numbers[left] <= pivot) && (left < right)) left++; if (left != right){ numbers[right] = numbers[left]; right--; } } numbers[left] = pivot; pivot = left; left = l_hold; right = r_hold; if (left < pivot) q_sort(numbers, left, pivot-1); if (right > pivot) q_sort(numbers, pivot+1, right); }

  12. ModelSim Tip In tb_mu0 module function [8*7-1:0] opcode_expr; input [3:0] opcode; opcode_expr = opcode == 0 ? "LDA": opcode == 1 ? "STO": opcode == 2 ? "ADD": opcode == 3 ? "SUB": opcode == 4 ? "JMP": opcode == 5 ? "JGE": opcode == 6 ? "JNE": opcode == 7 ? "STP": opcode == 8 ? "MOVIDX" opcode == 9 ? "LDIDX" opcode ==10 ? "STIDX" opcode ==11 ? "ADDIDX" opcode ==12 ? "SUBIDX“ "NaO"; endfunction wire [8*7-1:0] opcode_name; assign opcode_name = opcode_expr(dut.ir[15:12]);

More Related