rggen-systemverilog 0.33.1 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +2 -2
- data/lib/rggen/systemverilog/common/feature.rb +20 -13
- data/lib/rggen/systemverilog/common/utility/data_object.rb +1 -1
- data/lib/rggen/systemverilog/common/utility/structure_definition.rb +2 -2
- data/lib/rggen/systemverilog/common/utility.rb +2 -2
- data/lib/rggen/systemverilog/ral/bit_field/type.rb +18 -10
- data/lib/rggen/systemverilog/ral/feature.rb +4 -6
- data/lib/rggen/systemverilog/ral/register/type.rb +3 -3
- data/lib/rggen/systemverilog/ral/register_block/sv_ral_model.rb +1 -1
- data/lib/rggen/systemverilog/ral/register_common.rb +1 -1
- data/lib/rggen/systemverilog/ral/register_file/sv_ral_model.rb +4 -4
- data/lib/rggen/systemverilog/ral.rb +5 -0
- data/lib/rggen/systemverilog/register_map/keyword_checker.rb +62 -0
- data/lib/rggen/systemverilog/register_map/name.rb +9 -0
- data/lib/rggen/systemverilog/rtl/bit_field/sv_rtl_top.rb +15 -23
- data/lib/rggen/systemverilog/rtl/bit_field/type/custom.rb +8 -16
- data/lib/rggen/systemverilog/rtl/bit_field/type/rc_w0c_w1c_wc_woc.rb +3 -6
- data/lib/rggen/systemverilog/rtl/bit_field/type/ro_rotrg.rb +2 -4
- data/lib/rggen/systemverilog/rtl/bit_field/type/rohw.rb +3 -6
- data/lib/rggen/systemverilog/rtl/bit_field/type/row0trg_row1trg.rb +2 -4
- data/lib/rggen/systemverilog/rtl/bit_field/type/rowo_rowotrg.rb +4 -8
- data/lib/rggen/systemverilog/rtl/bit_field/type/rs_w0s_w1s_ws_wos.rb +2 -4
- data/lib/rggen/systemverilog/rtl/bit_field/type/rw_rwtrg_w1.rb +3 -6
- data/lib/rggen/systemverilog/rtl/bit_field/type/rwc.rb +2 -4
- data/lib/rggen/systemverilog/rtl/bit_field/type/rwe_rwl.rb +2 -4
- data/lib/rggen/systemverilog/rtl/bit_field/type/rwhw.rb +3 -6
- data/lib/rggen/systemverilog/rtl/bit_field/type/rws.rb +2 -4
- data/lib/rggen/systemverilog/rtl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc.rb +1 -2
- data/lib/rggen/systemverilog/rtl/bit_field/type/w0t_w1t.rb +1 -2
- data/lib/rggen/systemverilog/rtl/bit_field/type/w0trg_w1trg.rb +1 -2
- data/lib/rggen/systemverilog/rtl/bit_field/type/wo_wo1_wotrg.rb +2 -4
- data/lib/rggen/systemverilog/rtl/bit_field/type/wrc_wrs.rb +1 -2
- data/lib/rggen/systemverilog/rtl/bit_field/type.rb +2 -6
- data/lib/rggen/systemverilog/rtl/bit_field_index.rb +18 -9
- data/lib/rggen/systemverilog/rtl/feature.rb +11 -15
- data/lib/rggen/systemverilog/rtl/register/type/external.rb +1 -1
- data/lib/rggen/systemverilog/rtl/register_block/protocol/apb.rb +11 -5
- data/lib/rggen/systemverilog/rtl/register_block/protocol/avalon.erb +17 -0
- data/lib/rggen/systemverilog/rtl/register_block/protocol/avalon.rb +37 -0
- data/lib/rggen/systemverilog/rtl/register_block/protocol/axi4lite.rb +6 -3
- data/lib/rggen/systemverilog/rtl/register_block/protocol/native.erb +19 -0
- data/lib/rggen/systemverilog/rtl/register_block/protocol/native.rb +19 -0
- data/lib/rggen/systemverilog/rtl/register_block/protocol/wishbone.rb +7 -4
- data/lib/rggen/systemverilog/rtl/register_block/protocol.rb +45 -26
- data/lib/rggen/systemverilog/rtl/register_block/sv_rtl_top.rb +1 -1
- data/lib/rggen/systemverilog/rtl/register_index.rb +8 -8
- data/lib/rggen/systemverilog/rtl/register_type.rb +1 -1
- data/lib/rggen/systemverilog/rtl.rb +7 -1
- data/lib/rggen/systemverilog/rtl_package/feature.rb +3 -3
- data/lib/rggen/systemverilog/rtl_package/register/sv_rtl_package.rb +2 -2
- data/lib/rggen/systemverilog/version.rb +1 -1
- metadata +11 -9
- data/lib/rggen/systemverilog/rtl/global/array_port_format.rb +0 -21
@@ -4,17 +4,14 @@ RgGen.define_list_item_feature(:bit_field, :type, [:rw, :rwtrg, :w1]) do
|
|
4
4
|
sv_rtl do
|
5
5
|
build do
|
6
6
|
output :value_out, {
|
7
|
-
name: "o_#{full_name}", width:
|
8
|
-
array_size: array_size, array_format: array_port_format
|
7
|
+
name: "o_#{full_name}", width:, array_size:
|
9
8
|
}
|
10
9
|
if rwtrg?
|
11
10
|
output :write_trigger, {
|
12
|
-
name: "o_#{full_name}_write_trigger", width: 1,
|
13
|
-
array_size: array_size, array_format: array_port_format
|
11
|
+
name: "o_#{full_name}_write_trigger", width: 1, array_size:
|
14
12
|
}
|
15
13
|
output :read_trigger, {
|
16
|
-
name: "o_#{full_name}_read_trigger", width: 1,
|
17
|
-
array_size: array_size, array_format: array_port_format
|
14
|
+
name: "o_#{full_name}_read_trigger", width: 1, array_size:
|
18
15
|
}
|
19
16
|
end
|
20
17
|
end
|
@@ -5,13 +5,11 @@ RgGen.define_list_item_feature(:bit_field, :type, :rwc) do
|
|
5
5
|
build do
|
6
6
|
unless bit_field.reference?
|
7
7
|
input :clear, {
|
8
|
-
name: "i_#{full_name}_clear", width: 1,
|
9
|
-
array_size: array_size, array_format: array_port_format
|
8
|
+
name: "i_#{full_name}_clear", width: 1, array_size:
|
10
9
|
}
|
11
10
|
end
|
12
11
|
output :value_out, {
|
13
|
-
name: "o_#{full_name}", width:
|
14
|
-
array_size: array_size, array_format: array_port_format
|
12
|
+
name: "o_#{full_name}", width:, array_size:
|
15
13
|
}
|
16
14
|
end
|
17
15
|
|
@@ -5,13 +5,11 @@ RgGen.define_list_item_feature(:bit_field, :type, [:rwe, :rwl]) do
|
|
5
5
|
build do
|
6
6
|
unless bit_field.reference?
|
7
7
|
input :control, {
|
8
|
-
name: "i_#{full_name}_#{enable_or_lock}", width: 1,
|
9
|
-
array_size: array_size, array_format: array_port_format
|
8
|
+
name: "i_#{full_name}_#{enable_or_lock}", width: 1, array_size:
|
10
9
|
}
|
11
10
|
end
|
12
11
|
output :value_out, {
|
13
|
-
name: "o_#{full_name}", width:
|
14
|
-
array_size: array_size, array_format: array_port_format
|
12
|
+
name: "o_#{full_name}", width:, array_size:
|
15
13
|
}
|
16
14
|
end
|
17
15
|
|
@@ -5,17 +5,14 @@ RgGen.define_list_item_feature(:bit_field, :type, :rwhw) do
|
|
5
5
|
build do
|
6
6
|
unless bit_field.reference?
|
7
7
|
input :valid, {
|
8
|
-
name: "i_#{full_name}_valid", width: 1,
|
9
|
-
array_size: array_size, array_format: array_port_format
|
8
|
+
name: "i_#{full_name}_valid", width: 1, array_size:
|
10
9
|
}
|
11
10
|
end
|
12
11
|
input :value_in, {
|
13
|
-
name: "i_#{full_name}", width:
|
14
|
-
array_size: array_size, array_format: array_port_format
|
12
|
+
name: "i_#{full_name}", width:, array_size:
|
15
13
|
}
|
16
14
|
output :value_out, {
|
17
|
-
name: "o_#{full_name}", width:
|
18
|
-
array_size: array_size, array_format: array_port_format
|
15
|
+
name: "o_#{full_name}", width:, array_size:
|
19
16
|
}
|
20
17
|
end
|
21
18
|
|
@@ -5,13 +5,11 @@ RgGen.define_list_item_feature(:bit_field, :type, :rws) do
|
|
5
5
|
build do
|
6
6
|
unless bit_field.reference?
|
7
7
|
input :set, {
|
8
|
-
name: "i_#{full_name}_set", width: 1,
|
9
|
-
array_size: array_size, array_format: array_port_format
|
8
|
+
name: "i_#{full_name}_set", width: 1, array_size:
|
10
9
|
}
|
11
10
|
end
|
12
11
|
output :value_out, {
|
13
|
-
name: "o_#{full_name}", width:
|
14
|
-
array_size: array_size, array_format: array_port_format
|
12
|
+
name: "o_#{full_name}", width:, array_size:
|
15
13
|
}
|
16
14
|
end
|
17
15
|
|
@@ -4,8 +4,7 @@ RgGen.define_list_item_feature(:bit_field, :type, [:w0t, :w1t]) do
|
|
4
4
|
sv_rtl do
|
5
5
|
build do
|
6
6
|
output :value_out, {
|
7
|
-
name: "o_#{full_name}", width:
|
8
|
-
array_size: array_size, array_format: array_port_format
|
7
|
+
name: "o_#{full_name}", width:, array_size:
|
9
8
|
}
|
10
9
|
end
|
11
10
|
|
@@ -4,8 +4,7 @@ RgGen.define_list_item_feature(:bit_field, :type, [:w0trg, :w1trg]) do
|
|
4
4
|
sv_rtl do
|
5
5
|
build do
|
6
6
|
output :trigger, {
|
7
|
-
name: "o_#{full_name}_trigger", width:
|
8
|
-
array_size: array_size, array_format: array_port_format
|
7
|
+
name: "o_#{full_name}_trigger", width:, array_size:
|
9
8
|
}
|
10
9
|
end
|
11
10
|
|
@@ -4,13 +4,11 @@ RgGen.define_list_item_feature(:bit_field, :type, [:wo, :wo1, :wotrg]) do
|
|
4
4
|
sv_rtl do
|
5
5
|
build do
|
6
6
|
output :value_out, {
|
7
|
-
name: "o_#{full_name}", width:
|
8
|
-
array_size: array_size, array_format: array_port_format
|
7
|
+
name: "o_#{full_name}", width:, array_size:
|
9
8
|
}
|
10
9
|
if wotrg?
|
11
10
|
output :write_trigger, {
|
12
|
-
name: "o_#{full_name}_write_trigger", width: 1,
|
13
|
-
array_size: array_size, array_format: array_port_format
|
11
|
+
name: "o_#{full_name}_write_trigger", width: 1, array_size:
|
14
12
|
}
|
15
13
|
end
|
16
14
|
end
|
@@ -4,8 +4,7 @@ RgGen.define_list_item_feature(:bit_field, :type, [:wrc, :wrs]) do
|
|
4
4
|
sv_rtl do
|
5
5
|
build do
|
6
6
|
output :value_out, {
|
7
|
-
name: "o_#{full_name}", width:
|
8
|
-
array_size: array_size, array_format: array_port_format
|
7
|
+
name: "o_#{full_name}", width:, array_size:
|
9
8
|
}
|
10
9
|
end
|
11
10
|
|
@@ -9,10 +9,6 @@ RgGen.define_list_feature(:bit_field, :type) do
|
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
-
def array_port_format
|
13
|
-
configuration.array_port_format
|
14
|
-
end
|
15
|
-
|
16
12
|
def full_name
|
17
13
|
bit_field.full_name('_')
|
18
14
|
end
|
@@ -38,7 +34,7 @@ RgGen.define_list_feature(:bit_field, :type) do
|
|
38
34
|
end
|
39
35
|
|
40
36
|
def initial_value
|
41
|
-
index = bit_field.initial_value_array? &&
|
37
|
+
index = bit_field.initial_value_array? && loop_variables || nil
|
42
38
|
bit_field.initial_value[index]
|
43
39
|
end
|
44
40
|
|
@@ -50,7 +46,7 @@ RgGen.define_list_feature(:bit_field, :type) do
|
|
50
46
|
bit_field.reference? &&
|
51
47
|
bit_field
|
52
48
|
.find_reference(register_block.bit_fields)
|
53
|
-
.value(bit_field.
|
49
|
+
.value(bit_field.local_indexes, bit_field.reference_width)
|
54
50
|
end
|
55
51
|
|
56
52
|
def bit_field_if
|
@@ -5,7 +5,7 @@ module RgGen
|
|
5
5
|
module RTL
|
6
6
|
module BitFieldIndex
|
7
7
|
EXPORTED_METHODS = [
|
8
|
-
:local_index, :
|
8
|
+
:local_index, :local_indexes, :loop_variables, :flat_loop_index, :array_size
|
9
9
|
].freeze
|
10
10
|
|
11
11
|
def self.included(feature)
|
@@ -18,8 +18,8 @@ module RgGen
|
|
18
18
|
create_identifier(local_index_name)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
[*register.
|
21
|
+
def local_indexes
|
22
|
+
[*register.local_indexes, local_index_name]
|
23
23
|
end
|
24
24
|
|
25
25
|
def loop_variables
|
@@ -27,13 +27,22 @@ module RgGen
|
|
27
27
|
[*register.loop_variables, local_index].compact
|
28
28
|
end
|
29
29
|
|
30
|
+
def flat_loop_index
|
31
|
+
return unless inside_loop?
|
32
|
+
|
33
|
+
size = array_size
|
34
|
+
factors =
|
35
|
+
Array.new(size.size) { |i| size[(i + 1)..].inject(1, :*) }
|
36
|
+
factors
|
37
|
+
.zip(loop_variables)
|
38
|
+
.map { |f, v| f == 1 && v || "#{f}*#{v}" }
|
39
|
+
.join('+')
|
40
|
+
end
|
41
|
+
|
30
42
|
def array_size
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
*register.array_size,
|
35
|
-
*bit_field.sequence_size
|
36
|
-
].compact
|
43
|
+
return unless inside_loop?
|
44
|
+
|
45
|
+
[*register.array_size(hierarchical: true), *bit_field.sequence_size]
|
37
46
|
end
|
38
47
|
|
39
48
|
private
|
@@ -6,32 +6,28 @@ module RgGen
|
|
6
6
|
class Feature < Common::Feature
|
7
7
|
private
|
8
8
|
|
9
|
-
def create_variable(data_type, attributes, &
|
10
|
-
DataObject.new(
|
11
|
-
:variable, attributes.merge(data_type: data_type), &block
|
12
|
-
)
|
9
|
+
def create_variable(data_type, attributes, &)
|
10
|
+
DataObject.new(:variable, attributes.merge(data_type:), &)
|
13
11
|
end
|
14
12
|
|
15
|
-
def create_if_instance(_, attributes, &
|
16
|
-
InterfaceInstance.new(attributes, &
|
13
|
+
def create_if_instance(_, attributes, &)
|
14
|
+
InterfaceInstance.new(attributes, &)
|
17
15
|
end
|
18
16
|
|
19
|
-
def create_port(direction, attributes, &
|
17
|
+
def create_port(direction, attributes, &)
|
20
18
|
attributes =
|
21
19
|
{ data_type: 'logic' }
|
22
20
|
.merge(attributes)
|
23
|
-
.merge(direction:
|
24
|
-
DataObject.new(:argument, attributes, &
|
21
|
+
.merge(direction:)
|
22
|
+
DataObject.new(:argument, attributes, &)
|
25
23
|
end
|
26
24
|
|
27
|
-
def create_if_port(_, attributes, &
|
28
|
-
InterfacePort.new(attributes, &
|
25
|
+
def create_if_port(_, attributes, &)
|
26
|
+
InterfacePort.new(attributes, &)
|
29
27
|
end
|
30
28
|
|
31
|
-
def create_parameter(parameter_type, attributes, &
|
32
|
-
DataObject.new(
|
33
|
-
:parameter, attributes.merge(parameter_type: parameter_type), &block
|
34
|
-
)
|
29
|
+
def create_parameter(parameter_type, attributes, &)
|
30
|
+
DataObject.new(:parameter, attributes.merge(parameter_type:), &)
|
35
31
|
end
|
36
32
|
|
37
33
|
define_entity :logic, :create_variable, :variable, -> { component }
|
@@ -5,7 +5,7 @@ RgGen.define_list_item_feature(:register, :type, :external) do
|
|
5
5
|
build do
|
6
6
|
parameter :strobe_width, {
|
7
7
|
name: "#{register.name}_strobe_width".upcase,
|
8
|
-
data_type: :int, default:
|
8
|
+
data_type: :int, default: bus_width / 8
|
9
9
|
}
|
10
10
|
interface_port :bus_if, {
|
11
11
|
name: "#{register.name}_bus_if",
|
@@ -1,21 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RgGen.define_list_item_feature(:register_block, :protocol, :apb) do
|
4
|
-
|
4
|
+
register_map do
|
5
5
|
verify(:component) do
|
6
|
-
error_condition {
|
6
|
+
error_condition { register_block.bus_width > 32 }
|
7
7
|
message do
|
8
|
-
'bus width over 32
|
9
|
-
"#{
|
8
|
+
'bus width over 32 bits is not supported: ' \
|
9
|
+
"#{register_block.bus_width}"
|
10
|
+
end
|
11
|
+
position do
|
12
|
+
register_block.feature(:bus_width).position
|
10
13
|
end
|
11
14
|
end
|
12
15
|
|
13
16
|
verify(:component) do
|
14
17
|
error_condition { configuration.address_width > 32 }
|
15
18
|
message do
|
16
|
-
'address width over 32
|
19
|
+
'address width over 32 bits is not supported: ' \
|
17
20
|
"#{configuration.address_width}"
|
18
21
|
end
|
22
|
+
position do
|
23
|
+
configuration.feature(:address_width).position
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
rggen_avalon_adapter #(
|
2
|
+
.ADDRESS_WIDTH (<%= address_width %>),
|
3
|
+
.LOCAL_ADDRESS_WIDTH (<%= local_address_width %>),
|
4
|
+
.BUS_WIDTH (<%= bus_width %>),
|
5
|
+
.REGISTERS (<%= total_registers %>),
|
6
|
+
.PRE_DECODE (<%= pre_decode %>),
|
7
|
+
.BASE_ADDRESS (<%= base_address %>),
|
8
|
+
.BYTE_SIZE (<%= byte_size %>),
|
9
|
+
.ERROR_STATUS (<%= error_status %>),
|
10
|
+
.DEFAULT_READ_DATA (<%= default_read_data %>),
|
11
|
+
.INSERT_SLICER (<%= insert_slicer %>)
|
12
|
+
) u_adapter (
|
13
|
+
.i_clk (<%= clock %>),
|
14
|
+
.i_rst_n (<%= reset %>),
|
15
|
+
.avalon_if (<%= avalon_if %>),
|
16
|
+
.register_if (<%= register_if %>)
|
17
|
+
);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RgGen.define_list_item_feature(:register_block, :protocol, :avalon) do
|
4
|
+
register_map do
|
5
|
+
verify(:component) do
|
6
|
+
error_condition { configuration.address_width > 64 }
|
7
|
+
message do
|
8
|
+
'address width over 64 bits is not supported: ' \
|
9
|
+
"#{configuration.address_width}"
|
10
|
+
end
|
11
|
+
position do
|
12
|
+
configuration.feature(:address_width).position
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
verify(:component) do
|
17
|
+
error_condition { register_block.bus_width > 1024 }
|
18
|
+
message do
|
19
|
+
'bus width over 1024 bits is not supported: ' \
|
20
|
+
"#{register_block.bus_width}"
|
21
|
+
end
|
22
|
+
position do
|
23
|
+
register_block.feature(:bus_width).position
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
sv_rtl do
|
29
|
+
build do
|
30
|
+
interface_port :avalon_if, {
|
31
|
+
name: 'avalon_if', interface_type: 'rggen_avalon_if', modport: 'agent'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
main_code :register_block, from_template: true
|
36
|
+
end
|
37
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RgGen.define_list_item_feature(:register_block, :protocol, :axi4lite) do
|
4
|
-
|
4
|
+
register_map do
|
5
5
|
verify(:component) do
|
6
|
-
error_condition { ![32, 64].include?(
|
6
|
+
error_condition { ![32, 64].include?(register_block.bus_width) }
|
7
7
|
message do
|
8
8
|
'bus width either 32 bit or 64 bit is only supported: ' \
|
9
|
-
"#{
|
9
|
+
"#{register_block.bus_width}"
|
10
|
+
end
|
11
|
+
position do
|
12
|
+
register_block.feature(:bus_width).position
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
rggen_native_adapter #(
|
2
|
+
.ADDRESS_WIDTH (<%= address_width %>),
|
3
|
+
.LOCAL_ADDRESS_WIDTH (<%= local_address_width %>),
|
4
|
+
.BUS_WIDTH (<%= bus_width %>),
|
5
|
+
.STROBE_WIDTH (<%= strobe_width %>),
|
6
|
+
.REGISTERS (<%= total_registers %>),
|
7
|
+
.PRE_DECODE (<%= pre_decode %>),
|
8
|
+
.BASE_ADDRESS (<%= base_address %>),
|
9
|
+
.BYTE_SIZE (<%= byte_size %>),
|
10
|
+
.USE_READ_STROBE (<%= use_read_strobe %>),
|
11
|
+
.ERROR_STATUS (<%= error_status %>),
|
12
|
+
.DEFAULT_READ_DATA (<%= default_read_data %>),
|
13
|
+
.INSERT_SLICER (<%= insert_slicer %>)
|
14
|
+
) u_adapter (
|
15
|
+
.i_clk (<%= clock %>),
|
16
|
+
.i_rst_n (<%= reset %>),
|
17
|
+
.csrbus_if (<%= csrbus_if %>),
|
18
|
+
.register_if (<%= register_if %>)
|
19
|
+
);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RgGen.define_list_item_feature(:register_block, :protocol, :native) do
|
4
|
+
sv_rtl do
|
5
|
+
build do
|
6
|
+
parameter :strobe_width, {
|
7
|
+
name: 'STROBE_WIDTH', data_type: :int, default: bus_width / 8
|
8
|
+
}
|
9
|
+
parameter :use_read_strobe, {
|
10
|
+
name: 'USE_READ_STROBE', data_type: :bit, default: 0
|
11
|
+
}
|
12
|
+
interface_port :csrbus_if, {
|
13
|
+
name: 'csrbus_if', interface_type: 'rggen_bus_if', modport: 'slave'
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
main_code :register_block, from_template: true
|
18
|
+
end
|
19
|
+
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
RgGen.define_list_item_feature(:register_block, :protocol, :wishbone) do
|
4
|
-
|
4
|
+
register_map do
|
5
5
|
verify(:component) do
|
6
|
-
error_condition {
|
6
|
+
error_condition { register_block.bus_width > 64 }
|
7
7
|
message do
|
8
|
-
'bus width over 64
|
9
|
-
"#{
|
8
|
+
'bus width over 64 bits is not supported: ' \
|
9
|
+
"#{register_block.bus_width}"
|
10
|
+
end
|
11
|
+
position do
|
12
|
+
register_block.feature(:bus_width).position
|
10
13
|
end
|
11
14
|
end
|
12
15
|
end
|
@@ -6,57 +6,76 @@ RgGen.define_list_feature(:register_block, :protocol) do
|
|
6
6
|
feature_registries << registry
|
7
7
|
end
|
8
8
|
|
9
|
+
def default_protocol
|
10
|
+
available_protocols.first
|
11
|
+
end
|
12
|
+
|
13
|
+
def find_protocol(value)
|
14
|
+
available_protocols
|
15
|
+
.find { value.to_sym.casecmp?(_1) }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def feature_registries
|
21
|
+
@feature_registries ||= []
|
22
|
+
end
|
23
|
+
|
9
24
|
def available_protocols
|
10
25
|
feature_registries
|
11
26
|
.map { |registry| registry.enabled_features(:protocol) }
|
12
27
|
.inject(:&)
|
13
28
|
end
|
29
|
+
end
|
14
30
|
|
15
|
-
|
31
|
+
[:configuration, :register_map].each do |component_type|
|
32
|
+
component(component_type) do
|
33
|
+
base_feature do
|
34
|
+
build { |protocol| @protocol = protocol }
|
35
|
+
end
|
16
36
|
|
17
|
-
|
18
|
-
|
37
|
+
default_feature do
|
38
|
+
end
|
39
|
+
|
40
|
+
factory do
|
41
|
+
convert_value do |value, position|
|
42
|
+
shared_context.find_protocol(value) ||
|
43
|
+
(error "unknown protocol: #{value.inspect}", position)
|
44
|
+
end
|
45
|
+
end
|
19
46
|
end
|
20
47
|
end
|
21
48
|
|
22
49
|
configuration do
|
23
50
|
base_feature do
|
24
51
|
property :protocol
|
25
|
-
build { |protocol| @protocol = protocol }
|
26
52
|
printable :protocol
|
27
53
|
end
|
28
54
|
|
29
|
-
default_feature do
|
30
|
-
end
|
31
|
-
|
32
55
|
factory do
|
33
|
-
convert_value do |value, position|
|
34
|
-
protocol = find_protocol(value)
|
35
|
-
protocol ||
|
36
|
-
(error "unknown protocol: #{value.inspect}", position)
|
37
|
-
end
|
38
|
-
|
39
56
|
default_value do |position|
|
40
|
-
default_protocol ||
|
57
|
+
shared_context.default_protocol ||
|
41
58
|
(error 'no protocols are available', position)
|
42
59
|
end
|
43
60
|
|
44
61
|
def target_feature_key(data)
|
45
62
|
data.value
|
46
63
|
end
|
64
|
+
end
|
65
|
+
end
|
47
66
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
available_protocols.find(&value.to_sym.method(:casecmp?))
|
52
|
-
end
|
67
|
+
register_map do
|
68
|
+
base_feature do
|
69
|
+
property :protocol, default: -> { configuration.protocol }
|
53
70
|
|
54
|
-
def
|
55
|
-
|
71
|
+
def position
|
72
|
+
super || configuration.feature(:protocol).position
|
56
73
|
end
|
74
|
+
end
|
57
75
|
|
58
|
-
|
59
|
-
|
76
|
+
factory do
|
77
|
+
def target_feature_key(configuration, data)
|
78
|
+
data&.value || configuration.protocol
|
60
79
|
end
|
61
80
|
end
|
62
81
|
end
|
@@ -91,7 +110,7 @@ RgGen.define_list_feature(:register_block, :protocol) do
|
|
91
110
|
private
|
92
111
|
|
93
112
|
def bus_width
|
94
|
-
|
113
|
+
register_block.bus_width
|
95
114
|
end
|
96
115
|
|
97
116
|
def local_address_width
|
@@ -120,8 +139,8 @@ RgGen.define_list_feature(:register_block, :protocol) do
|
|
120
139
|
end
|
121
140
|
|
122
141
|
factory do
|
123
|
-
def target_feature_key(
|
124
|
-
|
142
|
+
def target_feature_key(_configuration, register_block)
|
143
|
+
register_block.protocol
|
125
144
|
end
|
126
145
|
end
|
127
146
|
end
|
@@ -8,7 +8,7 @@ module RgGen
|
|
8
8
|
|
9
9
|
EXPORTED_METHODS = [
|
10
10
|
:loop_variables, :local_loop_variables,
|
11
|
-
:local_index, :
|
11
|
+
:local_index, :local_indexes,
|
12
12
|
:index, :inside_loop?
|
13
13
|
].freeze
|
14
14
|
|
@@ -45,15 +45,15 @@ module RgGen
|
|
45
45
|
.join('+')
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
[*upper_register_file&.
|
48
|
+
def local_indexes
|
49
|
+
[*upper_register_file&.local_indexes, local_index]
|
50
50
|
end
|
51
51
|
|
52
52
|
def index(offset_or_offsets = nil)
|
53
53
|
offset_or_offsets
|
54
54
|
.then(&method(:index_operands))
|
55
55
|
.then(&method(:partial_sums))
|
56
|
-
.then(&method(:
|
56
|
+
.then(&method(:reduce_indexes))
|
57
57
|
end
|
58
58
|
|
59
59
|
def inside_loop?
|
@@ -84,11 +84,11 @@ module RgGen
|
|
84
84
|
]
|
85
85
|
end
|
86
86
|
|
87
|
-
def
|
88
|
-
if
|
89
|
-
|
87
|
+
def reduce_indexes(indexes)
|
88
|
+
if indexes.empty? || indexes.all?(&method(:integer?))
|
89
|
+
indexes.sum
|
90
90
|
else
|
91
|
-
|
91
|
+
indexes.join('+')
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|