-
Notifications
You must be signed in to change notification settings - Fork 3
/
gvcontrol
executable file
·51 lines (36 loc) · 1.92 KB
/
gvcontrol
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
#!/usr/bin/env python3
import argparse
import gv.gvsoc_control as gvsoc
parser = argparse.ArgumentParser(description='Control GVSOC')
parser.add_argument("--host", dest="host", default="localhost", help="Specify host name")
parser.add_argument("--port", dest="port", default=42951, type=int, help="Specify host port")
parser.add_argument("--path-to-in-folder", dest="path_in", default='../', type=str, help="Specify the relative path to the folder containing the inputs")
parser.add_argument("--path-to-out-folder", dest="path_out", default='../', type=str, help="Specify the relative path to the folder containing the outputs")
parser.add_argument("--duration", dest="duration", default=3000000000000, type=int, help="Specify the relative path to the folder containing the outputs")
args = parser.parse_args()
gv = gvsoc.Proxy(args.host, args.port)
testbench = gvsoc.Testbench(gv)
# Open SAI interfaces in PDM mode
i2s_in = testbench.i2s_get(1)
i2s_in.open(is_pdm=True)
i2s_out = testbench.i2s_get(2)
i2s_out.open(is_pdm=True) # , sampling_freq=3072000)
# Setup channel 0 RX with input PDM binary file
i2s_in.slot_open(slot=2, is_rx=True, word_size=32)
# Wav file as input - Pcm to Pdm conversion
# Set modulation params
i2s_in.slot_rx_file_reader(slot=2, filetype="wav", filepath=args.path_in + '/samples/dataset/noisy/p232_334.wav', width=16, interpolation_ratio_shift = 6, interpolation_type = 'linear')
# Setup channel 0 as PDM Tx
i2s_out.slot_open(slot=0, is_rx=False, word_size=32)
# Wav file as output - Pdm to Pcm conversion
i2s_out.slot_tx_file_dumper(slot=0, filetype="wav", filepath=args.path_out + '/output_p232_334.wav', width=32, cic_n = 8, cic_m = 2, cic_r = 64, cic_shift = 24, wav_sampling_freq = 48000)
# CIC_N = 8; CIC_M = 2; CIC_R = 64; CIC_Shift = 27
# Run for 3 s
gv.run(args.duration)
# Stop the clock and the RX slot
i2s_in.slot_close(slot=2)
i2s_out.slot_close(slot=0)
i2s_in.close()
i2s_out.close()
gv.quit()
gv.close()