mirror of
https://github.com/DrasLorus/HLS_arbitrary_Precision_Types.git
synced 2024-07-06 14:35:18 +02:00
Compare commits
2 commits
8d77b77113
...
7a58367433
Author | SHA1 | Date | |
---|---|---|---|
7a58367433 | |||
084b5bbd8b |
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -39,7 +39,9 @@
|
||||||
test
|
test
|
||||||
|
|
||||||
# packages
|
# packages
|
||||||
packages/tarball/*.tar.gz
|
packages/tarball/*
|
||||||
|
!packages/tarball/makefile
|
||||||
|
!packages/tarball/make_tarball.sh
|
||||||
|
|
||||||
packages/debian/*
|
packages/debian/*
|
||||||
!packages/debian/control
|
!packages/debian/control
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#
|
#
|
||||||
# Copyright 2019 Xilinx, Inc.
|
# Copyright 2019 Xilinx, Inc.
|
||||||
|
# Copyright 2022 DrasLorus
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
|
@ -13,10 +14,25 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
|
all: a.out ex1.out ex2.out ex3.out
|
||||||
|
|
||||||
a.out: test.cpp
|
a.out: test.cpp
|
||||||
g++ -I../../include test.cpp -std=c++11
|
g++ -I../../include test.cpp -std=c++14 -o a.out
|
||||||
./a.out
|
./a.out
|
||||||
|
|
||||||
|
ex1.out: ap_int_manip_ex.cpp
|
||||||
|
g++ -I../../include ap_int_manip_ex.cpp -std=c++14 -o ex1.out
|
||||||
|
./ex1.out
|
||||||
|
|
||||||
|
ex2.out: ap_int_manip_ex2.cpp
|
||||||
|
g++ -I../../include ap_int_manip_ex2.cpp -std=c++14 -o ex2.out
|
||||||
|
./ex2.out
|
||||||
|
|
||||||
|
ex3.out: ap_int_manip_ex3.cpp
|
||||||
|
g++ -I../../include ap_int_manip_ex3.cpp -std=c++14 -o ex3.out
|
||||||
|
./ex3.out
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean:
|
clean:
|
||||||
rm -rf a.out
|
rm -rf *.out
|
||||||
|
|
20
examples/ap_int/ap_int_manip_ex.cpp
Normal file
20
examples/ap_int/ap_int_manip_ex.cpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#include <ap_int.h>
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int, char **) {
|
||||||
|
const ap_int<16> A = -3987;
|
||||||
|
const ap_int<16> s_A = ~(A >> 2) + 1;
|
||||||
|
|
||||||
|
cout << A << " " << s_A << " " << round(3987. / 4) << endl;
|
||||||
|
|
||||||
|
const bool Ri[2] = {false, true};
|
||||||
|
const ap_int<16> R_val[2] = {-int8_t(Ri[0]), -int8_t(Ri[1])};
|
||||||
|
|
||||||
|
const ap_int<16> ps_A = (R_val[0] ^ (A >> 2)) + Ri[0];
|
||||||
|
const ap_int<16> ms_A = (R_val[1] ^ (A >> 2)) + Ri[1];
|
||||||
|
|
||||||
|
cout << ps_A << " " << ms_A << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
17
examples/ap_int/ap_int_manip_ex2.cpp
Normal file
17
examples/ap_int/ap_int_manip_ex2.cpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#include <ap_int.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int, char **) {
|
||||||
|
const ap_int<32> A = 0xDEADBEEF;
|
||||||
|
const ap_int<32> s_A = ~(A >> 2) + 1;
|
||||||
|
|
||||||
|
cout << A << " " << s_A << " " << (int64_t) round(-1. * A.to_float() / 4.) << endl;
|
||||||
|
|
||||||
|
const ap_int<16> dead = A(31, 16);
|
||||||
|
const ap_int<16> beaf = A(15, 0);
|
||||||
|
printf("%08x || %04x || %04x\n", A.to_uint(), dead.to_int(), beaf.to_int());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
18
examples/ap_int/ap_int_manip_ex3.cpp
Normal file
18
examples/ap_int/ap_int_manip_ex3.cpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#include <ap_int.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int main(int, char **) {
|
||||||
|
const ap_int<8> A = 79; // 0x4F = 79
|
||||||
|
const ap_int<4> msb_A_4bits = A(7, 4); // 0x4 = 4
|
||||||
|
const ap_int<4> lsb_A_4bits = A(3, 0); // 0xF = -1
|
||||||
|
|
||||||
|
const ap_int<8> msb_A_8bits = A(7, 4); // 0x04 = 4
|
||||||
|
const ap_int<8> lsb_A_8bits = A(3, 0); // 0x0F = 15
|
||||||
|
|
||||||
|
printf("%d || %d || %d\n", A.to_int(), msb_A_4bits.to_int(), lsb_A_4bits.to_int());
|
||||||
|
printf("%d || %d || %d\n", A.to_int(), msb_A_8bits.to_int(), lsb_A_8bits.to_int());
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
17
packages/ap_fixed.h
Normal file
17
packages/ap_fixed.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 DrasLorus.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ap_types/ap_fixed.h>
|
17
packages/ap_int.h
Normal file
17
packages/ap_int.h
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2022 DrasLorus.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ap_types/ap_int.h>
|
|
@ -1,5 +1,5 @@
|
||||||
Package: hls-ap-types
|
Package: hls-ap-types
|
||||||
Version: 0.0.1
|
Version: 0.0.1.rc2
|
||||||
Maintainer: Camille 'DrasLorus' Monière <draslorus@draslorus.fr>
|
Maintainer: Camille 'DrasLorus' Monière <draslorus@draslorus.fr>
|
||||||
Depends:
|
Depends:
|
||||||
Architecture: all
|
Architecture: all
|
||||||
|
|
|
@ -1,8 +1,30 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
version="$(grep "Version" control | cut -d ' ' -f 2)"
|
|
||||||
|
|
||||||
mkdir -p hls-ap-types_"$version"-1_all/usr/include/ap_types
|
#
|
||||||
cp -r ../../include hls-ap-types_"$version"-1_all/usr/include/ap_types
|
# Copyright 2022 DrasLorus.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
version="$(grep "Version" control | cut -d ' ' -f 2)"
|
||||||
|
deb_dir="hls-ap-types_$version-1_all"
|
||||||
|
include_dir="$deb_dir/usr/include"
|
||||||
|
rm -rfv "$deb_dir"
|
||||||
|
|
||||||
|
install -dm755 "$include_dir"/ap_types/etc
|
||||||
|
install -m644 -t "$include_dir"/ap_types ../../include/*.h
|
||||||
|
install -Dm644 -t "$include_dir"/ap_types/etc ../../include/etc/ap_private.h
|
||||||
|
install -m644 -t "$include_dir"/ ../ap_*.h
|
||||||
|
|
||||||
mkdir -p hls-ap-types_"$version"-1_all/DEBIAN
|
mkdir -p hls-ap-types_"$version"-1_all/DEBIAN
|
||||||
cp control hls-ap-types_"$version"-1_all/DEBIAN
|
cp control hls-ap-types_"$version"-1_all/DEBIAN
|
||||||
|
|
|
@ -1,28 +1,21 @@
|
||||||
# This is an example PKGBUILD file. Use this as a start to creating your own,
|
# Maintainer: DrasLorus <draslorus@draslorus.fr>
|
||||||
# and remove these comments. For more information, see 'man PKGBUILD'.
|
|
||||||
# NOTE: Please fill out the license field for your package! If it is unknown,
|
|
||||||
# then please put 'unknown'.
|
|
||||||
|
|
||||||
# Maintainer: Your Name <youremail@domain.com>
|
|
||||||
pkgname=hls-ap-types
|
pkgname=hls-ap-types
|
||||||
pkgver=0.0.1.rc1
|
pkgver=0.0.1.rc2
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
|
|
||||||
pkgdesc="AP types for everyone"
|
pkgdesc="AP types for everyone"
|
||||||
arch=('any')
|
arch=('any')
|
||||||
url="https://github.com/DrasLorus/HLS_arbitrary_Precision_Types"
|
url="https://github.com/DrasLorus/HLS_arbitrary_Precision_Types"
|
||||||
license=('apache2.0')
|
license=('Apache')
|
||||||
|
|
||||||
source=("$pkgname-$pkgver::https://github.com/DrasLorus/HLS_arbitrary_Precision_Types/releases/download/v0.0.1-RC1/hls-ap-types-0.0.1-RC1.tar.gz")
|
source=("https://github.com/DrasLorus/HLS_arbitrary_Precision_Types/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
|
||||||
|
|
||||||
sha256sums=('f3efea6d742bac7cb99d9b4b7ff718ce82a5f9c6d9f7a4334aca9750ad7cd9fd')
|
|
||||||
|
|
||||||
|
sha256sums=('90837e08801ab75f9084c6070a14ee60cae0d78b6a4bec47f1b49a4b9772b90d')
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
cd "$srcdir"
|
cd "$srcdir"
|
||||||
|
|
||||||
_files="$(find include -name .h)"
|
|
||||||
|
|
||||||
make PREFIX="${pkgdir}" install
|
make PREFIX="${pkgdir}" install
|
||||||
install -dvm644 "${pkgdir}/usr/share/licenses/hls-ap-types/LICENSE" LICENSE.txt
|
install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
|
||||||
|
install -m644 -t "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" "${pkgname}-${pkgver}/LICENSE.TXT"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,30 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
tar -cvzf hls-ap-types-0.0.1-RC1.tar.gz ../../include makefile ../../LICENSE.TXT
|
|
||||||
|
#
|
||||||
|
# Copyright 2022 DrasLorus.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
version="0.0.1.rc2"
|
||||||
|
tar_dir="hls-ap-types-$version"
|
||||||
|
|
||||||
|
rm -rfv "$tar_dir"
|
||||||
|
|
||||||
|
install -dm755 "$tar_dir"/ap_types/etc
|
||||||
|
install -m644 -t "$tar_dir"/ ../../LICENSE.TXT
|
||||||
|
install -m644 -t "$tar_dir"/ap_types ../../include/*.h
|
||||||
|
install -Dm644 -t "$tar_dir"/ap_types/etc ../../include/etc/ap_private.h
|
||||||
|
install -m644 -t "$tar_dir"/ ../ap_*.h
|
||||||
|
|
||||||
|
tar -cvzf "$tar_dir".tar.gz "$tar_dir" makefile
|
|
@ -1,15 +1,34 @@
|
||||||
files:=$(wildcard include/*.h)
|
#
|
||||||
files+=include/etc/ap_private.h
|
# Copyright 2022 DrasLorus.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
tar_dir=hls-ap-types-0.0.1.rc2
|
||||||
|
|
||||||
|
ap_types_files:=$(wildcard $(tar_dir)/ap_types/*.h)
|
||||||
|
top_files:=$(wildcard $(tar_dir)/*.h)
|
||||||
|
priv_files:=$(wildcard $(tar_dir)/ap_types/etc/*.h)
|
||||||
|
|
||||||
all: install
|
all: install
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@install -dvm755 $(PREFIX)/usr/include/ap_types
|
install -dCm755 $(PREFIX)/usr/include/ap_types/etc
|
||||||
@install -vm644 -t $(PREFIX)/usr/include/ap_types/ $(files)
|
install -Cm644 -t $(PREFIX)/usr/include $(top_files)
|
||||||
@ln -vs ap_types/ap_fixed.h $(PREFIX)/usr/include/ap_fixed.h
|
install -Cm644 -t $(PREFIX)/usr/include/ap_types/ $(ap_types_files)
|
||||||
@ln -vs ap_types/ap_int.h $(PREFIX)/usr/include/ap_int.h
|
install -Cm644 -t $(PREFIX)/usr/include/ap_types/etc $(priv_files)
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
unlink $(PREFIX)/usr/include/ap_fixed.h
|
rm $(PREFIX)/usr/include/ap_fixed.h
|
||||||
unlink $(PREFIX)/usr/include/ap_int.h
|
rm $(PREFIX)/usr/include/ap_int.h
|
||||||
@rm -rv $(PREFIX)/usr/include/ap_types
|
@rm -rv $(PREFIX)/usr/include/ap_types
|
Loading…
Reference in a new issue