Giter Club home page Giter Club logo

soc2's Introduction

SOC2

CPU7B (LoongArch32 ISA)

More blogs are kept at:

Pipeline

Single issue, in order, 5-stage pipeline

_f _d _e _m _w

Modules

 +-----------------------------------------------------------------------------------------+
 | CPU7B                               +----------------------------------------------+    |                           
 |                                     | EXU               +--------+    +-------+    |    |
 |                                     |     +---------+   |        |    |       |    |    |
 |                                     |     |         |   |        |    |  alu  |    |    |
 |  +-----------------------------+    |     |   csr   |   |        |    +-------+    |    |
 |  |IFU                          |    |     |         |   |        |    +-------+    |    |
 |  |    +----------+  +------+   |    |     +---------+   |        |    |  bru  |    |    |
 |  |    |          |  |      |   |    |     +---------+   |  ecl   |    |       |    |    |
 |  |    | ifu_fdp  |->|decode|.. | -> |     |         |   |   &    |    +-------+    |    |
 |  |    |          |  |      |   |    |     | regfile |   |  byp   |    +-------+    |    |
 |  |    +----------+  +------+   |    |     |         |   |        |    |       |    |    |
 |  |      |    |                 |    |     +-------- +   |        |    |  mul  |    |    |
 |  |      |    |                 |    |                   |        |    +-------+    |    |
 |  +------|----|-----------------+    |  +-----------+    |        |    +-------+    |    |          
 |         |    |                      |  |           |    |        |    |  div  |    |    |
 |         |    |                      |  |    lsu    |    |        |    |       |    |    |
 |         |    |                      |  |           |    +--------+    +-------+    |    |
 |         |    |                      |  +------------                               |    |
 |         |    |                      +-----|------|---------------------------------+    |
 |         |    |                            |      |                                      |
 |     +----------------------------------------------+                                    |
 |     |              axi interface                   |                                    |
 |     +----------------------------------------------+                                clk |-- 75MHz
 |                  |      |                                                               |
 +------------------|      |---------------------------------------------------------------+
                    |      |
             +--------------------+
             |                    |      +----------------------------------+
             |                    |      |          |                       |
         ----|                    |------|          |  VGA text mode 80x25  |
    (DMA)    |     axi_matrix     |      | VGA RAM  |                       |
         ----|        2x2         |------|          |  640x480 70Hz         |
             |                    |      |          |                    clk|-- 25MHz
             |                    |      +----------------------------------+
             +--------------------+
                    |      |
                    |      |
                  +----------+              
                  |          |
                  |          |
                  |   SRAM   |
                  |          |
                  |          |
                  +----------+
   
   
   
                                                        +--------------+    
                                               25MHz ---|c0            |
                                               75MHz ---|c1            |
                                                        |   pll        |   refclk
                                                        |        inclk0|--- 50MHz
                                                        +--------------+  

LA32 Instructions

Implemented

  • Integer Arithmetic Instructions

  ADD.W SUB.W ADDI.W 

  LU12I.W PCADDU12I 

  SLT[U] SLT[U]I 

  AND OR NOR XOR

  ANDI ORI XORI

  NOP
  • Bit-Shift Instructions
  SLL.W SRL.W SRA.W SLL.W SRL.W SRA.W

  SLLI.W SRLI.W SRAI.W
  • Branch Instructions
  BEQ BNE BLT[U] BGE[U]

  B BL

  JIRL
  • Integer Multiply
  MUL.W MULH.W[U]
  • Common Memory Access Instructions
  LD.B LD.H LD.W LD.BU LD.HU LD.HU

  ST.B ST.H ST.W
  • CSR Access Instructions
  CSRRD CSRWR CSRXCHG
  • Misc
  ERTN

CSR registers

  0x0  CRMD.ie CRMD.plv
  
  0x1  PRMD.pie PRMD.pplv

  0x5  ESTAT

  0x6  ERA
  
  0x7  BADV

  0xc  EENTRY

  0x41 TCFG

  0x42 TVAL
  
  0x43 TICLR

Exceptions

  • Load/Store Address Misaligned

  • Illegal Instruction

  • TIMER INTERRUPT


To do ...

  • Integer Divide Instructions
  DIV.W[U]  MOD.W[U]
  • Common Memory Access Instructions
  PRELD
  • Atomic Memory Access Instructions
  LL.W SC.W
  • Barrier Instructions
  DBAR IBAR
  • Floating-point Instructions

  • Cache and TLB Instructions

  • Misc

  SYSCALL BREAK

  RDCNTV{L/H}.W RDCNTID

  IDLE

Memory Map

        0x0  +--------------+
(0x1c000000) |              |
             |    RAM       |  64KB
             |              |
             |              |
     0xffff  |              |
    0x10000  +--------------+
             | VGA RAM(2KB) |
    0x107ff  +--------------+   
             |              |  64KB
             | Reserved     |
             | VGA RAM      | 
    0x20000  +--------------+         0x20000  RW   uartdr     (32-bit register, 
             |              |                                   low 8 bits are used to transmit and receive data)
             |              |  64KB
             | Device MMIO  |         
             |              |         
    0x2ffff  |              |
             +--------------+
             |              |
             |              |

             .....

             |              |
             |              |
0x1c000000   +--------------+
             |              |
             |    RAM       |  64KB
             |              |
             |              |
             |              |
             +--------------+
             |              |
             |              |

             .....

Build and Test

Build cpu7b

u@uu:~/prjs/cpu7b$ cd systhesis/altera/
u@uu:~/prjs/cpu7b/systhesis/altera$ make

### Run all the tests

`````shell
u@unamed:~/prjs/cpu7b/simulation$ ./run_all_tests.sh 
run tests

test0
# PASS!

test1_ld.w
# PASS!

test3_st.w
# PASS!

test4_beq
# PASS!

test5_jirl
# PASS!

test6_beq_testbyp
# PASS!

test8_mulw
# PASS!

test9_mulhwu
# PASS!

test10_mulhw
# PASS!

test11_csrrd
# PASS!

test12_csrwr
# PASS!

test13_csrxchg
# PASS!

test14_csr_crmd
# PASS!

test15_csr_prmd
# PASS!

test16_ale_exception
# PASS!

test17_exception_crmd_prmd
# PASS!

test18_csr_badv
# PASS!

test19_csr_tcfg
# PASS!

test20_csr_tcfg_periodic
# PASS!

test21_timer_intr_right_after_branch
# PASS!

test22_timer_intr_on_pipeline_bubble
# PASS!

test23_lsu_stall_ifu_at_e
# PASS!

test24_beq_ld.w
# PASS!

test25_lsu_stall
# PASS!

test26_illinstr_exception
# PASS!

test27_estat
# PASS!


Debug

Test code

u@uu:~/prjs/cpu7b/simulation/test0$ vim testcode/start.S

Compile and Simulate

u@uu:~/prjs/cpu7b/simulation/test0$ ./simulate.sh 

View the Signals

u@uu:~/prjs/cpu7b/simulation/test0$ ./viewwave.sh



Test

screenshot0

With timer interrupt, dinosaur jumps

screenshot1

Space Invaders

screenshot1

soc2's People

Contributors

whensungoesdown avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.