origen_verilog 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80796409ee6e42886de1605a432950942dfa194acd55fe3e25212fc2721889c2
4
- data.tar.gz: 802f08a8edc22ff0381b058d3fc004d1cc933fabbcf497457970ad3a6f961a9e
3
+ metadata.gz: d8a72a2d45842605da53d1676dc4b18d8b703e46dedb038141d32d3c5ef2d573
4
+ data.tar.gz: 7fefa5c0a725295dbb2b27487d622ad8d1864d578cac367cd5d511222a94d70a
5
5
  SHA512:
6
- metadata.gz: 60adeb9de92dcdeb2059687d7c055cdf03ab046ecea42d413060682704a4ddd30b44059e48b51d8125eaeac2e87c5b0ac8e4dd6c72ec4c22fde2b57208931afe
7
- data.tar.gz: 06c4bf52b809323520f85e68493e3f6dd95b2d9a7c5f28cc98fc54c76a1db5dbcaeb92449601e9a1849fbb6a13ea85dc1b1c48caa17f8014b8ae287ddaaa06e4
6
+ metadata.gz: 5005b17b7b837f3590427a5ca9c4c77334ea36a1b752b5e0e01a706ea610fc884af8916420a69dc46a5bb3ab9cc77dae88247dc4f6be94c29fe293b206a590a0
7
+ data.tar.gz: 234d1a5b66981caa859a59cf3531b5d050e62c3a8a7f6e71d51041ba44a98da6dc77147b4ffbe8426964b8b62ae7736888e87447231dfade9effc157802b367f
data/config/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module OrigenVerilog
2
2
  MAJOR = 0
3
- MINOR = 5
4
- BUGFIX = 2
3
+ MINOR = 6
4
+ BUGFIX = 0
5
5
  DEV = nil
6
6
 
7
7
  VERSION = [MAJOR, MINOR, BUGFIX].join(".") + (DEV ? ".pre#{DEV}" : '')
data/grammars/verilog.rb CHANGED
@@ -7374,7 +7374,11 @@ module OrigenVerilog
7374
7374
 
7375
7375
  module NetType0
7376
7376
  def to_ast
7377
- text_value
7377
+ if text_value == "wire real" || text_value == 'wreal'
7378
+ "real"
7379
+ else
7380
+ text_value
7381
+ end
7378
7382
  end
7379
7383
  end
7380
7384
 
@@ -7390,11 +7394,11 @@ module OrigenVerilog
7390
7394
  end
7391
7395
 
7392
7396
  i0 = index
7393
- if (match_len = has_terminal?("supply0", false, index))
7397
+ if (match_len = has_terminal?("wire real", false, index))
7394
7398
  r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7395
7399
  @index += match_len
7396
7400
  else
7397
- terminal_parse_failure('"supply0"')
7401
+ terminal_parse_failure('"wire real"')
7398
7402
  r1 = nil
7399
7403
  end
7400
7404
  if r1
@@ -7403,11 +7407,11 @@ module OrigenVerilog
7403
7407
  r0.extend(NetType0)
7404
7408
  r0.extend(NetType0)
7405
7409
  else
7406
- if (match_len = has_terminal?("supply1", false, index))
7410
+ if (match_len = has_terminal?("wreal", false, index))
7407
7411
  r2 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7408
7412
  @index += match_len
7409
7413
  else
7410
- terminal_parse_failure('"supply1"')
7414
+ terminal_parse_failure('"wreal"')
7411
7415
  r2 = nil
7412
7416
  end
7413
7417
  if r2
@@ -7416,11 +7420,11 @@ module OrigenVerilog
7416
7420
  r0.extend(NetType0)
7417
7421
  r0.extend(NetType0)
7418
7422
  else
7419
- if (match_len = has_terminal?("tri", false, index))
7423
+ if (match_len = has_terminal?("real", false, index))
7420
7424
  r3 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7421
7425
  @index += match_len
7422
7426
  else
7423
- terminal_parse_failure('"tri"')
7427
+ terminal_parse_failure('"real"')
7424
7428
  r3 = nil
7425
7429
  end
7426
7430
  if r3
@@ -7429,11 +7433,11 @@ module OrigenVerilog
7429
7433
  r0.extend(NetType0)
7430
7434
  r0.extend(NetType0)
7431
7435
  else
7432
- if (match_len = has_terminal?("triand", false, index))
7436
+ if (match_len = has_terminal?("supply0", false, index))
7433
7437
  r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7434
7438
  @index += match_len
7435
7439
  else
7436
- terminal_parse_failure('"triand"')
7440
+ terminal_parse_failure('"supply0"')
7437
7441
  r4 = nil
7438
7442
  end
7439
7443
  if r4
@@ -7442,11 +7446,11 @@ module OrigenVerilog
7442
7446
  r0.extend(NetType0)
7443
7447
  r0.extend(NetType0)
7444
7448
  else
7445
- if (match_len = has_terminal?("trior", false, index))
7449
+ if (match_len = has_terminal?("supply1", false, index))
7446
7450
  r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7447
7451
  @index += match_len
7448
7452
  else
7449
- terminal_parse_failure('"trior"')
7453
+ terminal_parse_failure('"supply1"')
7450
7454
  r5 = nil
7451
7455
  end
7452
7456
  if r5
@@ -7455,11 +7459,11 @@ module OrigenVerilog
7455
7459
  r0.extend(NetType0)
7456
7460
  r0.extend(NetType0)
7457
7461
  else
7458
- if (match_len = has_terminal?("tri0", false, index))
7462
+ if (match_len = has_terminal?("tri", false, index))
7459
7463
  r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7460
7464
  @index += match_len
7461
7465
  else
7462
- terminal_parse_failure('"tri0"')
7466
+ terminal_parse_failure('"tri"')
7463
7467
  r6 = nil
7464
7468
  end
7465
7469
  if r6
@@ -7468,11 +7472,11 @@ module OrigenVerilog
7468
7472
  r0.extend(NetType0)
7469
7473
  r0.extend(NetType0)
7470
7474
  else
7471
- if (match_len = has_terminal?("tri1", false, index))
7475
+ if (match_len = has_terminal?("triand", false, index))
7472
7476
  r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7473
7477
  @index += match_len
7474
7478
  else
7475
- terminal_parse_failure('"tri1"')
7479
+ terminal_parse_failure('"triand"')
7476
7480
  r7 = nil
7477
7481
  end
7478
7482
  if r7
@@ -7481,11 +7485,11 @@ module OrigenVerilog
7481
7485
  r0.extend(NetType0)
7482
7486
  r0.extend(NetType0)
7483
7487
  else
7484
- if (match_len = has_terminal?("uwire", false, index))
7488
+ if (match_len = has_terminal?("trior", false, index))
7485
7489
  r8 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7486
7490
  @index += match_len
7487
7491
  else
7488
- terminal_parse_failure('"uwire"')
7492
+ terminal_parse_failure('"trior"')
7489
7493
  r8 = nil
7490
7494
  end
7491
7495
  if r8
@@ -7494,11 +7498,11 @@ module OrigenVerilog
7494
7498
  r0.extend(NetType0)
7495
7499
  r0.extend(NetType0)
7496
7500
  else
7497
- if (match_len = has_terminal?("wire", false, index))
7501
+ if (match_len = has_terminal?("tri0", false, index))
7498
7502
  r9 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7499
7503
  @index += match_len
7500
7504
  else
7501
- terminal_parse_failure('"wire"')
7505
+ terminal_parse_failure('"tri0"')
7502
7506
  r9 = nil
7503
7507
  end
7504
7508
  if r9
@@ -7507,11 +7511,11 @@ module OrigenVerilog
7507
7511
  r0.extend(NetType0)
7508
7512
  r0.extend(NetType0)
7509
7513
  else
7510
- if (match_len = has_terminal?("wand", false, index))
7514
+ if (match_len = has_terminal?("tri1", false, index))
7511
7515
  r10 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7512
7516
  @index += match_len
7513
7517
  else
7514
- terminal_parse_failure('"wand"')
7518
+ terminal_parse_failure('"tri1"')
7515
7519
  r10 = nil
7516
7520
  end
7517
7521
  if r10
@@ -7520,11 +7524,11 @@ module OrigenVerilog
7520
7524
  r0.extend(NetType0)
7521
7525
  r0.extend(NetType0)
7522
7526
  else
7523
- if (match_len = has_terminal?("wor", false, index))
7527
+ if (match_len = has_terminal?("uwire", false, index))
7524
7528
  r11 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7525
7529
  @index += match_len
7526
7530
  else
7527
- terminal_parse_failure('"wor"')
7531
+ terminal_parse_failure('"uwire"')
7528
7532
  r11 = nil
7529
7533
  end
7530
7534
  if r11
@@ -7533,8 +7537,50 @@ module OrigenVerilog
7533
7537
  r0.extend(NetType0)
7534
7538
  r0.extend(NetType0)
7535
7539
  else
7536
- @index = i0
7537
- r0 = nil
7540
+ if (match_len = has_terminal?("wire", false, index))
7541
+ r12 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7542
+ @index += match_len
7543
+ else
7544
+ terminal_parse_failure('"wire"')
7545
+ r12 = nil
7546
+ end
7547
+ if r12
7548
+ r12 = SyntaxNode.new(input, (index-1)...index) if r12 == true
7549
+ r0 = r12
7550
+ r0.extend(NetType0)
7551
+ r0.extend(NetType0)
7552
+ else
7553
+ if (match_len = has_terminal?("wand", false, index))
7554
+ r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7555
+ @index += match_len
7556
+ else
7557
+ terminal_parse_failure('"wand"')
7558
+ r13 = nil
7559
+ end
7560
+ if r13
7561
+ r13 = SyntaxNode.new(input, (index-1)...index) if r13 == true
7562
+ r0 = r13
7563
+ r0.extend(NetType0)
7564
+ r0.extend(NetType0)
7565
+ else
7566
+ if (match_len = has_terminal?("wor", false, index))
7567
+ r14 = instantiate_node(SyntaxNode,input, index...(index + match_len))
7568
+ @index += match_len
7569
+ else
7570
+ terminal_parse_failure('"wor"')
7571
+ r14 = nil
7572
+ end
7573
+ if r14
7574
+ r14 = SyntaxNode.new(input, (index-1)...index) if r14 == true
7575
+ r0 = r14
7576
+ r0.extend(NetType0)
7577
+ r0.extend(NetType0)
7578
+ else
7579
+ @index = i0
7580
+ r0 = nil
7581
+ end
7582
+ end
7583
+ end
7538
7584
  end
7539
7585
  end
7540
7586
  end
@@ -7,26 +7,31 @@ module OrigenVerilog
7
7
  def initialize(options = {})
8
8
  @name = options[:ast].to_a[0]
9
9
 
10
- options[:ast].pins.each do |node|
11
- node = node.evaluate # Resolve any functions in the ranges
12
- if node.type == :input_declaration
13
- direction = :input
14
- elsif node.type == :ouput_declaration
15
- direction = :output
16
- else
17
- direction = :io
18
- end
19
- if r = node.find(:range)
20
- size = r.to_a[0] - r.to_a[1] + 1
21
- offset = r.to_a[1]
22
- else
23
- size = 1
24
- offset = nil
25
- end
26
- n = node.to_a.dup
27
- while n.last.is_a?(String)
28
- add_pin n.pop.to_sym, direction: direction, size: size, offset: offset
29
- end
10
+ options[:ast].pins(digital: true).each { |n| _add_pin_(n, :digital) }
11
+ options[:ast].pins(analog: true).each { |n| _add_pin_(n, :analog) }
12
+ end
13
+
14
+ private
15
+
16
+ def _add_pin_(node, type)
17
+ node = node.evaluate # Resolve any functions in the ranges
18
+ if node.type == :input_declaration
19
+ direction = :input
20
+ elsif node.type == :ouput_declaration
21
+ direction = :output
22
+ else
23
+ direction = :io
24
+ end
25
+ if r = node.find(:range)
26
+ size = r.to_a[0] - r.to_a[1] + 1
27
+ offset = r.to_a[1]
28
+ else
29
+ size = 1
30
+ offset = nil
31
+ end
32
+ n = node.to_a.dup
33
+ while n.last.is_a?(String)
34
+ add_pin n.pop.to_sym, direction: direction, size: size, offset: offset, type: type
30
35
  end
31
36
  end
32
37
  end
@@ -50,9 +50,39 @@ module OrigenVerilog
50
50
  end
51
51
  end
52
52
 
53
- # Returns an array containing all input, output and inout AST nodes
54
- def pins
55
- find_all(:input_declaration, :output_declaration, :inout_declaration)
53
+ # Returns an array containing all input, output and inout AST nodes.
54
+ # Supply analog: true in the options to return only those pins defined as a
55
+ # real/wreal type and digital: true to return only the pins without a real/wreal
56
+ # type.
57
+ def pins(options = {})
58
+ pins = find_all(:input_declaration, :output_declaration, :inout_declaration)
59
+ if options[:analog] || options[:digital]
60
+ wreals = self.wreals.map { |n| n.to_a.last }
61
+ subset = []
62
+ pins.each do |pin|
63
+ attrs = pin.to_a
64
+ if attrs.include?('real') || wreals.include?(attrs.last)
65
+ subset << pin if options[:analog]
66
+ else
67
+ subset << pin if options[:digital]
68
+ end
69
+ end
70
+ subset
71
+ else
72
+ pins
73
+ end
74
+ end
75
+
76
+ # Returns an array containing all wire real/wreal declaration AST nodes, which have
77
+ # been declared as part of a module definition, returning something like this:
78
+ # [
79
+ # s(:net_declaration, "real", "vdd")),
80
+ # s(:net_declaration, "real", "vddf")),
81
+ # ]
82
+ def wreals
83
+ find_all(:non_port_module_item)
84
+ .map { |item| item.find(:net_declaration) }
85
+ .select { |net| net.to_a.include?('real') }
56
86
  end
57
87
 
58
88
  # Evaluates all functions and turns numbers into Ruby literals
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: origen_verilog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen McGinty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-20 00:00:00.000000000 Z
11
+ date: 2019-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: origen
@@ -59,7 +59,6 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
- - bin/fix_my_workspace
63
62
  - config/application.rb
64
63
  - config/boot.rb
65
64
  - config/commands.rb
data/bin/fix_my_workspace DELETED
@@ -1,100 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $VERBOSE = nil # Don't care about world writable dir warnings and the like
3
-
4
- if $_fix_my_workspace_version_check
5
- $_fix_my_workspace_version = '0.7.0'
6
- else
7
- if File.exist?(File.expand_path('../../lib/origen.rb', __FILE__))
8
- # If this script is being run from within an origen-core workspace, use that Origen-core,
9
- # not the system-installed origen-core version.
10
- $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
11
- require 'origen'
12
- else
13
- # Use system-installed Origen (the gem in system Ruby)
14
- require 'origen'
15
- end
16
-
17
- if !Origen.site_config.gem_manage_bundler
18
- puts 'Sorry but you have opted to manage Bundler yourself via your Origen site config, and this means'
19
- puts 'that I cannot make certain assumptions about how your workspace is configured.'
20
- puts 'You will need to either resolve this problem yourself, or else change the value of'
21
- puts 'gem_mange_bundler to true.'
22
- puts 'See here for more details on how to do that: http://origen-sdk.org/origen/guides/starting/company/'
23
-
24
- else
25
- ENV['BUNDLE_GEMFILE'] = File.join(Origen.root, 'Gemfile')
26
- ENV['BUNDLE_PATH'] = File.expand_path(Origen.site_config.gem_install_dir)
27
- ENV['BUNDLE_BIN'] = File.join(Origen.root, 'lbin')
28
-
29
- # Force copy system gems to local gems
30
- if Origen.site_config.gem_use_from_system
31
- local_gem_dir = "#{ENV['BUNDLE_PATH']}/ruby/#{Pathname.new(Gem.dir).basename}"
32
- gem_dir = Pathname.new(Gem.dir)
33
-
34
- Origen.site_config.gem_use_from_system.each do |gem, version|
35
- begin
36
- # This will raise an error if the system doesn't have this gem installed, that
37
- # will be rescued below
38
- spec = Gem::Specification.find_by_name(gem, version)
39
-
40
- local_dir = File.join(local_gem_dir, Pathname.new(spec.gem_dir).relative_path_from(gem_dir))
41
- FileUtils.mkdir_p local_dir
42
- FileUtils.cp_r("#{spec.gem_dir}/.", local_dir)
43
-
44
- local_file = Pathname.new(File.join(local_gem_dir, Pathname.new(spec.cache_file).relative_path_from(gem_dir)))
45
- FileUtils.mkdir_p local_file.dirname
46
- FileUtils.cp(spec.cache_file, local_file)
47
-
48
- if spec.extension_dir && File.exist?(spec.extension_dir)
49
- local_dir = File.join(local_gem_dir, Pathname.new(spec.extension_dir).relative_path_from(gem_dir))
50
- FileUtils.mkdir_p local_dir
51
- FileUtils.cp_r("#{spec.extension_dir}/.", local_dir)
52
- end
53
-
54
- local_file = Pathname.new(File.join(local_gem_dir, Pathname.new(spec.spec_file).relative_path_from(gem_dir)))
55
- FileUtils.mkdir_p local_file.dirname
56
- FileUtils.cp(spec.spec_file, local_file)
57
-
58
- rescue Gem::LoadError
59
- # This just means that one of the gems that should be copied from the system
60
- # was not actually installed in the system, so nothing we can do about that here
61
- end
62
- end
63
- end
64
-
65
- # Delete lbin
66
- FileUtils.rm_rf(ENV['BUNDLE_BIN']) if File.exist?(ENV['BUNDLE_BIN'])
67
-
68
- # Run bundler with correct switches
69
- cmd = "bundle install --gemfile #{ENV['BUNDLE_GEMFILE']} --binstubs #{ENV['BUNDLE_BIN']} --path #{ENV['BUNDLE_PATH']}"
70
- `chmod o-w #{Origen.root}` # Stops some annoying world writable warnings during install
71
- `chmod o-w #{Origen.root}/bin` if File.exist?("#{Origen.root}/bin")
72
- `chmod o-w #{Origen.root}/.bin` if File.exist?("#{Origen.root}/.bin")
73
-
74
- # Try again, this time updating the bundle
75
- if system(cmd)
76
- fixed = true
77
- elsif system 'bundle update'
78
- fixed = true
79
- end
80
-
81
- if File.exist?(ENV['BUNDLE_BIN'])
82
- `chmod o-w #{ENV['BUNDLE_BIN']}`
83
-
84
- # Make .bat versions of all executables, Bundler should really be doing this when running
85
- # on windows
86
- if Origen.os.windows?
87
- Dir.glob("#{ENV['BUNDLE_BIN']}/*").each do |bin|
88
- unless bin =~ /.bat$/
89
- bat = "#{bin}.bat"
90
- unless File.exist?(bat)
91
- File.open(bat, 'w') { |f| f.write('@"ruby.exe" "%~dpn0" %*') }
92
- end
93
- end
94
- end
95
- end
96
- end
97
-
98
- system 'origen -v' if fixed
99
- end
100
- end