source: trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Interfaces_testbench_generate_file.cpp @ 41

Last change on this file since 41 was 41, checked in by rosiere, 17 years ago

Vhdl_Testbench : Modification du testbench. Maintenant complétement encapsuler dans la classe "Interfaces".
Suppression de la class Vhdl_Testbench dans un avenir proche :D
Suppression du répertoire Configuration.old

File size: 2.8 KB
Line 
1#ifdef VHDL_TESTBENCH
2
3/*
4 * $Id$
5 *
6 * [ Description ]
7 *
8 */
9
10#include "Behavioural/include/Interfaces.h"
11
12namespace morpheo              {
13namespace behavioural          {
14
15  void Interfaces::testbench_generate_file  (void) 
16  {
17    log_printf(FUNC,Behavioural,"generate_file","Begin");
18
19    Vhdl   * vhdl        = new Vhdl(_name+"_Testbench");
20    string   counter     = "counter";
21    string   clock       = this->get_clock();
22    uint32_t cycle       = this->get_cycle();
23
24    vhdl      ->set_signal    (counter, "natural", "0");
25    vhdl      ->set_signal    (clock  , 1        , 0); // modif Signal_set_signal
26    this->set_signal    (vhdl);
27
28    vhdl->set_body("");
29    vhdl->set_body("------------------------------------------------------");
30    vhdl->set_body("-- Component");
31    vhdl->set_body("------------------------------------------------------");
32    vhdl->set_body("");
33
34    list<string> * list_signal = new list<string>;
35    this->get_signal (list_signal);
36
37    vhdl->set_library_work (_name + "_Pack");
38    vhdl->set_body("instance_"+_name+" : "+_name);
39    vhdl->set_body("port map (");
40   
41    list<string>::iterator i   = list_signal->begin();
42    if (i != list_signal->end())
43      {
44        vhdl->set_body("\t "+*i+"\t=>\t"+*i);
45        ++i;
46      }
47    while (i != list_signal->end())
48      {
49        vhdl->set_body("\t,"+*i+"\t=>\t"+*i);
50        ++i;
51      }
52    vhdl->set_body("         );");
53
54    delete list_signal;
55
56    vhdl->set_body("");
57    vhdl->set_body("------------------------------------------------------");
58    vhdl->set_body("-- Port's affectation");
59    vhdl->set_body("------------------------------------------------------");
60    vhdl->set_body("");
61    string test_name = this->testbench_body(vhdl,counter);
62
63    vhdl->set_body("");
64    vhdl->set_body("------------------------------------------------------");
65    vhdl->set_body("-- process clock");
66    vhdl->set_body("------------------------------------------------------");
67    vhdl->set_body("");
68    vhdl->set_body(clock+" <= not "+clock+" after 50 ns;");
69    vhdl->set_body("");
70    vhdl->set_body("process ("+clock+")");
71    vhdl->set_body("begin");
72    vhdl->set_body("\tif "+clock+"'event and "+clock+" = '1' then");
73    vhdl->set_body("\t\t"+counter+" <= "+counter+"+1;");
74    vhdl->set_body("");
75    vhdl->set_body("\t\tassert     ("+test_name+" = '1') report \"Test KO\" severity FAILURE;");
76    vhdl->set_body("\t\tassert not ("+counter+" = "+toString(cycle)+") report \"Test OK\" severity FAILURE;");
77    vhdl->set_body("");
78    vhdl->set_body("\tend if;");
79    vhdl->set_body("end process;");
80
81    vhdl->generate_file();
82
83    delete vhdl;
84   
85    log_printf(FUNC,Behavioural,"generate_file","End");
86  };
87
88}; // end namespace behavioural         
89}; // end namespace morpheo             
90
91#endif
Note: See TracBrowser for help on using the repository browser.