Re: [myhdl-list] please help with best way how to construct unittest testbench
Brought to you by:
jandecaluwe
From: Marcel H. <1he...@in...> - 2016-01-29 15:31:29
|
On 29.01.2016 16:05, David Belohrad wrote: > Dear all, > > my question is simple: when using unittest/testcase, one can write more testbenches. I have wrote one, like the one below. As you can see, the 'testbench' is quite long, as one has to initialize all the signals, instantiate the DUT, provide reset and clock, and it does nothing (yet). > > I want to add a second test-bench, but I'd like to re-use the fraction of instantiation and initialization of the DUT. This is quite a work (not for this design, but for more complex designs). So far I have seen only testbenches, which were implementing each test case as a separate test function, which contained each time copy of signal assignments and instantiation of DUT. Is there any way, how to write a second test bench, and re-use the instances and signal assignments aready done? In fact, it would be great if I could just instantiate it once, assign signals, and then in the test functions just by driving the signals and compare with expected *without re-starting the simulation*. > > Any hint appreciated. I had the same issue this week and decided to make up my mind and try some things out. I decided to use decoraters to wrap the tests to instantiate the clock etc. https://gist.github.com/punkkeks/9594800803bff9c57853 You have to use the _@myhdltest_ decoratetor to use this. In the setup method you have to instantiate all your signals (for an example, just see the gist). To trace a testcase you can use one of the three methods: 1. @trace decorator 2. self.trace = True in the setUp method 3. --trace as commandline argument If you have any improvements, let me know ;) Regards Marcel |