rggen 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -2
  3. data/lib/rggen.rb +0 -1
  4. data/lib/rggen/default.rb +7 -0
  5. data/lib/rggen/default_setup_file.rb +1 -2
  6. data/lib/rggen/version.rb +1 -3
  7. metadata +25 -81
  8. data/lib/rggen/built_in.rb +0 -57
  9. data/lib/rggen/built_in/bit_field/bit_assignment.rb +0 -114
  10. data/lib/rggen/built_in/bit_field/comment.rb +0 -18
  11. data/lib/rggen/built_in/bit_field/initial_value.rb +0 -75
  12. data/lib/rggen/built_in/bit_field/name.rb +0 -41
  13. data/lib/rggen/built_in/bit_field/reference.rb +0 -139
  14. data/lib/rggen/built_in/bit_field/sv_rtl_top.rb +0 -89
  15. data/lib/rggen/built_in/bit_field/type.rb +0 -245
  16. data/lib/rggen/built_in/bit_field/type/rc_w0c_w1c.erb +0 -15
  17. data/lib/rggen/built_in/bit_field/type/rc_w0c_w1c.rb +0 -59
  18. data/lib/rggen/built_in/bit_field/type/reserved.erb +0 -3
  19. data/lib/rggen/built_in/bit_field/type/reserved.rb +0 -16
  20. data/lib/rggen/built_in/bit_field/type/ro.erb +0 -6
  21. data/lib/rggen/built_in/bit_field/type/ro.rb +0 -31
  22. data/lib/rggen/built_in/bit_field/type/rof.erb +0 -6
  23. data/lib/rggen/built_in/bit_field/type/rof.rb +0 -17
  24. data/lib/rggen/built_in/bit_field/type/rs_w0s_w1s.erb +0 -13
  25. data/lib/rggen/built_in/bit_field/type/rs_w0s_w1s.rb +0 -46
  26. data/lib/rggen/built_in/bit_field/type/rw_wo.erb +0 -9
  27. data/lib/rggen/built_in/bit_field/type/rw_wo.rb +0 -30
  28. data/lib/rggen/built_in/bit_field/type/rwc_rwe_rwl.erb +0 -16
  29. data/lib/rggen/built_in/bit_field/type/rwc_rwe_rwl.rb +0 -92
  30. data/lib/rggen/built_in/bit_field/type/w0trg_w1trg.erb +0 -9
  31. data/lib/rggen/built_in/bit_field/type/w0trg_w1trg.rb +0 -29
  32. data/lib/rggen/built_in/global/address_width.rb +0 -34
  33. data/lib/rggen/built_in/global/array_port_format.rb +0 -19
  34. data/lib/rggen/built_in/global/bus_width.rb +0 -35
  35. data/lib/rggen/built_in/global/fold_sv_interface_port.rb +0 -24
  36. data/lib/rggen/built_in/register/markdown.erb +0 -11
  37. data/lib/rggen/built_in/register/markdown.rb +0 -26
  38. data/lib/rggen/built_in/register/name.rb +0 -36
  39. data/lib/rggen/built_in/register/offset_address.rb +0 -106
  40. data/lib/rggen/built_in/register/size.rb +0 -95
  41. data/lib/rggen/built_in/register/sv_rtl_top.rb +0 -82
  42. data/lib/rggen/built_in/register/type.rb +0 -344
  43. data/lib/rggen/built_in/register/type/default_sv_ral.erb +0 -8
  44. data/lib/rggen/built_in/register/type/default_sv_rtl.erb +0 -15
  45. data/lib/rggen/built_in/register/type/external.erb +0 -11
  46. data/lib/rggen/built_in/register/type/external.rb +0 -128
  47. data/lib/rggen/built_in/register/type/indirect.rb +0 -327
  48. data/lib/rggen/built_in/register/type/indirect_sv_ral.erb +0 -13
  49. data/lib/rggen/built_in/register/type/indirect_sv_rtl.erb +0 -17
  50. data/lib/rggen/built_in/register_block/byte_size.rb +0 -61
  51. data/lib/rggen/built_in/register_block/markdown.erb +0 -8
  52. data/lib/rggen/built_in/register_block/markdown.rb +0 -36
  53. data/lib/rggen/built_in/register_block/name.rb +0 -38
  54. data/lib/rggen/built_in/register_block/protocol.rb +0 -100
  55. data/lib/rggen/built_in/register_block/protocol/apb.erb +0 -10
  56. data/lib/rggen/built_in/register_block/protocol/apb.rb +0 -89
  57. data/lib/rggen/built_in/register_block/protocol/axi4lite.erb +0 -11
  58. data/lib/rggen/built_in/register_block/protocol/axi4lite.rb +0 -125
  59. data/lib/rggen/built_in/register_block/sv_ral_block_model.erb +0 -11
  60. data/lib/rggen/built_in/register_block/sv_ral_package.rb +0 -65
  61. data/lib/rggen/built_in/register_block/sv_rtl_macros.erb +0 -9
  62. data/lib/rggen/built_in/register_block/sv_rtl_top.rb +0 -86
  63. data/lib/rggen/built_in/version.rb +0 -7
  64. data/lib/rggen/setup/default.rb +0 -30
  65. data/sample/block_0.md +0 -155
  66. data/sample/block_0.rb +0 -90
  67. data/sample/block_0.sv +0 -678
  68. data/sample/block_0.xlsx +0 -0
  69. data/sample/block_0.yml +0 -99
  70. data/sample/block_0_ral_pkg.sv +0 -184
  71. data/sample/block_1.md +0 -39
  72. data/sample/block_1.rb +0 -22
  73. data/sample/block_1.sv +0 -136
  74. data/sample/block_1.xlsx +0 -0
  75. data/sample/block_1.yml +0 -26
  76. data/sample/block_1_ral_pkg.sv +0 -68
  77. data/sample/config.json +0 -5
  78. data/sample/config.yml +0 -3
@@ -1,13 +0,0 @@
1
- function new(string name);
2
- super.new(name, <%= register.width%>, 0);
3
- endfunction
4
- function void build();
5
- <% field_model_constructors.each do |constructor| %>
6
- <%= constructor %>
7
- <% end%>
8
- endfunction
9
- function void setup_index_fields();
10
- <% index_properties.each do |reg_name, field_name, value| %>
11
- setup_index_field("<%= reg_name %>", "<%= field_name%>", <%= value %>);
12
- <% end %>
13
- endfunction
@@ -1,17 +0,0 @@
1
- rggen_indirect_register #(
2
- .READABLE (<%= readable %>),
3
- .WRITABLE (<%= writable %>),
4
- .ADDRESS_WIDTH (<%= address_width %>),
5
- .OFFSET_ADDRESS (<%= offset_address %>),
6
- .BUS_WIDTH (<%= bus_width %>),
7
- .DATA_WIDTH (<%= width %>),
8
- .VALID_BITS (<%= valid_bits %>),
9
- .INDIRECT_INDEX_WIDTH (<%= index_width %>),
10
- .INDIRECT_INDEX_VALUE (<%= concat(index_values) %>)
11
- ) u_register (
12
- .i_clk (<%= register_block.clock %>),
13
- .i_rst_n (<%= register_block.reset %>),
14
- .register_if (<%= register_if %>),
15
- .i_indirect_index (<%= indirect_index %>),
16
- .bit_field_if (<%= bit_field_if %>)
17
- );
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_simple_feature(:register_block, :byte_size) do
4
- register_map do
5
- property :byte_size
6
- property :local_address_width
7
-
8
- build do |value|
9
- @byte_size =
10
- begin
11
- Integer(value)
12
- rescue ArgumentError, TypeError
13
- error "cannot convert #{value.inspect} into byte size"
14
- end
15
- @local_address_width = (@byte_size - 1).bit_length
16
- end
17
-
18
- verify(:feature) do
19
- error_condition { !byte_size }
20
- message { 'no byte size is given' }
21
- end
22
-
23
- verify(:feature) do
24
- error_condition { !byte_size.positive? }
25
- message do
26
- "non positive value is not allowed for byte size: #{byte_size}"
27
- end
28
- end
29
-
30
- verify(:feature) do
31
- error_condition { byte_size > max_byte_size }
32
- message do
33
- 'input byte size is greater than maximum byte size: ' \
34
- "input byte size #{byte_size} maximum byte size #{max_byte_size}"
35
- end
36
- end
37
-
38
- verify(:feature) do
39
- error_condition { (byte_size % byte_width).positive? }
40
- message do
41
- "byte size is not aligned with bus width(#{bus_width}): #{byte_size}"
42
- end
43
- end
44
-
45
- printable :byte_size
46
-
47
- private
48
-
49
- def max_byte_size
50
- 2**configuration.address_width
51
- end
52
-
53
- def byte_width
54
- configuration.byte_width
55
- end
56
-
57
- def bus_width
58
- configuration.bus_width
59
- end
60
- end
61
- end
@@ -1,8 +0,0 @@
1
- ## <%= register_block.name %>
2
-
3
- <% register_block.printables.each do |name, printable| %>
4
- * <%= name %>
5
- * <%= printable || 'NA' %>
6
- <% end %>
7
-
8
- <%= register_table %>
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_simple_feature(:register_block, :markdown) do
4
- markdown do
5
- export def anchor_id
6
- register_block.name
7
- end
8
-
9
- write_file '<%= register_block.name %>.md' do |file|
10
- file.body do |code|
11
- register_block.generate_code(:markdown, :top_down, code)
12
- end
13
- end
14
-
15
- main_code :markdown, from_template: true
16
-
17
- private
18
-
19
- def register_table
20
- table([:name, :offset_address], table_rows)
21
- end
22
-
23
- def table_rows
24
- register_block.registers
25
- .zip(register_block.registers.map(&:printables))
26
- .map { |register, printables| table_row(register, printables) }
27
- end
28
-
29
- def table_row(register, printables)
30
- [
31
- anchor_link(printables[:name], register.anchor_id),
32
- printables[:offset_address]
33
- ]
34
- end
35
- end
36
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_simple_feature(:register_block, :name) do
4
- register_map do
5
- property :name
6
-
7
- input_pattern variable_name
8
-
9
- build do |value|
10
- @name =
11
- if pattern_matched?
12
- match_data.to_s
13
- else
14
- error "illegal input value for register block name: #{value.inspect}"
15
- end
16
- end
17
-
18
- verify(:feature) do
19
- error_condition { !name }
20
- message { 'no register block name is given' }
21
- end
22
-
23
- verify(:feature) do
24
- error_condition { duplicated_name? }
25
- message { "duplicated register block name: #{name}" }
26
- end
27
-
28
- printable :name
29
-
30
- private
31
-
32
- def duplicated_name?
33
- register_map
34
- .register_blocks
35
- .any? { |register_block| register_block.name == name }
36
- end
37
- end
38
- end
@@ -1,100 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_feature(:register_block, :protocol) do
4
- shared_context do
5
- def feature_registry(registry = nil)
6
- @registry = registry if registry
7
- @registry
8
- end
9
-
10
- def available_protocols
11
- feature_registry
12
- .enabled_features(:protocol)
13
- .select(&method(:valid_protocol?))
14
- end
15
-
16
- def valid_protocol?(protocol)
17
- feature_registry.feature?(:protocol, protocol)
18
- end
19
- end
20
-
21
- configuration do
22
- base_feature do
23
- property :protocol
24
- build { |protocol| @protocol = protocol }
25
- printable :protocol
26
- end
27
-
28
- default_feature do
29
- end
30
-
31
- factory do
32
- convert_value do |value, position|
33
- protocol = find_protocol(value)
34
- protocol ||
35
- (error "unknown protocol: #{value.inspect}", position)
36
- end
37
-
38
- default_value do |position|
39
- default_protocol ||
40
- (error 'no protocols are available', position)
41
- end
42
-
43
- def select_feature(data)
44
- target_features[data.value]
45
- end
46
-
47
- private
48
-
49
- def find_protocol(value)
50
- available_protocols.find(&value.to_sym.method(:casecmp?))
51
- end
52
-
53
- def default_protocol
54
- available_protocols.first
55
- end
56
-
57
- def available_protocols
58
- @available_protocols ||= shared_context.available_protocols
59
- end
60
- end
61
- end
62
-
63
- sv_rtl do
64
- shared_context.feature_registry(registry)
65
-
66
- base_feature do
67
- private
68
-
69
- def address_width
70
- configuration.address_width
71
- end
72
-
73
- def bus_width
74
- configuration.bus_width
75
- end
76
-
77
- def byte_width
78
- configuration.byte_width
79
- end
80
-
81
- def local_address_width
82
- register_block.local_address_width
83
- end
84
-
85
- def total_registers
86
- register_block.total_registers
87
- end
88
-
89
- def register_if
90
- register_block.register_if
91
- end
92
- end
93
-
94
- factory do
95
- def select_feature(configuration, _register_block)
96
- target_features[configuration.protocol]
97
- end
98
- end
99
- end
100
- end
@@ -1,10 +0,0 @@
1
- rggen_apb_adapter #(
2
- .ADDRESS_WIDTH (<%= local_address_width %>),
3
- .BUS_WIDTH (<%= bus_width %>),
4
- .REGISTERS (<%= total_registers %>)
5
- ) u_adapter (
6
- .i_clk (<%= register_block.clock %>),
7
- .i_rst_n (<%= register_block.reset %>),
8
- .apb_if (<%= apb_if %>),
9
- .register_if (<%= register_if %>)
10
- );
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:register_block, :protocol, :apb) do
4
- configuration do
5
- verify(:component) do
6
- error_condition { configuration.bus_width > 32 }
7
- message do
8
- 'bus width over 32 bit is not supported: ' \
9
- "#{configuration.bus_width}"
10
- end
11
- end
12
-
13
- verify(:component) do
14
- error_condition { configuration.address_width > 32 }
15
- message do
16
- 'address width over 32 bit is not supported: ' \
17
- "#{configuration.address_width}"
18
- end
19
- end
20
- end
21
-
22
- sv_rtl do
23
- build do
24
- if configuration.fold_sv_interface_port?
25
- interface_port :register_block, :apb_if, {
26
- name: 'apb_if', interface_type: 'rggen_apb_if', modport: 'slave'
27
- }
28
- else
29
- input :register_block, :psel, {
30
- name: 'i_psel', data_type: :logic, width: 1
31
- }
32
- input :register_block, :penable, {
33
- name: 'i_penable', data_type: :logic, width: 1
34
- }
35
- input :register_block, :paddr, {
36
- name: 'i_paddr', data_type: :logic, width: address_width
37
- }
38
- input :register_block, :pprot, {
39
- name: 'i_pprot', data_type: :logic, width: 3
40
- }
41
- input :register_block, :pwrite, {
42
- name: 'i_pwrite', data_type: :logic, width: 1
43
- }
44
- input :register_block, :pstrb, {
45
- name: 'i_pstrb', data_type: :logic,
46
- width: byte_width
47
- }
48
- input :register_block, :pwdata, {
49
- name: 'i_pwdata', data_type: :logic, width: bus_width
50
- }
51
- output :register_block, :pready, {
52
- name: 'o_pready', data_type: :logic, width: 1
53
- }
54
- output :register_block, :prdata, {
55
- name: 'o_prdata', data_type: :logic, width: bus_width
56
- }
57
- output :register_block, :pslverr, {
58
- name: 'o_pslverr', data_type: :logic, width: 1
59
- }
60
- interface :register_block, :apb_if, {
61
- name: 'apb_if', interface_type: 'rggen_apb_if',
62
- parameter_values: [address_width, bus_width],
63
- variables: [
64
- 'psel', 'penable', 'paddr', 'pprot', 'pwrite', 'pstrb', 'pwdata',
65
- 'pready', 'prdata', 'pslverr'
66
- ]
67
- }
68
- end
69
- end
70
-
71
- main_code :register_block, from_template: true
72
- main_code :register_block do |code|
73
- unless configuration.fold_sv_interface_port?
74
- [
75
- [apb_if.psel, psel],
76
- [apb_if.penable, penable],
77
- [apb_if.paddr, paddr],
78
- [apb_if.pprot, pprot],
79
- [apb_if.pwrite, pwrite],
80
- [apb_if.pstrb, pstrb],
81
- [apb_if.pwdata, pwdata],
82
- [pready, apb_if.pready],
83
- [prdata, apb_if.prdata],
84
- [pslverr, apb_if.pslverr]
85
- ].map { |lhs, rhs| code << assign(lhs, rhs) << nl }
86
- end
87
- end
88
- end
89
- end
@@ -1,11 +0,0 @@
1
- rggen_axi4lite_adapter #(
2
- .ADDRESS_WIDTH (<%= local_address_width %>),
3
- .BUS_WIDTH (<%= bus_width %>),
4
- .REGISTERS (<%= total_registers %>),
5
- .WRITE_FIRST (<%= write_first %>)
6
- ) u_adapter (
7
- .i_clk (<%= register_block.clock %>),
8
- .i_rst_n (<%= register_block.reset %>),
9
- .axi4lite_if (<%= axi4lite_if %>),
10
- .register_if (<%= register_if %>)
11
- );
@@ -1,125 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RgGen.define_list_item_feature(:register_block, :protocol, :axi4lite) do
4
- configuration do
5
- verify(:component) do
6
- error_condition { ![32, 64].include?(configuration.bus_width) }
7
- message do
8
- 'bus width eigher 32 bit or 64 bit is only supported: ' \
9
- "#{configuration.bus_width}"
10
- end
11
- end
12
- end
13
-
14
- sv_rtl do
15
- build do
16
- parameter :register_block, :write_first, {
17
- name: 'WRITE_FIRST',
18
- data_type: :bit,
19
- default: 1
20
- }
21
- if configuration.fold_sv_interface_port?
22
- interface_port :register_block, :axi4lite_if, {
23
- name: 'axi4lite_if',
24
- interface_type: 'rggen_axi4lite_if', modport: 'slave'
25
- }
26
- else
27
- input :register_block, :awvalid, {
28
- name: 'i_awvalid', data_type: :logic, width: 1
29
- }
30
- output :register_block, :awready, {
31
- name: 'o_awready', data_type: :logic, width: 1
32
- }
33
- input :register_block, :awaddr, {
34
- name: 'i_awaddr', data_type: :logic, width: address_width
35
- }
36
- input :register_block, :awprot, {
37
- name: 'i_awprot', data_type: :logic, width: 3
38
- }
39
- input :register_block, :wvalid, {
40
- name: 'i_wvalid', data_type: :logic, width: 1
41
- }
42
- output :register_block, :wready, {
43
- name: 'o_wready', data_type: :logic, width: 1
44
- }
45
- input :register_block, :wdata, {
46
- name: 'i_wdata', data_type: :logic, width: bus_width
47
- }
48
- input :register_block, :wstrb, {
49
- name: 'i_wstrb', data_type: :logic, width: byte_width
50
- }
51
- output :register_block, :bvalid, {
52
- name: 'o_bvalid', data_type: :logic, width: 1
53
- }
54
- input :register_block, :bready, {
55
- name: 'i_bready', data_type: :logic, width: 1
56
- }
57
- output :register_block, :bresp, {
58
- name: 'o_bresp', data_type: :logic, width: 2
59
- }
60
- input :register_block, :arvalid, {
61
- name: 'i_arvalid', data_type: :logic, width: 1
62
- }
63
- output :register_block, :arready, {
64
- name: 'o_arready', data_type: :logic, width: 1
65
- }
66
- input :register_block, :araddr, {
67
- name: 'i_araddr', data_type: :logic, width: address_width
68
- }
69
- input :register_block, :arprot, {
70
- name: 'i_arprot', data_type: :logic, width: 3
71
- }
72
- output :register_block, :rvalid, {
73
- name: 'o_rvalid', data_type: :logic, width: 1
74
- }
75
- input :register_block, :rready, {
76
- name: 'i_rready', data_type: :logic, width: 1
77
- }
78
- output :register_block, :rdata, {
79
- name: 'o_rdata', data_type: :logic, width: bus_width
80
- }
81
- output :register_block, :rresp, {
82
- name: 'o_rresp', data_type: :logic, width: 2
83
- }
84
- interface :register_block, :axi4lite_if, {
85
- name: 'axi4lite_if', interface_type: 'rggen_axi4lite_if',
86
- parameter_values: [address_width, bus_width],
87
- variables: [
88
- 'awvalid', 'awready', 'awaddr', 'awprot',
89
- 'wvalid', 'wready', 'wdata', 'wstrb',
90
- 'bvalid', 'bready', 'bresp',
91
- 'arvalid', 'arready', 'araddr', 'arprot',
92
- 'rvalid', 'rready', 'rdata', 'rresp'
93
- ]
94
- }
95
- end
96
- end
97
-
98
- main_code :register_block, from_template: true
99
- main_code :register_block do |code|
100
- unless configuration.fold_sv_interface_port?
101
- [
102
- [axi4lite_if.awvalid, awvalid],
103
- [awready, axi4lite_if.awready],
104
- [axi4lite_if.awaddr, awaddr],
105
- [axi4lite_if.awprot, awprot],
106
- [axi4lite_if.wvalid, wvalid],
107
- [wready, axi4lite_if.wready],
108
- [axi4lite_if.wdata, wdata],
109
- [axi4lite_if.wstrb, wstrb],
110
- [bvalid, axi4lite_if.bvalid],
111
- [axi4lite_if.bready, bready],
112
- [bresp, axi4lite_if.bresp],
113
- [axi4lite_if.arvalid, arvalid],
114
- [arready, axi4lite_if.arready],
115
- [axi4lite_if.araddr, araddr],
116
- [axi4lite_if.arprot, arprot],
117
- [rvalid, axi4lite_if.rvalid],
118
- [axi4lite_if.rready, rready],
119
- [rdata, axi4lite_if.rdata],
120
- [rresp, axi4lite_if.rresp]
121
- ].each { |lhs, rhs| code << assign(lhs, rhs) << nl }
122
- end
123
- end
124
- end
125
- end