Skip to content

Commit 9abf9e6

Browse files
authored
vfixed sat add/sub sequencing (#208)
1 parent 791d133 commit 9abf9e6

8 files changed

+79
-33
lines changed

arches/isa_json/gen_uarch_rv64v_json.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,21 @@
193193
"vmv.v.x" : {"pipe" : "vint", "uop_gen" : "ARITH", "latency" : 1},
194194
"vmv.v.i" : {"pipe" : "vint", "uop_gen" : "ARITH", "latency" : 1},
195195

196-
# TODO: Vector Fixed-Point Arithmetic Instructions: Vector Single-Width Saturating Add and Subtract
196+
# Vector Fixed-Point Arithmetic Instructions: Vector Single-Width Saturating Add and Subtract
197+
"vsaddu.vv" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
198+
"vsaddu.vx" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
199+
"vsaddu.vi" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
200+
201+
"vsadd.vv" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
202+
"vsadd.vx" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
203+
"vsadd.vi" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
204+
205+
"vssubu.vv" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
206+
"vssubu.vx" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
207+
208+
"vssub.vv" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
209+
"vssub.vx" : {"pipe" : "vfixed", "uop_gen" : "ARITH", "latency" : 1},
210+
197211
# TODO: Vector Fixed-Point Arithmetic Instructions: Vector Single-Width Averaging Add and Subtract
198212
# Vector Fixed-Point Arithmetic Instructions: Vector Single-Width Fractional Multiply with Rounding and Saturation
199213
"vsmul.vx" : {"pipe" : "vmul", "uop_gen" : "ARITH", "latency" : 3},

arches/isa_json/olympia_uarch_rv64v.json

+30-30
Original file line numberDiff line numberDiff line change
@@ -1645,39 +1645,39 @@
16451645
},
16461646
{
16471647
"mnemonic": "vsadd.vi",
1648-
"pipe": "?",
1649-
"uop_gen": "NONE",
1650-
"latency": 0
1648+
"pipe": "vint",
1649+
"uop_gen": "ARITH",
1650+
"latency": 1
16511651
},
16521652
{
16531653
"mnemonic": "vsadd.vv",
1654-
"pipe": "?",
1655-
"uop_gen": "NONE",
1656-
"latency": 0
1654+
"pipe": "vint",
1655+
"uop_gen": "ARITH",
1656+
"latency": 1
16571657
},
16581658
{
16591659
"mnemonic": "vsadd.vx",
1660-
"pipe": "?",
1661-
"uop_gen": "NONE",
1662-
"latency": 0
1660+
"pipe": "vint",
1661+
"uop_gen": "ARITH",
1662+
"latency": 1
16631663
},
16641664
{
16651665
"mnemonic": "vsaddu.vi",
1666-
"pipe": "?",
1667-
"uop_gen": "NONE",
1668-
"latency": 0
1666+
"pipe": "vint",
1667+
"uop_gen": "ARITH",
1668+
"latency": 1
16691669
},
16701670
{
16711671
"mnemonic": "vsaddu.vv",
1672-
"pipe": "?",
1673-
"uop_gen": "NONE",
1674-
"latency": 0
1672+
"pipe": "vint",
1673+
"uop_gen": "ARITH",
1674+
"latency": 1
16751675
},
16761676
{
16771677
"mnemonic": "vsaddu.vx",
1678-
"pipe": "?",
1679-
"uop_gen": "NONE",
1680-
"latency": 0
1678+
"pipe": "vint",
1679+
"uop_gen": "ARITH",
1680+
"latency": 1
16811681
},
16821682
{
16831683
"mnemonic": "vsbc.vvm",
@@ -1945,27 +1945,27 @@
19451945
},
19461946
{
19471947
"mnemonic": "vssub.vv",
1948-
"pipe": "?",
1949-
"uop_gen": "NONE",
1950-
"latency": 0
1948+
"pipe": "vint",
1949+
"uop_gen": "ARITH",
1950+
"latency": 1
19511951
},
19521952
{
19531953
"mnemonic": "vssub.vx",
1954-
"pipe": "?",
1955-
"uop_gen": "NONE",
1956-
"latency": 0
1954+
"pipe": "vint",
1955+
"uop_gen": "ARITH",
1956+
"latency": 1
19571957
},
19581958
{
19591959
"mnemonic": "vssubu.vv",
1960-
"pipe": "?",
1961-
"uop_gen": "NONE",
1962-
"latency": 0
1960+
"pipe": "vint",
1961+
"uop_gen": "ARITH",
1962+
"latency": 1
19631963
},
19641964
{
19651965
"mnemonic": "vssubu.vx",
1966-
"pipe": "?",
1967-
"uop_gen": "NONE",
1968-
"latency": 0
1966+
"pipe": "vint",
1967+
"uop_gen": "ARITH",
1968+
"latency": 1
19691969
},
19701970
{
19711971
"mnemonic": "vsub.vv",

core/Dispatch.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ namespace olympia
137137
LSU_BUSY = InstArchInfo::TargetPipe::LSU,
138138
MUL_BUSY = InstArchInfo::TargetPipe::MUL,
139139
VINT_BUSY = InstArchInfo::TargetPipe::VINT,
140+
VFIXED_BUSY = InstArchInfo::TargetPipe::VFIXED,
140141
VMASK_BUSY = InstArchInfo::TargetPipe::VMASK,
141142
VMUL_BUSY = InstArchInfo::TargetPipe::VMUL,
142143
VDIV_BUSY = InstArchInfo::TargetPipe::VDIV,
@@ -176,6 +177,8 @@ namespace olympia
176177
sparta::Counter::COUNT_NORMAL, getClock()),
177178
sparta::CycleCounter(getStatisticSet(), "stall_vint_busy", "VINT busy",
178179
sparta::Counter::COUNT_NORMAL, getClock()),
180+
sparta::CycleCounter(getStatisticSet(), "stall_vfixed_busy", "VFIXED busy",
181+
sparta::Counter::COUNT_NORMAL, getClock()),
179182
sparta::CycleCounter(getStatisticSet(), "stall_vmask_busy", "VMASK busy",
180183
sparta::Counter::COUNT_NORMAL, getClock()),
181184
sparta::CycleCounter(getStatisticSet(), "stall_vmul_busy", "VMUL busy",
@@ -215,6 +218,8 @@ namespace olympia
215218
sparta::Counter::COUNT_NORMAL),
216219
sparta::Counter(getStatisticSet(), "count_vint_insts", "Total VINT insts",
217220
sparta::Counter::COUNT_NORMAL),
221+
sparta::Counter(getStatisticSet(), "count_vfixed_insts", "Total VFIXED insts",
222+
sparta::Counter::COUNT_NORMAL),
218223
sparta::Counter(getStatisticSet(), "count_vmask_insts", "Total VMASK insts",
219224
sparta::Counter::COUNT_NORMAL),
220225
sparta::Counter(getStatisticSet(), "count_vmul_insts", "Total VMUL insts",

core/InstArchInfo.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace olympia
1818
{"lsu", InstArchInfo::TargetPipe::LSU},
1919
{"mul", InstArchInfo::TargetPipe::MUL},
2020
{"vint", InstArchInfo::TargetPipe::VINT},
21+
{"vfixed", InstArchInfo::TargetPipe::VFIXED},
2122
{"vmask", InstArchInfo::TargetPipe::VMASK},
2223
{"vset", InstArchInfo::TargetPipe::VSET},
2324
{"vmul", InstArchInfo::TargetPipe::VMUL},
@@ -39,6 +40,7 @@ namespace olympia
3940
{InstArchInfo::TargetPipe::LSU, "LSU"},
4041
{InstArchInfo::TargetPipe::MUL, "MUL"},
4142
{InstArchInfo::TargetPipe::VINT, "VINT"},
43+
{InstArchInfo::TargetPipe::VFIXED, "VFIXED"},
4244
{InstArchInfo::TargetPipe::VMASK, "VMASK"},
4345
{InstArchInfo::TargetPipe::VSET, "VSET"},
4446
{InstArchInfo::TargetPipe::VMUL, "VMUL"},

core/InstArchInfo.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ namespace olympia
4949
LSU,
5050
MUL,
5151
VINT,
52+
VFIXED,
5253
VMASK,
5354
VMUL,
5455
VDIV,

test/core/vector/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vmulvx_e8m4.json ${
1717
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vwmulvv_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vwmulvv_e8m4.json SYMBOLIC)
1818
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vmseqvv_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vmseqvv_e8m4.json SYMBOLIC)
1919
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vrgather.json ${CMAKE_CURRENT_BINARY_DIR}/vrgather.json SYMBOLIC)
20-
21-
20+
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsadd.json ${CMAKE_CURRENT_BINARY_DIR}/vsadd.json SYMBOLIC)
2221

2322
sparta_named_test(Vector_test_vsetivli Vector_test -l top info vsetivli.out -c test_cores/test_big_core.yaml --input-file vsetivli_vaddvv_e8m4.json)
2423
sparta_named_test(Vector_test_vsetvli Vector_test -l top info vsetvli.out -c test_cores/test_big_core.yaml --input-file vsetvli_vaddvv_e32m1ta.json)
@@ -28,4 +27,5 @@ sparta_named_test(Vector_test_multiple_vset Vector_test -l top info mulitple_vse
2827
sparta_named_test(Vector_test_vmulvx Vector_test -l top info vmulvx.out -c test_cores/test_big_core.yaml --input-file vmulvx_e8m4.json)
2928
sparta_named_test(Vector_test_vmulvv Vector_test -l top info vmulvv.out -c test_cores/test_big_core.yaml --input-file vwmulvv_e8m4.json)
3029
sparta_named_test(Vector_test_vmseqvv Vector_test -l top info vmseqvv.out -c test_cores/test_big_core.yaml --input-file vmseqvv_e8m4.json)
30+
sparta_named_test(Vector_test_vsadd Vector_test -l top info vsadd.out -c test_cores/test_big_core.yaml --input-file vsadd.json)
3131
sparta_named_test(Vector_unsupported_test Vector_test -l top info unsupported.out -c test_cores/test_big_core.yaml --input-file vrgather.json)

test/core/vector/Vector_test.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ void runTests(int argc, char **argv)
293293
}
294294
EXPECT_TRUE(sparta_exception_fired);
295295
}
296+
else if (input_file.find("vsadd.json") != std::string::npos)
297+
{
298+
cls.runSimulator(&sim);
299+
300+
rob_tester.test_num_insts_retired(2);
301+
rob_tester.test_num_uops_retired(5);
302+
rob_tester.test_last_inst_has_tail(false);
303+
}
296304
else
297305
{
298306
sparta_assert(false, "Invalid input file: " << input_file);

test/core/vector/vsadd.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"mnemonic": "vsetvli",
4+
"rs1": 1,
5+
"vtype": "0x2",
6+
"rd": 0,
7+
"vl": 256,
8+
"vta": 0
9+
},
10+
{
11+
"mnemonic": "vsadd.vv",
12+
"vd": 12,
13+
"vs2": 8,
14+
"vs1": 4
15+
}
16+
]

0 commit comments

Comments
 (0)