All ALU tests pass
parent
c1fd5a6c12
commit
5b1aee887b
|
@ -1 +1,2 @@
|
|||
*.swp
|
||||
obj_dir
|
||||
|
|
2
Makefile
2
Makefile
|
@ -1,7 +1,7 @@
|
|||
obj_dir/Vcpu.cpp: cpu.v test_main.cpp
|
||||
verilator -Wall -cc cpu.v --exe test_main.cpp
|
||||
|
||||
obj_dir/Vcpu: obj_dir/Vcpu.cpp
|
||||
obj_dir/Vcpu: obj_dir/Vcpu.cpp test_main.cpp
|
||||
cd obj_dir; make -j -f Vcpu.mk Vcpu
|
||||
|
||||
test: obj_dir/Vcpu
|
||||
|
|
7
cpu.v
7
cpu.v
|
@ -187,8 +187,11 @@ module cpu (
|
|||
vr[15] <= {7'b0, vr[x][0]};
|
||||
vr[x] <= vr[x] >> 1;
|
||||
end
|
||||
7: { vr[15], vr[x] } <= ({8'b0, vr[y]} - {8'b0, vr[x]}) ^ (1 << 8);
|
||||
15: begin
|
||||
7: begin
|
||||
vr[x] <= vr[y] - vr[x];
|
||||
vr[15] <= {7'b0, vr[y] >= vr[x]};
|
||||
end
|
||||
14: begin
|
||||
vr[15] <= {7'b0, vr[x][7]};
|
||||
vr[x] <= vr[x] << 1;
|
||||
end
|
||||
|
|
|
@ -99,4 +99,21 @@ int main(int argc, char **argv)
|
|||
test_alu_instruction_vf(0x45, 0x45, 0x8125, 0x00, 0x01);
|
||||
printf("SUB (borrow) ");
|
||||
test_alu_instruction_vf(0x15, 0x45, 0x8125, 0xD0, 0x00);
|
||||
// SHR
|
||||
printf("SHR (one) ");
|
||||
test_alu_instruction_vf(0x45, 0x00, 0x8126, 0x45>>1, 0x01);
|
||||
printf("SHR (zero) ");
|
||||
test_alu_instruction_vf(0x44, 0x00, 0x8126, 0x44>>1, 0x00);
|
||||
// SUBN
|
||||
printf("SUBN (no borrow) ");
|
||||
test_alu_instruction_vf(0x15, 0x45, 0x8127, 0x30, 0x01);
|
||||
printf("SUBN (zero, no borrow) ");
|
||||
test_alu_instruction_vf(0x45, 0x45, 0x8127, 0x00, 0x01);
|
||||
printf("SUBN (borrow) ");
|
||||
test_alu_instruction_vf(0x45, 0x15, 0x8127, 0xD0, 0x00);
|
||||
// SHL
|
||||
printf("SHL (one) ");
|
||||
test_alu_instruction_vf(0xA4, 0x00, 0x812E, (0xA4<<1)&0xFF, 0x01);
|
||||
printf("SHL (zero) ");
|
||||
test_alu_instruction_vf(0x24, 0x00, 0x812E, (0x24<<1)&0xFF, 0x00);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue