origen 0.7.34 → 0.7.35
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/version.rb +1 -1
- data/lib/origen/utility.rb +81 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44428e2ccbfc3cd21605f6181962b7962c52f098
|
4
|
+
data.tar.gz: 021be942ef879236ffb661e579ab8372014530f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dd377601afa928bb2ef2a5d1991f730ab373619112c389be8ebd6aefbaac88889a5d50a245a8eb05d2958a459caed54297e28851415ec9e7a4aa8c14f8841bb
|
7
|
+
data.tar.gz: 375b2f1b4ea20532f1488d4c782b4f61bd3202c2b3a2fa5005c0d93b7a26e744913df7e9c5dcb38a8b88dcd6e7102da879eec454133f9208e9ac2749c358846e
|
data/config/version.rb
CHANGED
data/lib/origen/utility.rb
CHANGED
@@ -7,5 +7,86 @@ module Origen
|
|
7
7
|
autoload :InputCapture, 'origen/utility/input_capture'
|
8
8
|
autoload :BlockArgs, 'origen/utility/block_args'
|
9
9
|
autoload :FileDiff, 'origen/utility/file_diff.rb'
|
10
|
+
|
11
|
+
# Creates a hex-like representation of a register read value, where bits within
|
12
|
+
# a nibble have different flags set the nibble will be expanded to bits
|
13
|
+
#
|
14
|
+
# read_hex(0x55) # => "0x55"
|
15
|
+
# read_hex(nil) # => "0xX"
|
16
|
+
#
|
17
|
+
# myreg.size # => 32
|
18
|
+
#
|
19
|
+
# read_hex(myreg) # => "0xXXXXXXXX"
|
20
|
+
# myreg[7..4].store
|
21
|
+
# read_hex(myreg) # => "0xXXXXXXSX"
|
22
|
+
# myreg[23..16].read
|
23
|
+
# read_hex(myreg) # => "0xXX00XXSX"
|
24
|
+
# myreg[23..16].read(0x12)
|
25
|
+
# read_hex(myreg) # => "0xXX12XXSX"
|
26
|
+
# reg[31..28].overlay("sub")
|
27
|
+
# reg[31..28].read
|
28
|
+
# read_hex(myreg) # => "0xVX12XXSX"
|
29
|
+
# reg[5].clear_flags
|
30
|
+
# read_hex(myreg) # => "0xVX12XX_ssxs_X"
|
31
|
+
# reg[21].overlay("sub")
|
32
|
+
# reg[18].store
|
33
|
+
# read_hex(myreg) # => "0xVX_00v1_0s10_XX_ssxs_X"
|
34
|
+
def self.read_hex(reg_or_val)
|
35
|
+
if reg_or_val.respond_to?(:data)
|
36
|
+
# Make a binary string of the data, like 010S0011SSSS0110
|
37
|
+
# (where S, X or V represent store, dont care or overlay)
|
38
|
+
regval = ''
|
39
|
+
reg_or_val.shift_out_left do |bit|
|
40
|
+
if bit.is_to_be_stored?
|
41
|
+
regval += 'S'
|
42
|
+
elsif bit.is_to_be_read?
|
43
|
+
if bit.has_overlay?
|
44
|
+
regval += 'V'
|
45
|
+
else
|
46
|
+
regval += bit.data.to_s
|
47
|
+
end
|
48
|
+
else
|
49
|
+
regval += 'X'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Now group by nibbles to give a hex-like representation, and where nibbles
|
54
|
+
# that are not all of the same type are expanded, e.g. -010s-3S6
|
55
|
+
outstr = ''
|
56
|
+
regex = '^'
|
57
|
+
(reg_or_val.size / 4).times { regex += '(....)' }
|
58
|
+
regex += '$'
|
59
|
+
Regexp.new(regex) =~ regval
|
60
|
+
|
61
|
+
nibbles = []
|
62
|
+
(reg_or_val.size / 4).times do |n| # now grouped by nibble
|
63
|
+
nibbles << Regexp.last_match[n + 1]
|
64
|
+
end
|
65
|
+
|
66
|
+
nibbles.each_with_index do |nibble, i|
|
67
|
+
# If contains any special chars...
|
68
|
+
if nibble =~ /[XSV]/
|
69
|
+
# If all the same...
|
70
|
+
if nibble[0] == nibble[1] && nibble[1] == nibble[2] && nibble[2] == nibble[3]
|
71
|
+
outstr += nibble[0, 1] # .to_s
|
72
|
+
# Otherwise present this nibble in 'binary' format
|
73
|
+
else
|
74
|
+
outstr += (i == 0 ? '' : '_') + nibble.downcase + (i == nibbles.size - 1 ? '' : '_')
|
75
|
+
end
|
76
|
+
# Otherwise if all 1s and 0s...
|
77
|
+
else
|
78
|
+
outstr += '%1X' % nibble.to_i(2)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
"0x#{outstr.gsub('__', '_')}"
|
82
|
+
|
83
|
+
else
|
84
|
+
if reg_or_val
|
85
|
+
reg_or_val.to_hex
|
86
|
+
else
|
87
|
+
'0xX'
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
10
91
|
end
|
11
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: origen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.35
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen McGinty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|