mirror of
https://gitlab.com/brendanhaines/cpu.git
synced 2024-12-26 19:16:48 -07:00
passes quick test: slli, srli, srai
This commit is contained in:
parent
46a0972803
commit
913ffb3af6
10
hdl/core.v
10
hdl/core.v
|
@ -222,9 +222,9 @@ always @(*) begin
|
||||||
10'b100xxxxxxx: s_id_aluop = ALUOP_XOR; // XORI
|
10'b100xxxxxxx: s_id_aluop = ALUOP_XOR; // XORI
|
||||||
10'b110xxxxxxx: s_id_aluop = ALUOP_OR; // ORI
|
10'b110xxxxxxx: s_id_aluop = ALUOP_OR; // ORI
|
||||||
10'b111xxxxxxx: s_id_aluop = ALUOP_AND; // ANDI
|
10'b111xxxxxxx: s_id_aluop = ALUOP_AND; // ANDI
|
||||||
10'b0010000000: s_id_aluop = ALUOP_SL; // SLLI
|
10'b001000000x: s_id_aluop = ALUOP_SL; // SLLI // NOTE: technically s_id_funct7[0] must be 0 however GCC allows shifts of up to 63b despite assembling for 32b. I can tolerate this deviation from ISA spec at essentially no cost
|
||||||
10'b1010000000: s_id_aluop = ALUOP_SRL; // SRLI
|
10'b101000000x: s_id_aluop = ALUOP_SRL; // SRLI // NOTE: technically s_id_funct7[0] must be 0 however GCC allows shifts of up to 63b despite assembling for 32b. I can tolerate this deviation from ISA spec at essentially no cost
|
||||||
10'b1010100000: s_id_aluop = ALUOP_SRA; // SRAI
|
10'b101010000x: s_id_aluop = ALUOP_SRA; // SRAI // NOTE: technically s_id_funct7[0] must be 0 however GCC allows shifts of up to 63b despite assembling for 32b. I can tolerate this deviation from ISA spec at essentially no cost
|
||||||
default: begin
|
default: begin
|
||||||
s_id_s1 = 32'hxxxxxxxx;
|
s_id_s1 = 32'hxxxxxxxx;
|
||||||
s_id_s2 = 32'hxxxxxxxx;
|
s_id_s2 = 32'hxxxxxxxx;
|
||||||
|
@ -312,10 +312,10 @@ always @(*) begin
|
||||||
s_ex_alu_out = s_ex_data1 << s_ex_data2;
|
s_ex_alu_out = s_ex_data1 << s_ex_data2;
|
||||||
end
|
end
|
||||||
ALUOP_SRL: begin
|
ALUOP_SRL: begin
|
||||||
s_ex_alu_out = s_ex_data1 >> s_ex_data2;
|
s_ex_alu_out = s_ex_data1 >> s_ex_data2[5:0]; // NOTE: shamt is only 5 bits. Increased for gcc support
|
||||||
end
|
end
|
||||||
ALUOP_SRA: begin
|
ALUOP_SRA: begin
|
||||||
s_ex_alu_out = s_ex_data1 >>> s_ex_data2;
|
s_ex_alu_out = $signed(s_ex_data1) >>> s_ex_data2[5:0]; // NOTE: shamt is only 5 bits. Increased for gcc support
|
||||||
end
|
end
|
||||||
ALUOP_SLT: begin
|
ALUOP_SLT: begin
|
||||||
s_ex_alu_out = $signed(s_ex_data1) < $signed(s_ex_data2);
|
s_ex_alu_out = $signed(s_ex_data1) < $signed(s_ex_data2);
|
||||||
|
|
29
test/test.S
29
test/test.S
|
@ -8,9 +8,6 @@ _start:
|
||||||
# JAL
|
# JAL
|
||||||
# JALR
|
# JALR
|
||||||
|
|
||||||
# SLLI
|
|
||||||
# SRLI
|
|
||||||
# SRAI
|
|
||||||
# SLTI
|
# SLTI
|
||||||
# SLTUI
|
# SLTUI
|
||||||
|
|
||||||
|
@ -96,6 +93,32 @@ _start:
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
|
|
||||||
|
# slli
|
||||||
|
slli x24, x23, 4 # x24 = 0x00007880
|
||||||
|
slli x25, x2, 1 # x25 = 0xfffffffe
|
||||||
|
slli x26, x2, 63 # x26 = 0x00000000 // NOTE: I would expect GCC to throw an error here. It tolerates up to 63 bit shift despite assembling for 32b
|
||||||
|
slli x27, x2, 31 # x27 = 0x80000000
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
|
# srli
|
||||||
|
srli x28, x23, 4 # x28 = 0x00000078
|
||||||
|
srli x29, x2, 1 # x29 = 0x7fffffff
|
||||||
|
srli x30, x2, 63 # x30 = 0x00000000 // NOTE: I would expect GCC to throw an error here. It tolerates up to 63 bit shift despite assembling for 32b
|
||||||
|
srli x3, x2, 31 # x3 = 0x00000001
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
|
# srai
|
||||||
|
srai x4, x23, 4 # x4 = 0x00000078 // fails
|
||||||
|
srai x5, x2, 1 # x5 = 0xffffffff
|
||||||
|
srai x6, x2, 63 # x6 = 0xffffffff // NOTE: I would expect GCC to throw an error here. It tolerates up to 63 bit shift despite assembling for 32b
|
||||||
|
srai x7, x2, 31 # x7 = 0xffffffff
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
# counter and infinite loop
|
# counter and infinite loop
|
||||||
nop
|
nop
|
||||||
|
|
Loading…
Reference in New Issue
Block a user