Class: GTKWave::TransactionFilter
- Inherits:
-
Object
- Object
- GTKWave::TransactionFilter
- Defined in:
- lib/libfst/tfp.rb
Overview
This is a base class which ease the creation of GTKWave Transaction Filter Process.
Such a process is called by GTKWave which feeds it some VCD on the standard input, the process decodes what it can from the input then writes some kind of VCD on the standard output, which is interpreted and displayed by GTKWave.
Instance Attribute Summary collapse
- #args ⇒ String readonly
- #data_start_tocken ⇒ Integer readonly
- #ivcd ⇒ VCD::Reader readonly
- #max_seqn ⇒ Integer readonly
- #max_time ⇒ Integer readonly
- #min_time ⇒ Integer readonly
- #name ⇒ String readonly
-
#signames ⇒ Array<String>
readonly
Signal names ordered according to "seqn".
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ TransactionFilter
constructor
A new instance of TransactionFilter.
- #read ⇒ Object
Constructor Details
#initialize ⇒ TransactionFilter
Returns a new instance of TransactionFilter.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/libfst/tfp.rb', line 37 def initialize @ivcd = VCD::Reader.new($stdin) exit 0 if $stdin.eof? @signames = [] @ivcd.comments.each do |cmnt| case cmnt when /^name (.+)$/ @name = $1 when /^data_start 0x(\h+)$/ @data_start_tocken = $1.to_i(16) when /^min_time (\d+)$/ @min_time = $1.to_i when /^max_time (\d+)$/ @max_time = $1.to_i when /^max_seqn (\d+)$/ @max_seqn = $1.to_i when /^seqn (\d+) (.+)$/ @signames[$1.to_i - 1] = $2 when /^args "(.*?)"$/ @args = $1.split(/\s*;\s*/).reject{|v| v.empty?} end end raise "Cannot find name comment" if @name.nil? raise "Cannot find data_start comment" if @data_start_tocken.nil? raise "Cannot find min_time comment" if @min_time.nil? raise "Cannot find max_time comment" if @max_time.nil? raise "Cannot find max_seqn comment" if @max_seqn.nil? raise "Cannot find args comment" if @args.nil? @ivcd.on_comment do |cmnt| m = cmnt.match(/^data_end 0x(\h+)$/) next if m.nil? @ivcd.stop_parsing if m[1].to_i(16) == @data_start_tocken end end |
Instance Attribute Details
#args ⇒ String (readonly)
34 35 36 |
# File 'lib/libfst/tfp.rb', line 34 def args @args end |
#data_start_tocken ⇒ Integer (readonly)
30 31 32 |
# File 'lib/libfst/tfp.rb', line 30 def data_start_tocken @data_start_tocken end |
#max_seqn ⇒ Integer (readonly)
33 34 35 |
# File 'lib/libfst/tfp.rb', line 33 def max_seqn @max_seqn end |
#max_time ⇒ Integer (readonly)
32 33 34 |
# File 'lib/libfst/tfp.rb', line 32 def max_time @max_time end |
#min_time ⇒ Integer (readonly)
31 32 33 |
# File 'lib/libfst/tfp.rb', line 31 def min_time @min_time end |
#name ⇒ String (readonly)
29 30 31 |
# File 'lib/libfst/tfp.rb', line 29 def name @name end |
#signames ⇒ Array<String> (readonly)
Returns Signal names ordered according to "seqn".
35 36 37 |
# File 'lib/libfst/tfp.rb', line 35 def signames @signames end |
Class Method Details
.run ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/libfst/tfp.rb', line 83 def self.run loop do read_all_input = false begin decoder = self.new decoder.read read_all_input = true decoder.write rescue => e $stderr.puts e.(highlight: true, order: :top) # $stderr.puts e.message unless read_all_input then #$stderr.puts "Flushing STDIN..." $stdin.each_line do |line| #$stderr.puts line break if line =~ /^\$comment\s+data_end\s+0x\h+\s+\$end\n$/ end #$stderr.puts "DONE" end $stdout.puts '$name DECODE_ERROR' $stdout.puts "#0 ?red?#{e.}" $stdout.puts '$finish' $stdout.flush end end end |
Instance Method Details
#read ⇒ Object
78 79 80 |
# File 'lib/libfst/tfp.rb', line 78 def read @ivcd.read end |