rggen 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/c_header/LICENSE +21 -0
- data/{c → c_header}/rggen.h +0 -0
- data/lib/rggen/builtins.rb +2 -5
- data/lib/rggen/builtins/bit_field/type.rb +22 -7
- data/lib/rggen/builtins/bit_field/types/ro.erb +2 -2
- data/lib/rggen/builtins/bit_field/types/ro.rb +2 -2
- data/lib/rggen/builtins/bit_field/types/rw.erb +5 -9
- data/lib/rggen/builtins/bit_field/types/rw.rb +5 -5
- data/lib/rggen/builtins/bit_field/types/rwl_rwe.erb +3 -7
- data/lib/rggen/builtins/bit_field/types/rwl_rwe.rb +6 -7
- data/lib/rggen/builtins/bit_field/types/w0c_w1c.erb +8 -12
- data/lib/rggen/builtins/bit_field/types/w0c_w1c.rb +5 -2
- data/lib/rggen/builtins/bit_field/types/w0s_w1s.erb +8 -12
- data/lib/rggen/builtins/bit_field/types/w0s_w1s.rb +3 -6
- data/lib/rggen/builtins/register/array.rb +0 -93
- data/lib/rggen/builtins/register/reg_model.rb +1 -1
- data/lib/rggen/builtins/register/rtl_top.rb +68 -0
- data/lib/rggen/builtins/register/type.rb +74 -0
- data/lib/rggen/builtins/register/types/default.erb +10 -0
- data/lib/rggen/builtins/register/types/external.erb +11 -0
- data/lib/rggen/builtins/register/types/external.rb +11 -0
- data/lib/rggen/builtins/register/types/indirect.erb +13 -0
- data/lib/rggen/builtins/register/types/indirect.rb +43 -0
- data/lib/rggen/builtins/register_block/clock_reset.rb +2 -2
- data/lib/rggen/builtins/register_block/host_if.rb +11 -12
- data/lib/rggen/builtins/register_block/host_ifs/apb.erb +7 -25
- data/lib/rggen/builtins/register_block/host_ifs/apb.rb +4 -13
- data/lib/rggen/builtins/register_block/host_ifs/axi4lite.erb +6 -34
- data/lib/rggen/builtins/register_block/host_ifs/axi4lite.rb +8 -30
- data/lib/rggen/builtins/register_block/irq_controller.rb +4 -4
- data/lib/rggen/builtins/register_block/rtl_top.erb +7 -0
- data/lib/rggen/builtins/register_block/rtl_top.rb +28 -0
- data/lib/rggen/core_components.rb +3 -0
- data/lib/rggen/core_components/ral/item.rb +2 -6
- data/lib/rggen/core_components/rtl/component.rb +8 -8
- data/lib/rggen/core_components/rtl/item.rb +41 -38
- data/lib/rggen/core_components/verilog_utility.rb +23 -4
- data/lib/rggen/core_components/verilog_utility/declaration.rb +14 -4
- data/lib/rggen/core_components/verilog_utility/identifier.rb +19 -0
- data/lib/rggen/core_components/verilog_utility/interface_instantiation.rb +33 -0
- data/lib/rggen/core_components/verilog_utility/interface_port_declaration.rb +29 -0
- data/lib/rggen/core_components/verilog_utility/local_scope.rb +64 -0
- data/lib/rggen/core_extensions/facets.rb +1 -1
- data/lib/rggen/core_extensions/forwardable.rb +1 -1
- data/lib/rggen/version.rb +2 -2
- data/ral/LICENSE +21 -0
- data/ral/rggen_ral_macros.svh +1 -4
- data/ral/rggen_ral_reg.svh +35 -3
- data/rtl/LICENSE +21 -0
- data/rtl/compile.f +21 -6
- data/rtl/rggen_address_decoder.sv +23 -0
- data/rtl/rggen_apb_if.sv +41 -0
- data/rtl/rggen_axi4lite_if.sv +68 -0
- data/rtl/rggen_bit_field_if.sv +28 -0
- data/rtl/rggen_bit_field_ro.sv +9 -0
- data/rtl/rggen_bit_field_rw.sv +25 -0
- data/rtl/rggen_bit_field_rwl_rwe.sv +29 -0
- data/rtl/rggen_bit_field_w01s_w01c.sv +55 -0
- data/rtl/rggen_bus_if.sv +43 -0
- data/rtl/rggen_bus_splitter.sv +87 -0
- data/rtl/rggen_default_register.sv +15 -0
- data/rtl/rggen_external_register.sv +83 -0
- data/rtl/rggen_host_if_apb.sv +29 -0
- data/rtl/rggen_host_if_axi4lite.sv +14 -0
- data/rtl/rggen_indirect_register.sv +21 -0
- data/rtl/{register_block/rggen_irq_controller.sv → rggen_irq_controller.sv} +0 -0
- data/rtl/rggen_register_base.sv +57 -0
- data/rtl/rggen_register_if.sv +42 -0
- data/rtl/rggen_rtl_pkg.sv +23 -0
- data/sample/LICENSE +21 -0
- data/sample/sample_0.sv +315 -444
- data/sample/sample_0_ral_pkg.sv +7 -7
- data/sample/sample_1.sv +104 -162
- data/sample/sample_1_ral_pkg.sv +3 -3
- data/sample/sample_setup.rb +2 -2
- data/setup/default.rb +3 -3
- metadata +35 -23
- data/lib/rggen/builtins/register/address_decoder.erb +0 -12
- data/lib/rggen/builtins/register/address_decoder.rb +0 -82
- data/lib/rggen/builtins/register/bus_exporter.erb +0 -28
- data/lib/rggen/builtins/register/bus_exporter.rb +0 -52
- data/lib/rggen/builtins/register/read_data.rb +0 -61
- data/lib/rggen/builtins/register_block/response_mux.erb +0 -18
- data/lib/rggen/builtins/register_block/response_mux.rb +0 -47
- data/lib/rggen/builtins/register_block/top_module.rb +0 -20
- data/rtl/bit_field/rggen_bit_field_common.svh +0 -15
- data/rtl/bit_field/rggen_bit_field_ro.sv +0 -8
- data/rtl/bit_field/rggen_bit_field_rw.sv +0 -27
- data/rtl/bit_field/rggen_bit_field_rwl_rwe.sv +0 -49
- data/rtl/bit_field/rggen_bit_field_w01s_w01c.sv +0 -67
- data/rtl/register/rggen_address_decoder.sv +0 -37
- data/rtl/register/rggen_bus_exporter.sv +0 -96
- data/rtl/register_block/rggen_host_if_apb.sv +0 -42
- data/rtl/register_block/rggen_host_if_axi4lite.sv +0 -257
- data/rtl/register_block/rggen_host_if_common.svh +0 -9
- data/rtl/register_block/rggen_response_mux.sv +0 -113
@@ -173,6 +173,80 @@ list_item :register, :type do
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
+
rtl do
|
177
|
+
item_base do
|
178
|
+
export :register_if
|
179
|
+
|
180
|
+
delegate [:data_width, :byte_width] => :configuration
|
181
|
+
delegate [:local_address_width] => :register_block
|
182
|
+
delegate [:loop_variables, :local_index, :dimensions] => :register
|
183
|
+
|
184
|
+
build do
|
185
|
+
interface :register, :bit_field_if,
|
186
|
+
type: :rggen_bit_field_if,
|
187
|
+
name: :bit_field_if,
|
188
|
+
parameters: [data_width] if total_bit_fields > 0
|
189
|
+
end
|
190
|
+
|
191
|
+
def register_if
|
192
|
+
register_block.register_if[register.index]
|
193
|
+
end
|
194
|
+
|
195
|
+
private
|
196
|
+
|
197
|
+
def actual_bit_fields
|
198
|
+
@non_reserved_bit_fields ||= register.bit_fields.reject(&:reserved?)
|
199
|
+
end
|
200
|
+
|
201
|
+
def total_bit_fields
|
202
|
+
actual_bit_fields.size
|
203
|
+
end
|
204
|
+
|
205
|
+
def start_address
|
206
|
+
address_code(register.start_address)
|
207
|
+
end
|
208
|
+
|
209
|
+
def end_address
|
210
|
+
return address_code(register.end_address) unless register.array?
|
211
|
+
address_code(
|
212
|
+
register.start_address + byte_width - 1
|
213
|
+
)
|
214
|
+
end
|
215
|
+
|
216
|
+
def address_code(address)
|
217
|
+
base = hex(address, local_address_width)
|
218
|
+
if register.array? && register.multiple?
|
219
|
+
increment_value = hex(byte_width, local_address_width)
|
220
|
+
"#{base} + #{increment_value} * #{local_index}"
|
221
|
+
else
|
222
|
+
base
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def valid_bits
|
227
|
+
hex(valid_bits_value, data_width)
|
228
|
+
end
|
229
|
+
|
230
|
+
def valid_bits_value
|
231
|
+
actual_bit_fields.inject(0) do |bits, bit_field|
|
232
|
+
bits |= (((1 << bit_field.width) - 1) << bit_field.lsb)
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
default_item do
|
238
|
+
generate_code :register do
|
239
|
+
process_template File.join(__dir__, 'types', 'default.erb')
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
factory do
|
244
|
+
def select_target_item(_, register)
|
245
|
+
@target_items[register.type]
|
246
|
+
end
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
176
250
|
c_header do
|
177
251
|
item_base do
|
178
252
|
define_helpers do
|
@@ -0,0 +1,10 @@
|
|
1
|
+
rggen_default_register #(
|
2
|
+
.ADDRESS_WIDTH (<%= local_address_width %>),
|
3
|
+
.START_ADDRESS (<%= start_address %>),
|
4
|
+
.END_ADDRESS (<%= end_address %>),
|
5
|
+
.DATA_WIDTH (<%= data_width %>),
|
6
|
+
.VALID_BITS (<%= valid_bits %>)
|
7
|
+
) u_<%= register.name %> (
|
8
|
+
.register_if (<%= register.register_if %>),
|
9
|
+
.bit_field_if (<%= bit_field_if %>)
|
10
|
+
);
|
@@ -0,0 +1,11 @@
|
|
1
|
+
rggen_external_register #(
|
2
|
+
.ADDRESS_WIDTH (<%= local_address_width %>),
|
3
|
+
.START_ADDRESS (<%= start_address %>),
|
4
|
+
.END_ADDRESS (<%= end_address %>),
|
5
|
+
.DATA_WIDTH (<%= configuration.data_width %>)
|
6
|
+
) u_<%= register.name %> (
|
7
|
+
.clk (<%= register_block.clock %>),
|
8
|
+
.rst_n (<%= register_block.reset %>),
|
9
|
+
.register_if (<%= register.register_if %>),
|
10
|
+
.bus_if (<%= bus_if %>)
|
11
|
+
);
|
@@ -5,6 +5,17 @@ list_item :register, :type, :external do
|
|
5
5
|
need_no_bit_fields
|
6
6
|
end
|
7
7
|
|
8
|
+
rtl do
|
9
|
+
build do
|
10
|
+
interface_port :register_block, :bus_if,
|
11
|
+
name: "#{register.name}_bus_if",
|
12
|
+
type: :rggen_bus_if,
|
13
|
+
modport: :master
|
14
|
+
end
|
15
|
+
|
16
|
+
generate_code_from_template :register
|
17
|
+
end
|
18
|
+
|
8
19
|
c_header do
|
9
20
|
delegate [:name, :byte_size] => :register
|
10
21
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
rggen_indirect_register #(
|
2
|
+
.ADDRESS_WIDTH (<%= local_address_width %>),
|
3
|
+
.START_ADDRESS (<%= start_address %>),
|
4
|
+
.END_ADDRESS (<%= end_address %>),
|
5
|
+
.INDEX_WIDTH (<%= indirect_index_width %>),
|
6
|
+
.INDEX_VALUE (<%= indirect_index_value %>),
|
7
|
+
.DATA_WIDTH (<%= data_width %>),
|
8
|
+
.VALID_BITS (<%= valid_bits %>)
|
9
|
+
) u_<%= register.name %> (
|
10
|
+
.register_if (<%= register.register_if %>),
|
11
|
+
.bit_field_if (<%= bit_field_if %>),
|
12
|
+
.i_index (<%= indirect_index %>)
|
13
|
+
);
|
@@ -126,6 +126,49 @@ list_item :register, :type, :indirect do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
+
rtl do
|
130
|
+
build do
|
131
|
+
logic :register, :indirect_index, width: indirect_index_width
|
132
|
+
end
|
133
|
+
|
134
|
+
generate_code :register do |code|
|
135
|
+
code << indirect_index_assignment << nl
|
136
|
+
code << process_template
|
137
|
+
end
|
138
|
+
|
139
|
+
def indirect_index_fields
|
140
|
+
@indirect_index_fields ||= register.indexes.map do |i|
|
141
|
+
register_block.bit_fields.find_by(name: i.name)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def indirect_index_assignment
|
146
|
+
assign(
|
147
|
+
indirect_index, concat(indirect_index_fields.map(&:value))
|
148
|
+
)
|
149
|
+
end
|
150
|
+
|
151
|
+
def indirect_index_width
|
152
|
+
indirect_index_fields.sum(0, &:width)
|
153
|
+
end
|
154
|
+
|
155
|
+
def indirect_index_value
|
156
|
+
concat(indirect_index_values)
|
157
|
+
end
|
158
|
+
|
159
|
+
def indirect_index_values
|
160
|
+
variables = loop_variables
|
161
|
+
register.indexes.map.with_index do |index, i|
|
162
|
+
if index.value
|
163
|
+
hex(index.value, indirect_index_fields[i].width)
|
164
|
+
else
|
165
|
+
variable = variables.shift
|
166
|
+
variable[indirect_index_fields[i].width - 1, 0]
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
129
172
|
c_header do
|
130
173
|
address_struct_member do
|
131
174
|
variable_declaration(name: register.name, data_type: data_type)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
simple_item :register_block, :clock_reset do
|
2
2
|
rtl do
|
3
3
|
build do
|
4
|
-
input :clock, name: 'clk' , width: 1
|
5
|
-
input :reset, name: 'rst_n', width: 1
|
4
|
+
input :register_block, :clock, name: 'clk' , width: 1
|
5
|
+
input :register_block, :reset, name: 'rst_n', width: 1
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
@@ -40,19 +40,18 @@ list_item :register_block, :host_if do
|
|
40
40
|
shared_context.enabled_host_ifs = @enabled_items
|
41
41
|
|
42
42
|
item_base do
|
43
|
+
delegate [:local_address_width, :clock, :reset] => :register_block
|
44
|
+
delegate [:data_width] => :configuration
|
45
|
+
|
43
46
|
build do
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
logic :response_ready, width: 1
|
53
|
-
logic :read_data , width: configuration.data_width
|
54
|
-
logic :status , width: 2
|
55
|
-
end
|
47
|
+
interface :register_block, :register_if,
|
48
|
+
type: :rggen_register_if,
|
49
|
+
parameters: [local_address_width, data_width],
|
50
|
+
dimensions: [total_registers]
|
51
|
+
end
|
52
|
+
|
53
|
+
def total_registers
|
54
|
+
register_block.registers.sum(0, &:count)
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
@@ -1,28 +1,10 @@
|
|
1
1
|
rggen_host_if_apb #(
|
2
|
-
.
|
3
|
-
.
|
4
|
-
.
|
2
|
+
.LOCAL_ADDRESS_WIDTH (<%= local_address_width %>),
|
3
|
+
.DATA_WIDTH (<%= data_width %>),
|
4
|
+
.TOTAL_REGISTERS (<%= total_registers %>)
|
5
5
|
) u_host_if (
|
6
|
-
.clk
|
7
|
-
.rst_n
|
8
|
-
.
|
9
|
-
.
|
10
|
-
.i_psel (<%= apb.psel %>),
|
11
|
-
.i_penable (<%= apb.penable %>),
|
12
|
-
.i_pwrite (<%= apb.pwrite %>),
|
13
|
-
.i_pwdata (<%= apb.pwdata %>),
|
14
|
-
.i_pstrb (<%= apb.pstrb %>),
|
15
|
-
.o_pready (<%= apb.pready %>),
|
16
|
-
.o_prdata (<%= apb.prdata %>),
|
17
|
-
.o_pslverr (<%= apb.pslverr %>),
|
18
|
-
.o_command_valid (<%= host_if.command_valid %>),
|
19
|
-
.o_write (<%= host_if.write %>),
|
20
|
-
.o_read (<%= host_if.read %>),
|
21
|
-
.o_address (<%= host_if.address %>),
|
22
|
-
.o_strobe (<%= host_if.strobe %>),
|
23
|
-
.o_write_data (<%= host_if.write_data %>),
|
24
|
-
.o_write_mask (<%= host_if.write_mask %>),
|
25
|
-
.i_response_ready (<%= host_if.response_ready %>),
|
26
|
-
.i_read_data (<%= host_if.read_data %>),
|
27
|
-
.i_status (<%= host_if.status %>)
|
6
|
+
.clk (<%= clock %>),
|
7
|
+
.rst_n (<%= reset %>),
|
8
|
+
.apb_if (<%= apb_if %>),
|
9
|
+
.register_if (<%= register_if %>)
|
28
10
|
);
|
@@ -14,20 +14,11 @@ list_item :register_block, :host_if, :apb do
|
|
14
14
|
|
15
15
|
rtl do
|
16
16
|
build do
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
input :psel , name: 'i_psel' , width: 1
|
21
|
-
input :penable, name: 'i_penable', width: 1
|
22
|
-
input :pwrite , name: 'i_pwrite' , width: 1
|
23
|
-
input :pwdata , name: 'i_pwdata' , width: configuration.data_width
|
24
|
-
input :pstrb , name: 'i_pstrb' , width: configuration.byte_width
|
25
|
-
output :pready , name: 'o_pready' , width: 1
|
26
|
-
output :prdata , name: 'o_prdata' , width: configuration.data_width
|
27
|
-
output :pslverr, name: 'o_pslverr', width: 1
|
28
|
-
end
|
17
|
+
interface_port :register_block, :apb_if,
|
18
|
+
type: :rggen_apb_if,
|
19
|
+
modport: :slave
|
29
20
|
end
|
30
21
|
|
31
|
-
generate_code_from_template :
|
22
|
+
generate_code_from_template :register_block
|
32
23
|
end
|
33
24
|
end
|
@@ -1,38 +1,10 @@
|
|
1
1
|
rggen_host_if_axi4lite #(
|
2
|
-
.DATA_WIDTH (<%= data_width %>),
|
3
|
-
.HOST_ADDRESS_WIDTH (<%= address_width %>),
|
4
2
|
.LOCAL_ADDRESS_WIDTH (<%= local_address_width %>),
|
5
|
-
.
|
3
|
+
.DATA_WIDTH (<%= data_width %>),
|
4
|
+
.ACCESS_PRIORITY (<%= access_priority %>)
|
6
5
|
) u_host_if (
|
7
|
-
.clk
|
8
|
-
.rst_n
|
9
|
-
.
|
10
|
-
.
|
11
|
-
.i_awaddr (<%= axi4lite.awaddr %>),
|
12
|
-
.i_awprot (<%= axi4lite.awprot %>),
|
13
|
-
.i_wvalid (<%= axi4lite.wvalid %>),
|
14
|
-
.o_wready (<%= axi4lite.wready %>),
|
15
|
-
.i_wdata (<%= axi4lite.wdata %>),
|
16
|
-
.i_wstrb (<%= axi4lite.wstrb %>),
|
17
|
-
.o_bvalid (<%= axi4lite.bvalid %>),
|
18
|
-
.i_bready (<%= axi4lite.bready %>),
|
19
|
-
.o_bresp (<%= axi4lite.bresp %>),
|
20
|
-
.i_arvalid (<%= axi4lite.arvalid %>),
|
21
|
-
.o_arready (<%= axi4lite.arready %>),
|
22
|
-
.i_araddr (<%= axi4lite.araddr %>),
|
23
|
-
.i_arprot (<%= axi4lite.arprot %>),
|
24
|
-
.o_rvalid (<%= axi4lite.rvalid %>),
|
25
|
-
.i_rready (<%= axi4lite.rready %>),
|
26
|
-
.o_rdata (<%= axi4lite.rdata %>),
|
27
|
-
.o_rresp (<%= axi4lite.rresp %>),
|
28
|
-
.o_command_valid (<%= host_if.command_valid %>),
|
29
|
-
.o_write (<%= host_if.write %>),
|
30
|
-
.o_read (<%= host_if.read %>),
|
31
|
-
.o_address (<%= host_if.address %>),
|
32
|
-
.o_strobe (<%= host_if.strobe %>),
|
33
|
-
.o_write_data (<%= host_if.write_data %>),
|
34
|
-
.o_write_mask (<%= host_if.write_mask %>),
|
35
|
-
.i_response_ready (<%= host_if.response_ready %>),
|
36
|
-
.i_read_data (<%= host_if.read_data %>),
|
37
|
-
.i_status (<%= host_if.status %>)
|
6
|
+
.clk (<%= clock %>),
|
7
|
+
.rst_n (<%= reset %>),
|
8
|
+
.axi4lite_if (<%= axi4lite_if %>),
|
9
|
+
.register_if (<%= register_if %>)
|
38
10
|
);
|
@@ -9,38 +9,16 @@ list_item :register_block, :host_if, :axi4lite do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
rtl do
|
12
|
-
delegate [
|
13
|
-
:address_width, :data_width, :byte_width
|
14
|
-
] => :configuration
|
15
|
-
delegate [
|
16
|
-
:local_address_width, :clock, :reset
|
17
|
-
] => :register_block
|
18
|
-
|
19
12
|
build do
|
20
|
-
parameter :
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
output :wready , name: 'o_wready' , width: 1
|
28
|
-
input :wdata , name: 'i_wdata' , width: data_width
|
29
|
-
input :wstrb , name: 'i_wstrb' , width: byte_width
|
30
|
-
output :bvalid , name: 'o_bvalid' , width: 1
|
31
|
-
input :bready , name: 'i_bready' , width: 1
|
32
|
-
output :bresp , name: 'o_bresp' , width: 2
|
33
|
-
input :arvalid, name: 'i_arvalid', width: 1
|
34
|
-
output :arready, name: 'o_arready', width: 1
|
35
|
-
input :araddr , name: 'i_araddr' , width: address_width
|
36
|
-
input :arprot , name: 'i_arprot' , width: 3
|
37
|
-
output :rvalid , name: 'o_rvalid' , width: 1
|
38
|
-
input :rready , name: 'i_rready' , width: 1
|
39
|
-
output :rdata , name: 'o_rdata' , width: data_width
|
40
|
-
output :rresp , name: 'o_rresp' , width: 2
|
41
|
-
end
|
13
|
+
parameter :register_block, :access_priority,
|
14
|
+
name: 'ACCESS_PRIORITY',
|
15
|
+
type: :'rggen_rtl_pkg::rggen_direction',
|
16
|
+
default: :'rggen_rtl_pkg::RGGEN_WRITE'
|
17
|
+
interface_port :register_block, :axi4lite_if,
|
18
|
+
type: :rggen_axi4lite_if,
|
19
|
+
modport: :slave
|
42
20
|
end
|
43
21
|
|
44
|
-
generate_code_from_template :
|
22
|
+
generate_code_from_template :register_block
|
45
23
|
end
|
46
24
|
end
|
@@ -3,12 +3,12 @@ simple_item :register_block, :irq_controller do
|
|
3
3
|
available? { total_interrupts > 0 }
|
4
4
|
|
5
5
|
build do
|
6
|
-
output :irq, width: 1 , name: 'o_irq'
|
7
|
-
logic :ier, width: total_interrupts
|
8
|
-
logic :isr, width: total_interrupts
|
6
|
+
output :register_block, :irq, width: 1 , name: 'o_irq'
|
7
|
+
logic :register_block, :ier, width: total_interrupts
|
8
|
+
logic :register_block, :isr, width: total_interrupts
|
9
9
|
end
|
10
10
|
|
11
|
-
generate_code :
|
11
|
+
generate_code :register_block do |code|
|
12
12
|
code << assign_ier << nl
|
13
13
|
code << assign_isr << nl
|
14
14
|
code << process_template
|
@@ -0,0 +1,7 @@
|
|
1
|
+
`define rggen_connect_bit_field_if(RIF, FIF, MSB, LSB) \
|
2
|
+
assign FIF.read_access = RIF.read_access; \
|
3
|
+
assign FIF.write_access = RIF.write_access; \
|
4
|
+
assign FIF.write_data = RIF.write_data[MSB:LSB]; \
|
5
|
+
assign FIF.write_mask = RIF.write_mask[MSB:LSB]; \
|
6
|
+
assign RIF.value[MSB:LSB] = FIF.value; \
|
7
|
+
assign RIF.read_data[MSB:LSB] = FIF.read_data;
|
@@ -0,0 +1,28 @@
|
|
1
|
+
define_simple_item :register_block, :rtl_top do
|
2
|
+
rtl do
|
3
|
+
write_file '<%= register_block.name %>.sv' do |f|
|
4
|
+
f.body { source_file_body }
|
5
|
+
end
|
6
|
+
|
7
|
+
def source_file_body
|
8
|
+
module_definition register_block.name do |m|
|
9
|
+
m.parameters register_block.parameter_declarations(:register_block)
|
10
|
+
m.ports register_block.port_declarations(:register_block)
|
11
|
+
m.signals register_block.signal_declarations(:register_block)
|
12
|
+
m.body { |code| module_body(code) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def module_body(code)
|
17
|
+
register_block.generate_code(:register_block, :top_down, code)
|
18
|
+
end
|
19
|
+
|
20
|
+
generate_pre_code :register_block do
|
21
|
+
process_template
|
22
|
+
end
|
23
|
+
|
24
|
+
generate_post_code :register_block do
|
25
|
+
:'`undef rggen_connect_bit_field_if'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|