Simulation files of Polyphase Filter in VHDL for FPGA.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
4.8KB

  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.numeric_std.ALL;
  4. USE work.POLY_FIR_PKG.ALL;
  5. USE work.simu_pkg.ALL;
  6. USE work.utils.ALL;
  7. LIBRARY std;
  8. USE std.textio.ALL;
  9. USE work.coeff.ALL;
  10. ENTITY poly_fir_tb IS
  11. GENERIC (
  12. demi_periode : time := 5 ns;
  13. -- duree de la demi periode des horloges
  14. test_e : string := "D:\Stage\ALMA_OPFB\simu\polyphase_fir - v0.2\tb_txts_files\input.txt";
  15. -- fichier test contenant les echantillons d'entree
  16. test_s : string := "D:\Stage\ALMA_OPFB\simu\polyphase_fir - v0.2\tb_txts_files\output.txt"
  17. -- fichier contenant les echantillons de sortie
  18. --fir_addr : std_logic_vector(band5a_w_fc-1 DOWNTO 0) := std_logic_vector(unsigned(band5a_fc_index, band5a_w_fc))
  19. -- coeff de décimation
  20. );
  21. END poly_fir_tb;
  22. ARCHITECTURE beh OF poly_fir_tb IS
  23. TYPE vect_from_matrix_fir_data_out IS ARRAY (0 TO cst_nb_subfilters*cst_nb_parallel_firs-1) OF smpl_fir_data_out;
  24. FILE fichier_e : text IS IN test_e;
  25. FILE fichier_s : text IS IN test_s;
  26. --FILE fichier_c : text IS IN test_c;
  27. SIGNAL initialisation : std_logic;
  28. SIGNAL h : std_logic;
  29. SIGNAL entree_fir : vect_adc_data_out := (OTHERS => (OTHERS => '0'));
  30. SIGNAL sortie_fir : vect_from_matrix_fir_data_out := (OTHERS => (OTHERS => '0'));
  31. SIGNAL sortie_fir_sim : matrix_fir_data_out := (OTHERS => (OTHERS => (OTHERS => '0')));
  32. --SIGNAL coeffs_fir : vect_fir_coeffs_in := ;
  33. SIGNAL sortie_fir_sim_vect : vect_from_matrix_fir_data_out := (OTHERS => (OTHERS => '0'));
  34. SIGNAL verif : donnee_sortie;
  35. BEGIN -- ARCHITECTURE beh
  36. module_simu : ENTITY work.poly_fir_blk(polyphase)
  37. PORT MAP(h, fir_coeffs_generated, entree_fir, sortie_fir_sim);
  38. horloge_entree : horloge(h, demi_periode, demi_periode);
  39. sortie_fir_sim_process : PROCESS(sortie_fir_sim)
  40. VARIABLE mots_lignes : natural := cst_nb_parallel_firs;
  41. BEGIN
  42. FOR k IN 0 TO mots_lignes-1 LOOP
  43. FOR j IN 0 TO cst_nb_subfilters-1 LOOP
  44. sortie_fir_sim_vect(k*cst_nb_subfilters+j) <= sortie_fir_sim(j)(k);
  45. END LOOP;
  46. END LOOP;
  47. END PROCESS;
  48. source : PROCESS
  49. CONSTANT header : natural := 1; -- nombre de ligne d'en tête
  50. CONSTANT nbr_ech : natural := 800000; -- nombre d'echantillons d'entree dans le fichier test
  51. CONSTANT mots_ligne : natural := cst_nb_samples_adc_in; -- nombre de mots par ligne dans le ficher
  52. VARIABLE nbr_ligne : natural := 10000; --2750; --15625; -- nombre de lignes restant à lire dans le fichier
  53. VARIABLE i : natural := 1;
  54. VARIABLE donnee : integer;
  55. VARIABLE tempo : natural := 0;
  56. VARIABLE ligne : line;
  57. VARIABLE head : boolean := false;
  58. BEGIN -- PROCESS source
  59. WAIT UNTIL falling_edge(h);
  60. IF head = true THEN
  61. head := false;
  62. FOR i IN 0 TO header-1 LOOP
  63. readline(fichier_e, ligne);
  64. END LOOP;
  65. END IF;
  66. IF tempo > 0 THEN -- temps de synchro
  67. tempo := tempo -1;
  68. ELSIF nbr_ligne > 0 THEN
  69. readline(fichier_e, ligne);
  70. nbr_ligne := nbr_ligne-1;
  71. FOR k IN 0 TO mots_ligne -1 LOOP
  72. read(ligne, donnee);
  73. entree_fir(k) <= std_logic_vector(to_signed(donnee, cst_w_in));
  74. END LOOP; -- k
  75. END IF;
  76. END PROCESS source;
  77. test : PROCESS
  78. CONSTANT header : natural := 1; -- nombre de ligne d'en tête
  79. CONSTANT nbr_ech : natural := 2000000; --nombre d'echantillons d'entree dans le fichier test
  80. CONSTANT mots_ligne : natural := 200; -- nombre de mots par ligne dans le ficher
  81. VARIABLE nbr_ligne : natural := 10000; -- nombre de lignes restant à lire dans le fichier
  82. VARIABLE i : natural;
  83. VARIABLE donnee : donnee_sortie;
  84. VARIABLE ligne : line;
  85. VARIABLE tempo : natural := 8;
  86. VARIABLE sortie : integer;
  87. VARIABLE head : boolean := false;
  88. BEGIN -- PROCESS test
  89. WAIT UNTIL falling_edge(h);
  90. IF tempo > 0 THEN -- temps de synchro
  91. tempo := tempo -1;
  92. ASSERT false REPORT "Attente_2 ... " SEVERITY note;
  93. ELSIF nbr_ligne > 0 THEN
  94. readline(fichier_s, ligne);
  95. nbr_ligne := nbr_ligne-1;
  96. FOR k IN 0 TO mots_ligne-1 LOOP
  97. read(ligne, donnee(k));
  98. sortie := to_integer(signed(sortie_fir_sim_vect(k)));
  99. sortie_fir(k) <= std_logic_vector(to_signed(donnee(k), cst_w_out));
  100. verif(k) <= sortie - donnee(k);
  101. ASSERT verif(k) = 0 REPORT "Valeur fir FAUSSE"
  102. SEVERITY error;
  103. --ASSERT sortie /= donnee(k) REPORT "OK"
  104. -- SEVERITY note;
  105. END LOOP; -- k
  106. END IF;
  107. END PROCESS test;
  108. END ARCHITECTURE beh;