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
data/rtl/rggen_bus_if.sv
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
interface rggen_bus_if #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter int DATA_WIDTH = 32
|
4
|
+
)();
|
5
|
+
import rggen_rtl_pkg::*;
|
6
|
+
|
7
|
+
logic request;
|
8
|
+
logic [ADDRESS_WIDTH-1:0] address;
|
9
|
+
rggen_direction direction;
|
10
|
+
logic [DATA_WIDTH-1:0] write_data;
|
11
|
+
logic [DATA_WIDTH/8-1:0] write_strobe;
|
12
|
+
logic done;
|
13
|
+
logic read_done;
|
14
|
+
logic write_done;
|
15
|
+
logic [DATA_WIDTH-1:0] read_data;
|
16
|
+
rggen_status status;
|
17
|
+
|
18
|
+
modport master (
|
19
|
+
output request,
|
20
|
+
output address,
|
21
|
+
output direction,
|
22
|
+
output write_data,
|
23
|
+
output write_strobe,
|
24
|
+
input done,
|
25
|
+
input read_done,
|
26
|
+
input write_done,
|
27
|
+
input read_data,
|
28
|
+
input status
|
29
|
+
);
|
30
|
+
|
31
|
+
modport slave (
|
32
|
+
input request,
|
33
|
+
input address,
|
34
|
+
input direction,
|
35
|
+
input write_data,
|
36
|
+
input write_strobe,
|
37
|
+
output done,
|
38
|
+
output read_done,
|
39
|
+
output write_done,
|
40
|
+
output read_data,
|
41
|
+
output status
|
42
|
+
);
|
43
|
+
endinterface
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module rggen_bus_splitter #(
|
2
|
+
parameter int DATA_WIDTH = 32,
|
3
|
+
parameter int TOTAL_REGISTERS = 1
|
4
|
+
)(
|
5
|
+
input clk,
|
6
|
+
input rst_n,
|
7
|
+
rggen_bus_if.slave bus_if,
|
8
|
+
rggen_register_if.master register_if[TOTAL_REGISTERS]
|
9
|
+
);
|
10
|
+
import rggen_rtl_pkg::*;
|
11
|
+
|
12
|
+
localparam INDEX_WIDTH = $clog2(TOTAL_REGISTERS+1);
|
13
|
+
|
14
|
+
typedef struct packed {
|
15
|
+
logic [DATA_WIDTH-1:0] read_data;
|
16
|
+
rggen_status status;
|
17
|
+
} s_response;
|
18
|
+
|
19
|
+
logic [TOTAL_REGISTERS:0] select;
|
20
|
+
logic [TOTAL_REGISTERS:0] ready;
|
21
|
+
s_response response[TOTAL_REGISTERS+1];
|
22
|
+
logic response_ready;
|
23
|
+
logic no_register_selected;
|
24
|
+
logic done;
|
25
|
+
logic read_done;
|
26
|
+
logic write_done;
|
27
|
+
s_response selected_response;
|
28
|
+
genvar g_i;
|
29
|
+
|
30
|
+
assign bus_if.done = done;
|
31
|
+
assign bus_if.read_done = read_done;
|
32
|
+
assign bus_if.write_done = write_done;
|
33
|
+
assign bus_if.read_data = selected_response.read_data;
|
34
|
+
assign bus_if.status = selected_response.status;
|
35
|
+
|
36
|
+
generate for (g_i = 0;g_i < TOTAL_REGISTERS;++g_i) begin : g
|
37
|
+
assign register_if[g_i].request = bus_if.request;
|
38
|
+
assign register_if[g_i].address = bus_if.address;
|
39
|
+
assign register_if[g_i].direction = bus_if.direction;
|
40
|
+
assign register_if[g_i].write_data = bus_if.write_data;
|
41
|
+
assign register_if[g_i].write_strobe = bus_if.write_strobe;
|
42
|
+
assign select[g_i] = register_if[g_i].select;
|
43
|
+
assign ready[g_i] = register_if[g_i].ready;
|
44
|
+
assign response[g_i].read_data = register_if[g_i].read_data;
|
45
|
+
assign response[g_i].status = register_if[g_i].status;
|
46
|
+
end endgenerate
|
47
|
+
|
48
|
+
// dummy response
|
49
|
+
assign no_register_selected = ~|select[TOTAL_REGISTERS-1:0];
|
50
|
+
assign select[TOTAL_REGISTERS] = no_register_selected;
|
51
|
+
assign ready[TOTAL_REGISTERS] = no_register_selected;
|
52
|
+
assign response[TOTAL_REGISTERS] = '{read_data: '0, status: RGGEN_SLAVE_ERROR};
|
53
|
+
|
54
|
+
assign response_ready = |ready;
|
55
|
+
always_ff @(posedge clk, negedge rst_n) begin
|
56
|
+
if (!rst_n) begin
|
57
|
+
done <= '0;
|
58
|
+
read_done <= '0;
|
59
|
+
write_done <= '0;
|
60
|
+
selected_response <= '{read_data: '0, status: RGGEN_OKAY};
|
61
|
+
end
|
62
|
+
else if (bus_if.request && response_ready && (!done)) begin
|
63
|
+
done <= '1;
|
64
|
+
write_done <= (bus_if.direction == RGGEN_WRITE) ? '1 : '0;
|
65
|
+
read_done <= (bus_if.direction == RGGEN_READ ) ? '1 : '0;
|
66
|
+
selected_response <= response[calc_index()];
|
67
|
+
end
|
68
|
+
else begin
|
69
|
+
done <= '0;
|
70
|
+
read_done <= '0;
|
71
|
+
write_done <= '0;
|
72
|
+
selected_response <= '{read_data: '0, status: RGGEN_OKAY};
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
function automatic logic [INDEX_WIDTH-1:0] calc_index();
|
77
|
+
logic [INDEX_WIDTH-1:0] index;
|
78
|
+
for (int i = 0;i < INDEX_WIDTH;++i) begin
|
79
|
+
logic [TOTAL_REGISTERS:0] temp;
|
80
|
+
for (int j = 0;j <= TOTAL_REGISTERS;++j) begin
|
81
|
+
temp[j] = j[i] & select[j];
|
82
|
+
end
|
83
|
+
index[i] = |temp;
|
84
|
+
end
|
85
|
+
return index;
|
86
|
+
endfunction
|
87
|
+
endmodule
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module rggen_default_register #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter bit [ADDRESS_WIDTH-1:0] START_ADDRESS = '0,
|
4
|
+
parameter bit [ADDRESS_WIDTH-1:0] END_ADDRESS = '0,
|
5
|
+
parameter int DATA_WIDTH = 32,
|
6
|
+
parameter bit [DATA_WIDTH-1:0] VALID_BITS = '0
|
7
|
+
)(
|
8
|
+
rggen_register_if.slave register_if,
|
9
|
+
rggen_bit_field_if.master bit_field_if
|
10
|
+
);
|
11
|
+
rggen_register_base #(
|
12
|
+
ADDRESS_WIDTH, START_ADDRESS, END_ADDRESS,
|
13
|
+
DATA_WIDTH, VALID_BITS
|
14
|
+
) u_register_base (register_if, bit_field_if, 1'b1);
|
15
|
+
endmodule
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module rggen_external_register #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter bit [ADDRESS_WIDTH-1:0] START_ADDRESS = '0,
|
4
|
+
parameter bit [ADDRESS_WIDTH-1:0] END_ADDRESS = '0,
|
5
|
+
parameter int DATA_WIDTH = 32
|
6
|
+
)(
|
7
|
+
input clk,
|
8
|
+
input rst_n,
|
9
|
+
rggen_register_if.slave register_if,
|
10
|
+
rggen_bus_if.master bus_if
|
11
|
+
);
|
12
|
+
import rggen_rtl_pkg::*;
|
13
|
+
|
14
|
+
localparam int EXTERNAL_SIZE = END_ADDRESS - START_ADDRESS + 1;
|
15
|
+
localparam int EXTERNAL_ADDRESS_WIDTH = $clog2(EXTERNAL_SIZE);
|
16
|
+
|
17
|
+
logic address_match;
|
18
|
+
logic request;
|
19
|
+
logic [EXTERNAL_ADDRESS_WIDTH-1:0] address;
|
20
|
+
rggen_direction direction;
|
21
|
+
logic [DATA_WIDTH-1:0] write_data;
|
22
|
+
logic [DATA_WIDTH/8-1:0] write_strobe;
|
23
|
+
logic access_done;
|
24
|
+
|
25
|
+
rggen_address_decoder #(
|
26
|
+
ADDRESS_WIDTH, START_ADDRESS, END_ADDRESS, DATA_WIDTH
|
27
|
+
) u_address_decoder (register_if.address, address_match);
|
28
|
+
|
29
|
+
always_ff @(posedge clk, negedge rst_n) begin
|
30
|
+
if (!rst_n) begin
|
31
|
+
access_done <= '0;
|
32
|
+
end
|
33
|
+
else if (request && bus_if.done) begin
|
34
|
+
access_done <= '1;
|
35
|
+
end
|
36
|
+
else begin
|
37
|
+
access_done <= '0;
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
// Local -> External
|
42
|
+
assign bus_if.request = request;
|
43
|
+
assign bus_if.address = address;
|
44
|
+
assign bus_if.direction = direction;
|
45
|
+
assign bus_if.write_data = write_data;
|
46
|
+
assign bus_if.write_strobe = write_strobe;
|
47
|
+
always_ff @(posedge clk, negedge rst_n) begin
|
48
|
+
if (!rst_n) begin
|
49
|
+
request <= '0;
|
50
|
+
address <= '0;
|
51
|
+
direction <= RGGEN_READ;
|
52
|
+
write_data <= '0;
|
53
|
+
write_strobe <= '0;
|
54
|
+
end
|
55
|
+
else if (request && bus_if.done) begin
|
56
|
+
request <= '0;
|
57
|
+
address <= '0;
|
58
|
+
direction <= RGGEN_READ;
|
59
|
+
write_data <= '0;
|
60
|
+
write_strobe <= '0;
|
61
|
+
end
|
62
|
+
else if (register_if.request && address_match && (!request) && (!access_done)) begin
|
63
|
+
request <= '1;
|
64
|
+
address <= calc_address(register_if.address);
|
65
|
+
direction <= register_if.direction;
|
66
|
+
write_data <= register_if.write_data;
|
67
|
+
write_strobe <= register_if.write_strobe;
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
function automatic logic [EXTERNAL_ADDRESS_WIDTH-1:0] calc_address(input [ADDRESS_WIDTH-1:0] address);
|
72
|
+
logic [ADDRESS_WIDTH-1:0] external_address;
|
73
|
+
external_address = address - START_ADDRESS;
|
74
|
+
return external_address[EXTERNAL_ADDRESS_WIDTH-1:0];
|
75
|
+
endfunction
|
76
|
+
|
77
|
+
// External -> Local
|
78
|
+
assign register_if.select = address_match;
|
79
|
+
assign register_if.ready = bus_if.done;
|
80
|
+
assign register_if.value = bus_if.read_data;
|
81
|
+
assign register_if.read_data = bus_if.read_data;
|
82
|
+
assign register_if.status = bus_if.status;
|
83
|
+
endmodule
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module rggen_host_if_apb #(
|
2
|
+
parameter int LOCAL_ADDRESS_WIDTH = 16,
|
3
|
+
parameter int DATA_WIDTH = 32,
|
4
|
+
parameter int TOTAL_REGISTERS = 1
|
5
|
+
)(
|
6
|
+
input clk,
|
7
|
+
input rst_n,
|
8
|
+
rggen_apb_if.slave apb_if,
|
9
|
+
rggen_register_if.master register_if[TOTAL_REGISTERS]
|
10
|
+
);
|
11
|
+
import rggen_rtl_pkg::*;
|
12
|
+
|
13
|
+
rggen_bus_if #(LOCAL_ADDRESS_WIDTH, DATA_WIDTH) bus_if();
|
14
|
+
|
15
|
+
assign apb_if.pready = bus_if.done;
|
16
|
+
assign apb_if.prdata = bus_if.read_data;
|
17
|
+
assign apb_if.pslverr = bus_if.status[1];
|
18
|
+
assign bus_if.request = apb_if.psel;
|
19
|
+
assign bus_if.address = apb_if.paddr[LOCAL_ADDRESS_WIDTH-1:0];
|
20
|
+
assign bus_if.direction = rggen_direction'(apb_if.pwrite);
|
21
|
+
assign bus_if.write_data = apb_if.pwdata;
|
22
|
+
assign bus_if.write_strobe = apb_if.pstrb;
|
23
|
+
|
24
|
+
rggen_bus_splitter #(
|
25
|
+
DATA_WIDTH, TOTAL_REGISTERS
|
26
|
+
) u_bus_splitter (
|
27
|
+
clk, rst_n, bus_if, register_if
|
28
|
+
);
|
29
|
+
endmodule
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module rggen_host_if_axi4lite
|
2
|
+
import rggen_rtl_pkg::*;
|
3
|
+
#(
|
4
|
+
parameter int LOCAL_ADDRESS_WIDTH = 16,
|
5
|
+
parameter int DATA_WIDTH = 32,
|
6
|
+
parameter rggen_direction ACCESS_PRIORITY = RGGEN_WRITE
|
7
|
+
)(
|
8
|
+
input clk,
|
9
|
+
input rst_n,
|
10
|
+
rggen_axi4lite_if.slave axi4lite_if,
|
11
|
+
rggen_bus_if.master bus_if
|
12
|
+
);
|
13
|
+
// TODO
|
14
|
+
endmodule
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module rggen_indirect_register #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter bit [ADDRESS_WIDTH-1:0] START_ADDRESS = '0,
|
4
|
+
parameter bit [ADDRESS_WIDTH-1:0] END_ADDRESS = '0,
|
5
|
+
parameter int INDEX_WIDTH = 1,
|
6
|
+
parameter bit [INDEX_WIDTH-1:0] INDEX_VALUE = '0,
|
7
|
+
parameter int DATA_WIDTH = 32,
|
8
|
+
parameter bit [DATA_WIDTH-1:0] VALID_BITS = '0
|
9
|
+
)(
|
10
|
+
rggen_register_if.slave register_if,
|
11
|
+
rggen_bit_field_if.master bit_field_if,
|
12
|
+
input [INDEX_WIDTH-1:0] i_index
|
13
|
+
);
|
14
|
+
logic index_match;
|
15
|
+
|
16
|
+
assign index_match = (i_index == INDEX_VALUE) ? 1'b1 : 1'b0;
|
17
|
+
rggen_register_base #(
|
18
|
+
ADDRESS_WIDTH, START_ADDRESS, END_ADDRESS,
|
19
|
+
DATA_WIDTH, VALID_BITS
|
20
|
+
) u_register_base (register_if, bit_field_if, index_match);
|
21
|
+
endmodule
|
File without changes
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module rggen_register_base #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter bit [ADDRESS_WIDTH-1:0] START_ADDRESS = '0,
|
4
|
+
parameter bit [ADDRESS_WIDTH-1:0] END_ADDRESS = '0,
|
5
|
+
parameter int DATA_WIDTH = 32,
|
6
|
+
parameter bit [DATA_WIDTH-1:0] VALID_BITS = '0
|
7
|
+
)(
|
8
|
+
rggen_register_if.slave register_if,
|
9
|
+
rggen_bit_field_if.master bit_field_if,
|
10
|
+
input logic i_additional_match
|
11
|
+
);
|
12
|
+
import rggen_rtl_pkg::*;
|
13
|
+
|
14
|
+
logic address_match;
|
15
|
+
logic select;
|
16
|
+
genvar g_i;
|
17
|
+
|
18
|
+
// Decode Address
|
19
|
+
assign select = (address_match && i_additional_match) ? 1'b1 : 1'b0;
|
20
|
+
rggen_address_decoder #(
|
21
|
+
ADDRESS_WIDTH, START_ADDRESS, END_ADDRESS, DATA_WIDTH
|
22
|
+
) u_address_decoder (register_if.address, address_match);
|
23
|
+
|
24
|
+
// Drive Register IF
|
25
|
+
assign register_if.select = select;
|
26
|
+
assign register_if.ready = (register_if.request && select) ? 1'b1 : 1'b0;
|
27
|
+
assign register_if.status = RGGEN_OKAY;
|
28
|
+
|
29
|
+
generate for (g_i = 0;g_i < DATA_WIDTH;++g_i) begin : g
|
30
|
+
if (VALID_BITS[g_i]) begin
|
31
|
+
assign register_if.value[g_i] = bit_field_if.value[g_i];
|
32
|
+
assign register_if.read_data[g_i] = bit_field_if.read_data[g_i];
|
33
|
+
end
|
34
|
+
else begin
|
35
|
+
assign register_if.value[g_i] = '0;
|
36
|
+
assign register_if.read_data[g_i] = '0;
|
37
|
+
end
|
38
|
+
end endgenerate
|
39
|
+
|
40
|
+
// Drive Bit Field IF
|
41
|
+
assign bit_field_if.read_access = (
|
42
|
+
register_if.request && select && (register_if.direction == RGGEN_READ)
|
43
|
+
) ? 1'b1 : 1'b0;
|
44
|
+
assign bit_field_if.write_access = (
|
45
|
+
register_if.request && select && (register_if.direction == RGGEN_WRITE)
|
46
|
+
) ? 1'b1 : 1'b0;
|
47
|
+
assign bit_field_if.write_data = register_if.write_data;
|
48
|
+
assign bit_field_if.write_mask = get_write_mask(register_if.write_strobe);
|
49
|
+
|
50
|
+
function automatic logic [DATA_WIDTH-1:0] get_write_mask(logic [DATA_WIDTH/8-1:0] strobe);
|
51
|
+
logic [DATA_WIDTH-1:0] mask;
|
52
|
+
for (int i= 0;i < DATA_WIDTH;i += 8) begin
|
53
|
+
mask[i+:8] = {8{strobe[i/8]}};
|
54
|
+
end
|
55
|
+
return mask;
|
56
|
+
endfunction
|
57
|
+
endmodule
|
@@ -0,0 +1,42 @@
|
|
1
|
+
interface rggen_register_if #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter int DATA_WIDTH = 32
|
4
|
+
)();
|
5
|
+
import rggen_rtl_pkg::*;
|
6
|
+
|
7
|
+
logic request;
|
8
|
+
logic select;
|
9
|
+
logic [ADDRESS_WIDTH-1:0] address;
|
10
|
+
rggen_direction direction;
|
11
|
+
logic [DATA_WIDTH-1:0] write_data;
|
12
|
+
logic [DATA_WIDTH/8-1:0] write_strobe;
|
13
|
+
logic ready;
|
14
|
+
logic [DATA_WIDTH-1:0] read_data;
|
15
|
+
logic [DATA_WIDTH-1:0] value;
|
16
|
+
rggen_status status;
|
17
|
+
|
18
|
+
modport master (
|
19
|
+
output request,
|
20
|
+
input select,
|
21
|
+
output address,
|
22
|
+
output direction,
|
23
|
+
output write_data,
|
24
|
+
output write_strobe,
|
25
|
+
input ready,
|
26
|
+
input read_data,
|
27
|
+
input status
|
28
|
+
);
|
29
|
+
|
30
|
+
modport slave (
|
31
|
+
input request,
|
32
|
+
output select,
|
33
|
+
input address,
|
34
|
+
input direction,
|
35
|
+
input write_data,
|
36
|
+
input write_strobe,
|
37
|
+
output ready,
|
38
|
+
output read_data,
|
39
|
+
output status,
|
40
|
+
output value
|
41
|
+
);
|
42
|
+
endinterface
|
@@ -0,0 +1,23 @@
|
|
1
|
+
package rggen_rtl_pkg;
|
2
|
+
typedef enum logic {
|
3
|
+
RGGEN_READ = 1'b0,
|
4
|
+
RGGEN_WRITE = 1'b1
|
5
|
+
} rggen_direction;
|
6
|
+
|
7
|
+
typedef enum logic [1:0] {
|
8
|
+
RGGEN_OKAY = 2'b00,
|
9
|
+
RGGEN_EXOKAY = 2'b01,
|
10
|
+
RGGEN_SLAVE_ERROR = 2'b10,
|
11
|
+
RGGEN_DECODE_ERROR = 2'b11
|
12
|
+
} rggen_status;
|
13
|
+
|
14
|
+
typedef enum bit {
|
15
|
+
RGGEN_SET_MODE = 1'b0,
|
16
|
+
RGGEN_CLEAR_MODE = 1'b1
|
17
|
+
} rggen_rwsc_mode;
|
18
|
+
|
19
|
+
typedef enum bit {
|
20
|
+
RGGEN_LOCK_MODE = 1'b0,
|
21
|
+
RGGEN_ENABLE_MODE = 1'b1
|
22
|
+
} rggen_rwle_mode;
|
23
|
+
endpackage
|
data/sample/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Taichi Ishitani
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|