1 Star 1 Fork 0

themql / COA_exp

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

实现指令

R型

字段 OP rs rt rd shamt func 功能描述
位数 6 5 5 5 5 6
汇编助记符 编码
add rd,rs,rt 000_000 rs rt rd 00000 100_000 rs + rt -> rd
sub rd,rs,rt 000_000 rs rt rd 00000 100_010 rs - rt -> rd
and rd,rs,rt 000_000 rs rt rd 00000 100_100 rs & rt -> rd
or rd,rs,rt 000_000 00000 100_101 rs | rt -> rd
xor rd,rs,rt 000_000 00000 100_110 rs ^ rt -> td
nor rd,rs,rt 000_000 00000 100_111 ~ (rs | rt) -> rd
sltu rd,rs,rt 000_000 00000 101_011 (rs < rt) ?1 :0
sllv rd,rt,rs 000_000 00000 000_100 rt << rs -> rd
jr rs 000_000 rs 00000 00000 00000 001_000 rs -> PC

I型

字段 OP rs rt imm 功能描述
位数 6 5 5 16
汇编助记符 编码
addi rt,rs,imm 001_000 rs rt imm rs + imm -> rt
andi rt,rs,imm 001_100 rs & imm -> rt
xori rt,rs,imm 001_110 rs ^ imm -> rt
sltiu rt,rs,imm 001_011 (rs < imm) ?1 :0
beq rs,rt,label 000_100 rs rt offset (rs == rt) ?PC + 4 + offset * 4 -> PC
bne rs,rt,label 000_101 rs rt offset (rs != rt) ?PC + 4 + offset * 4 -> PC
lw rt,offset(rs) 100_011 rs rt offset (rs + offset) -> rt
sw rt,offset 101_011 rs rt offset rt -> (rs + offset)

J型

字段 OP address 功能描述
位数 6 26
汇编助记符 编码
j label 000_010 address {(PC + 4)[31 -: 4], address, 2'b00} -> PC
jal label 000_011 address (PC + 4) -> $31(单周期实现)/ (PC + 8) -> $31(流水线实现), {(PC + 4)[31 -: 4], address, 2'b00} -> PC

汇编转机器码

安装好工具链(mips-2013.05-65-mips-sde-elf),使用如下脚本生成mif文件

https://github.com/Ellen7ions/bin2mem

Q:为什么和书里给的机器码有点不一样?

A:MIPS标准指令系统考虑到流水线延迟,引入分支延迟槽,就是位于分支指令后面的一条指令,不管分支发生与否其总是被执行。所以本实验用编译器生成的机器码,每条跳转指令后都有一条空指令(00000000)。

Repository Comments ( 0 )

Sign in to post a comment

About

计算机组成原理与系统结构实验(Computer Organization and Architecture experiment) expand collapse
SystemVerilog and 6 more languages
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
1
https://git.oschina.net/themql/COA_exp.git
git@git.oschina.net:themql/COA_exp.git
themql
COA_exp
COA_exp
master

Search