HDLRuby 2.7.5 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +22 -0
- data/lib/HDLRuby/hdr_samples/adder_gen_gen.rb +40 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +1 -1
- data/lib/HDLRuby/hdr_samples/parseq_bench.rb +61 -0
- data/lib/HDLRuby/hdr_samples/range_bench.rb +4 -1
- data/lib/HDLRuby/hdr_samples/rom_nest.rb +27 -0
- data/lib/HDLRuby/hdr_samples/with_channel_other.rb +128 -0
- data/lib/HDLRuby/hdr_samples/with_def.rb +29 -0
- data/lib/HDLRuby/hdr_samples/with_of.rb +51 -0
- data/lib/HDLRuby/hdr_samples/with_reconf.rb +75 -72
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +32 -0
- data/lib/HDLRuby/hdrcc.rb +8 -1
- data/lib/HDLRuby/hruby_high.rb +177 -27
- data/lib/HDLRuby/hruby_low.rb +207 -3
- data/lib/HDLRuby/hruby_low2c.rb +180 -59
- data/lib/HDLRuby/hruby_low2vhd.rb +12 -0
- data/lib/HDLRuby/hruby_low_bool2select.rb +12 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +20 -1
- data/lib/HDLRuby/hruby_low_resolve.rb +30 -1
- data/lib/HDLRuby/hruby_low_without_select.rb +11 -1
- data/lib/HDLRuby/hruby_tools.rb +1 -0
- data/lib/HDLRuby/hruby_verilog.rb +9 -1
- data/lib/HDLRuby/sim/hruby_sim.h +23 -1
- data/lib/HDLRuby/sim/hruby_sim_core.c +65 -8
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +1 -1
- data/lib/HDLRuby/std/reconf.rb +3 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +9 -2
    
        data/lib/HDLRuby/hruby_low2c.rb
    CHANGED
    
    | @@ -135,6 +135,8 @@ module HDLRuby::Low | |
| 135 135 | 
             
                        objs.each { |obj| res << "   " << Low2C.make_name(obj) << "();\n" }
         | 
| 136 136 | 
             
                        # Sets the top systemT.
         | 
| 137 137 | 
             
                        res << "   top_system = " << Low2C.obj_name(top) << ";\n"
         | 
| 138 | 
            +
                        # Enable it.
         | 
| 139 | 
            +
                        res << "   set_enable_system(top_system,1);\n"
         | 
| 138 140 | 
             
                        # Starts the simulation.
         | 
| 139 141 | 
             
                        res<< "   hruby_sim_core(\"#{name}\",#{init_visualizer},-1);\n"
         | 
| 140 142 | 
             
                        # Close the main.
         | 
| @@ -170,6 +172,7 @@ module HDLRuby::Low | |
| 170 172 | 
             
                    # is the list of extra h files to include.
         | 
| 171 173 | 
             
                    # def to_c(level = 0, *hnames)
         | 
| 172 174 | 
             
                    def to_c(res, level = 0, *hnames)
         | 
| 175 | 
            +
                        # puts "SystemT.to_c with name=#{Low2C.obj_name(self)}#{@wrapper ? " and wrapper=#{Low2C.obj_name(@wrapper)}" : ""}"
         | 
| 173 176 | 
             
                        # The header
         | 
| 174 177 | 
             
                        # res = Low2C.includes(*hnames)
         | 
| 175 178 | 
             
                        res << Low2C.includes(*hnames)
         | 
| @@ -179,7 +182,16 @@ module HDLRuby::Low | |
| 179 182 |  | 
| 180 183 | 
             
                        # Generate the signals of the system.
         | 
| 181 184 | 
             
                        # self.each_signal { |signal| signal.to_c(level) }
         | 
| 182 | 
            -
                         | 
| 185 | 
            +
                        if ((defined? @wrapper) && @wrapper) then
         | 
| 186 | 
            +
                            # It is a reconfiguring system, alias the signals.
         | 
| 187 | 
            +
                            wrap_signals = @wrapper.each_signal.to_a
         | 
| 188 | 
            +
                            self.each_signal.with_index do |signal,i|
         | 
| 189 | 
            +
                                signal.to_c_alias(res,wrap_signals[i],level)
         | 
| 190 | 
            +
                            end
         | 
| 191 | 
            +
                        else
         | 
| 192 | 
            +
                            # It is a single system, default generation.
         | 
| 193 | 
            +
                            self.each_signal { |signal| signal.to_c(res,level) }
         | 
| 194 | 
            +
                        end
         | 
| 183 195 |  | 
| 184 196 | 
             
                        # Generate the code for all the blocks included in the system.
         | 
| 185 197 | 
             
                        self.scope.each_scope_deep do |scope|
         | 
| @@ -356,8 +368,13 @@ module HDLRuby::Low | |
| 356 368 | 
             
                        end
         | 
| 357 369 | 
             
                        self.scope.each_block_deep do |block|
         | 
| 358 370 | 
             
                            block.each_inner do |signal|
         | 
| 359 | 
            -
                                #  | 
| 360 | 
            -
                                 | 
| 371 | 
            +
                                # signal.value.to_ch(res) if signal.value
         | 
| 372 | 
            +
                                if signal.value then
         | 
| 373 | 
            +
                                    signal.value.each_node_deep do |node|
         | 
| 374 | 
            +
                                        # res << node.to_ch if node.is_a?(Value)
         | 
| 375 | 
            +
                                        node.to_ch(res) if node.is_a?(Value)
         | 
| 376 | 
            +
                                    end
         | 
| 377 | 
            +
                                end
         | 
| 361 378 | 
             
                            end
         | 
| 362 379 | 
             
                            block.each_node_deep do |node|
         | 
| 363 380 | 
             
                                # res << node.to_ch if node.is_a?(Value)
         | 
| @@ -681,6 +698,10 @@ module HDLRuby::Low | |
| 681 698 | 
             
                            res << "behavior->owner = NULL;\n"
         | 
| 682 699 | 
             
                        end
         | 
| 683 700 |  | 
| 701 | 
            +
                        # Set the behavior as not enabled. */
         | 
| 702 | 
            +
                        res << " " * (level+1)*3
         | 
| 703 | 
            +
                        res << "behavior->enabled = 0;\n"
         | 
| 704 | 
            +
             | 
| 684 705 | 
             
                        # Set the behavior as inactive. */
         | 
| 685 706 | 
             
                        res << " " * (level+1)*3
         | 
| 686 707 | 
             
                        res << "behavior->activated = 0;\n"
         | 
| @@ -702,6 +723,10 @@ module HDLRuby::Low | |
| 702 723 | 
             
                            end.to_a
         | 
| 703 724 | 
             
                            # Keep only one ref per signal.
         | 
| 704 725 | 
             
                            refs.uniq! { |node| node.full_name }
         | 
| 726 | 
            +
                            # Remove the inner signals from the list.
         | 
| 727 | 
            +
                            self.block.each_inner do |inner|
         | 
| 728 | 
            +
                                refs.delete_if {|r| r.name == inner.name }
         | 
| 729 | 
            +
                            end
         | 
| 705 730 | 
             
                            # Generate the event.
         | 
| 706 731 | 
             
                            events = refs.map {|ref| Event.new(:anyedge,ref.clone) }
         | 
| 707 732 | 
             
                            # Add them to the behavior for further processing.
         | 
| @@ -833,11 +858,8 @@ module HDLRuby::Low | |
| 833 858 | 
             
                    #  +level+ is the hierachical level of the object.
         | 
| 834 859 | 
             
                    # def to_c(level = 0)
         | 
| 835 860 | 
             
                    def to_c(res,level = 0)
         | 
| 836 | 
            -
                        #  | 
| 837 | 
            -
                        # res = ""
         | 
| 838 | 
            -
             | 
| 861 | 
            +
                        # puts "Signal.to_c with name: #{Low2C.obj_name(self)}"
         | 
| 839 862 | 
             
                        # Declare the global variable holding the signal.
         | 
| 840 | 
            -
                        # res << "SignalI #{self.to_c_signal(level+1)};\n\n"
         | 
| 841 863 | 
             
                        res << "SignalI "
         | 
| 842 864 | 
             
                        self.to_c_signal(res,level+1)
         | 
| 843 865 | 
             
                        res << ";\n\n"
         | 
| @@ -845,6 +867,7 @@ module HDLRuby::Low | |
| 845 867 | 
             
                        # The header of the signal generation.
         | 
| 846 868 | 
             
                        res << " " * level*3
         | 
| 847 869 | 
             
                        res << "SignalI " << Low2C.make_name(self) << "() {\n"
         | 
| 870 | 
            +
             | 
| 848 871 | 
             
                        # res << " " * level*3
         | 
| 849 872 | 
             
                        # res << "Value l,r,d;\n"
         | 
| 850 873 | 
             
                        # res << " " * (level+1)*3
         | 
| @@ -857,7 +880,6 @@ module HDLRuby::Low | |
| 857 880 | 
             
                        # Sets the global variable of the signal.
         | 
| 858 881 | 
             
                        res << "\n"
         | 
| 859 882 | 
             
                        res << " " * (level+1)*3
         | 
| 860 | 
            -
                        # res << "#{self.to_c_signal(level+1)} = signalI;\n"
         | 
| 861 883 | 
             
                        self.to_c_signal(res,level+1)
         | 
| 862 884 | 
             
                        res << " = signalI;\n"
         | 
| 863 885 |  | 
| @@ -891,11 +913,12 @@ module HDLRuby::Low | |
| 891 913 | 
             
                        if self.value then
         | 
| 892 914 | 
             
                            # There is an initial value.
         | 
| 893 915 | 
             
                            res << " " * (level+1)*3
         | 
| 894 | 
            -
                            # res << "copy_value( | 
| 895 | 
            -
                            # | 
| 916 | 
            +
                            # res << "copy_value("
         | 
| 917 | 
            +
                            # self.value.to_c_expr(res,level+2)
         | 
| 918 | 
            +
                            # res << ",signalI->c_value);\n"
         | 
| 896 919 | 
             
                            res << "copy_value("
         | 
| 897 920 | 
             
                            self.value.to_c_expr(res,level+2)
         | 
| 898 | 
            -
                            res << ",signalI-> | 
| 921 | 
            +
                            res << ",signalI->f_value);\n"
         | 
| 899 922 | 
             
                        end
         | 
| 900 923 |  | 
| 901 924 | 
             
                        # Initially the signal can be overwritten by anything.
         | 
| @@ -948,6 +971,43 @@ module HDLRuby::Low | |
| 948 971 |  | 
| 949 972 | 
             
                        return res;
         | 
| 950 973 | 
             
                    end
         | 
| 974 | 
            +
             | 
| 975 | 
            +
                    ## Generates the C text of the equivalent HDLRuby code in case
         | 
| 976 | 
            +
                    #  the signals is actually an alias to another signal.
         | 
| 977 | 
            +
                    #  +other+ is the target signal of the alias.
         | 
| 978 | 
            +
                    #  +level+ is the hierachical level of the object.
         | 
| 979 | 
            +
                    def to_c_alias(res,target,level = 0)
         | 
| 980 | 
            +
                        # puts "Signal.to_c_alias with name: #{Low2C.obj_name(self)}"
         | 
| 981 | 
            +
                        # The resulting string.
         | 
| 982 | 
            +
                        # res = ""
         | 
| 983 | 
            +
             | 
| 984 | 
            +
                        # Declare the global variable holding the signal.
         | 
| 985 | 
            +
                        res << "SignalI "
         | 
| 986 | 
            +
                        self.to_c_signal(res,level+1)
         | 
| 987 | 
            +
                        res << ";\n\n"
         | 
| 988 | 
            +
             | 
| 989 | 
            +
                        # The header of the signal generation.
         | 
| 990 | 
            +
                        res << " " * level*3
         | 
| 991 | 
            +
                        res << "SignalI " << Low2C.make_name(self) << "() {\n"
         | 
| 992 | 
            +
             | 
| 993 | 
            +
                        res << "SignalI signalI = #{Low2C.obj_name(target)};\n"
         | 
| 994 | 
            +
             | 
| 995 | 
            +
                        # Sets the global variable of the signal.
         | 
| 996 | 
            +
                        res << "\n"
         | 
| 997 | 
            +
                        res << " " * (level+1)*3
         | 
| 998 | 
            +
                        self.to_c_signal(res,level+1)
         | 
| 999 | 
            +
                        res << " = signalI;\n"
         | 
| 1000 | 
            +
             | 
| 1001 | 
            +
                        # Generate the return of the signal.
         | 
| 1002 | 
            +
                        res << "\n"
         | 
| 1003 | 
            +
                        res << " " * (level+1)*3
         | 
| 1004 | 
            +
                        res << "return signalI;\n"
         | 
| 1005 | 
            +
             | 
| 1006 | 
            +
                        # Close the signal.
         | 
| 1007 | 
            +
                        res << " " * level*3
         | 
| 1008 | 
            +
                        res << "};\n\n"
         | 
| 1009 | 
            +
                        return res
         | 
| 1010 | 
            +
                    end
         | 
| 951 1011 | 
             
                end
         | 
| 952 1012 |  | 
| 953 1013 |  | 
| @@ -989,9 +1049,22 @@ module HDLRuby::Low | |
| 989 1049 | 
             
                        # Set the name
         | 
| 990 1050 | 
             
                        res << " " * (level+1)*3
         | 
| 991 1051 | 
             
                        res << "systemI->name = \"#{self.name}\";\n"
         | 
| 992 | 
            -
                        # Set the type.
         | 
| 1052 | 
            +
                        # # Set the type.
         | 
| 1053 | 
            +
                        # res << " " * (level+1)*3
         | 
| 1054 | 
            +
                        # res << "systemI->system = " << Low2C.obj_name(self.systemT) << ";\n"
         | 
| 1055 | 
            +
                        # Set the systems.
         | 
| 1056 | 
            +
                        num_sys = self.each_systemT.to_a.size
         | 
| 993 1057 | 
             
                        res << " " * (level+1)*3
         | 
| 994 | 
            -
                        res << "systemI-> | 
| 1058 | 
            +
                        res << "systemI->num_systems = #{num_sys};\n"
         | 
| 1059 | 
            +
                        res << " " * (level+1)*3
         | 
| 1060 | 
            +
                        res << "systemI->systems = calloc(sizeof(SystemT), #{num_sys});\n"
         | 
| 1061 | 
            +
                        self.each_systemT.with_index do |sysT,i|
         | 
| 1062 | 
            +
                            res << " " * (level+1)*3
         | 
| 1063 | 
            +
                            res << "systemI->systems[#{i}] = #{Low2C.obj_name(sysT)};\n"
         | 
| 1064 | 
            +
                        end
         | 
| 1065 | 
            +
             | 
| 1066 | 
            +
                        # Configure the instance to current systemT.
         | 
| 1067 | 
            +
                        res << (" " * (level*3)) << "configure(systemI,0);\n"
         | 
| 995 1068 |  | 
| 996 1069 | 
             
                        # Generate the return of the signal.
         | 
| 997 1070 | 
             
                        res << "\n"
         | 
| @@ -1090,6 +1163,10 @@ module HDLRuby::Low | |
| 1090 1163 | 
             
                            res << "code->owner = NULL;\n"
         | 
| 1091 1164 | 
             
                        end
         | 
| 1092 1165 |  | 
| 1166 | 
            +
                        # Set the code as enabled (for now, may change in a near future). */
         | 
| 1167 | 
            +
                        res << " " * (level+1)*3
         | 
| 1168 | 
            +
                        res << "code->enabled = 1;\n"
         | 
| 1169 | 
            +
             | 
| 1093 1170 | 
             
                        # Set the code as inactive. */
         | 
| 1094 1171 | 
             
                        res << " " * (level+1)*3
         | 
| 1095 1172 | 
             
                        res << "code->activated = 0;\n"
         | 
| @@ -1382,6 +1459,28 @@ module HDLRuby::Low | |
| 1382 1459 | 
             
                    end
         | 
| 1383 1460 | 
             
                end
         | 
| 1384 1461 |  | 
| 1462 | 
            +
                ## Extends the TimeTerminate class with generation of C text.
         | 
| 1463 | 
            +
                class TimeTerminate
         | 
| 1464 | 
            +
             | 
| 1465 | 
            +
                    # Generates the C text of the equivalent HDLRuby code.
         | 
| 1466 | 
            +
                    # +level+ is the hierachical level of the object.
         | 
| 1467 | 
            +
                    def to_c(res,level = 0)
         | 
| 1468 | 
            +
                        # Save the value pool state.
         | 
| 1469 | 
            +
                        res << (" " * (level*3)) << "terminate();\n"
         | 
| 1470 | 
            +
                    end
         | 
| 1471 | 
            +
                end
         | 
| 1472 | 
            +
             | 
| 1473 | 
            +
                ## Extends the Configure class with generation of C text.
         | 
| 1474 | 
            +
                class Configure
         | 
| 1475 | 
            +
             | 
| 1476 | 
            +
                    # Generates the C text of the equivalent HDLRuby code.
         | 
| 1477 | 
            +
                    # +level+ is the hierachical level of the object.
         | 
| 1478 | 
            +
                    def to_c(res,level = 0)
         | 
| 1479 | 
            +
                        # Save the value pool state.
         | 
| 1480 | 
            +
                        res << (" " * (level*3)) << "configure(#{Low2C.obj_name(self.ref.resolve)},#{self.index});\n"
         | 
| 1481 | 
            +
                    end
         | 
| 1482 | 
            +
                end
         | 
| 1483 | 
            +
             | 
| 1385 1484 |  | 
| 1386 1485 | 
             
                ## Extends the If class with generation of C text.
         | 
| 1387 1486 | 
             
                class If
         | 
| @@ -1893,6 +1992,16 @@ module HDLRuby::Low | |
| 1893 1992 | 
             
                        # Should never be here.
         | 
| 1894 1993 | 
             
                        raise AnyError, "Internal error: to_c should be implemented in class :#{self.class}"
         | 
| 1895 1994 | 
             
                    end
         | 
| 1995 | 
            +
             | 
| 1996 | 
            +
                    ## Generates the C text for an expression access to the expression,
         | 
| 1997 | 
            +
                    #  default case.
         | 
| 1998 | 
            +
                    #  +level+ is the hierachical level of the object.
         | 
| 1999 | 
            +
                    def to_c_expr(res,level = 0)
         | 
| 2000 | 
            +
                        res << "({"
         | 
| 2001 | 
            +
                        self.to_c(res,level+1)
         | 
| 2002 | 
            +
                        res << (" " * ((level+1)*3))
         | 
| 2003 | 
            +
                        res << "pop();})"
         | 
| 2004 | 
            +
                    end
         | 
| 1896 2005 | 
             
                end
         | 
| 1897 2006 |  | 
| 1898 2007 |  | 
| @@ -2455,46 +2564,64 @@ module HDLRuby::Low | |
| 2455 2564 | 
             
                        return res
         | 
| 2456 2565 | 
             
                    end
         | 
| 2457 2566 |  | 
| 2458 | 
            -
                    # Generates the C text of expression for the equivalent HDLRuby code.
         | 
| 2459 | 
            -
                    # +level+ is the hierachical level of the object.
         | 
| 2460 | 
            -
                    def to_c_expr(res,level = 0)
         | 
| 2461 | 
            -
             | 
| 2462 | 
            -
             | 
| 2463 | 
            -
             | 
| 2464 | 
            -
             | 
| 2465 | 
            -
             | 
| 2466 | 
            -
             | 
| 2467 | 
            -
             | 
| 2468 | 
            -
             | 
| 2469 | 
            -
             | 
| 2470 | 
            -
             | 
| 2471 | 
            -
             | 
| 2472 | 
            -
             | 
| 2473 | 
            -
             | 
| 2474 | 
            -
             | 
| 2475 | 
            -
             | 
| 2476 | 
            -
             | 
| 2477 | 
            -
             | 
| 2478 | 
            -
             | 
| 2479 | 
            -
             | 
| 2480 | 
            -
             | 
| 2481 | 
            -
             | 
| 2482 | 
            -
             | 
| 2483 | 
            -
             | 
| 2484 | 
            -
             | 
| 2485 | 
            -
             | 
| 2486 | 
            -
             | 
| 2487 | 
            -
             | 
| 2488 | 
            -
             | 
| 2489 | 
            -
             | 
| 2490 | 
            -
             | 
| 2491 | 
            -
             | 
| 2492 | 
            -
             | 
| 2493 | 
            -
             | 
| 2494 | 
            -
             | 
| 2495 | 
            -
             | 
| 2496 | 
            -
             | 
| 2497 | 
            -
                    end
         | 
| 2567 | 
            +
                    # # # Generates the C text of expression for the equivalent HDLRuby code.
         | 
| 2568 | 
            +
                    # # # +level+ is the hierachical level of the object.
         | 
| 2569 | 
            +
                    # # def to_c_expr(res,level = 0)
         | 
| 2570 | 
            +
                    # #     # Gather the content to concat.
         | 
| 2571 | 
            +
                    # #     expressions = self.each_expression.to_a
         | 
| 2572 | 
            +
                    # #     # Create the resulting string.
         | 
| 2573 | 
            +
                    # #     res << "({\n"
         | 
| 2574 | 
            +
                    # #     # Overrides the upper src0, src1, ..., and dst...
         | 
| 2575 | 
            +
                    # #     # And allocates a new value for dst.
         | 
| 2576 | 
            +
                    # #     res << (" " * ((level+1)*3))
         | 
| 2577 | 
            +
                    # #     res << "Value "
         | 
| 2578 | 
            +
                    # #     res << expressions.size.times.map do |i| 
         | 
| 2579 | 
            +
                    # #         "src#{i}"
         | 
| 2580 | 
            +
                    # #     end.join(",")
         | 
| 2581 | 
            +
                    # #     res << ";\n"
         | 
| 2582 | 
            +
                    # #     res << (" " * ((level+1)*3))
         | 
| 2583 | 
            +
                    # #     res << "Value dst = get_value();\n"
         | 
| 2584 | 
            +
                    # #     # Save the value pool state.
         | 
| 2585 | 
            +
                    # #     res << (" " * (level*3)) << "SV;\n"
         | 
| 2586 | 
            +
                    # #     # Compute each sub expression.
         | 
| 2587 | 
            +
                    # #     expressions.each_with_index do |expr,i|
         | 
| 2588 | 
            +
                    # #         res << (" " * ((level+1)*3))
         | 
| 2589 | 
            +
                    # #         res << "src#{i} = "
         | 
| 2590 | 
            +
                    # #         expr.to_c_expr(res,level+2)
         | 
| 2591 | 
            +
                    # #         res << ";\n"
         | 
| 2592 | 
            +
                    # #     end
         | 
| 2593 | 
            +
                    # #     # Compute the direction.
         | 
| 2594 | 
            +
                    # #     # Compute the resulting concatenation.
         | 
| 2595 | 
            +
                    # #     res << (" " * ((level+1)*3))
         | 
| 2596 | 
            +
                    # #     res << "concat_value(#{expressions.size},"
         | 
| 2597 | 
            +
                    # #     res << "#{self.type.direction == :little ? 1 : 0},dst,"
         | 
| 2598 | 
            +
                    # #     res << expressions.size.times.map { |i| "src#{i}" }.join(",")
         | 
| 2599 | 
            +
                    # #     res << ");\n"
         | 
| 2600 | 
            +
                    # #     # Save the value pool state.
         | 
| 2601 | 
            +
                    # #     res << (" " * (level*3)) << "SV;\n"
         | 
| 2602 | 
            +
                    # #     # Close the computation.
         | 
| 2603 | 
            +
                    # #     res << (" " * (level*3))
         | 
| 2604 | 
            +
                    # #     res << "dst; })"
         | 
| 2605 | 
            +
                    # #     return res
         | 
| 2606 | 
            +
                    # # end
         | 
| 2607 | 
            +
                    # def to_c_expr(res,level = 0)
         | 
| 2608 | 
            +
                    #     # Save the value pool state.
         | 
| 2609 | 
            +
                    #     res << "({ PV;"
         | 
| 2610 | 
            +
                    #     # Gather the content to concat.
         | 
| 2611 | 
            +
                    #     expressions = self.each_expression.to_a
         | 
| 2612 | 
            +
                    #     # Compute each sub expression.
         | 
| 2613 | 
            +
                    #     expressions.each_with_index do |expr,i|
         | 
| 2614 | 
            +
                    #         expr.to_c(res,level+2)
         | 
| 2615 | 
            +
                    #     end
         | 
| 2616 | 
            +
                    #     # Compute the resulting concatenation.
         | 
| 2617 | 
            +
                    #     res << (" " * ((level+1)*3))
         | 
| 2618 | 
            +
                    #     res << "sconcat(#{expressions.size},"
         | 
| 2619 | 
            +
                    #     res << (self.type.direction == :little ? "1" : "0")
         | 
| 2620 | 
            +
                    #     res << ");\n"
         | 
| 2621 | 
            +
                    #     # Restore the value pool state.
         | 
| 2622 | 
            +
                    #     res << "RV; pop();})"
         | 
| 2623 | 
            +
                    #     return res
         | 
| 2624 | 
            +
                    # end
         | 
| 2498 2625 | 
             
                end
         | 
| 2499 2626 |  | 
| 2500 2627 |  | 
| @@ -2778,17 +2905,11 @@ module HDLRuby::Low | |
| 2778 2905 | 
             
                    # +left+ tells if it is a left value or not.
         | 
| 2779 2906 | 
             
                    # def to_c(level = 0, left = false)
         | 
| 2780 2907 | 
             
                    def to_c(res,level = 0, left = false)
         | 
| 2781 | 
            -
                        # # puts "RefName to_c for #{self.name}"
         | 
| 2782 | 
            -
                        # self.resolve.to_c_signal(res,level+1)
         | 
| 2783 | 
            -
                        # res << "->" << (left ? "f_value" : "c_value")
         | 
| 2784 | 
            -
                        # return res
         | 
| 2785 2908 | 
             
                        # puts "RefName to_c for #{self.name}"
         | 
| 2786 2909 | 
             
                        res << (" " * (level*3))
         | 
| 2787 | 
            -
                        # res << "d="
         | 
| 2788 2910 | 
             
                        res << "push("
         | 
| 2789 2911 | 
             
                        self.resolve.to_c_signal(res,level+1)
         | 
| 2790 2912 | 
             
                        res << "->" << (left ? "f_value" : "c_value")
         | 
| 2791 | 
            -
                        # res << ";\n"
         | 
| 2792 2913 | 
             
                        res << ");\n"
         | 
| 2793 2914 | 
             
                        return res
         | 
| 2794 2915 | 
             
                    end
         | 
| @@ -925,6 +925,18 @@ module HDLRuby::Low | |
| 925 925 | 
             
                        end.join(" & ") + ";\n"
         | 
| 926 926 | 
             
                    end
         | 
| 927 927 | 
             
                end
         | 
| 928 | 
            +
             | 
| 929 | 
            +
                ## Extends the TimeTerminate class with generation of HDLRuby::High text.
         | 
| 930 | 
            +
                class TimeTerminate
         | 
| 931 | 
            +
             | 
| 932 | 
            +
                    # Generates the text of the equivalent HDLRuby::High code.
         | 
| 933 | 
            +
                    # +vars+ is the list of the variables and
         | 
| 934 | 
            +
                    # +level+ is the hierachical level of the object.
         | 
| 935 | 
            +
                    def to_vhdl(vars,level = 0)
         | 
| 936 | 
            +
                        # Generate a report statement.
         | 
| 937 | 
            +
                        return " " * (level*3) + "finish;\n"
         | 
| 938 | 
            +
                    end
         | 
| 939 | 
            +
                end
         | 
| 928 940 |  | 
| 929 941 | 
             
                ## Extends the If class with generation of HDLRuby::High text.
         | 
| 930 942 | 
             
                class If
         | 
| @@ -75,6 +75,18 @@ module HDLRuby::Low | |
| 75 75 | 
             
                    end
         | 
| 76 76 | 
             
                end
         | 
| 77 77 |  | 
| 78 | 
            +
             | 
| 79 | 
            +
                ## Extends the TimeTerminate class with functionality for converting booleans
         | 
| 80 | 
            +
                #  in assignments to select operators.
         | 
| 81 | 
            +
                class TimeTerminate
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                    # Converts booleans in assignments to select operators.
         | 
| 84 | 
            +
                    def boolean_in_assign2select!
         | 
| 85 | 
            +
                        # Nothing to do.
         | 
| 86 | 
            +
                        return self
         | 
| 87 | 
            +
                    end
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
             | 
| 78 90 |  | 
| 79 91 | 
             
                ## Extends the If class with functionality for converting booleans
         | 
| 80 92 | 
             
                #  in assignments to select operators.
         | 
| @@ -71,7 +71,7 @@ module HDLRuby::Low | |
| 71 71 | 
             
                class Statement
         | 
| 72 72 | 
             
                    # Explicit the types conversions in the statement.
         | 
| 73 73 | 
             
                    def explicit_types!
         | 
| 74 | 
            -
                        raise "Should implement explicit_types for class #{self.class}."
         | 
| 74 | 
            +
                        raise "Should implement explicit_types! for class #{self.class}."
         | 
| 75 75 | 
             
                    end
         | 
| 76 76 | 
             
                end
         | 
| 77 77 |  | 
| @@ -98,7 +98,26 @@ module HDLRuby::Low | |
| 98 98 | 
             
                        self.map_args!(&:explicit_types)
         | 
| 99 99 | 
             
                        return self
         | 
| 100 100 | 
             
                    end
         | 
| 101 | 
            +
                end
         | 
| 102 | 
            +
             | 
| 103 | 
            +
             | 
| 104 | 
            +
                ## Extends the Configure class with fixing of types and constants.
         | 
| 105 | 
            +
                class Configure
         | 
| 106 | 
            +
                    # Explicit the types conversions in the statement.
         | 
| 107 | 
            +
                    def explicit_types!
         | 
| 108 | 
            +
                        # Nothing to do.
         | 
| 109 | 
            +
                        return self
         | 
| 110 | 
            +
                    end
         | 
| 111 | 
            +
                end
         | 
| 101 112 |  | 
| 113 | 
            +
             | 
| 114 | 
            +
                ## Extends the TimeTerminate class with fixing of types and constants.
         | 
| 115 | 
            +
                class TimeTerminate
         | 
| 116 | 
            +
                    # Explicit the types conversions in the statement.
         | 
| 117 | 
            +
                    def explicit_types!
         | 
| 118 | 
            +
                        # Nothing to do.
         | 
| 119 | 
            +
                        return self
         | 
| 120 | 
            +
                    end
         | 
| 102 121 | 
             
                end
         | 
| 103 122 |  | 
| 104 123 |  | 
| @@ -50,9 +50,25 @@ module HDLRuby::Low | |
| 50 50 | 
             
                        return found if found
         | 
| 51 51 | 
             
                        # Maybe it is a sub scope.
         | 
| 52 52 | 
             
                        return self.each_scope.find { |scope| scope.name == name }
         | 
| 53 | 
            +
                        # Maybe it in the behavior.
         | 
| 54 | 
            +
                        return self.behavior.get_by_name
         | 
| 53 55 | 
             
                    end
         | 
| 54 56 | 
             
                end
         | 
| 55 57 |  | 
| 58 | 
            +
                ##
         | 
| 59 | 
            +
                #  Extends Behavior with the capability of finding one of its inner object
         | 
| 60 | 
            +
                #  by name.
         | 
| 61 | 
            +
                class Behavior
         | 
| 62 | 
            +
                    
         | 
| 63 | 
            +
                    ## Find an inner object by +name+.
         | 
| 64 | 
            +
                    #  NOTE: return nil if not found.
         | 
| 65 | 
            +
                    def get_by_name(name)
         | 
| 66 | 
            +
                        if (self.block.name == name.to_sym) then
         | 
| 67 | 
            +
                            return self.block
         | 
| 68 | 
            +
                        end
         | 
| 69 | 
            +
                        return self.block.get_by_name(name)
         | 
| 70 | 
            +
                    end
         | 
| 71 | 
            +
                end
         | 
| 56 72 |  | 
| 57 73 | 
             
                ##
         | 
| 58 74 | 
             
                #  Extends SystemI with the capability of finding one of its inner object
         | 
| @@ -79,7 +95,16 @@ module HDLRuby::Low | |
| 79 95 | 
             
                        # Ensure the name is a symbol.
         | 
| 80 96 | 
             
                        name = name.to_sym
         | 
| 81 97 | 
             
                        # Look in the signals.
         | 
| 82 | 
            -
                         | 
| 98 | 
            +
                        found = self.get_inner(name)
         | 
| 99 | 
            +
                        return found if found
         | 
| 100 | 
            +
                        # Check the sub blocks names.
         | 
| 101 | 
            +
                        self.each_block do |block|
         | 
| 102 | 
            +
                            # puts "block=#{block.name}"
         | 
| 103 | 
            +
                            if (block.name == name) then
         | 
| 104 | 
            +
                                return block
         | 
| 105 | 
            +
                            end
         | 
| 106 | 
            +
                        end
         | 
| 107 | 
            +
                        return nil
         | 
| 83 108 | 
             
                    end
         | 
| 84 109 | 
             
                end
         | 
| 85 110 |  | 
| @@ -199,6 +224,7 @@ module HDLRuby::Low | |
| 199 224 | 
             
                        if self.ref.is_a?(RefName) then
         | 
| 200 225 | 
             
                            # puts "ref name=#{self.ref.name}"
         | 
| 201 226 | 
             
                            obj = self.ref.resolve
         | 
| 227 | 
            +
                            # puts "obj=#{obj}"
         | 
| 202 228 | 
             
                            # Look into the object for the name.
         | 
| 203 229 | 
             
                            return obj.get_by_name(self.name)
         | 
| 204 230 | 
             
                        else
         | 
| @@ -208,12 +234,15 @@ module HDLRuby::Low | |
| 208 234 | 
             
                            while parent
         | 
| 209 235 | 
             
                                # puts "parent=#{parent}"
         | 
| 210 236 | 
             
                                if parent.respond_to?(:get_by_name) then
         | 
| 237 | 
            +
                                    # puts "get_by_name"
         | 
| 211 238 | 
             
                                    found = parent.get_by_name(self.name)
         | 
| 239 | 
            +
                                    # puts "found" if found
         | 
| 212 240 | 
             
                                    return found if found
         | 
| 213 241 | 
             
                                end
         | 
| 214 242 | 
             
                                parent = parent.parent
         | 
| 215 243 | 
             
                            end
         | 
| 216 244 | 
             
                            # Not found.
         | 
| 245 | 
            +
                            puts "Not found!"
         | 
| 217 246 | 
             
                            return nil
         | 
| 218 247 | 
             
                        end
         | 
| 219 248 | 
             
                    end
         | 
| @@ -163,7 +163,7 @@ module HDLRuby::Low | |
| 163 163 | 
             
                    end
         | 
| 164 164 | 
             
                end
         | 
| 165 165 |  | 
| 166 | 
            -
                ## Extends the  | 
| 166 | 
            +
                ## Extends the Print class with functionality for converting select
         | 
| 167 167 | 
             
                #  expressions to case statements.
         | 
| 168 168 | 
             
                class Print
         | 
| 169 169 | 
             
                    # Extract the Select expressions.
         | 
| @@ -175,6 +175,16 @@ module HDLRuby::Low | |
| 175 175 | 
             
                        return selects
         | 
| 176 176 | 
             
                    end
         | 
| 177 177 | 
             
                end
         | 
| 178 | 
            +
             | 
| 179 | 
            +
                ## Extends the TimeTerminate class with functionality for converting select
         | 
| 180 | 
            +
                #  expressions to case statements.
         | 
| 181 | 
            +
                class TimeTerminate
         | 
| 182 | 
            +
                    # Extract the Select expressions.
         | 
| 183 | 
            +
                    def extract_selects!
         | 
| 184 | 
            +
                        # Nothing to extract.
         | 
| 185 | 
            +
                        return []
         | 
| 186 | 
            +
                    end
         | 
| 187 | 
            +
                end
         | 
| 178 188 |  | 
| 179 189 | 
             
                ## Extends the If class with functionality for converting select
         | 
| 180 190 | 
             
                #  expressions to case statements.
         | 
    
        data/lib/HDLRuby/hruby_tools.rb
    CHANGED
    
    
| @@ -171,7 +171,7 @@ module HDLRuby::Low | |
| 171 171 |  | 
| 172 172 | 
             
                # Enhance Print with generation of verilog code.
         | 
| 173 173 | 
             
                class Print
         | 
| 174 | 
            -
                    # Converts the  | 
| 174 | 
            +
                    # Converts the print to Verilog code.
         | 
| 175 175 | 
             
                    def to_verilog(spc = 3)
         | 
| 176 176 | 
             
                        code = "#{" " * spc}$write(#{self.each_arg.map do |arg|
         | 
| 177 177 | 
             
                        arg.to_verilog
         | 
| @@ -180,6 +180,14 @@ module HDLRuby::Low | |
| 180 180 | 
             
                    end
         | 
| 181 181 | 
             
                end
         | 
| 182 182 |  | 
| 183 | 
            +
                # Enhance TimeTerminate with generation of verilog code.
         | 
| 184 | 
            +
                class TimeTerminate
         | 
| 185 | 
            +
                    # Converts the terminate to Verilog code.
         | 
| 186 | 
            +
                    def to_verilog(spc = 3)
         | 
| 187 | 
            +
                        return "#{" " * spc}$finish;"
         | 
| 188 | 
            +
                    end
         | 
| 189 | 
            +
                end
         | 
| 190 | 
            +
             | 
| 183 191 | 
             
                # To scheduling to the Block.
         | 
| 184 192 | 
             
                # Enhance Block with generation of verilog code.
         | 
| 185 193 | 
             
                class Block
         | 
    
        data/lib/HDLRuby/sim/hruby_sim.h
    CHANGED
    
    | @@ -467,7 +467,10 @@ typedef struct SystemIS_ { | |
| 467 467 | 
             
                Object owner;       /* The owner if any. */
         | 
| 468 468 |  | 
| 469 469 | 
             
                char* name;         /* The name of the signal. */
         | 
| 470 | 
            -
                SystemT system;     /* The instantiated system. */
         | 
| 470 | 
            +
                SystemT system;     /* The currently instantiated system. */
         | 
| 471 | 
            +
             | 
| 472 | 
            +
                int num_systems;    /* The number of systems possibly instantiated here. */
         | 
| 473 | 
            +
                SystemT* systems;   /* The systems possibly instantiated here. */
         | 
| 471 474 | 
             
            } SystemIS;
         | 
| 472 475 |  | 
| 473 476 |  | 
| @@ -499,6 +502,8 @@ typedef struct BehaviorS_ { | |
| 499 502 | 
             
                Event* events;      /* The events of the behavior. */
         | 
| 500 503 | 
             
                Block block;        /* The block of the behavior. */
         | 
| 501 504 |  | 
| 505 | 
            +
                int enabled;        /* Tells if the behavior is enabled or not. */
         | 
| 506 | 
            +
             | 
| 502 507 | 
             
                int activated;      /* Tells if the behavior is activated or not. */
         | 
| 503 508 |  | 
| 504 509 | 
             
                int timed;          /* Tell if the behavior is timed or not:
         | 
| @@ -519,6 +524,8 @@ typedef struct CodeS_ { | |
| 519 524 | 
             
                Event* events;      /* The events of the behavior. */
         | 
| 520 525 | 
             
                void (*function)(); /* The function to execute for the code. */
         | 
| 521 526 |  | 
| 527 | 
            +
                int enabled;        /* Tells if the behavior is enabled or not. */
         | 
| 528 | 
            +
             | 
| 522 529 | 
             
                int activated;      /* Tells if the code is activated or not. */
         | 
| 523 530 | 
             
            } CodeS;
         | 
| 524 531 |  | 
| @@ -623,6 +630,16 @@ extern unsigned long long make_delay(int value, Unit unit); | |
| 623 630 | 
             
             * @param func function to applie on each signal. */
         | 
| 624 631 | 
             
            extern void each_all_signal(void (*func)(SignalI));
         | 
| 625 632 |  | 
| 633 | 
            +
             | 
| 634 | 
            +
            /** Configure a system instance.
         | 
| 635 | 
            +
             *  @param systemI the system instance to configure.
         | 
| 636 | 
            +
             *  @param idx the index of the target system. */
         | 
| 637 | 
            +
            extern void configure(SystemI systemI, int idx);
         | 
| 638 | 
            +
             | 
| 639 | 
            +
             | 
| 640 | 
            +
            /** Terminates the simulation. */
         | 
| 641 | 
            +
            extern void terminate();
         | 
| 642 | 
            +
             | 
| 626 643 | 
             
            /* Interface to the visualization engine. */
         | 
| 627 644 |  | 
| 628 645 | 
             
            typedef struct {
         | 
| @@ -701,6 +718,11 @@ extern void init_vcd_visualizer(char* name); | |
| 701 718 |  | 
| 702 719 | 
             
            /* The interface to the simulator core. */
         | 
| 703 720 |  | 
| 721 | 
            +
            /** Sets the enable status of the behaviors of a system type. 
         | 
| 722 | 
            +
             *  @param systemT the system type to process.
         | 
| 723 | 
            +
             *  @param status the enable status. */
         | 
| 724 | 
            +
            extern void set_enable_system(SystemT systemT, int status);
         | 
| 725 | 
            +
             | 
| 704 726 | 
             
            /** The simulation core function.
         | 
| 705 727 | 
             
             *  @param name the name of the simulation.
         | 
| 706 728 | 
             
             *  @param init_vizualizer the vizualizer engine initializer.
         |