rggen-vhdl 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/CODE_OF_CONDUCT.md +84 -0
  3. data/LICENSE +21 -0
  4. data/README.md +74 -0
  5. data/lib/rggen/vhdl.rb +50 -0
  6. data/lib/rggen/vhdl/bit_field/type.rb +85 -0
  7. data/lib/rggen/vhdl/bit_field/type/rc_w0c_w1c_wc_woc.erb +27 -0
  8. data/lib/rggen/vhdl/bit_field/type/rc_w0c_w1c_wc_woc.rb +51 -0
  9. data/lib/rggen/vhdl/bit_field/type/ro.erb +24 -0
  10. data/lib/rggen/vhdl/bit_field/type/ro.rb +21 -0
  11. data/lib/rggen/vhdl/bit_field/type/rof.erb +24 -0
  12. data/lib/rggen/vhdl/bit_field/type/rof.rb +7 -0
  13. data/lib/rggen/vhdl/bit_field/type/rs_w0s_w1s_ws_wos.erb +27 -0
  14. data/lib/rggen/vhdl/bit_field/type/rs_w0s_w1s_ws_wos.rb +42 -0
  15. data/lib/rggen/vhdl/bit_field/type/rw_w1_wo_wo1.erb +26 -0
  16. data/lib/rggen/vhdl/bit_field/type/rw_w1_wo_wo1.rb +23 -0
  17. data/lib/rggen/vhdl/bit_field/type/rwc.erb +25 -0
  18. data/lib/rggen/vhdl/bit_field/type/rwc.rb +24 -0
  19. data/lib/rggen/vhdl/bit_field/type/rwe_rwl.erb +25 -0
  20. data/lib/rggen/vhdl/bit_field/type/rwe_rwl.rb +33 -0
  21. data/lib/rggen/vhdl/bit_field/type/rws.erb +24 -0
  22. data/lib/rggen/vhdl/bit_field/type/rws.rb +27 -0
  23. data/lib/rggen/vhdl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc.erb +26 -0
  24. data/lib/rggen/vhdl/bit_field/type/w0crs_w0src_w1crs_w1src_wcrs_wsrc.rb +36 -0
  25. data/lib/rggen/vhdl/bit_field/type/w0t_w1t.erb +25 -0
  26. data/lib/rggen/vhdl/bit_field/type/w0t_w1t.rb +22 -0
  27. data/lib/rggen/vhdl/bit_field/type/w0trg_w1trg.erb +17 -0
  28. data/lib/rggen/vhdl/bit_field/type/w0trg_w1trg.rb +19 -0
  29. data/lib/rggen/vhdl/bit_field/type/wrc_wrs.erb +25 -0
  30. data/lib/rggen/vhdl/bit_field/type/wrc_wrs.rb +22 -0
  31. data/lib/rggen/vhdl/bit_field/vhdl_top.rb +93 -0
  32. data/lib/rggen/vhdl/component.rb +7 -0
  33. data/lib/rggen/vhdl/factories.rb +11 -0
  34. data/lib/rggen/vhdl/feature.rb +31 -0
  35. data/lib/rggen/vhdl/register/default.erb +29 -0
  36. data/lib/rggen/vhdl/register/type.rb +109 -0
  37. data/lib/rggen/vhdl/register/type/default.erb +31 -0
  38. data/lib/rggen/vhdl/register/type/external.erb +29 -0
  39. data/lib/rggen/vhdl/register/type/external.rb +44 -0
  40. data/lib/rggen/vhdl/register/type/indirect.erb +35 -0
  41. data/lib/rggen/vhdl/register/type/indirect.rb +34 -0
  42. data/lib/rggen/vhdl/register/vhdl_top.rb +40 -0
  43. data/lib/rggen/vhdl/register_block/protocol.rb +48 -0
  44. data/lib/rggen/vhdl/register_block/protocol/apb.erb +34 -0
  45. data/lib/rggen/vhdl/register_block/protocol/apb.rb +20 -0
  46. data/lib/rggen/vhdl/register_block/protocol/axi4lite.erb +49 -0
  47. data/lib/rggen/vhdl/register_block/protocol/axi4lite.rb +42 -0
  48. data/lib/rggen/vhdl/register_block/vhdl_top.erb +26 -0
  49. data/lib/rggen/vhdl/register_block/vhdl_top.rb +103 -0
  50. data/lib/rggen/vhdl/register_file/vhdl_top.rb +25 -0
  51. data/lib/rggen/vhdl/setup.rb +11 -0
  52. data/lib/rggen/vhdl/utility.rb +28 -0
  53. data/lib/rggen/vhdl/utility/data_object.rb +91 -0
  54. data/lib/rggen/vhdl/utility/identifier.rb +38 -0
  55. data/lib/rggen/vhdl/utility/local_scope.rb +66 -0
  56. data/lib/rggen/vhdl/version.rb +7 -0
  57. metadata +130 -0
@@ -0,0 +1,24 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ STORAGE => false
5
+ )
6
+ port map (
7
+ i_clk => '0',
8
+ i_rst_n => '0',
9
+ i_sw_valid => <%= bit_field_valid %>,
10
+ i_sw_read_mask => <%= bit_field_read_mask %>,
11
+ i_sw_write_enable => "0",
12
+ i_sw_write_mask => <%= bit_field_write_mask %>,
13
+ i_sw_write_data => <%= bit_field_write_data %>,
14
+ o_sw_read_data => <%= bit_field_read_data %>,
15
+ o_sw_value => <%= bit_field_value %>,
16
+ i_hw_write_enable => "0",
17
+ i_hw_write_data => (others => '0'),
18
+ i_hw_set => (others => '0'),
19
+ i_hw_clear => (others => '0'),
20
+ i_value => <%= initial_value %>,
21
+ i_mask => (others => '1'),
22
+ o_value => open,
23
+ o_value_unmasked => open
24
+ );
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, :rof) do
4
+ vhdl do
5
+ main_code :bit_field, from_template: true
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ INITIAL_VALUE => <%= initial_value %>,
5
+ SW_READ_ACTION => <%= read_action %>,
6
+ SW_WRITE_ACTION => <%= write_action %>,
7
+ HW_CLEAR_WIDTH => <%= width %>
8
+ )
9
+ port map (
10
+ i_clk => <%= clock %>,
11
+ i_rst_n => <%= reset %>,
12
+ i_sw_valid => <%= bit_field_valid %>,
13
+ i_sw_read_mask => <%= bit_field_read_mask %>,
14
+ i_sw_write_enable => <%= write_enable %>,
15
+ i_sw_write_mask => <%= bit_field_write_mask %>,
16
+ i_sw_write_data => <%= bit_field_write_data %>,
17
+ o_sw_read_data => <%= bit_field_read_data %>,
18
+ o_sw_value => <%= bit_field_value %>,
19
+ i_hw_write_enable => "0",
20
+ i_hw_write_data => (others => '0'),
21
+ i_hw_set => (others => '0'),
22
+ i_hw_clear => <%= clear[loop_variables] %>,
23
+ i_value => (others => '0'),
24
+ i_mask => (others => '1'),
25
+ o_value => <%= value_out[loop_variables] %>,
26
+ o_value_unmasked => open
27
+ );
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:rs, :w0s, :w1s, :ws, :wos]) do
4
+ vhdl do
5
+ build do
6
+ input :clear, {
7
+ name: "i_#{full_name}_clear", width: width, array_size: array_size
8
+ }
9
+ output :value_out, {
10
+ name: "o_#{full_name}", 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
+ rs: 'RGGEN_READ_SET',
21
+ w0s: 'RGGEN_READ_DEFAULT',
22
+ w1s: 'RGGEN_READ_DEFAULT',
23
+ ws: 'RGGEN_READ_DEFAULT',
24
+ wos: 'RGGEN_READ_NONE'
25
+ }[bit_field.type]
26
+ end
27
+
28
+ def write_action
29
+ {
30
+ rs: 'RGGEN_WRITE_NONE',
31
+ w0s: 'RGGEN_WRITE_0_SET',
32
+ w1s: 'RGGEN_WRITE_1_SET',
33
+ ws: 'RGGEN_WRITE_SET',
34
+ wos: 'RGGEN_WRITE_SET'
35
+ }[bit_field.type]
36
+ end
37
+
38
+ def write_enable
39
+ bit_field.writable? && bin(1, 1) || bin(0, 1)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ INITIAL_VALUE => <%= initial_value %>,
5
+ SW_READ_ACTION => <%= read_action %>,
6
+ SW_WRITE_ONCE => <%= write_once %>
7
+ )
8
+ port map (
9
+ i_clk => <%= clock %>,
10
+ i_rst_n => <%= reset %>,
11
+ i_sw_valid => <%= bit_field_valid %>,
12
+ i_sw_read_mask => <%= bit_field_read_mask %>,
13
+ i_sw_write_enable => "1",
14
+ i_sw_write_mask => <%= bit_field_write_mask %>,
15
+ i_sw_write_data => <%= bit_field_write_data %>,
16
+ o_sw_read_data => <%= bit_field_read_data %>,
17
+ o_sw_value => <%= bit_field_value %>,
18
+ i_hw_write_enable => "0",
19
+ i_hw_write_data => (others => '0'),
20
+ i_hw_set => (others => '0'),
21
+ i_hw_clear => (others => '0'),
22
+ i_value => (others => '0'),
23
+ i_mask => (others => '1'),
24
+ o_value => <%= value_out[loop_variables] %>,
25
+ o_value_unmasked => open
26
+ );
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:rw, :w1, :wo, :wo1]) do
4
+ vhdl do
5
+ build do
6
+ output :value_out, {
7
+ name: "o_#{full_name}", width: width, array_size: array_size
8
+ }
9
+ end
10
+
11
+ main_code :bit_field, from_template: true
12
+
13
+ private
14
+
15
+ def read_action
16
+ bit_field.readable? && 'RGGEN_READ_DEFAULT' || 'RGGEN_READ_NONE'
17
+ end
18
+
19
+ def write_once
20
+ [:w1, :wo1].include?(bit_field.type)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ INITIAL_VALUE => <%= initial_value %>,
5
+ HW_CLEAR_WIDTH => 1
6
+ )
7
+ port map (
8
+ i_clk => <%= clock %>,
9
+ i_rst_n => <%= reset %>,
10
+ i_sw_valid => <%= bit_field_valid %>,
11
+ i_sw_read_mask => <%= bit_field_read_mask %>,
12
+ i_sw_write_enable => "1",
13
+ i_sw_write_mask => <%= bit_field_write_mask %>,
14
+ i_sw_write_data => <%= bit_field_write_data %>,
15
+ o_sw_read_data => <%= bit_field_read_data %>,
16
+ o_sw_value => <%= bit_field_value %>,
17
+ i_hw_write_enable => "0",
18
+ i_hw_write_data => (others => '0'),
19
+ i_hw_set => (others => '0'),
20
+ i_hw_clear => <%= clear_signal %>,
21
+ i_value => (others => '0'),
22
+ i_mask => (others => '1'),
23
+ o_value => <%= value_out[loop_variables] %>,
24
+ o_value_unmasked => open
25
+ );
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, :rwc) do
4
+ vhdl do
5
+ build do
6
+ unless bit_field.reference?
7
+ input :clear, {
8
+ name: "i_#{full_name}_clear", width: 1, array_size: array_size
9
+ }
10
+ end
11
+ output :value_out, {
12
+ name: "o_#{full_name}", width: width, array_size: array_size
13
+ }
14
+ end
15
+
16
+ main_code :bit_field, from_template: true
17
+
18
+ private
19
+
20
+ def clear_signal
21
+ reference_bit_field || clear[loop_variables]
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ INITIAL_VALUE => <%= initial_value %>,
5
+ SW_WRITE_ENABLE_POLARITY => <%= control_signal_polarity %>
6
+ )
7
+ port map (
8
+ i_clk => <%= clock %>,
9
+ i_rst_n => <%= reset %>,
10
+ i_sw_valid => <%= bit_field_valid %>,
11
+ i_sw_read_mask => <%= bit_field_read_mask %>,
12
+ i_sw_write_enable => <%= control_signal %>,
13
+ i_sw_write_mask => <%= bit_field_write_mask %>,
14
+ i_sw_write_data => <%= bit_field_write_data %>,
15
+ o_sw_read_data => <%= bit_field_read_data %>,
16
+ o_sw_value => <%= bit_field_value %>,
17
+ i_hw_write_enable => "0",
18
+ i_hw_write_data => (others => '0'),
19
+ i_hw_set => (others => '0'),
20
+ i_hw_clear => (others => '0'),
21
+ i_value => (others => '0'),
22
+ i_mask => (others => '1'),
23
+ o_value => <%= value_out[loop_variables] %>,
24
+ o_value_unmasked => open
25
+ );
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:rwe, :rwl]) do
4
+ vhdl 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}", width: width, array_size: array_size
14
+ }
15
+ end
16
+
17
+ main_code :bit_field, from_template: true
18
+
19
+ private
20
+
21
+ def enable_or_lock
22
+ { rwe: 'enable', rwl: 'lock' }[bit_field.type]
23
+ end
24
+
25
+ def control_signal_polarity
26
+ { rwe: 'RGGEN_ACTIVE_HIGH', rwl: 'RGGEN_ACTIVE_LOW' }[bit_field.type]
27
+ end
28
+
29
+ def control_signal
30
+ reference_bit_field || control[loop_variables]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ INITIAL_VALUE => <%= initial_value %>
5
+ )
6
+ port map (
7
+ i_clk => <%= clock %>,
8
+ i_rst_n => <%= reset %>,
9
+ i_sw_valid => <%= bit_field_valid %>,
10
+ i_sw_read_mask => <%= bit_field_read_mask %>,
11
+ i_sw_write_enable => "1",
12
+ i_sw_write_mask => <%= bit_field_write_mask %>,
13
+ i_sw_write_data => <%= bit_field_write_data %>,
14
+ o_sw_read_data => <%= bit_field_read_data %>,
15
+ o_sw_value => <%= bit_field_value %>,
16
+ i_hw_write_enable => <%= set_signal %>,
17
+ i_hw_write_data => <%= value_in[loop_variables] %>,
18
+ i_hw_set => (others => '0'),
19
+ i_hw_clear => (others => '0'),
20
+ i_value => (others => '0'),
21
+ i_mask => (others => '1'),
22
+ o_value => <%= value_out[loop_variables] %>,
23
+ o_value_unmasked => open
24
+ );
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, :rws) do
4
+ vhdl do
5
+ build do
6
+ unless bit_field.reference?
7
+ input :set, {
8
+ name: "i_#{full_name}_set", width: 1, array_size: array_size
9
+ }
10
+ end
11
+ input :value_in, {
12
+ name: "i_#{full_name}", width: width, array_size: array_size
13
+ }
14
+ output :value_out, {
15
+ name: "o_#{full_name}", width: width, array_size: array_size
16
+ }
17
+ end
18
+
19
+ main_code :bit_field, from_template: true
20
+
21
+ private
22
+
23
+ def set_signal
24
+ reference_bit_field || set[loop_variables]
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ INITIAL_VALUE => <%= initial_value %>,
5
+ SW_READ_ACTION => <%= read_action %>,
6
+ SW_WRITE_ACTION => <%= write_action %>
7
+ )
8
+ port map (
9
+ i_clk => <%= clock %>,
10
+ i_rst_n => <%= reset %>,
11
+ i_sw_valid => <%= bit_field_valid %>,
12
+ i_sw_read_mask => <%= bit_field_read_mask %>,
13
+ i_sw_write_enable => "1",
14
+ i_sw_write_mask => <%= bit_field_write_mask %>,
15
+ i_sw_write_data => <%= bit_field_write_data %>,
16
+ o_sw_read_data => <%= bit_field_read_data %>,
17
+ o_sw_value => <%= bit_field_value %>,
18
+ i_hw_write_enable => "0",
19
+ i_hw_write_data => (others => '0'),
20
+ i_hw_set => (others => '0'),
21
+ i_hw_clear => (others => '0'),
22
+ i_value => (others => '0'),
23
+ i_mask => (others => '1'),
24
+ o_value => <%= value_out[loop_variables] %>,
25
+ o_value_unmasked => open
26
+ );
@@ -0,0 +1,36 @@
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
+ vhdl do
7
+ build do
8
+ output :value_out, {
9
+ name: "o_#{full_name}", width: width, array_size: array_size
10
+ }
11
+ end
12
+
13
+ main_code :bit_field, from_template: true
14
+
15
+ private
16
+
17
+ def read_action
18
+ read_set? && 'RGGEN_READ_SET' || 'RGGEN_READ_CLEAR'
19
+ end
20
+
21
+ def read_set?
22
+ [:w0crs, :w1crs, :wcrs].include?(bit_field.type)
23
+ end
24
+
25
+ def write_action
26
+ {
27
+ w0crs: 'RGGEN_WRITE_0_CLEAR',
28
+ w0src: 'RGGEN_WRITE_0_SET',
29
+ w1crs: 'RGGEN_WRITE_1_CLEAR',
30
+ w1src: 'RGGEN_WRITE_1_SET',
31
+ wcrs: 'RGGEN_WRITE_CLEAR',
32
+ wsrc: 'RGGEN_WRITE_SET'
33
+ }[bit_field.type]
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,25 @@
1
+ u_bit_field: entity work.rggen_bit_field
2
+ generic map (
3
+ WIDTH => <%= width %>,
4
+ INITIAL_VALUE => <%= initial_value %>,
5
+ SW_WRITE_ACTION => <%= write_action %>
6
+ )
7
+ port map (
8
+ i_clk => <%= clock %>,
9
+ i_rst_n => <%= reset %>,
10
+ i_sw_valid => <%= bit_field_valid %>,
11
+ i_sw_read_mask => <%= bit_field_read_mask %>,
12
+ i_sw_write_enable => "1",
13
+ i_sw_write_mask => <%= bit_field_write_mask %>,
14
+ i_sw_write_data => <%= bit_field_write_data %>,
15
+ o_sw_read_data => <%= bit_field_read_data %>,
16
+ o_sw_value => <%= bit_field_value %>,
17
+ i_hw_write_enable => "0",
18
+ i_hw_write_data => (others => '0'),
19
+ i_hw_set => (others => '0'),
20
+ i_hw_clear => (others => '0'),
21
+ i_value => (others => '0'),
22
+ i_mask => (others => '1'),
23
+ o_value => <%= value_out[loop_variables] %>,
24
+ o_value_unmasked => open
25
+ );
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ RgGen.define_list_item_feature(:bit_field, :type, [:w0t, :w1t]) do
4
+ vhdl do
5
+ build do
6
+ output :value_out, {
7
+ name: "o_#{full_name}", width: width, array_size: array_size
8
+ }
9
+ end
10
+
11
+ main_code :bit_field, from_template: true
12
+
13
+ private
14
+
15
+ def write_action
16
+ {
17
+ w0t: 'RGGEN_WRITE_0_TOGGLE',
18
+ w1t: 'RGGEN_WRITE_1_TOGGLE'
19
+ }[bit_field.type]
20
+ end
21
+ end
22
+ end