fixed vreg clearning
This commit is contained in:
@@ -35,3 +35,8 @@ HEX: ELF
|
||||
|
||||
ELF:
|
||||
$(COMP) $(CC_FLAGS) $(VX_STR) $(VX_VEC) $(VX_FIO) $(NEWLIB) $(VX_INT) $(VX_IO) $(VX_API) $(VX_TEST) $(VX_MAIN).c $(LIBS) -Iinclude -o $(VX_MAIN).elf
|
||||
|
||||
run:
|
||||
../../simX/obj_dir/Vcache_simX -E -a rv32i --core vx_vector_main.hex -s -b 1> emulator.debug
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void vx_vec_test(int *);
|
||||
void vx_vec_test(int n, int* a, int* b, int* c); //vvaddint32
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
|
||||
|
||||
|
||||
.type vx_vec_test, @function
|
||||
.global vx_vec_test
|
||||
vx_vec_test:
|
||||
li a1, 7
|
||||
sw a1, 0(a0)
|
||||
ret
|
||||
|
||||
|
||||
|
||||
|
||||
# slli a0, a0, 2
|
||||
# add a0, a0, a3
|
||||
# vmv.v.x vv0, a2
|
||||
# # vsplat4 vv0, a2
|
||||
# stripmine_loop:
|
||||
# vlb4 vv1, (a1)
|
||||
# vcmpez4 vp0, vv1
|
||||
# !vp0 vlw4 vv1, (a3)
|
||||
# !vp0 vlw4 vv2, (a4)
|
||||
# !vp0 vfma4 vv1, vv0, vv1, vv2
|
||||
# !vp0 vsw4 vv1, (a4)
|
||||
# addi a1, a1, 4
|
||||
# addi a3, a3, 16
|
||||
# addi a4, a4, 16
|
||||
# bleu a3, a0, stripmine_loop
|
||||
# handle edge cases
|
||||
# when (n % 4) != 0 ...
|
||||
# vector-vector add routine of 32-bit integers
|
||||
# void vvaddint32(size_t n, const int*x, const int*y, int*z)
|
||||
# { for (size_t i=0; i<n; i++) { z[i]=x[i]+y[i]; } }
|
||||
#
|
||||
# a0 = n, a1 = x, a2 = y, a3 = z
|
||||
# Non-vector instructions are indented
|
||||
vsetvli t0, a0, e32 # Set vector length based on 32-bit vectors
|
||||
vlw.v v0, (a1) # Get first vector
|
||||
sub a0, a0, t0 # Decrement number done
|
||||
slli t0, t0, 2 # Multiply number done by 4 bytes
|
||||
add a1, a1, t0 # Bump pointer
|
||||
vlw.v v1, (a2) # Get second vector
|
||||
add a2, a2, t0 # Bump pointer
|
||||
vadd.vv v2, v0, v1 # Sum vectors
|
||||
vsw.v v2, (a3) # Store result
|
||||
add a3, a3, t0 # Bump pointer
|
||||
bnez a0, vx_vec_test # Loop back
|
||||
ret # Finished
|
||||
@@ -1,32 +1,29 @@
|
||||
|
||||
#include "../../runtime/intrinsics/vx_intrinsics.h"
|
||||
#include "vx_vec.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
vx_tmc(1);
|
||||
// int * a = malloc(4);
|
||||
// int * b = malloc(4);
|
||||
// int * c = malloc(4);
|
||||
vx_tmc(1);
|
||||
|
||||
printf("Hello\n");
|
||||
|
||||
int n = 64;
|
||||
int *a = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
||||
int *b = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
||||
int *c = (int*)malloc(sizeof(int) * n); //{1, 1, 1, 1, 1};
|
||||
|
||||
for(int i = 0; i < n; ++i)
|
||||
{
|
||||
a[i] = b[i] = c[i] = 1;
|
||||
}
|
||||
|
||||
vx_vec_test(n, a, b, c);
|
||||
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
printf("a[%d]=%d, b[%d]=%d, c[%d]=%d\n", i, a[i], i, b[i], i, c[i]);
|
||||
}
|
||||
|
||||
|
||||
int * a = malloc(4);
|
||||
*a = 5;
|
||||
printf("Value of a: %d\n", *a);
|
||||
|
||||
vx_vec_test(a);
|
||||
|
||||
printf("Value of a: %d\n", *a);
|
||||
|
||||
|
||||
// for (int i = 0; i < 4; i++)
|
||||
// {
|
||||
// if (c[i] != (a[i] + b[i]))
|
||||
// {
|
||||
// printf("Fail\n");
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
vx_tmc(0);
|
||||
vx_tmc(0);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user