Commit 174089eb authored by Marc's avatar Marc
Browse files

Module integrated with bypasses working

parent 4bf87459
......@@ -45,9 +45,10 @@ mat_mul: mat_mul.o
cp mat_mul.srec test.srec
sparc-gaisler-elf-objdump -d mat_mul.o > mat_mul.dump
mat_mul_simd: mat_mul_simd.o
mat_mul_simd: mat_mul_simd.o bin_change
$(XCC) $(XCFLAGS) mat_mul_simd.o $(XLDFLAGS)-o mat_mul_simd.exe
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd.exe mat_mul_simd.srec
sparc-gaisler-elf-objcopy -O srec --gap-fill 0 mat_mul_simd.exe tmp.mat_mul_simd.srec
./bin_change tmp.mat_mul_simd.srec mat_mul_simd.list mat_mul_simd.srec 83288001
cp mat_mul_simd.srec test.srec
sparc-gaisler-elf-objdump -d mat_mul_simd.o > mat_mul_simd.dump
......
......@@ -9,12 +9,12 @@ int main(){
const bitset<1> imm ("0");
int input;
cout<<"Use default addresses?(1/0)\n";
cin>>input;
bitset<5> rd(1);
bitset<5> rs1(2);
bitset<5> rs2(1);
if(!input){
//cout<<"Use default addresses?(1/0)\n";
//cin>>input;
//bitset<5> rd(1);
//bitset<5> rs1(2);
//bitset<5> rs2(1);
//if(!input){
cout<<"Input destination register:\n";
cin>>input;
bitset<5> rd(input);
......@@ -24,7 +24,7 @@ int main(){
cout<<"Input source2 register:\n";
cin>>input;
bitset<5> rs2(input);
}
//}
cout<<"Input stage1 op:\n";
cin>>input;
bitset<5> op1(input);
......
......@@ -8,57 +8,24 @@ int main()
{
char string[3*(3+(6*N*N+N))];
int pos = 0;
// puts("Matrix Multiplication");
int A[4][4] = {{1,2,3,4},{1,2,3,4},{1,2,3,4},{1,2,3,4}};
int D[N][N], B[N][N], C[N][N];
printf("a: %p\n",&A);
printf("b: %p\n",&B);
printf("c: %p\n",&C);
char A[N][N], B[N][N], C[N][N];
srand(N);
for(int i=0; i<N; i++)
for(int j=0; j<N; j++) {
A[i][j] = i;
B[i][j] = j;
A[i][j] = rand()%10;
B[i][j] = rand()%10;
}
int sum = 0;
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
for(int i=0; i<N; i++)
for(int j=0; j<N; j++){
for(int k=0; k<N; k++){
__asm__("nop");
__asm__("nop");
sum=sum+A[i][k]*B[k][j];
__asm__("nop");
__asm__("nop");
}
C[i][j] = sum;
sum = 0;
}
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
pos += sprintf(&string[pos],"A:\n");
for(int i=0; i<N; i++){
......
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#define N 4
int main()
{
char string[3*(3+(6*N*N+N))];
int pos = 0;
unsigned char A[N][N], B[N][N], C[N][N];
srand(N);
for(int i=0; i<N; i++)
for(int j=0; j<N; j++) {
A[i][j] = 4*i+j;//rand()%10;
B[j][i] = 4*i+j;//rand()%10;
}
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
int sum =0;
for(int i = 0; i<N; i++)
for(int j=0; j<N; j++){
for(int k=0; k<N; k+=4){
char a = A[i][k];
char b = B[j][k];
sum += a*b;
a = A[i][k+1];
b = B[j][k+1];
sum += a*b;
a = A[i][k+2];
b = B[j][k+2];
sum += a*b;
a = A[i][k+3];
b = B[j][k+3];
sum += a*b;
}
C[i][j] = sum;
sum =0;
}
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
__asm__("nop");
pos += sprintf(&string[pos],"A:\n");
for(int i=0; i<N; i++){
for(int j=0; j<N; j++)
pos+=sprintf(&string[pos],"%d ", A[i][j]);
pos+=sprintf(&string[pos],"\n");
}
pos += sprintf(&string[pos],"B:\n");
for(int i=0; i<N; i++){
for(int j=0; j<N; j++)
pos+=sprintf(&string[pos],"%d ", B[j][i]);
pos+=sprintf(&string[pos],"\n");
}
pos += sprintf(&string[pos],"C:\n");
for(int i=0; i<N; i++){
for(int j=0; j<N; j++)
pos+=sprintf(&string[pos],"%d ", C[i][j]);
pos+=sprintf(&string[pos],"\n");
}
puts(string);
puts("END OF TEST");
}
This source diff could not be displayed because it is too large. You can view the blob instead.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//This is a simple test, since the compiler support is not provided
//It is necessary to modify the srec file by hand
int main()
{
int a,b,c;
//test nop
a = 0x01020304;
b = 0x00010203;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
//nop 82488001
printf("NOP (move) c=%#010x, expected 0x01020304 mask 1111\n", c);
//test add
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
//add a b
printf("add: c=%#010x, expected result 0x01030507 mask 1111\n", c);
//test sadd
a=0x8180ff01;
b=0x81ff7f7f;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 0000
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("sadd: c=%#010x, expected result 0x8180ff01 mask 0000\n", c);
//test sub
a=0x0a0a0a0a;
b=0x00050a0b;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("sub: c=%#010x, expected result 0x0a0a0a0a mask 0000\n", c);
//test ssub
a=0x807f0afb;
b=0x05fffb0a;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 0001
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("ssub: c=%#010x, expected result 0x807f0af1 mask 0001\n", c);
//test Max MAX signed
a=0x0204080a;
b=0x204080a0;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 1011
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("signed max max: c=%#010x, expected result 0x00000020 mask 1011\n", c);
//test Max MAX unsigned
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 1110
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("unsigned max max: c=%#010x, expected result 0x00000080 mask 1110\n", c);
//test Min MIN unsigned
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 1111
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("unsigned min min: c=%#010x, expected result 0x00000002 mask 1111\n", c);
//test Min MIN signed
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 1100
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("signed min min: c=%#010x, expected result 0x00000002 mask 1100\n", c);
//test dot product
a=0x01020304;
b=0x00010203;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//1010
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("dot product: c=%#010x, expected result 0x0000000C mask 1010\n", c);
//test dot product2
a=0xfffe03fc;
b=0x00ff0203;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("dot product2: c=%#010x, expected result 0x00000000 mask 1010\n", c);
//test saturated mul
a=0x7f7ffdff;
b=0x7fff7f80;
//c=0x7f81807f
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("saturate mul: c=%#010x, expected result 0x7f7f80ff mask 1010\n",c);
//test div
a=0x40404040;
b=0x01020040;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 1111
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("div: c=%#010x, expected result 0x4020ff01 mask 1111\n", c);
//test div2
a=0xF6F6F6F6;
b=0x0102ff0a;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("div2: c=%#010x, expected result 0xf6fb0aff mask 1111\n", c);
//test nand as not (a nand a = !a)
a=0xdeadbeaf;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
//mask 0011
__asm__("sll %g2, %g1, %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("nand: c=%#010x, expected result 0xDEAD4150 mask 0011\n", c);
//test xor reduction
a=0xfeedcafe;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("sll %g2, %g1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("xor reduce: c=%#010x, expected result 0x00000027 mask 0011\n", c);
puts("END OF TEST");
}
82488001
82488021
80C80000
824881A1
82488041
80C80001
824881C1
80C8000B
824888A1
80C8000E
82489AA1
80C8000F
82489EC1
80C8000C
82488CC1
80C8000A
82488461
82488461
824881E1
80C8000F
82488081
82488081
80C80003
82488142
82489001
ghdl -m -fexplicit --ieee=synopsys --mb-comments --warn-no-binding -O2 --workdir=gnu/work --work=work `cat ghdl.path` testbench
./testbench --assert-level=error --ieee-asserts=disable
LEON3 MP Demonstration design
GRLIB Version 2020.2.0, build 4254
Target technology: inferred , memory library: inferred
ahbctrl: AHB arbiter/multiplexer rev 1
ahbctrl: Common I/O area disabled
ahbctrl: AHB masters: 2, AHB slaves: 8
ahbctrl: Configuration area at 0xfffff000, 4 kbyte
ahbctrl: mst0: Cobham Gaisler LEON3 SPARC V8 Processor
ahbctrl: mst1: Cobham Gaisler AHB Debug UART
ahbctrl: slv0: European Space Agency LEON2 Memory Controller
ahbctrl: memory at 0x00000000, size 512 Mbyte, cacheable, prefetch
ahbctrl: memory at 0x20000000, size 512 Mbyte
ahbctrl: memory at 0x40000000, size 1024 Mbyte, cacheable, prefetch
ahbctrl: slv1: Cobham Gaisler AHB/APB Bridge
ahbctrl: memory at 0x80000000, size 1 Mbyte
apbctrl: APB Bridge at 0x80000000 rev 1
apbctrl: slv0: European Space Agency LEON2 Memory Controller
apbctrl: I/O ports at 0x80000000, size 256 byte
apbctrl: slv1: Cobham Gaisler Generic UART
apbctrl: I/O ports at 0x80000100, size 256 byte
apbctrl: slv2: Cobham Gaisler Multi-processor Interrupt Ctrl.
apbctrl: I/O ports at 0x80000200, size 256 byte
apbctrl: slv3: Cobham Gaisler Modular Timer Unit
apbctrl: I/O ports at 0x80000300, size 256 byte
apbctrl: slv7: Cobham Gaisler AHB Debug UART
apbctrl: I/O ports at 0x80000700, size 256 byte
apbctrl: slv11: Cobham Gaisler General Purpose I/O port
apbctrl: I/O ports at 0x80000b00, size 256 byte
grgpio11: 8-bit GPIO Unit rev 3
gptimer3: Timer Unit rev 1, 8-bit scaler, 4 32-bit timers, irq 8
irqmp: Multi-processor Interrupt Controller rev 4, #cpu 1, eirq 0
apbuart1: Generic UART rev 1, fifo 32, irq 2, scaler bits 12
ahbuart7: AHB Debug UART rev 0
leon3_0: LEON3 SPARC V8 processor rev 3: iuft: 0, fpft: 0, cacheft: 0
leon3_0: icache 1*4 kbyte, dcache 1*4 kbyte
UART: NOP (move) c=0x01020304, expected 0x01020304 mask 1111
UART: add: c=0x01030507, expected result 0x01030507 mask 1111
UART: sadd: c=0x8180ff01, expected result 0x8180ff01 mask 0000
UART: sub: c=0x0a0a0a0a, expected result 0x0a0a0a0a mask 0000
UART: ssub: c=0x807f0af1, expected result 0x807f0af1 mask 0001
UART: signed max max: c=0x00000020, expected result 0x00000020 mask 1011
UART: unsigned max max: c=0x00000080, expected result 0x00000080 mask 1110
UART: unsigned min min: c=0x00000002, expected result 0x00000002 mask 1111
UART: signed min min: c=0x00000002, expected result 0x00000002 mask 1100
UART: dot product: c=0x0000000c, expected result 0x0000000C mask 1010
UART: dot product2: c=0000000000, expected result 0x00000000 mask 1010
UART: saturate mul: c=0x7f7f80ff, expected result 0x7f7f80ff mask 1010
UART: div: c=0x4020ff01, expected result 0x4020ff01 mask 1111
UART: div2: c=0xf6fb0aff, expected result 0xf6fb0aff mask 1111
UART: nand: c=0xdead4150, expected result 0xDEAD4150 mask 0011
UART: xor reduce: c=0x00000027, expected result 0x00000027 mask 0011
UART: END OF TEST
testbench.vhd:411:6:@2754733ns:(assertion failure): *** IU in error mode, simulation halted ***
./testbench:error: assertion failed
in process .testbench(behav).iuerr
./testbench:error: simulation failed
......@@ -12,9 +12,7 @@ int main()
b = 0x00010203;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
//nop 82488001
printf("NOP (move) c=%#010x, expected 0x01020304\n", c);
......@@ -22,22 +20,18 @@ int main()
//test add
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("add %g1, 1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
//add a b
printf("add: c=%#010x, expected result 0x01030507\n", c);
printf("add: c=%#010x, expected result 0x01030508\n", c);
//test sadd
a=0x8180ff01;
b=0x81ff7f7f;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("sadd: c=%#010x, expected result 0x80807e7f\n", c);
......@@ -46,9 +40,7 @@ int main()
b=0x00050a0b;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("sub: c=%#010x, expected result 0x0a0500ff\n", c);
......@@ -57,9 +49,7 @@ int main()
b=0x05fffb0a;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("ssub: c=%#010x, expected result 0x807f7ff1\n", c);
......@@ -68,38 +58,29 @@ int main()
b=0x204080a0;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("add %g1, 1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("signed max max: c=%#010x, expected result 0x00000040\n", c);
printf("signed max max: c=%#010x, expected result 0x00000041\n", c);
//test Max MAX unsigned
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("unsigned max max: c=%#010x, expected result 0x000000a0\n", c);
//test Min MIN unsigned
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("unsigned min min: c=%#010x, expected result 0x00000002\n", c);
//test Min MIN signed
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("signed min min: c=%#010x, expected result 0xffffff80\n", c);
......@@ -108,20 +89,17 @@ int main()
b=0x00010203;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("add %g1, 1, %g1");
__asm__("st %g1, [ %fp + -12 ]");
printf("dot product: c=%#010x, expected result 0x00000014\n", c);
printf("dot product: c=%#010x, expected result 0x00000015\n", c);
//test dot product2
a=0xfffe03fc;
b=0x00ff0203;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("dot product2: c=%#010x, expected result 0xfffffffc\n", c);
......@@ -131,9 +109,7 @@ int main()
//c=0x7f81807f
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("saturate mul: c=%#010x, expected result 0x7f81807f\n",c);
......@@ -142,9 +118,7 @@ int main()
b=0x01020040;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("div: c=%#010x, expected result 0x4020ff01\n", c);
......@@ -153,9 +127,7 @@ int main()
b=0x0102ff0a;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("div2: c=%#010x, expected result 0xf6fb0aff\n", c);
......@@ -163,9 +135,7 @@ int main()
a=0xdeadbeaf;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("nand: c=%#010x, expected result 0x21524150\n", c);
......@@ -173,9 +143,7 @@ int main()
a=0xfeedcafe;
__asm__("ld [%fp + -4], %g2");
__asm__("ld [%fp + -8], %g1");
__asm__("nop");
__asm__("sll %g2, %g1, %g1");
__asm__("nop");
__asm__("st %g1, [ %fp + -12 ]");
printf("xor reduce: c=%#010x, expected result 0x00000027\n", c);
......
This diff is collapsed.