Skip to content

Commit bc9d3bb

Browse files
committed
replace magic libraries with open-source ones
1 parent 3c501df commit bc9d3bb

File tree

19 files changed

+176
-176
lines changed

19 files changed

+176
-176
lines changed

addition-gaps/cmd/test-addition/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package main
33
import (
44
"encoding/binary"
55
"fmt"
6+
"github.com/ReconfigureIO/sdaccel/xcl"
67
"os"
7-
"xcl"
88
)
99

1010
func main() {

addition-gaps/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package main
22

33
import (
44
// Import the entire framework (including bundled verilog)
5-
_ "sdaccel"
5+
_ "github.com/ReconfigureIO/sdaccel"
66

7-
aximemory "axi/memory"
8-
axiprotocol "axi/protocol"
7+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
8+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
99
)
1010

1111
// The Top function will be presented as a kernel

addition/cmd/test-addition/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package main
33
import (
44
"encoding/binary"
55
"fmt"
6+
"github.com/ReconfigureIO/sdaccel/xcl"
67
"os"
7-
"xcl"
88
)
99

1010
func main() {

addition/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package main
22

33
import (
44
// Import the entire framework (including bundled verilog)
5-
_ "sdaccel"
5+
_ "github.com/ReconfigureIO/sdaccel"
66

77
// Use the new AXI protocol package
8-
aximemory "axi/memory"
9-
axiprotocol "axi/protocol"
8+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
9+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
1010

1111
"github.com/ReconfigureIO/addition"
1212
)

histogram-array/cmd/test-histogram/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package main
33
import (
44
"encoding/binary"
55
"fmt"
6+
"github.com/ReconfigureIO/sdaccel/xcl"
67
"log"
78
"math/rand"
89
"reflect"
9-
"xcl"
1010
)
1111

1212
const (

histogram-array/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package main
22

33
import (
44
// import the entire framework (including bundled verilog)
5-
_ "sdaccel"
5+
_ "github.com/ReconfigureIO/sdaccel"
66
// Use the new AXI protocol package
7-
aximemory "axi/memory"
8-
axiprotocol "axi/protocol"
7+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
8+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
99
)
1010

1111
// magic identifier for exporting

histogram-parallel/cmd/test-histogram/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package main
33
import (
44
"encoding/binary"
55
"fmt"
6+
"github.com/ReconfigureIO/sdaccel/xcl"
67
"log"
78
"math/rand"
89
"reflect"
9-
"xcl"
1010
)
1111

1212
const (

histogram-parallel/main.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package main
22

33
import (
44
// Import the entire framework (including bundled verilog)
5-
_ "sdaccel"
5+
_ "github.com/ReconfigureIO/sdaccel"
66

7-
axiarbitrate "axi/arbitrate"
8-
aximemory "axi/memory"
9-
axiprotocol "axi/protocol"
7+
axiarbitrate "github.com/ReconfigureIO/sdaccel/axi/arbitrate"
8+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
9+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
1010
)
1111

1212
// Magic identifier for exporting

histogram/cmd/test-histogram/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ package main
33
import (
44
"encoding/binary"
55
"fmt"
6+
"github.com/ReconfigureIO/sdaccel/xcl"
67
"log"
78
"math/rand"
89
"reflect"
9-
"xcl"
1010
)
1111

1212
const (

histogram/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package main
22

33
import (
44
// Import the entire framework (including bundled verilog)
5-
_ "sdaccel"
5+
_ "github.com/ReconfigureIO/sdaccel"
66
// Use the new AXI protocol package
7-
aximemory "axi/memory"
8-
axiprotocol "axi/protocol"
7+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
8+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
99
)
1010

1111
// Magic identifier for exporting

memcopy/cmd/test-memcopy/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package main
22

33
import (
44
"encoding/binary"
5+
"github.com/ReconfigureIO/sdaccel/xcl"
56
"log"
67
"math/rand"
78
"reflect"
89
"testing/quick"
910
"time"
10-
"xcl"
1111
)
1212

1313
const DATA_WIDTH = 12

memcopy/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package main
22

33
import (
44
// Import the entire framework (including bundled verilog)
5-
_ "sdaccel"
5+
_ "github.com/ReconfigureIO/sdaccel"
66
// Use the new AXI protocol package
7-
aximemory "axi/memory"
8-
axiprotocol "axi/protocol"
7+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
8+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
99
)
1010

1111
// Magic identifier for exporting

memtest/cmd/memtest/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package main
22

33
import (
4+
"github.com/ReconfigureIO/sdaccel/xcl"
45
"log"
5-
"xcl"
66
)
77

88
func main() {

memtest/main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
// import the entire framework (including bundled verilog)
5-
_ "sdaccel"
6-
"sdaccel/memory"
5+
_ "github.com/ReconfigureIO/sdaccel"
6+
"github.com/ReconfigureIO/sdaccel/axi/memory"
77
)
88

99
// magic identifier for exporting

template/main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package main
22

33
import (
44
// Import the entire framework (including bundled verilog)
5-
_ "sdaccel"
5+
_ "github.com/ReconfigureIO/sdaccel"
66

77
// Use the new AXI protocol package
8-
aximemory "axi/memory"
9-
axiprotocol "axi/protocol"
8+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
9+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
1010
)
1111

1212
func Top(
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
package main
22

33
import (
4-
"encoding/binary"
5-
"xcl"
6-
"fmt"
4+
"encoding/binary"
5+
"fmt"
6+
"github.com/ReconfigureIO/sdaccel/xcl"
77
)
88

99
func main() {
10-
// Allocate a 'world' for interacting with kernels
11-
world := xcl.NewWorld()
12-
defer world.Release()
10+
// Allocate a 'world' for interacting with kernels
11+
world := xcl.NewWorld()
12+
defer world.Release()
1313

14-
// Import the kernel.
15-
// Right now these two identifiers are hard coded as an output from the build process
16-
krnl := world.Import("kernel_test").GetKernel("reconfigure_io_sdaccel_builder_stub_0_1")
17-
defer krnl.Release()
14+
// Import the kernel.
15+
// Right now these two identifiers are hard coded as an output from the build process
16+
krnl := world.Import("kernel_test").GetKernel("reconfigure_io_sdaccel_builder_stub_0_1")
17+
defer krnl.Release()
1818

19-
// Create/get data and pass arguments to the kernel as required. These could be small pieces of data,
20-
// pointers to memory, data lengths so the Kernel knows what to expect. This all depends on your project.
21-
// We have passed three arguments here, you can pass more as neccessary
19+
// Create/get data and pass arguments to the kernel as required. These could be small pieces of data,
20+
// pointers to memory, data lengths so the Kernel knows what to expect. This all depends on your project.
21+
// We have passed three arguments here, you can pass more as neccessary
2222

23-
// make an array to send to the kernel for processing
24-
input := make([]uint32, 10)
23+
// make an array to send to the kernel for processing
24+
input := make([]uint32, 10)
2525

26-
// seed it with incrementing values
27-
for i, _ := range input {
28-
input[i] = uint32(i)
29-
}
26+
// seed it with incrementing values
27+
for i, _ := range input {
28+
input[i] = uint32(i)
29+
}
3030

31-
// Create space in shared memory for our array input
32-
buff := world.Malloc(xcl.ReadOnly, uint(binary.Size(input)))
33-
defer buff.Free()
31+
// Create space in shared memory for our array input
32+
buff := world.Malloc(xcl.ReadOnly, uint(binary.Size(input)))
33+
defer buff.Free()
3434

35-
// Create a variable to hold the output from the FPGA
36-
var output [10]uint32
35+
// Create a variable to hold the output from the FPGA
36+
var output [10]uint32
3737

38-
// Create space in the shared memory for the output from the FPGA
39-
outputBuff := world.Malloc(xcl.ReadWrite, uint(binary.Size(output)))
40-
defer outputBuff.Free()
38+
// Create space in the shared memory for the output from the FPGA
39+
outputBuff := world.Malloc(xcl.ReadWrite, uint(binary.Size(output)))
40+
defer outputBuff.Free()
4141

42-
// write our input to the shared memory at the location we specified previously
43-
binary.Write(buff.Writer(), binary.LittleEndian, &input)
42+
// write our input to the shared memory at the location we specified previously
43+
binary.Write(buff.Writer(), binary.LittleEndian, &input)
4444

45-
// zero out output space
46-
binary.Write(outputBuff.Writer(), binary.LittleEndian, &output)
45+
// zero out output space
46+
binary.Write(outputBuff.Writer(), binary.LittleEndian, &output)
4747

48-
// Send the location of the input array as the first argument
49-
krnl.SetMemoryArg(0, buff)
50-
// Send the location the FPGA should put the result as the second argument
51-
krnl.SetMemoryArg(1, outputBuff)
52-
// Send the length of the input array, so the kernel knows what to expect, as the third argument
53-
krnl.SetArg(2, uint32(len(input)))
48+
// Send the location of the input array as the first argument
49+
krnl.SetMemoryArg(0, buff)
50+
// Send the location the FPGA should put the result as the second argument
51+
krnl.SetMemoryArg(1, outputBuff)
52+
// Send the length of the input array, so the kernel knows what to expect, as the third argument
53+
krnl.SetArg(2, uint32(len(input)))
5454

55-
// Run the kernel with the supplied arguments. This is the same for all projects.
56-
// The arguments ``(1, 1, 1)`` relate to x, y, z co-ordinates and correspond to our current
57-
// underlying technology.
58-
krnl.Run(1, 1, 1)
55+
// Run the kernel with the supplied arguments. This is the same for all projects.
56+
// The arguments ``(1, 1, 1)`` relate to x, y, z co-ordinates and correspond to our current
57+
// underlying technology.
58+
krnl.Run(1, 1, 1)
5959

60-
// Display/use the results returned from the FPGA as required!
60+
// Display/use the results returned from the FPGA as required!
6161

62-
binary.Read(outputBuff.Reader(), binary.LittleEndian, &output);
62+
binary.Read(outputBuff.Reader(), binary.LittleEndian, &output)
6363

64-
for _, val := range output {
65-
print(val)
66-
}
64+
for _, val := range output {
65+
print(val)
66+
}
6767

6868
}
+40-40
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
11
package main
22

33
import (
4-
// Import the entire framework (including bundled verilog)
5-
_ "sdaccel"
4+
// Import the entire framework (including bundled verilog)
5+
_ "github.com/ReconfigureIO/sdaccel"
66

7-
// Use the new AXI protocol package
8-
aximemory "axi/memory"
9-
axiprotocol "axi/protocol"
7+
// Use the new AXI protocol package
8+
aximemory "github.com/ReconfigureIO/sdaccel/axi/memory"
9+
axiprotocol "github.com/ReconfigureIO/sdaccel/axi/protocol"
1010
)
1111

1212
func Top(
13-
// Specify inputs and outputs to the kernel. Tell the kernel where to find data in shared memory, what data type
14-
// to expect or pass single integers directly to the kernel by sending them to the FPGA's control register
15-
16-
inputData uintptr,
17-
outputData uintptr,
18-
length uint32,
19-
20-
// Set up channels for interacting with the shared memory
21-
memReadAddr chan<- axiprotocol.Addr,
22-
memReadData <-chan axiprotocol.ReadData,
23-
24-
memWriteAddr chan<- axiprotocol.Addr,
25-
memWriteData chan<- axiprotocol.WriteData,
26-
memWriteResp <-chan axiprotocol.WriteResp) {
27-
28-
// Do whatever needs doing with the data from the host
29-
30-
// Read all the input data into a channel
31-
inputChan := make(chan uint32)
32-
go aximemory.ReadBurstUInt32(
33-
memReadAddr, memReadData, true, inputData, length, inputChan)
34-
35-
// Create a channel for the result of the calculation
36-
transformedChan := make(chan uint32)
37-
// multiply each element of the input channel by 2 and send to the channel we just made to hold the result
38-
go func(){
39-
// no need to stop here, which will save us some clocks checking
40-
for {
41-
transformedChan <- (<-inputChan) * 2
42-
}
43-
}()
44-
45-
// Write transformed results back to memory
46-
aximemory.WriteBurstUInt32(
47-
memWriteAddr, memWriteData, memWriteResp, true, outputData, length, transformedChan)
13+
// Specify inputs and outputs to the kernel. Tell the kernel where to find data in shared memory, what data type
14+
// to expect or pass single integers directly to the kernel by sending them to the FPGA's control register
15+
16+
inputData uintptr,
17+
outputData uintptr,
18+
length uint32,
19+
20+
// Set up channels for interacting with the shared memory
21+
memReadAddr chan<- axiprotocol.Addr,
22+
memReadData <-chan axiprotocol.ReadData,
23+
24+
memWriteAddr chan<- axiprotocol.Addr,
25+
memWriteData chan<- axiprotocol.WriteData,
26+
memWriteResp <-chan axiprotocol.WriteResp) {
27+
28+
// Do whatever needs doing with the data from the host
29+
30+
// Read all the input data into a channel
31+
inputChan := make(chan uint32)
32+
go aximemory.ReadBurstUInt32(
33+
memReadAddr, memReadData, true, inputData, length, inputChan)
34+
35+
// Create a channel for the result of the calculation
36+
transformedChan := make(chan uint32)
37+
// multiply each element of the input channel by 2 and send to the channel we just made to hold the result
38+
go func() {
39+
// no need to stop here, which will save us some clocks checking
40+
for {
41+
transformedChan <- (<-inputChan) * 2
42+
}
43+
}()
44+
45+
// Write transformed results back to memory
46+
aximemory.WriteBurstUInt32(
47+
memWriteAddr, memWriteData, memWriteResp, true, outputData, length, transformedChan)
4848
}

0 commit comments

Comments
 (0)