-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgvcontrol
executable file
·66 lines (53 loc) · 1.79 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/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=30000, type=int, help="Specify host port")
parser.add_argument("--wav_in", required=True, type=str, help="Specify the relative path to the input wav file")
parser.add_argument("--wav_out", required=True, type=str, help="Specify the relative path to the output wav file")
parser.add_argument("--duration", dest="duration", default=3e12, type=int, help="Duration of the simulation in ps")
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(2)
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.wav_in,
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.wav_out,
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()