twiddle_factors_128_dot_vhd_generation.py
71 lines
| 2.8 KiB
| text/x-python
|
PythonLexer
|
r3 | def build_twiddle_factors_128_dot_vhdl(): | ||
with open("twiddle_factors_128.vhd", "w") as text_file: | ||||
text_file.write("library IEEE;\n") | ||||
text_file.write("use IEEE.numeric_std.all;\n") | ||||
text_file.write("use IEEE.std_logic_1164.all;\n\n") | ||||
text_file.write("package twiddle_factors_128 is\n\n") | ||||
text_file.write("constant Coef_SZ : integer := 16;\n") | ||||
text_file.write("constant NB_Coeffs : integer := 128;\n\n") | ||||
text_file.write("--============================================================\n") | ||||
text_file.write("-- create each initial values for each coefs ============\n") | ||||
text_file.write("--!!!!!!!!!!It should be interfaced with a software !!!!!!!!!!\n") | ||||
text_file.write("--============================================================\n\n") | ||||
for i in range(128): | ||||
text_file.write("constant c_{} : std_logic_vector(Coef_SZ-1 downto 0) := std_logic_vector(TO_SIGNED(121,Coef_SZ));\n".format(i)) | ||||
text_file.write("\n--************************************************--\n\n") | ||||
for i in range(128): | ||||
text_file.write("constant cps_{} : std_logic_vector(Coef_SZ-1 downto 0) := std_logic_vector(TO_SIGNED(160,Coef_SZ));\n".format(i)) | ||||
text_file.write("\n--************************************************--\n\n") | ||||
for i in range(128): | ||||
text_file.write("constant cms_{} : std_logic_vector(Coef_SZ-1 downto 0) := std_logic_vector(TO_SIGNED(82,Coef_SZ));\n".format(i)) | ||||
text_file.write("\n--************************************************--\n\n") | ||||
range_j = 16 | ||||
range_i = 8 | ||||
text_file.write("constant twiddleFactors_c : std_logic_vector( (NB_Coeffs * Coef_SZ)-1 downto 0) :=\n") | ||||
text_file.write("(") | ||||
for j in range(16): | ||||
text_file.write("\n") | ||||
for i in range(8): | ||||
if (i+j*range_i) == (range_j*range_i-1): | ||||
text_file.write("c_{} );\n\n".format(i+j*range_i)) | ||||
else: | ||||
text_file.write("c_{} & ".format(i+j*range_i)) | ||||
text_file.write("constant twiddleFactors_cps : std_logic_vector( (NB_Coeffs * Coef_SZ)-1 downto 0) :=\n") | ||||
text_file.write("(") | ||||
for j in range(16): | ||||
text_file.write("\n") | ||||
for i in range(8): | ||||
if (i+j*range_i) == (range_j*range_i-1): | ||||
text_file.write("cps_{} );\n\n".format(i+j*range_i)) | ||||
else: | ||||
text_file.write("cps_{} & ".format(i+j*range_i)) | ||||
text_file.write("constant twiddleFactors_cms : std_logic_vector( (NB_Coeffs * Coef_SZ)-1 downto 0) :=\n") | ||||
text_file.write("(") | ||||
for j in range(16): | ||||
text_file.write("\n") | ||||
for i in range(8): | ||||
if (i+j*range_i) == (range_j*range_i-1): | ||||
text_file.write("cms_{} );\n".format(i+j*range_i)) | ||||
else: | ||||
text_file.write("cms_{} & ".format(i+j*range_i)) | ||||
text_file.write("end;\n\n") | ||||
if __name__ == '__main__': | ||||
build_twiddle_factors_128_dot_vhdl() | ||||
print'file built' | ||||