动手写CPU----day6验证逻辑和移位指令
作者:互联网
目录
1.验证逻辑指令
inst_rom.S
.org 0x0
.global _start
.set noat
_start:
lui $1,0x0101
ori $1,$1,0x0101
ori $2,$1,0x1100 # $2 = $1 | 0x1100 = 0x01011101
or $1,$1,$2 # $1 = $1 | $2 = 0x01011101
andi $3,$1,0x00fe # $3 = $1 & 0x00fe = 0x00000000
and $1,$3,$1 # $1 = $3 & $1 = 0x00000000
xori $4,$1,0xff00 # $4 = $1 ^ 0xff00 = 0x0000ff00
xor $1,$4,$1 # $1 = $4 ^ $1 = 0x0000ff00
nor $1,$4,$1 # $1 = $4 ~^ $1 = 0xffff00ff nor is "not or"
将上面的文件放到共享文件夹里,然后直接make all得到inst_rom.data
然后将inst_rom.data放到testbench的文件夹内,进行仿真
结果如下可看见写入到寄存器的时候数据是没问题的,所以验证成功
2.验证移位指令
.org 0x0
.set noat
.global _start
_start:
lui $2,0x0404
ori $2,$2,0x0404
ori $7,$0,0x7
ori $5,$0,0x5
ori $8,$0,0x8
sync
sll $2,$2,8 # $2 = 0x40404040 sll 8 = 0x04040400
sllv $2,$2,$7 # $2 = 0x04040400 sll 7 = 0x02020000
srl $2,$2,8 # $2 = 0x02020000 srl 8 = 0x00020200
srlv $2,$2,$5 # $2 = 0x00020200 srl 5 = 0x00001010
nop
sll $2,$2,19 # $2 = 0x00001010 sll 19 = 0x80800000
ssnop
sra $2,$2,16 # $2 = 0x80800000 sra 16 = 0xffff8080
srav $2,$2,$8 # $2 = 0xffff8080 sra 8 = 0xffffff80
同样进行操作如上即可
得到inst_rom.data进行仿真
可以看到每一个寄存器在对应写入的位置和写入的数值都是正确的,但是目前对于最后两条指令sra,srav可能还存在问题,还在改进
标签:sll,sra,rom,day6,----,start,inst,ori,移位指令 来源: https://blog.csdn.net/qq_37858023/article/details/117718481