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/lib/rggen/version.rb
CHANGED
data/ral/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.
|
data/ral/rggen_ral_macros.svh
CHANGED
@@ -3,12 +3,9 @@
|
|
3
3
|
|
4
4
|
`define rggen_ral_create_field_model(handle, name, width, lsb, access, volatile, reset, has_reset, hdl_path) \
|
5
5
|
begin \
|
6
|
-
string __hdl_path = hdl_path; \
|
7
6
|
handle = new(name); \
|
8
7
|
handle.configure(this.cfg, this, width, lsb, access, volatile, reset, has_reset, 1, 1); \
|
9
|
-
|
10
|
-
this.add_hdl_path_slice(__hdl_path, lsb, width); \
|
11
|
-
end \
|
8
|
+
this.add_field_hdl_path(hdl_path, lsb, width); \
|
12
9
|
end
|
13
10
|
|
14
11
|
`define rggen_ral_create_reg_model(handle, name, array_index, offset_address, rights, unmapped, hdl_path) \
|
data/ral/rggen_ral_reg.svh
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
class rggen_ral_reg extends uvm_reg;
|
4
4
|
protected int indexes[$];
|
5
5
|
protected uvm_object cfg;
|
6
|
+
protected string hdl_path_scopes[string];
|
6
7
|
|
7
8
|
extern function new(string name, int unsigned n_bits, int has_coverage);
|
8
9
|
|
@@ -11,12 +12,16 @@ class rggen_ral_reg extends uvm_reg;
|
|
11
12
|
uvm_reg_block blk_parent,
|
12
13
|
uvm_reg_file regfile_parent,
|
13
14
|
int indexes[$],
|
14
|
-
string hdl_path
|
15
|
+
string hdl_path = "",
|
16
|
+
bit single_hdl_variable = 0
|
15
17
|
);
|
16
18
|
extern virtual function void build();
|
17
19
|
|
18
20
|
extern virtual function uvm_reg_frontdoor create_frontdoor();
|
19
21
|
|
22
|
+
extern function void set_hdl_path_scope(string hdl_path_scope, string kind = "RTL");
|
23
|
+
extern function void add_field_hdl_path(string name, int offset, int size, string kind = "RTL", string separalor = ".");
|
24
|
+
|
20
25
|
extern protected virtual function void set_cfg(uvm_object cfg);
|
21
26
|
extern protected virtual function void create_fields();
|
22
27
|
endclass
|
@@ -30,13 +35,20 @@ function void rggen_ral_reg::configure(
|
|
30
35
|
uvm_reg_block blk_parent,
|
31
36
|
uvm_reg_file regfile_parent,
|
32
37
|
int indexes[$],
|
33
|
-
string hdl_path
|
38
|
+
string hdl_path,
|
39
|
+
bit single_hdl_variable
|
34
40
|
);
|
35
41
|
foreach (indexes[i]) begin
|
36
42
|
this.indexes.push_back(indexes[i]);
|
37
43
|
end
|
38
44
|
set_cfg(cfg);
|
39
|
-
|
45
|
+
if (single_hdl_variable) begin
|
46
|
+
super.configure(blk_parent, regfile_parent, hdl_path);
|
47
|
+
end
|
48
|
+
else begin
|
49
|
+
super.configure(blk_parent, regfile_parent);
|
50
|
+
set_hdl_path_scope(hdl_path);
|
51
|
+
end
|
40
52
|
endfunction
|
41
53
|
|
42
54
|
function void rggen_ral_reg::build();
|
@@ -47,6 +59,26 @@ function uvm_reg_frontdoor rggen_ral_reg::create_frontdoor();
|
|
47
59
|
return null;
|
48
60
|
endfunction
|
49
61
|
|
62
|
+
function void rggen_ral_reg::set_hdl_path_scope(string hdl_path_scope, string kind);
|
63
|
+
if (hdl_path_scope.len() > 0) begin
|
64
|
+
hdl_path_scopes[kind] = hdl_path_scope;
|
65
|
+
end
|
66
|
+
endfunction
|
67
|
+
|
68
|
+
function void rggen_ral_reg::add_field_hdl_path(string name, int offset, int size, string kind, string separalor);
|
69
|
+
string path;
|
70
|
+
if (name.len() == 0) begin
|
71
|
+
return;
|
72
|
+
end
|
73
|
+
if (hdl_path_scopes.exists(kind) && (hdl_path_scopes[kind].len() > 0)) begin
|
74
|
+
path = {hdl_path_scopes[kind], separalor, name};
|
75
|
+
end
|
76
|
+
else begin
|
77
|
+
path = name;
|
78
|
+
end
|
79
|
+
add_hdl_path_slice(path, offset, size, 0, kind);
|
80
|
+
endfunction
|
81
|
+
|
50
82
|
function void rggen_ral_reg::set_cfg(uvm_object cfg);
|
51
83
|
this.cfg = cfg;
|
52
84
|
endfunction
|
data/rtl/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.
|
data/rtl/compile.f
CHANGED
@@ -1,6 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
${RGGEN_HOME}/rtl/rggen_rtl_pkg.sv
|
2
|
+
${RGGEN_HOME}/rtl/rggen_bus_if.sv
|
3
|
+
${RGGEN_HOME}/rtl/rggen_register_if.sv
|
4
|
+
${RGGEN_HOME}/rtl/rggen_bit_field_if.sv
|
5
|
+
${RGGEN_HOME}/rtl/rggen_bus_splitter.sv
|
6
|
+
${RGGEN_HOME}/rtl/rggen_irq_controller.sv
|
7
|
+
${RGGEN_HOME}/rtl/rggen_address_decoder.sv
|
8
|
+
${RGGEN_HOME}/rtl/rggen_register_base.sv
|
9
|
+
${RGGEN_HOME}/rtl/rggen_default_register.sv
|
10
|
+
${RGGEN_HOME}/rtl/rggen_indirect_register.sv
|
11
|
+
${RGGEN_HOME}/rtl/rggen_external_register.sv
|
12
|
+
${RGGEN_HOME}/rtl/rggen_bit_field_ro.sv
|
13
|
+
${RGGEN_HOME}/rtl/rggen_bit_field_rw.sv
|
14
|
+
${RGGEN_HOME}/rtl/rggen_bit_field_rwl_rwe.sv
|
15
|
+
${RGGEN_HOME}/rtl/rggen_bit_field_w01s_w01c.sv
|
16
|
+
|
17
|
+
${RGGEN_HOME}/rtl/rggen_apb_if.sv
|
18
|
+
${RGGEN_HOME}/rtl/rggen_host_if_apb.sv
|
19
|
+
|
20
|
+
${RGGEN_HOME}/rtl/rggen_axi4lite_if.sv
|
21
|
+
${RGGEN_HOME}/rtl/rggen_host_if_axi4lite.sv
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module rggen_address_decoder #(
|
2
|
+
parameter int ADDRESS_WIDTH = 8,
|
3
|
+
parameter bit [ADDRESS_WIDTH-1:0] STAET_ADDRESS = '0,
|
4
|
+
parameter bit [ADDRESS_WIDTH-1:0] END_ADDRESS = '0,
|
5
|
+
parameter int DATA_WIDTH = 32
|
6
|
+
)(
|
7
|
+
input [ADDRESS_WIDTH-1:0] i_address,
|
8
|
+
output o_match
|
9
|
+
);
|
10
|
+
localparam int LSB = $clog2(DATA_WIDTH / 8);
|
11
|
+
localparam bit [ADDRESS_WIDTH-LSB-1:0] SADDRESS = STAET_ADDRESS[ADDRESS_WIDTH-1:LSB];
|
12
|
+
localparam bit [ADDRESS_WIDTH-LSB-1:0] EADDRESS = END_ADDRESS[ADDRESS_WIDTH-1:LSB];
|
13
|
+
|
14
|
+
generate if (SADDRESS == EADDRESS) begin
|
15
|
+
assign o_match = (i_address[ADDRESS_WIDTH-1:LSB] == SADDRESS) ? 1'b1 : 1'b0;
|
16
|
+
end
|
17
|
+
else begin
|
18
|
+
assign o_match = (
|
19
|
+
(i_address[ADDRESS_WIDTH-1:LSB] >= SADDRESS) &&
|
20
|
+
(i_address[ADDRESS_WIDTH-1:LSB] <= EADDRESS)
|
21
|
+
) ? 1'b1 : 1'b0;
|
22
|
+
end endgenerate
|
23
|
+
endmodule
|
data/rtl/rggen_apb_if.sv
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
interface rggen_apb_if #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter int DATA_WIDTH = 32
|
4
|
+
)();
|
5
|
+
logic psel;
|
6
|
+
logic penable;
|
7
|
+
logic [ADDRESS_WIDTH-1:0] paddr;
|
8
|
+
logic [2:0] pprot;
|
9
|
+
logic pwrite;
|
10
|
+
logic [DATA_WIDTH-1:0] pwdata;
|
11
|
+
logic [DATA_WIDTH/8-1:0] pstrb;
|
12
|
+
logic pready;
|
13
|
+
logic [DATA_WIDTH-1:0] prdata;
|
14
|
+
logic pslverr;
|
15
|
+
|
16
|
+
modport master (
|
17
|
+
output psel,
|
18
|
+
output penable,
|
19
|
+
output paddr,
|
20
|
+
output pprot,
|
21
|
+
output pwrite,
|
22
|
+
output pwdata,
|
23
|
+
output pstrb,
|
24
|
+
input pready,
|
25
|
+
input prdata,
|
26
|
+
input pslverr
|
27
|
+
);
|
28
|
+
|
29
|
+
modport slave (
|
30
|
+
input psel,
|
31
|
+
input penable,
|
32
|
+
input paddr,
|
33
|
+
input pprot,
|
34
|
+
input pwrite,
|
35
|
+
input pwdata,
|
36
|
+
input pstrb,
|
37
|
+
output pready,
|
38
|
+
output prdata,
|
39
|
+
output pslverr
|
40
|
+
);
|
41
|
+
endinterface
|
@@ -0,0 +1,68 @@
|
|
1
|
+
interface rggen_axi4lite_if #(
|
2
|
+
parameter int ADDRESS_WIDTH = 16,
|
3
|
+
parameter int DATA_WIDTH = 32
|
4
|
+
)();
|
5
|
+
logic awvalid;
|
6
|
+
logic awready;
|
7
|
+
logic [ADDRESS_WIDTH-1:0] awaddr;
|
8
|
+
logic [2:0] awprot;
|
9
|
+
logic wvalid;
|
10
|
+
logic wraedy;
|
11
|
+
logic [DATA_WIDTH-1:0] wdata;
|
12
|
+
logic [DATA_WIDTH/8-1:0] wstrb;
|
13
|
+
logic bvalid;
|
14
|
+
logic bready;
|
15
|
+
logic [1:0] bresp;
|
16
|
+
logic arvalid;
|
17
|
+
logic arready;
|
18
|
+
logic [ADDRESS_WIDTH-1:0] araddr;
|
19
|
+
logic [2:0] arprot;
|
20
|
+
logic rvalid;
|
21
|
+
logic rready;
|
22
|
+
logic [DATA_WIDTH-1:0] rdata;
|
23
|
+
logic [1:0] rresp;
|
24
|
+
|
25
|
+
modport master (
|
26
|
+
output awvalid,
|
27
|
+
input awready,
|
28
|
+
output awaddr,
|
29
|
+
output awprot,
|
30
|
+
output wvalid,
|
31
|
+
input wraedy,
|
32
|
+
output wdata,
|
33
|
+
output wstrb,
|
34
|
+
input bvalid,
|
35
|
+
output bready,
|
36
|
+
input bresp,
|
37
|
+
output arvalid,
|
38
|
+
input arready,
|
39
|
+
output araddr,
|
40
|
+
output arprot,
|
41
|
+
input rvalid,
|
42
|
+
output rready,
|
43
|
+
input rdata,
|
44
|
+
input rresp
|
45
|
+
);
|
46
|
+
|
47
|
+
modport slave (
|
48
|
+
input awvalid,
|
49
|
+
output awready,
|
50
|
+
input awaddr,
|
51
|
+
input awprot,
|
52
|
+
input wvalid,
|
53
|
+
output wraedy,
|
54
|
+
input wdata,
|
55
|
+
input wstrb,
|
56
|
+
output bvalid,
|
57
|
+
input bready,
|
58
|
+
output bresp,
|
59
|
+
input arvalid,
|
60
|
+
output arready,
|
61
|
+
input araddr,
|
62
|
+
input arprot,
|
63
|
+
output rvalid,
|
64
|
+
input rready,
|
65
|
+
output rdata,
|
66
|
+
output rresp
|
67
|
+
);
|
68
|
+
endinterface
|
@@ -0,0 +1,28 @@
|
|
1
|
+
interface rggen_bit_field_if #(
|
2
|
+
parameter int DATA_WIDTH = 32
|
3
|
+
)();
|
4
|
+
logic read_access;
|
5
|
+
logic write_access;
|
6
|
+
logic [DATA_WIDTH-1:0] write_data;
|
7
|
+
logic [DATA_WIDTH-1:0] write_mask;
|
8
|
+
logic [DATA_WIDTH-1:0] value;
|
9
|
+
logic [DATA_WIDTH-1:0] read_data;
|
10
|
+
|
11
|
+
modport master (
|
12
|
+
output read_access,
|
13
|
+
output write_access,
|
14
|
+
output write_data,
|
15
|
+
output write_mask,
|
16
|
+
input value,
|
17
|
+
input read_data
|
18
|
+
);
|
19
|
+
|
20
|
+
modport slave (
|
21
|
+
input read_access,
|
22
|
+
input write_access,
|
23
|
+
input write_data,
|
24
|
+
input write_mask,
|
25
|
+
output value,
|
26
|
+
output read_data
|
27
|
+
);
|
28
|
+
endinterface
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module rggen_bit_field_rw #(
|
2
|
+
parameter int WIDTH = 1,
|
3
|
+
parameter bit [WIDTH-1:0] INITIAL_VALUE = '0
|
4
|
+
)(
|
5
|
+
input logic clk,
|
6
|
+
input logic rst_n,
|
7
|
+
rggen_bit_field_if.slave bit_field_if,
|
8
|
+
output logic [WIDTH-1:0] o_value
|
9
|
+
);
|
10
|
+
logic [WIDTH-1:0] value;
|
11
|
+
|
12
|
+
assign o_value = value;
|
13
|
+
assign bit_field_if.value = value;
|
14
|
+
assign bit_field_if.read_data = value;
|
15
|
+
|
16
|
+
always_ff @(posedge clk, negedge rst_n) begin
|
17
|
+
if (!rst_n) begin
|
18
|
+
value <= INITIAL_VALUE;
|
19
|
+
end
|
20
|
+
else if (bit_field_if.write_access) begin
|
21
|
+
value <= (value & (~bit_field_if.write_mask))
|
22
|
+
| (bit_field_if.write_data & bit_field_if.write_mask );
|
23
|
+
end
|
24
|
+
end
|
25
|
+
endmodule
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module rggen_bit_field_rwl_rwe
|
2
|
+
import rggen_rtl_pkg::*;
|
3
|
+
#(
|
4
|
+
parameter rggen_rwle_mode MODE = RGGEN_LOCK_MODE,
|
5
|
+
parameter int WIDTH = 1,
|
6
|
+
parameter bit [WIDTH-1:0] INITIAL_VALUE = '0
|
7
|
+
)(
|
8
|
+
input logic clk,
|
9
|
+
input logic rst_n,
|
10
|
+
input logic i_lock_or_enable,
|
11
|
+
rggen_bit_field_if.slave bit_field_if,
|
12
|
+
output logic [WIDTH-1:0] o_value
|
13
|
+
);
|
14
|
+
logic [WIDTH-1:0] value;
|
15
|
+
|
16
|
+
assign o_value = value;
|
17
|
+
assign bit_field_if.value = value;
|
18
|
+
assign bit_field_if.read_data = value;
|
19
|
+
|
20
|
+
always_ff @(posedge clk, negedge rst_n) begin
|
21
|
+
if (!rst_n) begin
|
22
|
+
value <= INITIAL_VALUE;
|
23
|
+
end
|
24
|
+
else if ((i_lock_or_enable == MODE) && bit_field_if.write_access) begin
|
25
|
+
value <= (value & (~bit_field_if.write_mask))
|
26
|
+
| (bit_field_if.write_data & bit_field_if.write_mask );
|
27
|
+
end
|
28
|
+
end
|
29
|
+
endmodule
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module rggen_bit_field_w01s_w01c
|
2
|
+
import rggen_rtl_pkg::*;
|
3
|
+
#(
|
4
|
+
parameter rggen_rwsc_mode MODE = RGGEN_SET_MODE,
|
5
|
+
parameter bit SET_CLEAR_VALUE = 1'b0,
|
6
|
+
parameter int WIDTH = 1,
|
7
|
+
parameter bit [WIDTH-1:0] INITIAL_VALUE = '0
|
8
|
+
)(
|
9
|
+
input logic clk,
|
10
|
+
input logic rst_n,
|
11
|
+
input logic [WIDTH-1:0] i_set_or_clear,
|
12
|
+
rggen_bit_field_if.slave bit_field_if,
|
13
|
+
output logic [WIDTH-1:0] o_value
|
14
|
+
);
|
15
|
+
logic [WIDTH-1:0] value;
|
16
|
+
|
17
|
+
assign o_value = value;
|
18
|
+
assign bit_field_if.value[WIDTH-1:0] = value;
|
19
|
+
assign bit_field_if.read_data[WIDTH-1:0] = value;
|
20
|
+
|
21
|
+
always_ff @(posedge clk, negedge rst_n) begin
|
22
|
+
if (!rst_n) begin
|
23
|
+
value <= INITIAL_VALUE;
|
24
|
+
end
|
25
|
+
else begin
|
26
|
+
value <= get_next_value();
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
function automatic logic [WIDTH-1:0] get_next_value();
|
31
|
+
logic [WIDTH-1:0] write_data;
|
32
|
+
logic [WIDTH-1:0] write_mask;
|
33
|
+
logic [WIDTH-1:0] control_value;
|
34
|
+
logic [WIDTH-1:0] set;
|
35
|
+
logic [WIDTH-1:0] clear;
|
36
|
+
|
37
|
+
write_data = bit_field_if.write_data;
|
38
|
+
write_mask = bit_field_if.write_mask;
|
39
|
+
if (bit_field_if.write_access) begin
|
40
|
+
control_value = write_mask & ((SET_CLEAR_VALUE) ? write_data : ~write_data);
|
41
|
+
end
|
42
|
+
else begin
|
43
|
+
control_value = '0;
|
44
|
+
end
|
45
|
+
if (MODE == RGGEN_SET_MODE) begin
|
46
|
+
set = control_value;
|
47
|
+
clear = i_set_or_clear;
|
48
|
+
end
|
49
|
+
else begin
|
50
|
+
set = i_set_or_clear;
|
51
|
+
clear = control_value;
|
52
|
+
end
|
53
|
+
return set | (value & (~clear));
|
54
|
+
endfunction
|
55
|
+
endmodule
|