Module: HDLRuby::Verilog
- Defined in:
- lib/HDLRuby/hruby_verilog_name.rb
Overview
Program with inverse conversion last update 2019 01 29
Constant Summary collapse
- @@hdr2verilog =
This is sample. n = "abc_ABC_いろは" puts n
name = n.split("") {}
Instance Method Summary collapse
-
#name_to_verilog(name) ⇒ Object
Since it is possible to use $ and numbers other than the beginning of the character string, it is divided.
Instance Method Details
#name_to_verilog(name) ⇒ Object
Since it is possible to use $ and numbers other than the beginning of the character string, it is divided.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/HDLRuby/hruby_verilog_name.rb', line 14 def name_to_verilog(name) # name = name.to_s # # Convert special characters. # name = name.each_char.map do |c| # if c=~ /[a-z0-9]/ then # c # elsif c == "_" then # "__" # else # "_" + c.ord.to_s # end # end.join # # First character: only letter is possible. # unless name[0] =~ /[a-z_]/ then # name = "_" + name # end # return name name = name.to_s vname = @@hdr2verilog[name] unless vname then vname = "_v#{@@hdr2verilog.size}_#{name.split(/[^a-zA-Z_0-9]/)[-1]}" @@hdr2verilog[name] = vname end return vname end |