rggen-systemverilog 0.19.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rggen/systemverilog/common.rb +2 -2
  3. data/lib/rggen/systemverilog/common/component.rb +2 -6
  4. data/lib/rggen/systemverilog/common/feature.rb +39 -26
  5. data/lib/rggen/systemverilog/common/utility/interface_port.rb +7 -3
  6. data/lib/rggen/systemverilog/common/utility/local_scope.rb +2 -2
  7. data/lib/rggen/systemverilog/common/utility/structure_definition.rb +1 -3
  8. data/lib/rggen/systemverilog/ral.rb +4 -1
  9. data/lib/rggen/systemverilog/ral/bit_field/type.rb +15 -10
  10. data/lib/rggen/systemverilog/ral/bit_field/type/rwe_rwl.rb +1 -11
  11. data/lib/rggen/systemverilog/ral/feature.rb +4 -4
  12. data/lib/rggen/systemverilog/ral/register/type.rb +10 -52
  13. data/lib/rggen/systemverilog/ral/register/type/default.erb +1 -1
  14. data/lib/rggen/systemverilog/ral/register/type/external.rb +6 -10
  15. data/lib/rggen/systemverilog/ral/register/type/indirect.erb +3 -3
  16. data/lib/rggen/systemverilog/ral/register/type/indirect.rb +5 -2
  17. data/lib/rggen/systemverilog/ral/register_block/sv_ral_model.erb +8 -0
  18. data/lib/rggen/systemverilog/ral/register_block/sv_ral_model.rb +36 -0
  19. data/lib/rggen/systemverilog/ral/register_block/sv_ral_package.rb +1 -32
  20. data/lib/rggen/systemverilog/ral/register_common.rb +46 -0
  21. data/lib/rggen/systemverilog/ral/register_file/sv_ral_model.erb +8 -0
  22. data/lib/rggen/systemverilog/ral/register_file/sv_ral_model.rb +57 -0
  23. data/lib/rggen/systemverilog/ral/setup.rb +2 -1
  24. data/lib/rggen/systemverilog/rtl.rb +4 -1
  25. data/lib/rggen/systemverilog/rtl/bit_field/sv_rtl_top.rb +34 -19
  26. data/lib/rggen/systemverilog/rtl/bit_field/type.rb +1 -5
  27. data/lib/rggen/systemverilog/rtl/bit_field/type/rc_w0c_w1c.rb +3 -3
  28. data/lib/rggen/systemverilog/rtl/bit_field/type/ro.rb +1 -1
  29. data/lib/rggen/systemverilog/rtl/bit_field/type/rs_w0s_w1s.rb +2 -2
  30. data/lib/rggen/systemverilog/rtl/bit_field/type/rw_w1_wo_wo1.rb +1 -1
  31. data/lib/rggen/systemverilog/rtl/bit_field/type/rwc.rb +2 -2
  32. data/lib/rggen/systemverilog/rtl/bit_field/type/rwe.rb +2 -2
  33. data/lib/rggen/systemverilog/rtl/bit_field/type/rwl.rb +2 -2
  34. data/lib/rggen/systemverilog/rtl/bit_field/type/rws.rb +3 -3
  35. data/lib/rggen/systemverilog/rtl/bit_field/type/w0crs_w1crs.rb +1 -1
  36. data/lib/rggen/systemverilog/rtl/bit_field/type/w0src_w1src.rb +1 -1
  37. data/lib/rggen/systemverilog/rtl/bit_field/type/w0trg_w1trg.rb +1 -1
  38. data/lib/rggen/systemverilog/rtl/feature.rb +12 -16
  39. data/lib/rggen/systemverilog/rtl/partial_sum.rb +29 -0
  40. data/lib/rggen/systemverilog/rtl/register/sv_rtl_top.rb +10 -47
  41. data/lib/rggen/systemverilog/rtl/register/type.rb +25 -1
  42. data/lib/rggen/systemverilog/rtl/register/type/external.rb +10 -10
  43. data/lib/rggen/systemverilog/rtl/register/type/indirect.rb +2 -2
  44. data/lib/rggen/systemverilog/rtl/register_block/protocol.rb +2 -2
  45. data/lib/rggen/systemverilog/rtl/register_block/protocol/apb.rb +13 -14
  46. data/lib/rggen/systemverilog/rtl/register_block/protocol/axi4lite.rb +23 -25
  47. data/lib/rggen/systemverilog/rtl/register_block/sv_rtl_top.rb +11 -10
  48. data/lib/rggen/systemverilog/rtl/register_file/sv_rtl_top.rb +30 -0
  49. data/lib/rggen/systemverilog/rtl/register_index.rb +112 -0
  50. data/lib/rggen/systemverilog/rtl/setup.rb +1 -0
  51. data/lib/rggen/systemverilog/version.rb +1 -1
  52. metadata +11 -4
  53. data/lib/rggen/systemverilog/ral/register_block/sv_ral_block_model.erb +0 -11
@@ -13,75 +13,73 @@ RgGen.define_list_item_feature(:register_block, :protocol, :axi4lite) do
13
13
 
14
14
  sv_rtl do
15
15
  build do
16
- parameter :register_block, :write_first, {
17
- name: 'WRITE_FIRST',
18
- data_type: :bit,
19
- default: 1
16
+ parameter :write_first, {
17
+ name: 'WRITE_FIRST', data_type: :bit, default: 1
20
18
  }
21
19
  if configuration.fold_sv_interface_port?
22
- interface_port :register_block, :axi4lite_if, {
20
+ interface_port :axi4lite_if, {
23
21
  name: 'axi4lite_if',
24
22
  interface_type: 'rggen_axi4lite_if', modport: 'slave'
25
23
  }
26
24
  else
27
- input :register_block, :awvalid, {
25
+ input :awvalid, {
28
26
  name: 'i_awvalid', data_type: :logic, width: 1
29
27
  }
30
- output :register_block, :awready, {
28
+ output :awready, {
31
29
  name: 'o_awready', data_type: :logic, width: 1
32
30
  }
33
- input :register_block, :awaddr, {
31
+ input :awaddr, {
34
32
  name: 'i_awaddr', data_type: :logic, width: address_width
35
33
  }
36
- input :register_block, :awprot, {
34
+ input :awprot, {
37
35
  name: 'i_awprot', data_type: :logic, width: 3
38
36
  }
39
- input :register_block, :wvalid, {
37
+ input :wvalid, {
40
38
  name: 'i_wvalid', data_type: :logic, width: 1
41
39
  }
42
- output :register_block, :wready, {
40
+ output :wready, {
43
41
  name: 'o_wready', data_type: :logic, width: 1
44
42
  }
45
- input :register_block, :wdata, {
43
+ input :wdata, {
46
44
  name: 'i_wdata', data_type: :logic, width: bus_width
47
45
  }
48
- input :register_block, :wstrb, {
46
+ input :wstrb, {
49
47
  name: 'i_wstrb', data_type: :logic, width: byte_width
50
48
  }
51
- output :register_block, :bvalid, {
49
+ output :bvalid, {
52
50
  name: 'o_bvalid', data_type: :logic, width: 1
53
51
  }
54
- input :register_block, :bready, {
52
+ input :bready, {
55
53
  name: 'i_bready', data_type: :logic, width: 1
56
54
  }
57
- output :register_block, :bresp, {
55
+ output :bresp, {
58
56
  name: 'o_bresp', data_type: :logic, width: 2
59
57
  }
60
- input :register_block, :arvalid, {
58
+ input :arvalid, {
61
59
  name: 'i_arvalid', data_type: :logic, width: 1
62
60
  }
63
- output :register_block, :arready, {
61
+ output :arready, {
64
62
  name: 'o_arready', data_type: :logic, width: 1
65
63
  }
66
- input :register_block, :araddr, {
64
+ input :araddr, {
67
65
  name: 'i_araddr', data_type: :logic, width: address_width
68
66
  }
69
- input :register_block, :arprot, {
67
+ input :arprot, {
70
68
  name: 'i_arprot', data_type: :logic, width: 3
71
69
  }
72
- output :register_block, :rvalid, {
70
+ output :rvalid, {
73
71
  name: 'o_rvalid', data_type: :logic, width: 1
74
72
  }
75
- input :register_block, :rready, {
73
+ input :rready, {
76
74
  name: 'i_rready', data_type: :logic, width: 1
77
75
  }
78
- output :register_block, :rdata, {
76
+ output :rdata, {
79
77
  name: 'o_rdata', data_type: :logic, width: bus_width
80
78
  }
81
- output :register_block, :rresp, {
79
+ output :rresp, {
82
80
  name: 'o_rresp', data_type: :logic, width: 2
83
81
  }
84
- interface :register_block, :axi4lite_if, {
82
+ interface :axi4lite_if, {
85
83
  name: 'axi4lite_if', interface_type: 'rggen_axi4lite_if',
86
84
  parameter_values: [address_width, bus_width],
87
85
  variables: [
@@ -5,17 +5,16 @@ RgGen.define_simple_feature(:register_block, :sv_rtl_top) do
5
5
  export :total_registers
6
6
 
7
7
  build do
8
- input :register_block, :clock, {
8
+ input :clock, {
9
9
  name: 'i_clk', data_type: :logic, width: 1
10
10
  }
11
- input :register_block, :reset, {
11
+ input :reset, {
12
12
  name: 'i_rst_n', data_type: :logic, width: 1
13
13
  }
14
- interface :register_block, :register_if, {
14
+ interface :register_if, {
15
15
  name: 'register_if', interface_type: 'rggen_register_if',
16
16
  parameter_values: [address_width, bus_width, value_width],
17
- array_size: [total_registers],
18
- variables: ['value']
17
+ array_size: [total_registers], variables: ['value']
19
18
  }
20
19
  end
21
20
 
@@ -24,7 +23,7 @@ RgGen.define_simple_feature(:register_block, :sv_rtl_top) do
24
23
  end
25
24
 
26
25
  def total_registers
27
- register_block.registers.map(&:count).sum
26
+ register_block.files_and_registers.map(&:count).sum
28
27
  end
29
28
 
30
29
  private
@@ -65,19 +64,21 @@ RgGen.define_simple_feature(:register_block, :sv_rtl_top) do
65
64
  end
66
65
 
67
66
  def parameters
68
- register_block.declarations(:register_block, :parameter)
67
+ register_block.declarations[:parameter]
69
68
  end
70
69
 
71
70
  def ports
72
- register_block.declarations(:register_block, :port)
71
+ register_block.declarations[:port]
73
72
  end
74
73
 
75
74
  def variables
76
- register_block.declarations(:register_block, :variable)
75
+ register_block.declarations[:variable]
77
76
  end
78
77
 
79
78
  def sv_module_body(code)
80
- register_block.generate_code(:register_block, :top_down, code)
79
+ { register_block: nil, register_file: 1 }.each do |kind, depth|
80
+ register_block.generate_code(code, kind, :top_down, depth)
81
+ end
81
82
  end
82
83
  end
83
84
  end
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_simple_feature(:register_file, :sv_rtl_top) do
4
+ sv_rtl do
5
+ include RgGen::SystemVerilog::RTL::RegisterIndex
6
+
7
+ main_code :register_file do
8
+ local_scope("g_#{register_file.name}") do |scope|
9
+ scope.top_scope top_scope?
10
+ scope.loop_size loop_size
11
+ scope.body(&method(:body_code))
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def top_scope?
18
+ register_file(:upper).nil?
19
+ end
20
+
21
+ def loop_size
22
+ (register_file.array? || nil) &&
23
+ local_loop_variables.zip(register_file.array_size).to_h
24
+ end
25
+
26
+ def body_code(code)
27
+ register_file.generate_code(code, :register_file, :top_down, 1)
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RgGen
4
+ module SystemVerilog
5
+ module RTL
6
+ module RegisterIndex
7
+ include PartialSum
8
+
9
+ EXPORTED_METHODS = [
10
+ :loop_variables, :local_loop_variables,
11
+ :local_index, :local_indices,
12
+ :index, :inside_roop?
13
+ ].freeze
14
+
15
+ def self.included(feature)
16
+ feature.module_eval do
17
+ EXPORTED_METHODS.each { |m| export m }
18
+
19
+ pre_build do
20
+ @base_index = files_and_registers.sum(&:count)
21
+ end
22
+ end
23
+ end
24
+
25
+ def loop_variables
26
+ (inside_roop? || nil) &&
27
+ [*upper_register_file&.loop_variables, *local_loop_variables]
28
+ end
29
+
30
+ def local_loop_variables
31
+ (component.array? || nil) &&
32
+ begin
33
+ start_depth = (upper_register_file&.loop_variables&.size || 0) + 1
34
+ Array.new(component.array_size.size) do |i|
35
+ create_identifier(loop_index(i + start_depth))
36
+ end
37
+ end
38
+ end
39
+
40
+ def local_index
41
+ (component.array? || nil) &&
42
+ local_index_coefficients
43
+ .zip(local_loop_variables)
44
+ .map { |operands| product(operands, false) }
45
+ .join('+')
46
+ end
47
+
48
+ def local_indices
49
+ [*upper_register_file&.local_indices, local_index]
50
+ end
51
+
52
+ def index(offset_or_offsets = nil)
53
+ operands = index_operands(offset_or_offsets)
54
+ partial_indices = partial_sums(operands)
55
+ if partial_indices.empty? || partial_indices.all?(&method(:integer?))
56
+ partial_indices.sum
57
+ else
58
+ partial_indices.join('+')
59
+ end
60
+ end
61
+
62
+ def inside_roop?
63
+ component.array? || upper_register_file&.inside_roop? || false
64
+ end
65
+
66
+ private
67
+
68
+ def upper_register_file
69
+ component.register_file
70
+ end
71
+
72
+ def local_index_coefficients
73
+ coefficients = []
74
+ component.array_size.reverse.inject(1) do |total, size|
75
+ coefficients.unshift(total)
76
+ total * size
77
+ end
78
+ coefficients
79
+ end
80
+
81
+ def index_operands(offset_or_offsets)
82
+ offsets = offset_or_offsets && Array(offset_or_offsets)
83
+ [
84
+ *upper_register_file&.index(offsets&.slice(0..-2)),
85
+ @base_index,
86
+ *local_register_index(offsets&.slice(-1))
87
+ ]
88
+ end
89
+
90
+ def local_register_index(offset)
91
+ (component.array? || nil) &&
92
+ begin
93
+ operands = [component.count(false), offset || local_index]
94
+ product(operands, true)
95
+ end
96
+ end
97
+
98
+ def product(operands, need_bracket)
99
+ if operands.all?(&method(:integer?))
100
+ operands.reduce(:*)
101
+ elsif operands.first == 1
102
+ operands.last
103
+ elsif need_bracket
104
+ "#{operands.first}*(#{operands.last})"
105
+ else
106
+ operands.join('*')
107
+ end
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -8,6 +8,7 @@ RgGen.setup :'rggen-sv-rtl', RgGen::SystemVerilog::RTL do |builder|
8
8
  ]
9
9
  builder.enable :register_block, [:sv_rtl_top, :protocol]
10
10
  builder.enable :register_block, :protocol, [:apb, :axi4lite]
11
+ builder.enable :register_file, [:sv_rtl_top]
11
12
  builder.enable :register, [:sv_rtl_top]
12
13
  builder.enable :bit_field, [:sv_rtl_top]
13
14
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RgGen
4
4
  module SystemVerilog
5
- VERSION = '0.19.0'
5
+ VERSION = '0.20.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rggen-systemverilog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taichi Ishitani
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-17 00:00:00.000000000 Z
11
+ date: 2020-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docile
@@ -93,8 +93,12 @@ files:
93
93
  - lib/rggen/systemverilog/ral/register/type/external.rb
94
94
  - lib/rggen/systemverilog/ral/register/type/indirect.erb
95
95
  - lib/rggen/systemverilog/ral/register/type/indirect.rb
96
- - lib/rggen/systemverilog/ral/register_block/sv_ral_block_model.erb
96
+ - lib/rggen/systemverilog/ral/register_block/sv_ral_model.erb
97
+ - lib/rggen/systemverilog/ral/register_block/sv_ral_model.rb
97
98
  - lib/rggen/systemverilog/ral/register_block/sv_ral_package.rb
99
+ - lib/rggen/systemverilog/ral/register_common.rb
100
+ - lib/rggen/systemverilog/ral/register_file/sv_ral_model.erb
101
+ - lib/rggen/systemverilog/ral/register_file/sv_ral_model.rb
98
102
  - lib/rggen/systemverilog/ral/setup.rb
99
103
  - lib/rggen/systemverilog/rtl.rb
100
104
  - lib/rggen/systemverilog/rtl/bit_field/sv_rtl_top.rb
@@ -128,6 +132,7 @@ files:
128
132
  - lib/rggen/systemverilog/rtl/feature.rb
129
133
  - lib/rggen/systemverilog/rtl/global/array_port_format.rb
130
134
  - lib/rggen/systemverilog/rtl/global/fold_sv_interface_port.rb
135
+ - lib/rggen/systemverilog/rtl/partial_sum.rb
131
136
  - lib/rggen/systemverilog/rtl/register/sv_rtl_top.rb
132
137
  - lib/rggen/systemverilog/rtl/register/type.rb
133
138
  - lib/rggen/systemverilog/rtl/register/type/default.erb
@@ -142,6 +147,8 @@ files:
142
147
  - lib/rggen/systemverilog/rtl/register_block/protocol/axi4lite.rb
143
148
  - lib/rggen/systemverilog/rtl/register_block/sv_rtl_macros.erb
144
149
  - lib/rggen/systemverilog/rtl/register_block/sv_rtl_top.rb
150
+ - lib/rggen/systemverilog/rtl/register_file/sv_rtl_top.rb
151
+ - lib/rggen/systemverilog/rtl/register_index.rb
145
152
  - lib/rggen/systemverilog/rtl/setup.rb
146
153
  - lib/rggen/systemverilog/version.rb
147
154
  homepage: https://github.com/rggen/rggen-systemverilog
@@ -170,5 +177,5 @@ requirements: []
170
177
  rubygems_version: 3.1.2
171
178
  signing_key:
172
179
  specification_version: 4
173
- summary: rggen-systemverilog-0.19.0
180
+ summary: rggen-systemverilog-0.20.0
174
181
  test_files: []
@@ -1,11 +0,0 @@
1
- function new(string name);
2
- super.new(name);
3
- endfunction
4
- function void build();
5
- <% reg_model_constructors.each do |constructor| %>
6
- <%= constructor %>
7
- <% end %>
8
- endfunction
9
- function uvm_reg_map create_default_map();
10
- return create_map("default_map", 0, <%= byte_width %>, UVM_LITTLE_ENDIAN, 1);
11
- endfunction