rggen-veryl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +84 -0
  3. data/LICENSE +21 -0
  4. data/README.md +65 -0
  5. data/lib/rggen/veryl/bit_field/common.erb +8 -0
  6. data/lib/rggen/veryl/bit_field/type/custom.erb +25 -0
  7. data/lib/rggen/veryl/bit_field/type/custom.rb +121 -0
  8. data/lib/rggen/veryl/bit_field/type/rc_w0c_w1c_wc_woc.erb +21 -0
  9. data/lib/rggen/veryl/bit_field/type/rc_w0c_w1c_wc_woc.rb +46 -0
  10. data/lib/rggen/veryl/bit_field/type/ro_rotrg.erb +21 -0
  11. data/lib/rggen/veryl/bit_field/type/ro_rotrg.rb +40 -0
  12. data/lib/rggen/veryl/bit_field/type/rof.erb +20 -0
  13. data/lib/rggen/veryl/bit_field/type/rof.rb +7 -0
  14. data/lib/rggen/veryl/bit_field/type/rohw.erb +20 -0
  15. data/lib/rggen/veryl/bit_field/type/rohw.rb +28 -0
  16. data/lib/rggen/veryl/bit_field/type/row0trg_row1trg.erb +10 -0
  17. data/lib/rggen/veryl/bit_field/type/row0trg_row1trg.rb +30 -0
  18. data/lib/rggen/veryl/bit_field/type/rowo_rowotrg.erb +21 -0
  19. data/lib/rggen/veryl/bit_field/type/rowo_rowotrg.rb +52 -0
  20. data/lib/rggen/veryl/bit_field/type/rs_w0s_w1s_ws_wos.erb +21 -0
  21. data/lib/rggen/veryl/bit_field/type/rs_w0s_w1s_ws_wos.rb +36 -0
  22. data/lib/rggen/veryl/bit_field/type/rw_rwtrg_w1.erb +21 -0
  23. data/lib/rggen/veryl/bit_field/type/rw_rwtrg_w1.rb +46 -0
  24. data/lib/rggen/veryl/bit_field/type/rwc.erb +20 -0
  25. data/lib/rggen/veryl/bit_field/type/rwc.rb +26 -0
  26. data/lib/rggen/veryl/bit_field/type/rwe_rwl.erb +20 -0
  27. data/lib/rggen/veryl/bit_field/type/rwe_rwl.rb +34 -0
  28. data/lib/rggen/veryl/bit_field/type/rwhw.erb +19 -0
  29. data/lib/rggen/veryl/bit_field/type/rwhw.rb +30 -0
  30. data/lib/rggen/veryl/bit_field/type/rws.erb +20 -0
  31. data/lib/rggen/veryl/bit_field/type/rws.rb +26 -0
  32. data/lib/rggen/veryl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc.erb +21 -0
  33. data/lib/rggen/veryl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc.rb +35 -0
  34. data/lib/rggen/veryl/bit_field/type/w0t_w1t.erb +20 -0
  35. data/lib/rggen/veryl/bit_field/type/w0t_w1t.rb +23 -0
  36. data/lib/rggen/veryl/bit_field/type/w0trg_w1trg.erb +10 -0
  37. data/lib/rggen/veryl/bit_field/type/w0trg_w1trg.rb +20 -0
  38. data/lib/rggen/veryl/bit_field/type/wo_wo1_wotrg.erb +22 -0
  39. data/lib/rggen/veryl/bit_field/type/wo_wo1_wotrg.rb +38 -0
  40. data/lib/rggen/veryl/bit_field/type/wrc_wrs.erb +20 -0
  41. data/lib/rggen/veryl/bit_field/type/wrc_wrs.rb +20 -0
  42. data/lib/rggen/veryl/bit_field/type.rb +70 -0
  43. data/lib/rggen/veryl/bit_field/veryl_top.rb +102 -0
  44. data/lib/rggen/veryl/component.rb +8 -0
  45. data/lib/rggen/veryl/factories.rb +11 -0
  46. data/lib/rggen/veryl/feature.rb +46 -0
  47. data/lib/rggen/veryl/register/type/default.erb +15 -0
  48. data/lib/rggen/veryl/register/type/external.erb +13 -0
  49. data/lib/rggen/veryl/register/type/external.rb +28 -0
  50. data/lib/rggen/veryl/register/type/indirect.erb +17 -0
  51. data/lib/rggen/veryl/register/type/indirect.rb +22 -0
  52. data/lib/rggen/veryl/register/type/rw.erb +15 -0
  53. data/lib/rggen/veryl/register/type/rw.rb +7 -0
  54. data/lib/rggen/veryl/register/type.rb +34 -0
  55. data/lib/rggen/veryl/register/veryl_top.rb +43 -0
  56. data/lib/rggen/veryl/register_block/protocol/apb.erb +17 -0
  57. data/lib/rggen/veryl/register_block/protocol/apb.rb +14 -0
  58. data/lib/rggen/veryl/register_block/protocol/axi4lite.erb +19 -0
  59. data/lib/rggen/veryl/register_block/protocol/axi4lite.rb +20 -0
  60. data/lib/rggen/veryl/register_block/protocol/wishbone.erb +18 -0
  61. data/lib/rggen/veryl/register_block/protocol/wishbone.rb +17 -0
  62. data/lib/rggen/veryl/register_block/protocol.rb +54 -0
  63. data/lib/rggen/veryl/register_block/veryl_top.rb +71 -0
  64. data/lib/rggen/veryl/register_file/veryl_top.rb +26 -0
  65. data/lib/rggen/veryl/utility/data_object.rb +79 -0
  66. data/lib/rggen/veryl/utility/interface_instance.rb +43 -0
  67. data/lib/rggen/veryl/utility/local_scope.rb +48 -0
  68. data/lib/rggen/veryl/utility/modport.rb +29 -0
  69. data/lib/rggen/veryl/utility/module_definition.rb +63 -0
  70. data/lib/rggen/veryl/utility.rb +37 -0
  71. data/lib/rggen/veryl/version.rb +7 -0
  72. data/lib/rggen/veryl.rb +57 -0
  73. metadata +133 -0
@@ -0,0 +1,21 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ SW_READ_ACTION: rggen_sw_action::<%= read_action %>,
5
+ SW_WRITE_ACTION: rggen_sw_action::<%= write_action %>
6
+ )(
7
+ i_clk: <%= clock %>,
8
+ i_rst: <%= reset %>,
9
+ bit_field_if: <%= bit_field_if %>,
10
+ o_write_trigger: _,
11
+ o_read_trigger: _,
12
+ i_sw_write_enable: <%= sw_write_enable %>,
13
+ i_hw_write_enable: '0,
14
+ i_hw_write_data: '0,
15
+ i_hw_set: '0,
16
+ i_hw_clear: <%= clear[loop_variables] %>,
17
+ i_value: '0,
18
+ i_mask: '1,
19
+ o_value: <%= value_out[loop_variables] %>,
20
+ o_value_unmasked: _
21
+ );
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:rs, :w0s, :w1s, :ws, :wos]) do
4
+ veryl do
5
+ build do
6
+ input :clear, {
7
+ name: "i_#{full_name}_clear",
8
+ width: width, array_size: array_size
9
+ }
10
+ output :value_out, {
11
+ name: "o_#{full_name}",
12
+ width: width, array_size: array_size
13
+ }
14
+ end
15
+
16
+ main_code :bit_field, from_template: true
17
+
18
+ private
19
+
20
+ def read_action
21
+ {
22
+ rs: 'READ_SET', wos: 'READ_NONE'
23
+ }.fetch(bit_field.type, 'READ_DEFAULT')
24
+ end
25
+
26
+ def write_action
27
+ {
28
+ rs: 'WRITE_NONE', w0s: 'WRITE_0_SET', w1s: 'WRITE_1_SET'
29
+ }.fetch(bit_field.type, 'WRITE_SET')
30
+ end
31
+
32
+ def sw_write_enable
33
+ bit_field.writable? && all_bits_1 || all_bits_0
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,21 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ SW_WRITE_ONCE: <%= write_once %>,
5
+ TRIGGER: <%= trigger %>
6
+ )(
7
+ i_clk: <%= clock %>,
8
+ i_rst: <%= reset %>,
9
+ bit_field_if: <%= bit_field_if %>,
10
+ o_write_trigger: <%= write_trigger_signal %>,
11
+ o_read_trigger: <%= read_trigger_signal %>,
12
+ i_sw_write_enable: '1,
13
+ i_hw_write_enable: '0,
14
+ i_hw_write_data: '0,
15
+ i_hw_set: '0,
16
+ i_hw_clear: '0,
17
+ i_value: '0,
18
+ i_mask: '1,
19
+ o_value: <%= value_out[loop_variables] %>,
20
+ o_value_unmasked: _
21
+ );
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:rw, :rwtrg, :w1]) do
4
+ veryl do
5
+ build do
6
+ output :value_out, {
7
+ name: "o_#{full_name}",
8
+ width: width, array_size: array_size
9
+ }
10
+ if rwtrg?
11
+ output :write_trigger, {
12
+ name: "o_#{full_name}_write_trigger",
13
+ width: 1, array_size: array_size
14
+ }
15
+ output :read_trigger, {
16
+ name: "o_#{full_name}_read_trigger",
17
+ width: 1, array_size: array_size
18
+ }
19
+ end
20
+ end
21
+
22
+ main_code :bit_field, from_template: true
23
+
24
+ private
25
+
26
+ def rwtrg?
27
+ bit_field.type == :rwtrg
28
+ end
29
+
30
+ def trigger
31
+ rwtrg? && 1 || 0
32
+ end
33
+
34
+ def write_trigger_signal
35
+ rwtrg? && write_trigger[loop_variables] || unused
36
+ end
37
+
38
+ def read_trigger_signal
39
+ rwtrg? && read_trigger[loop_variables] || unused
40
+ end
41
+
42
+ def write_once
43
+ bit_field.type == :w1 && 1 || 0
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,20 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ HW_CLEAR_WIDTH: 1
5
+ )(
6
+ i_clk: <%= clock %>,
7
+ i_rst: <%= reset %>,
8
+ bit_field_if: <%= bit_field_if %>,
9
+ o_write_trigger: _,
10
+ o_read_trigger: _,
11
+ i_sw_write_enable: '1,
12
+ i_hw_write_enable: '0,
13
+ i_hw_write_data: '0,
14
+ i_hw_set: '0,
15
+ i_hw_clear: <%= clear_signal %>,
16
+ i_value: '0,
17
+ i_mask: '1,
18
+ o_value: <%= value_out[loop_variables] %>,
19
+ o_value_unmasked: _
20
+ );
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, :rwc) do
4
+ veryl do
5
+ build do
6
+ unless bit_field.reference?
7
+ input :clear, {
8
+ name: "i_#{full_name}_clear",
9
+ width: 1, array_size: array_size
10
+ }
11
+ end
12
+ output :value_out, {
13
+ name: "o_#{full_name}",
14
+ width: width, array_size: array_size
15
+ }
16
+ end
17
+
18
+ main_code :bit_field, from_template: true
19
+
20
+ private
21
+
22
+ def clear_signal
23
+ reference_bit_field || clear[loop_variables]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ SW_WRITE_ENABLE_POLARITY: rggen_polarity::<%= polarity %>
5
+ )(
6
+ i_clk: <%= clock %>,
7
+ i_rst: <%= reset %>,
8
+ bit_field_if: <%= bit_field_if %>,
9
+ o_write_trigger: _,
10
+ o_read_trigger: _,
11
+ i_sw_write_enable: <%= control_signal %>,
12
+ i_hw_write_enable: '0,
13
+ i_hw_write_data: '0,
14
+ i_hw_set: '0,
15
+ i_hw_clear: '0,
16
+ i_value: '0,
17
+ i_mask: '1,
18
+ o_value: <%= value_out[loop_variables] %>,
19
+ o_value_unmasked: _
20
+ );
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:rwe, :rwl]) do
4
+ veryl do
5
+ build do
6
+ unless bit_field.reference?
7
+ input :control, {
8
+ name: "i_#{full_name}_#{enable_or_lock}",
9
+ width: 1, array_size: array_size
10
+ }
11
+ end
12
+ output :value_out, {
13
+ name: "o_#{full_name}",
14
+ width: width, array_size: array_size
15
+ }
16
+ end
17
+
18
+ main_code :bit_field, from_template: true
19
+
20
+ private
21
+
22
+ def enable_or_lock
23
+ { rwe: 'enable', rwl: 'lock' }[bit_field.type]
24
+ end
25
+
26
+ def control_signal
27
+ reference_bit_field || control[loop_variables]
28
+ end
29
+
30
+ def polarity
31
+ { rwe: 'ACTIVE_HIGH', rwl: 'ACTIVE_LOW' }[bit_field.type]
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>
4
+ )(
5
+ i_clk: <%= clock %>,
6
+ i_rst: <%= reset %>,
7
+ bit_field_if: <%= bit_field_if %>,
8
+ o_write_trigger: _,
9
+ o_read_trigger: _,
10
+ i_sw_write_enable: '1,
11
+ i_hw_write_enable: <%= valid_signal %>,
12
+ i_hw_write_data: <%= value_in[loop_variables] %>,
13
+ i_hw_set: '0,
14
+ i_hw_clear: '0,
15
+ i_value: '0,
16
+ i_mask: '1,
17
+ o_value: <%= value_out[loop_variables] %>,
18
+ o_value_unmasked: _
19
+ );
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, :rwhw) do
4
+ veryl do
5
+ build do
6
+ unless bit_field.reference?
7
+ input :valid, {
8
+ name: "i_#{full_name}_valid",
9
+ width: 1, array_size: array_size
10
+ }
11
+ end
12
+ input :value_in, {
13
+ name: "i_#{full_name}",
14
+ width: width, array_size: array_size
15
+ }
16
+ output :value_out, {
17
+ name: "o_#{full_name}",
18
+ width: width, array_size: array_size
19
+ }
20
+ end
21
+
22
+ main_code :bit_field, from_template: true
23
+
24
+ private
25
+
26
+ def valid_signal
27
+ reference_bit_field || valid[loop_variables]
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,20 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ HW_SET_WIDTH: 1
5
+ )(
6
+ i_clk: <%= clock %>,
7
+ i_rst: <%= reset %>,
8
+ bit_field_if: <%= bit_field_if %>,
9
+ o_write_trigger: _,
10
+ o_read_trigger: _,
11
+ i_sw_write_enable: '1,
12
+ i_hw_write_enable: '0,
13
+ i_hw_write_data: '0,
14
+ i_hw_set: <%= set_signal %>,
15
+ i_hw_clear: '0,
16
+ i_value: '0,
17
+ i_mask: '1,
18
+ o_value: <%= value_out[loop_variables] %>,
19
+ o_value_unmasked: _
20
+ );
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, :rws) do
4
+ veryl do
5
+ build do
6
+ unless bit_field.reference?
7
+ input :set, {
8
+ name: "i_#{full_name}_set",
9
+ width: 1, array_size: array_size
10
+ }
11
+ end
12
+ output :value_out, {
13
+ name: "o_#{full_name}",
14
+ width: width, array_size: array_size
15
+ }
16
+ end
17
+
18
+ main_code :bit_field, from_template: true
19
+
20
+ private
21
+
22
+ def set_signal
23
+ reference_bit_field || set[loop_variables]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ SW_READ_ACTION: rggen_sw_action::<%= read_action %>,
5
+ SW_WRITE_ACTION: rggen_sw_action::<%= write_action %>
6
+ )(
7
+ i_clk: <%= clock %>,
8
+ i_rst: <%= reset %>,
9
+ bit_field_if: <%= bit_field_if %>,
10
+ o_write_trigger: _,
11
+ o_read_trigger: _,
12
+ i_sw_write_enable: '1,
13
+ i_hw_write_enable: '0,
14
+ i_hw_write_data: '0,
15
+ i_hw_set: '0,
16
+ i_hw_clear: '0,
17
+ i_value: '0,
18
+ i_mask: '1,
19
+ o_value: <%= value_out[loop_variables] %>,
20
+ o_value_unmasked: _
21
+ );
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(
4
+ :bit_field, :type, [:w0crs, :w0src, :w1crs, :w1src, :wcrs, :wsrc]
5
+ ) do
6
+ veryl do
7
+ build do
8
+ output :value_out, {
9
+ name: "o_#{full_name}",
10
+ width: width, array_size: array_size
11
+ }
12
+ end
13
+
14
+ main_code :bit_field, from_template: true
15
+
16
+ private
17
+
18
+ def read_action
19
+ {
20
+ w0crs: 'READ_SET', w1crs: 'READ_SET', wcrs: 'READ_SET'
21
+ }.fetch(bit_field.type, 'READ_CLEAR')
22
+ end
23
+
24
+ def write_action
25
+ {
26
+ w0crs: 'WRITE_0_CLEAR',
27
+ w0src: 'WRITE_0_SET',
28
+ w1crs: 'WRITE_1_CLEAR',
29
+ w1src: 'WRITE_1_SET',
30
+ wcrs: 'WRITE_CLEAR',
31
+ wsrc: 'WRITE_SET'
32
+ }[bit_field.type]
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,20 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ SW_WRITE_ACTION: rggen_sw_action::<%= write_action %>
5
+ )(
6
+ i_clk: <%= clock %>,
7
+ i_rst: <%= reset %>,
8
+ bit_field_if: <%= bit_field_if %>,
9
+ o_write_trigger: _,
10
+ o_read_trigger: _,
11
+ i_sw_write_enable: '1,
12
+ i_hw_write_enable: '0,
13
+ i_hw_write_data: '0,
14
+ i_hw_set: '0,
15
+ i_hw_clear: '0,
16
+ i_value: '0,
17
+ i_mask: '1,
18
+ o_value: <%= value_out[loop_variables] %>,
19
+ o_value_unmasked: _
20
+ );
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:w0t, :w1t]) do
4
+ veryl do
5
+ build do
6
+ output :value_out, {
7
+ name: "o_#{full_name}",
8
+ width: width, array_size: array_size
9
+ }
10
+ end
11
+
12
+ main_code :bit_field, from_template: true
13
+
14
+ private
15
+
16
+ def write_action
17
+ {
18
+ w0t: 'WRITE_0_TOGGLE',
19
+ w1t: 'WRITE_1_TOGGLE'
20
+ }[bit_field.type]
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ inst u_bit_field: rggen::rggen_bit_field_w01trg #(
2
+ TRIGGER_VALUE: <%= trigger_value %>,
3
+ WIDTH: <%= width %>
4
+ )(
5
+ i_clk: <%= clock %>,
6
+ i_rst: <%= reset %>,
7
+ bit_field_if: <%= bit_field_if %>,
8
+ i_value: '0,
9
+ o_trigger: <%= trigger[loop_variables] %>
10
+ );
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:w0trg, :w1trg]) do
4
+ veryl do
5
+ build do
6
+ output :trigger, {
7
+ name: "o_#{full_name}_trigger",
8
+ width: width, array_size: array_size
9
+ }
10
+ end
11
+
12
+ main_code :bit_field, from_template: true
13
+
14
+ private
15
+
16
+ def trigger_value
17
+ bin({ w0trg: 0, w1trg: 1 }[bit_field.type], 1)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ SW_READ_ACTION: rggen_sw_action::READ_NONE,
5
+ SW_WRITE_ONCE: <%= write_once %>,
6
+ TRIGGER: <%= trigger %>
7
+ )(
8
+ i_clk: <%= clock %>,
9
+ i_rst: <%= reset %>,
10
+ bit_field_if: <%= bit_field_if %>,
11
+ o_write_trigger: <%= write_trigger_signal %>,
12
+ o_read_trigger: _,
13
+ i_sw_write_enable: '1,
14
+ i_hw_write_enable: '0,
15
+ i_hw_write_data: '0,
16
+ i_hw_set: '0,
17
+ i_hw_clear: '0,
18
+ i_value: '0,
19
+ i_mask: '1,
20
+ o_value: <%= value_out[loop_variables] %>,
21
+ o_value_unmasked: _
22
+ );
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:wo, :wo1, :wotrg]) do
4
+ veryl do
5
+ build do
6
+ output :value_out, {
7
+ name: "o_#{full_name}",
8
+ width: width, array_size: array_size
9
+ }
10
+ if wotrg?
11
+ output :write_trigger, {
12
+ name: "o_#{full_name}_write_trigger",
13
+ width: 1, array_size: array_size
14
+ }
15
+ end
16
+ end
17
+
18
+ main_code :bit_field, from_template: true
19
+
20
+ private
21
+
22
+ def wotrg?
23
+ bit_field.type == :wotrg
24
+ end
25
+
26
+ def trigger
27
+ wotrg? && 1 || 0
28
+ end
29
+
30
+ def write_trigger_signal
31
+ wotrg? && write_trigger[loop_variables] || unused
32
+ end
33
+
34
+ def write_once
35
+ bit_field.type == :wo1 && 1 || 0
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ inst u_bit_field: rggen::rggen_bit_field #(
2
+ WIDTH: <%= width %>,
3
+ INITIAL_VALUE: <%= initial_value %>,
4
+ SW_READ_ACTION: rggen_sw_action::<%= read_action %>
5
+ )(
6
+ i_clk: <%= clock %>,
7
+ i_rst: <%= reset %>,
8
+ bit_field_if: <%= bit_field_if %>,
9
+ o_write_trigger: _,
10
+ o_read_trigger: _,
11
+ i_sw_write_enable: '1,
12
+ i_hw_write_enable: '0,
13
+ i_hw_write_data: '0,
14
+ i_hw_set: '0,
15
+ i_hw_clear: '0,
16
+ i_value: '0,
17
+ i_mask: '1,
18
+ o_value: <%= value_out[loop_variables] %>,
19
+ o_value_unmasked: _
20
+ );
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:wrc, :wrs]) do
4
+ veryl do
5
+ build do
6
+ output :value_out, {
7
+ name: "o_#{full_name}",
8
+ width: width, array_size: array_size
9
+ }
10
+ end
11
+
12
+ main_code :bit_field, from_template: true
13
+
14
+ private
15
+
16
+ def read_action
17
+ { wrc: 'READ_CLEAR', wrs: 'READ_SET' }[bit_field.type]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_feature(:bit_field, :type) do
4
+ veryl do
5
+ base_feature do
6
+ pre_code :bit_field, from_template: File.join(__dir__, 'common.erb')
7
+
8
+ private
9
+
10
+ def full_name
11
+ bit_field.full_name('_')
12
+ end
13
+
14
+ def width
15
+ bit_field.width
16
+ end
17
+
18
+ def lsb
19
+ bit_field.lsb(bit_field.local_index)
20
+ end
21
+
22
+ def clock
23
+ register_block.clock
24
+ end
25
+
26
+ def reset
27
+ register_block.reset
28
+ end
29
+
30
+ def array_size
31
+ bit_field.array_size
32
+ end
33
+
34
+ def initial_value
35
+ index =
36
+ bit_field.initial_value_array? && bit_field.local_index || nil
37
+ bit_field.initial_value[index]
38
+ end
39
+
40
+ def bit_field_if
41
+ bit_field.bit_field_sub_if
42
+ end
43
+
44
+ def reference_bit_field
45
+ return unless bit_field.reference?
46
+
47
+ bit_field
48
+ .find_reference(register_block.bit_fields)
49
+ .value(bit_field.local_indices, bit_field.reference_width)
50
+ end
51
+
52
+ def mask
53
+ reference_bit_field || all_bits_1
54
+ end
55
+
56
+ def loop_variables
57
+ bit_field.loop_variables
58
+ end
59
+ end
60
+
61
+ factory do
62
+ def target_feature_key(_configuration, bit_field)
63
+ return bit_field.type if target_features.key?(bit_field.type)
64
+
65
+ error "code generator for #{bit_field.type} " \
66
+ 'bit field type is not implemented'
67
+ end
68
+ end
69
+ end
70
+ end