Class: InfElm
- Defined in:
- lib/tdl/elements/originclass.rb,
lib/tdl/elements/originclass.rb,
lib/tdl/class_hdl/hdl_redefine_opertor.rb
Direct Known Subclasses
Constant Summary collapse
- @@child =
[]
Instance Attribute Summary collapse
-
#dimension ⇒ Object
Returns the value of attribute dimension.
Attributes inherited from BaseElm
Class Method Summary collapse
- .inherited(subclass) ⇒ Object
-
.parse_ports(port_array = nil, rep, inf_name, up_stream_rep) ⇒ Object
def left_port_length() (“/* #@inf_name.” + @port.to_s + “ */ ”).length end.
- .same_name_socket(way, mix, inf_array, base_new_inf = nil, belong_to_module = nil) ⇒ Object
- .subclass ⇒ Object
Instance Method Summary collapse
- #[](a, b = false) ⇒ Object
- #dimension_num(e) ⇒ Object
- #draw ⇒ Object
-
#initialize(dimension: []) ⇒ InfElm
constructor
A new instance of InfElm.
- #inst_port ⇒ Object
- #port_length ⇒ Object
-
#signal(index = nil) ⇒ Object
重覆盖掉.
Methods inherited from BaseElm
#matrix, #name_copy, #path_refs, recfg_nc, #s
Methods included from TdlSpace::ExCreateTP
Constructor Details
#initialize(dimension: []) ⇒ InfElm
Returns a new instance of InfElm.
454 455 456 457 458 |
# File 'lib/tdl/elements/originclass.rb', line 454 def initialize(dimension:[]) @instance_draw_stack = [] @correlation_proc = "" @dimension = dimension end |
Instance Attribute Details
#dimension ⇒ Object
Returns the value of attribute dimension.
452 453 454 |
# File 'lib/tdl/elements/originclass.rb', line 452 def dimension @dimension end |
Class Method Details
.inherited(subclass) ⇒ Object
338 339 340 341 342 |
# File 'lib/tdl/elements/originclass.rb', line 338 def self.inherited(subclass) unless @@child.include? subclass @@child << subclass if subclass != CLKInfElm end end |
.parse_ports(port_array = nil, rep, inf_name, up_stream_rep) ⇒ Object
def left_port_length()
("/* #{@inf_name}." + @port.to_s + " */ ").length
end
def right_port_length
(".#{@name.to_s} ").length
end
def ex_port(left_align_len = 7,right_align_len = 7)
if left_align_len >= left_port_length
sub_left_len = left_align_len - left_port_length
else
sub_left_len = 0
end
if right_align_len >= right_port_length
sub_right_len = right_align_len - right_port_length
else
sub_right_len = 0
end
if @port
("/* #{@inf_name}." + @port.to_s + " "*sub_left_len + "*/ " + "."+@name.to_s + " "*sub_right_len)
end
end
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
# File 'lib/tdl/elements/originclass.rb', line 384 def self.parse_ports(port_array=nil,rep,inf_name,up_stream_rep) ports = [] del_ports = [] if port_array ports = port_array.map do |e| me = e.match(rep) if me del_ports << e h = Hash.new h[:type] = AxiLite h[:modport] = me["modport"].downcase if h[:modport]=="master" h[:way] = :to_down elsif h[:modport]=="slaver" h[:way] = :from_up else h[:way] = :mirror end h[:name] = me["name"].downcase h[:origin_name] = me["name"] h[:vector] = me["vector"] if me["vector"] if me["ud_name"] h[:up_down] = me["ud_name"] =~ up_stream_rep ? "up_stream" : "down_stream" else h[:up_down] = "nil" end ## port_left_len = 4+"#{inf_name}.#{h[:modport]}".length+6 port_right_len = 4+h[:origin_name].length h[:port_left_len] = port_left_len h[:port_right_len] = port_right_len h[:inst_ex_port] = lambda {|left,right| if left >= port_left_len ll = left - port_left_len else ll = 1 end if right >= port_right_len rl = right - port_right_len else rl = 1 end "/* #{inf_name}.#{h[:modport]}" + " "*ll+ "*/ " + ".#{h[:origin_name]}"+" "*rl + " (\#{align_signal(#{h[:name]},q_mark=false)})" } yield h ## h else nil end end end # puts port_array,"=====",del_ports return_ports = port_array - del_ports return return_ports end |
.same_name_socket(way, mix, inf_array, base_new_inf = nil, belong_to_module = nil) ⇒ Object
485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/tdl/elements/originclass.rb', line 485 def self.same_name_socket(way,mix,inf_array,base_new_inf=nil,belong_to_module=nil) # return inf_array unless inf_array.is_a? Array unless inf_array.is_a? Array return inf_array if inf_array.respond_to?(:dimension) && inf_array.dimension.any? inf_array = [inf_array] end return nil if inf_array.empty? return inf_array[0] if (inf_array.length == 1 && mix.eql?(true)) unless base_new_inf unless inf_array[0].is_a? String new_inf = inf_array[0].copy() else new_inf = self.string_copy_inf(inf_array[0],belong_to_module) end else new_inf = base_new_inf end unless mix # new_inf = DataInf_C.new(copy_inf:data_c_array[0],dimension:[data_c_array.length]) new_inf.dimension = [inf_array.length] inf_array.each_index do |index| # DataInf_C.data_c_direct(slaver:data_c_array[index],master:new_data_c.signal(index)) if way == :to_down inf_array[index].direct(slaver:new_inf.signal(index)) elsif way == :from_up self.direct(master:new_inf.signal(index),slaver:inf_array[index],belong_to_module:belong_to_module) elsif way == :mirror self.data_c_direct_mirror(master:new_inf.signal(index),slaver:inf_array[index],belong_to_module:belong_to_module) else raise TdlError.new("\nASSIGN Array to port that dont support SAME_NAME_SOCKET\n") end # puts new_inf.signal(index),inf_array[index].signal end else new_inf.<<(*inf_array) end # puts new_data_c.signal return new_inf end |
.subclass ⇒ Object
344 345 346 |
# File 'lib/tdl/elements/originclass.rb', line 344 def self.subclass @@child end |
Instance Method Details
#[](a, b = false) ⇒ Object
471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/tdl/elements/originclass.rb', line 471 def [](a,b=false) if a.is_a? ClassHDL::OpertorChain a.slaver = true end if b.is_a? ClassHDL::OpertorChain b.slaver = true end return signal if @dimension.empty? TdlSpace::ArrayChain.new(self,a,b) end |
#dimension_num(e) ⇒ Object
549 550 551 552 553 554 555 556 557 558 559 |
# File 'lib/tdl/elements/originclass.rb', line 549 def dimension_num(e) if e.is_a? Array return e.size else if e.respond_to?(:dimension) && e.dimension.any? return e.dimension.last else return 1 end end end |
#draw ⇒ Object
460 461 462 463 464 465 466 467 468 |
# File 'lib/tdl/elements/originclass.rb', line 460 def draw @instance_draw_stack.each do |each_inst| if each_inst.is_a? Proc @correlation_proc += each_inst.call elsif each_inst.is_a? String @correlation_proc += each_inst end end end |
#inst_port ⇒ Object
352 353 354 355 356 |
# File 'lib/tdl/elements/originclass.rb', line 352 def inst_port return ["#{@inf_name}." + @port.to_s, @name.to_s,array_inst] end |
#port_length ⇒ Object
348 349 350 |
# File 'lib/tdl/elements/originclass.rb', line 348 def port_length() ("#{@inf_name}." + @port.to_s + " ").length end |
#signal(index = nil) ⇒ Object
重覆盖掉
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'lib/tdl/elements/originclass.rb', line 528 def signal(index=nil) #array interface # large_name_len("") RedefOpertor.with_normal_operators do with_new_align(0) do if @dimension.any? && index # puts "#{index}" # puts index.is_a? String if index.is_a? String sq = "[#{index}]" NqString.new("#{@name}#{sq}") # NqString.new("#{@name}") else NqString.new("#{@name}[#{align_signal(index)}]") end else NqString.new("#{@name}") end end end end |