Re: [myhdl-list] newb question
Brought to you by:
jandecaluwe
From: Christopher L. F. <cf...@uc...> - 2008-02-08 16:54:45
|
Couple more comments on this topic. One issue if the simulation were to be enhanced by C functions (no need for C++) the build and distribution would become much more work to build and build for the various platforms. But with that said, there have been posts that the simulation speed in some cases seem a bit slow. I used the python tool cProfile to capture some information on a simulation. The following was a simulation that wasn't horribly efficient as simulations go. The logic included some pwm's and other slowly changing signals. There were many clock cycles per event (many simulation steps). But to keep everything relative I had to keep the ratio high (many clk/sim step per event). The good thing is that because it was a long simulation most of the cProfile errors should of averaged out (this is my first experience with the python profile tools). The MyHDL simulation took 50078.309 CPU seconds (~13 hours) where the converted Verilog with same testbench (same timescale, etc) ran on Modelsim was much shorter. The first table shows the number of functions calls, total time, time per call, etc. The second table shows the call with subcalls and times. With the data below, I don't know if it is conclusive that optimizing intbv would help. You would need to optimize frequently called functions and relatively long functions. ------------ Table 1 -------------------- Ncalls Total Time Per Call (s) Cumulative Function 1 27367.717 s 2.737e+04 50078.309 _Simulation.py: 92(run) 900001800 2477.968 s 2.753e-06 16404.167 _Waiter.py:139(next) 400000792 2213.805 s 5.535e-06 7412.291 led_pulse.py: 64(registers) 700113088 2137.623 s 3.053e-06 6044.433 _Signal.py: 169(_set_next) 700113088 1985.815 s 2.836e-06 3780.550 _Signal.py: 140(_update) 400000792 1454.013 s 3.635e-06 2394.522 led_pulse.py: 30(pwm_regs) 400112492 1374.422 s 3.435e-06 2542.942 _Signal.py: 214(_setNextIntbv) 1000002000 1280.135 s 1.280e-06 14798.262 _always.py: 94(genfunc) 950496034 1116.341 s 1.174e-06 1624.344 _Signal.py: 405(__cmp__) 1801193755 1085.671 s 6.028e-07 1085.671 {isinstance} 400167349 1036.418 s 2.590e-06 1036.418 _intbv.py: 80(_checkBounds) 400608311 853.896 s 2.131e-06 1132.867 _intbv.py: 427(__cmp__) 50000099 765.953 s 1.532e-05 2308.521 tb_led_pulse.py: 64(ticks_per) 1800509971 702.584 s 3.902e-07 702.584 {method 'append' of 'list' objects} 1351104345 645.456 s 4.777e-07 646.963 {cmp} 100042182 619.051 s 6.188e-06 619.051 _Signal.py: 239(_printVcdBit) 1000011811 517.325 s 5.173e-07 517.325 {method 'pop' of 'list' objects} 100000199 401.288 s 4.013e-06 1081.786 tb_led_pulse.py: 58(clkgen) 100000303 9.161 s 9.161e-08 1600.072 _Waiter.py:126(next) 550000649 6.524 s 1.186e-08 356.524 _Signal.py: 251(__nonzero__) 200000398 6.849 s 3.424e-08 226.849 _Signal.py: 204(_setNextBool) 400003732 0.952 s 2.380e-09 220.952 _Signal.py: 159(_get_val) 800198082 1.977 s 2.471e-09 211.977 {method 'extend' of 'list' objects} 50000099 0.519 s 1.038e-08 321.007 led_pulse.py: 170(ramp_sm) 100000198 3.947 s 3.947e-08 224.504 _Signal.py: 209(_setNextInt) 100030091 6.383 s 6.381e-08 236.571 _Signal.py: 268(__add__) 100000200 1.236 s 1.236e-08 131.236 {method 'sort' of 'list' objects} 54822 1.464 s 2.670e-05 2.089 _bin.py: 29(_int2bitstring) 54857 0.727 s 1.325e-05 2.431 copy.py: 144(deepcopy) 54857 0.522 s 9.516e-06 0.550 copy.py: 260(_keep_alive) 54822 0.436 s 7.953e-06 2.632 _bin.py:45(bin) 54857 0.422 s 7.693e-06 0.743 _intbv.py: 39(__init__) 54822 0.374 s 6.822e-06 3.006 _Signal.py: 242(_printVcdVec) 329066 0.292 s 8.874e-07 0.292 {divmod} 54857 0.191 s 3.482e-06 0.934 _intbv.py: 99(__deepcopy__) 383493 0.108 s 2.816e-07 0.108 {abs} 54857 0.104 s 1.896e-06 0.104 {issubclass} 54822 0.083 s 1.514e-06 0.083 _intbv.py: 412(__long__) 52542 0.083 s 1.580e-06 0.119 _intbv.py: 190(__add__) 110039 0.076 s 6.907e-07 0.076 _intbv.py: 109(__nonzero__) 109714 0.059 s 5.378e-07 0.059 {method 'get' of 'dict' objects} 54013 0.055 s 1.018e-06 0.055 {method 'join' of 'str' objects} 167955 0.049 s 2.917e-07 0.049 {id} 8000 0.042 s 5.250e-06 0.216 led_pulse.py: 85(logic_addr) 54857 0.037 s 6.745e-07 0.037 {getattr} 8016 0.027 s 3.368e-06 0.261 _Waiter.py:171(next) 54865 0.024 s 4.374e-07 0.024 {len} 1692 0.019 s 1.123e-05 0.129 led_pulse.py: 107(logic_amp) 1692 0.017 s 1.005e-05 0.153 _Waiter.py:184(next) 9708 0.017 s 1.751e-06 0.363 _always_comb.py: 173(genfunc) 54013 0.016 s 2.962e-07 0.016 {method 'reverse' of 'list' objects} 103 0.016 s 1.553e-04 0.022 tb_led_pulse.py: 83(stim) 3378 0.008 s 2.368e-06 0.008 _Signal.py:46(purge) 824 0.003 s 3.641e-06 0.004 _Signal.py: 388(__int__) 1692 0.002 s 1.182e-06 0.002 _Waiter.py: 180(__init__) 101 0.002 s 1.980e-05 0.002 {time.localtime} 1 0.001 s 1.000e-03 0.001 {method 'close' of 'file' objects} 824 0.001 s 1.214e-06 0.001 _intbv.py: 409(__int__) 102 0.001 s 9.804e-06 0.001 _delay.py: 32(__init__) 259 0.000 s 0.000e+00 0.000 {method 'values' of 'dict' objects} 16 0.000 s 0.000e+00 0.001 led_pulse.py: 51(read) ------------ Table 2 -------------------- Ordered by: internal time Function called... ncalls tottime cumtime _Simulation.py:92(run) -> 3378 0.008 0.008 _Signal.py:46(purge) 700113088 1985.815 3780.550 _Signal.py:140(_update) 1 0.000 0.002 _Simulation.py:75(_finalize) 100000303 359.161 1600.072 _Waiter.py:126(next) 900001800 2477.968 16404.167 _Waiter.py:139(next) 8016 0.027 0.261 _Waiter.py:171(next) 1692 0.017 0.153 _Waiter.py:184(next) 1 0.000 0.000 _util.py:57(_printExcInfo) 100000302 53.018 53.018 {isinstance} 100000302 53.910 53.910 {method 'append' of 'list' objects} 700113088 169.890 169.890 {method 'extend' of 'list' objects} 1000011811 517.325 517.325 {method 'pop' of 'list' objects} 100000200 131.236 131.236 {method 'sort' of 'list' objects} 259 0.000 0.000 {method 'values' of 'dict' objects} _Waiter.py:139(next) -> 900001800 1145.934 13582.275 _always.py:94(genfunc) 900001800 343.925 343.925 {method 'append' of 'list' objects} led_pulse.py:64(registers) -> 400000400 220.950 220.950 _Signal.py:159(_get_val) 400000792 1225.857 4293.407 _Signal.py:169(_set_next) 400000792 467.805 684.128 _Signal.py:405(__cmp__) _Signal.py:169(_set_next) -> 200000398 226.849 226.849 _Signal.py:204(_setNextBool) 100000198 183.947 224.504 _Signal.py:209(_setNextInt) 400112492 1374.422 2542.942 _Signal.py:214(_setNextIntbv) 700113088 632.827 632.827 {isinstance} 700113088 279.688 279.688 {method 'append' of 'list' objects} _Signal.py:140(_update) -> 100042182 619.051 619.051 _Signal.py:239(_printVcdBit) 54822 0.374 3.006 _Signal.py:242(_printVcdVec) 110039 0.076 0.076 _intbv.py:109(__nonzero__) 400112492 852.963 1130.514 _intbv.py:427(__cmp__) 100084994 42.087 42.087 {method 'extend' of 'list' objects} led_pulse.py:30(pwm_regs) -> 100944 0.318 3.584 _Signal.py:169(_set_next) 400000400 254.121 254.121 _Signal.py:251(__nonzero__) 49885 0.168 0.315 _Signal.py:268(__add__) 400320469 465.501 682.488 _Signal.py:405(__cmp__) _Signal.py:214(_setNextIntbv) -> 400112492 1036.295 1036.295 _intbv.py:80(_checkBounds) 54857 0.727 2.431 copy.py:144(deepcopy) 400224550 129.794 129.794 {isinstance} _always.py:94(genfunc) -> 400000792 1454.013 2394.522 led_pulse.py:30(pwm_regs) 400000792 2213.805 7412.291 led_pulse.py:64(registers) 50000099 200.519 321.007 led_pulse.py:170(ramp_sm) 100000199 401.288 1081.786 tb_led_pulse.py:58(clkgen) 50000099 765.953 2308.521 tb_led_pulse.py:64(ticks_per) 19 0.000 0.000 {len} _Signal.py:405(__cmp__) -> 950496034/950336293 506.160 508.176 {cmp} {isinstance} -> _intbv.py:80(_checkBounds) -> _intbv.py:427(__cmp__) -> 400608311/400448570 139.296 140.223 {cmp} 400608311 139.170 139.170 {isinstance} tb_led_pulse.py:64(ticks_per) -> 200000396 592.609 1136.658 _Signal.py:169(_set_next) 99979207 146.211 236.247 _Signal.py:268(__add__) 100000198 122.592 169.663 _Signal.py:405(__cmp__) ------------------------------------------------------- From the above information (and information from other sims) it may expose some areas that could use a performance boost?? The MyHDL sim was ran on a Mac G5 1.8G with 6MB ram. On Feb 5, 2008, at 10:57 AM, Günter Dannoritzer wrote: > Neal Becker wrote: >> Hi. I just discovered myhdl. I'm very interested. >> >> Haven't tried any coding yet, just reading the docs - but I was >> immediately >> struck by the thought that intbv is going to be awfully slow coded in >> python - seems to cry out for a c++ implementation. Is this worth >> pursuing? >> > > I am not an expert on that subject, but there has been some discussion > on this list here before about that subject. Maybe looking in the > archive gives you some answers to your question. > > Cheers, > > Guenter > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > myhdl-list mailing list > myh...@li... > https://lists.sourceforge.net/lists/listinfo/myhdl-list |