aboutsummaryrefslogtreecommitdiffstats
path: root/techlibs/xilinx/tests/bram1.sh
blob: 7451a1b3e25c7f672190441f9884b646e88f2b3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

set -e

transp_list="0 1"
abits_list="1 2 4 8 10 16 20"
dbits_list="1 2 4 8 10 16 20 24 30 32 40 48 50 56 60 64 70 72 80"

use_xsim=false
unisims=/opt/Xilinx/Vivado/2014.4/data/verilog/src/unisims

echo "all: all_list" > bram1.mk
all_list=""

for transp in $transp_list; do
for abits in $abits_list; do
for dbits in $dbits_list; do
	if [ $(( (1 << $abits) * $dbits )) -gt 1000000 ]; then continue; fi
	id=`printf "%d%02d%02d" $transp $abits $dbits`
	echo "Creating bram1_$id.."
	rm -rf bram1_$id
	mkdir -p bram1_$id
	cp bram1.v bram1_tb.v bram1_$id/
	sed -i "/parameter/ s,ABITS *= *[0-9]*,ABITS = $abits," bram1_$id/*.v
	sed -i "/parameter/ s,DBITS *= *[0-9]*,DBITS = $dbits," bram1_$id/*.v
	sed -i "/parameter/ s,TRANSP *= *[0-9]*,TRANSP = $transp," bram1_$id/*.v
	{
		echo "set -e"
		echo "../../../../yosys -q -lsynth.log -p 'synth_xilinx -top bram1; write_verilog synth.v' bram1.v"
		if $use_xsim; then
			echo "xvlog --work gold bram1_tb.v bram1.v > gold.txt"
			echo "xvlog --work gate bram1_tb.v synth.v > gate.txt"
			echo "xelab -R gold.bram1_tb >> gold.txt"
			echo "xelab -L unisim -R gate.bram1_tb >> gate.txt"
		else
			echo "iverilog -o bram1_tb_gold bram1_tb.v bram1.v > gold.txt 2>&1"
			echo "iverilog -o bram1_tb_gate bram1_tb.v synth.v -y $unisims $unisims/../glbl.v > gate.txt 2>&1"
			echo "./bram1_tb_gold >> gold.txt"
			echo "./bram1_tb_gate >> gate.txt"
		fi
		echo "../bram1_cmp <( grep '#OUT#' gold.txt; ) <( grep '#OUT#' gate.txt; )"
	} > bram1_$id/run.sh
	{
		echo "bram1_$id/ok:"
		echo "	@cd bram1_$id && bash run.sh"
		echo "	@echo -n '[$id]'"
		echo "	@touch \$@"
	} >> bram1.mk
	all_list="$all_list bram1_$id/ok"
done; done; done

cc -o bram1_cmp ../../../tests/tools/cmp_tbdata.c
echo all_list: $(echo $all_list | tr ' ' '\n' | sort -R) >> bram1.mk

echo "Testing..."
${MAKE:-make} -f bram1.mk
echo

echo "Used bram types:"
grep -h 'Mapping to bram type' bram1_*/synth.log | sort | uniq -c

echo "Cleaning up..."
rm -rf bram1_cmp bram1.mk bram1_[0-9]*/
; import org.sufficientlysecure.keychain.keyimport.ImportKeysListEntry; import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing; import org.sufficientlysecure.keychain.operations.results.GetKeyResult; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.pgp.UncachedKeyRing.IteratorWithIOThrow; import org.sufficientlysecure.keychain.util.InputData; import org.sufficientlysecure.keychain.util.Log; import org.sufficientlysecure.keychain.util.PositionAwareInputStream; import java.io.BufferedInputStream; import java.io.IOException; import java.util.ArrayList; public class ImportKeysListLoader extends AsyncTaskLoader<AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>>> { public static class NonPgpPartException extends Exception { private int mCount; public NonPgpPartException(int count) { this.mCount = count; } public int getCount() { return mCount; } } final Context mContext; final InputData mInputData; ArrayList<ImportKeysListEntry> mData = new ArrayList<>(); LongSparseArray<ParcelableKeyRing> mParcelableRings = new LongSparseArray<>(); AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> mEntryListWrapper; public ImportKeysListLoader(Context context, InputData inputData) { super(context); this.mContext = context; this.mInputData = inputData; } @Override public AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> loadInBackground() { // This has already been loaded! nvm any further, just return if (mEntryListWrapper != null) { return mEntryListWrapper; } GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_OK, null); mEntryListWrapper = new AsyncTaskResultWrapper<>(mData, getKeyResult); if (mInputData == null) { Log.e(Constants.TAG, "Input data is null!"); return mEntryListWrapper; } generateListOfKeyrings(mInputData); return mEntryListWrapper; } @Override protected void onReset() { super.onReset(); // Ensure the loader is stopped onStopLoading(); } @Override protected void onStartLoading() { forceLoad(); } @Override protected void onStopLoading() { cancelLoad(); } @Override public void deliverResult(AsyncTaskResultWrapper<ArrayList<ImportKeysListEntry>> data) { super.deliverResult(data); } public LongSparseArray<ParcelableKeyRing> getParcelableRings() { return mParcelableRings; } /** * Reads all PGPKeyRing objects from input * * @param inputData * @return */ private void generateListOfKeyrings(InputData inputData) { PositionAwareInputStream progressIn = new PositionAwareInputStream( inputData.getInputStream()); // need to have access to the bufferedInput, so we can reuse it for the possible // PGPObject chunks after the first one, e.g. files with several consecutive ASCII // armor blocks BufferedInputStream bufferedInput = new BufferedInputStream(progressIn); try { // parse all keyrings IteratorWithIOThrow<UncachedKeyRing> it = UncachedKeyRing.fromStream(bufferedInput); while (it.hasNext()) { UncachedKeyRing ring = it.next(); ImportKeysListEntry item = new ImportKeysListEntry(getContext(), ring); mData.add(item); mParcelableRings.put(item.hashCode(), new ParcelableKeyRing(ring.getEncoded())); } } catch (IOException e) { Log.e(Constants.TAG, "IOException on parsing key file! Return NoValidKeysException!", e); OperationResult.OperationLog log = new OperationResult.OperationLog(); log.add(OperationResult.LogType.MSG_GET_NO_VALID_KEYS, 0); GetKeyResult getKeyResult = new GetKeyResult(GetKeyResult.RESULT_ERROR_NO_VALID_KEYS, log); mEntryListWrapper = new AsyncTaskResultWrapper<> (mData, getKeyResult); } } }