# KWS-SoC **Repository Path**: fog_valley_cloud/KWS-SoC ## Basic Information - **Project Name**: KWS-SoC - **Description**: This is an SoC design dedicated to Keyword Spotting (KWS) based on a neural-network accelerator and the wujian100 platform. - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-06-19 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # KWS-SoC This is a SoC for neural-network acceleration based on [wujian100_open](https://github.com/T-head-Semi/wujian100_open) platform, which is a low power open source MCU by T-Head. Specially, the accelerating kernel is designed for Keyword Spotting(KWS). Thus far, the current version is only for simulation. ## QUICK START ## This repository includes folders as following:
`reference model`:
* `my_audio.py`: This is a python script for preprocessing data.
* `test_mymodel_myaudio.py`: This is a python script to generate software comparison data.
* `test_list.txt`: This file contains the label information of the test files in the dataset.
* `ds_rnn_labels.txt`: This is a mapping table between results and labels.
* `data.dat`: This is 40 groups of floating point input data after preprocessing.
* `result.dat`: This is 40 groups of floating point result data after software computing.
`tools`:
* `float2hex.py`: This is a script for transforming all 40 groups floating point input data into hex data and distributing to 40 test folders.
* `result_div.py`: This is a script for distributing all 40 groups floating point reference result data into 40 test folders.
* `hex2float.py`: This is a script for transforming each kws result hex data generated by KWS-SoC into floating point data, and displaying a result label. `soc`: This folder includes source code of KWS-SoC.
`tb`: This folder includes testbench code of KWS-SoC.
`wujiankws.*`: These folders include Vivado project files, such as ip source codes and simulation scripts.
`testdata`: This folder includes test data sets. `test.pat`: This is a hexadecimal file generated by compiling C file generation instruction and linking of wujian100 platform, which is used for core execution. The generation method of this file can refer to the [wujian100_open](https://github.com/T-head-Semi/wujian100_open) ### Step 1: Generate input data and reference result ### 1. First you need to generate input hex data. You can run `my_audio.py` to generate a preprocessing .wav file. Then run `test_mymodel_myaudio.py` to generated input data and result data.
The input data is generated in `line 346`
```fingerprints = my_audio.my_mfcc(my_spectrogram) ```
And the result data is generated in `line 350`
```prob = sess.run(net.probs[0], feed_dict = {net.fingerprint_input: fingerprints_3d})```
2. Write the input data and result into a file. This can be done by `fopen` operation which has not been implemented in this project.
3. Copy the `data.dat` and `result.dat` and into testdata folder.
4. Copy and run `float2hex.py` and `result_div.py`. Transform and divide input data, also the result data into 40 groups of test folder.
### Step 2: Run behavior simulation in Vivado ### You may use **Vivado 2019.2** or later version. Otherwise, there may be IP incompatibility problem.
**Run behavior simulation** and the testbench will dump the kws_result_data.txt into test folder.
* To change the test data subset. You can modify the file number `tb.v` (in `tb` folder) line 289 and line 300. In default case, KWS-SoC will dump two groups of test data. If you want to change numbers of each excuation, you can modify this file. Also, you need to re-complile `test.pat` in origin [wujian100_open](https://github.com/T-head-Semi/wujian100_open)
Also, you need to modify `busmnt.v` (in `tb` folder) line 118 and line 130 to change to dump path of result. ### Step 3: Check the result ### Copy `hex2float.py` in a test folder(For example, test8 in testdata folder), run this script, and this step will generate `kws_result_data.txt` transformed by hex file `result_data_hex.txt`, which is dumped by testbench. Also, this file displays a forecast result label in the last line.