A simple vhdl fir description.
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.

132 lines
4.1KB

  1. LIBRARY ieee;
  2. USE ieee.std_logic_1164.ALL;
  3. USE ieee.numeric_std.ALL;
  4. USE work.general_includes.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 simple_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\simple_fir\tb_txts_files\input.txt";
  15. -- fichier test contenant les echantillons d'entree
  16. test_s : string := "D:\Stage\ALMA_OPFB\simu\simple_fir\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. -- coef de décimation
  20. );
  21. END simple_fir_tb;
  22. ARCHITECTURE beh OF simple_fir_tb IS
  23. FILE fichier_e : text IS IN test_e;
  24. FILE fichier_s : text IS IN test_s;
  25. --FILE fichier_c : text IS IN test_c;
  26. SIGNAL initialisation : std_logic;
  27. SIGNAL h : std_logic;
  28. SIGNAL entree_fir : vect_adc_data_out := (OTHERS => (OTHERS => '0'));
  29. SIGNAL sortie_fir : vect_fir_data_out := (OTHERS => (OTHERS => '0'));
  30. SIGNAL sortie_fir_sim : vect_fir_data_out := (OTHERS => (OTHERS => '0'));
  31. --SIGNAL coeffs_fir : vect_fir_coeffs_in := ;
  32. BEGIN -- ARCHITECTURE beh
  33. module_simu : ENTITY work.Tree_Fir(Shift_Reg_Fir)
  34. PORT MAP (h, fir_coeffs_generated, entree_fir, sortie_fir_sim);
  35. horloge_entree : horloge(h, demi_periode, demi_periode);
  36. source : PROCESS
  37. CONSTANT header : natural := 1; -- nombre de ligne d'en tête
  38. CONSTANT nbr_ech : natural := 249870; -- nombre d'echantillons d'entree dans le fichier test
  39. CONSTANT mots_ligne : natural := cst_nb_samples_adc_in; -- nombre de mots par ligne dans le ficher
  40. VARIABLE nbr_ligne : natural := 24987; --2750; --15625; -- nombre de lignes restant à lire dans le fichier
  41. VARIABLE i : natural := 1;
  42. VARIABLE donnee : integer;
  43. VARIABLE tempo : natural := 0;
  44. VARIABLE ligne : line;
  45. VARIABLE head : boolean := false;
  46. BEGIN -- PROCESS source
  47. WAIT UNTIL falling_edge(h);
  48. IF head = true THEN
  49. head := false;
  50. FOR i IN 0 TO header-1 LOOP
  51. readline(fichier_e, ligne);
  52. END LOOP;
  53. END IF;
  54. IF tempo > 0 THEN -- temps de synchro
  55. tempo := tempo -1;
  56. ELSIF nbr_ligne > 0 THEN
  57. readline(fichier_e, ligne);
  58. nbr_ligne := nbr_ligne-1;
  59. FOR k IN 0 TO mots_ligne -1 LOOP
  60. read(ligne, donnee);
  61. entree_fir(k) <= std_logic_vector(to_signed(donnee, cst_w_in));
  62. END LOOP; -- k
  63. END IF;
  64. END PROCESS source;
  65. test : PROCESS
  66. CONSTANT header : natural := 1; -- nombre de ligne d'en tête
  67. CONSTANT nbr_ech : natural := 249870;--nombre d'echantillons d'entree dans le fichier test
  68. CONSTANT mots_ligne : natural := 10; -- nombre de mots par ligne dans le ficher
  69. VARIABLE nbr_ligne : natural := 24987; -- nombre de lignes restant à lire dans le fichier
  70. VARIABLE i : natural;
  71. VARIABLE donnee : donnee_sortie;
  72. VARIABLE ligne : line;
  73. VARIABLE tempo : natural := 6;
  74. VARIABLE sortie : integer;
  75. VARIABLE head : boolean := false;
  76. BEGIN -- PROCESS test
  77. WAIT UNTIL falling_edge(h);
  78. IF tempo > 0 THEN -- temps de synchro
  79. tempo := tempo -1;
  80. ASSERT false REPORT "Attente_2 ... " SEVERITY note;
  81. ELSIF nbr_ligne > 0 THEN
  82. readline(fichier_s, ligne);
  83. nbr_ligne := nbr_ligne-1;
  84. FOR k IN 0 TO mots_ligne -1 LOOP
  85. read(ligne, donnee(k));
  86. sortie := to_integer(signed(sortie_fir_sim(k)));
  87. sortie_fir(k) <= std_logic_vector(to_signed(donnee(k), cst_w_out));
  88. ASSERT sortie = donnee(k) REPORT "Valeur fir FAUSSE"
  89. SEVERITY error;
  90. --ASSERT sortie /= donnee(k) REPORT "OK"
  91. -- SEVERITY note;
  92. END LOOP; -- k
  93. END IF;
  94. END PROCESS test;
  95. END ARCHITECTURE beh;