HsuChiChen / ncku-computer-organization

assembly code, RISC-V, and some implementation regarding computer organization

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Computer Organization

Time : 2020 fall (first half semester of sophomore)

lecture

more info in lec/*.pdf

subject teacher
計算機組織 陳中和

Code

more info in doc/*.docx


Environment

  1. OS
  • Ubuntu v18.04
  • Windows 10
  1. Software
  • riscv-gnu-toolchain(cross compiler), Python3
  • Modelsim

How to Run

more info in env/*.pdf

In Ubuntu v18.04

  1. assembly code to object file
riscv32-unknown-elf-as -mabi=ilp32 add.s -o add.o
  1. link object file to elf file
riscv32-unknown-elf-ld -b elf32-littleriscv -T link.ld add.o -o add.elf
  1. generate a file for debugging
riscv32-unknown-elf-objdump -dC add.elf > add.dump
  1. transform elf file to binary
riscv32-unknown-elf-objcopy -O binary add.elf add.bin
  1. Convert binary to Memory Initialization File
python3 bin2mem.py --bin add.bin

In Windows 10

  1. open modelsim
modelsim
  1. change to your file location
    file -> change Directory

  2. new project
    new -> project

  3. add source code
    Add Existing File -> import source code

  4. compile and simulate source code
    click estbench.sv -> compile -> simulate

  5. choose testbench work -> tb_core_ut disable "Enable optimization"

  6. add signal to wave signal you want to observe right click and add signal

  7. run all click run all

  8. check memory result view -> memory list

  9. check memory result Goto : 要看的memory位置


lab01

將教授上課講的RISC-V的一些基礎指令(addi,add,li,beq,jal,sw,lw)實作,把C語言轉成組合語言,挑戰題我們則是把題目敘述轉成C語言再轉成組合語言。另外還有環境與tool的基本使用:熟悉Virtualbox在Windows開Linux、Modelsim查看暫存器與記憶體的操作

lab02

本次實驗一樣是寫組合語言,不過相比起來,這次是有照著規定去編程,像RV32I暫存器個別都有規定-x1/ra(Return address)x2/sp(Stack pointer)x8/s0(frame pointer)......哪顆暫存器真的不能亂存,像目標暫存器不能為x0,因為x0要恆為0

lab03

學習Verilog,了解ALUDecoder運作原理。

lab04

當RISC-V遇到Interrupt(or Internal (Exception), External)時,Interrupt Handler與Interrupt Service Routine執行、處理的步驟,也稍微運用到了mask。

lab05

LLVM(Low Level Virtual Machine)模組化的編譯器強大的功能,讓我們能修改RISC-Vbackend,藉由類似RISC-V R-type定址格式,決定此架構下的機器語言指令對應的運算數。而挑戰題藉由比較兩個LLVM組合語言的檔案讓我們了解到程式優化前後的差別。

lab06

  1. GPIO
    • switch
    • blinky
  2. Timer
    • observation
    • blinky
  3. PWM
    • breathing light
    • colorful light

lab07

  • 超音波測距
  • I2C_LCD顯示器

lab08

了解目前市場主流SOC的匯流排架構AMBA之各項基本觀念與AMBA2.0-AHB之實際操作,實驗一寫C Code利用Tube這個Slave印出字體;實驗二在Bus上掛外部記憶體,並寫入自己的學號查看Modelsim驗證其結果;實驗三在Bus位置0x20000000上掛GPIO,並寫自己所屬組別用FPGA驗證其結果。

lec09

了解Master存取bus的優先權界定,由於只有一個bus對上多個Master發出的訊號,就需要有Mux去選要哪個訊號,其中Arbiter的仲裁機制又可分

  • Lab1做的Fixed Priority,每個Master的priority在設計系統時就先決定好了,才會出現當優先度高的Master不斷使用bus時就會dominate,其他的Master用不到,優點是在優先權高且極需用到bus的master可容易拿到bus
  • lab3做的Round Robin Priority,拿到bus使用權的Master,在下一次仲裁時priority會變最低,優點是每一個 Master有較平均的bus使用權。最後lab是Timer在一定時間後叫醒Master01-03的Request讓他們去爭奪寫入Tube,也是我們卡最久的,因為對接線上沒有充分了解。

lec10

介紹了新的組合控制邏輯單元Interrupt Controller,當一個Device產生中斷(External I/O)後,需經過Interrupt Controller的轉發訊號成IRQ,訊號才能到達CPU的ISR。(Interrupt Controller會回應該Device訊號Ack,表示Device的中斷已經被傳達)。而Lab2則新增一個來自FPGA板上的Switch Interrupt。

About

assembly code, RISC-V, and some implementation regarding computer organization


Languages

Language:Verilog 45.1%Language:VHDL 40.7%Language:Makefile 3.5%Language:SystemVerilog 3.4%Language:C 2.8%Language:Assembly 1.3%Language:HTML 0.8%Language:JavaScript 0.7%Language:Stata 0.6%Language:Tcl 0.4%Language:Batchfile 0.3%Language:Shell 0.3%Language:Python 0.2%Language:Pascal 0.0%