Skip to content

Commit

Permalink
Merge pull request #16 from zhangyiant/dev1.0.35
Browse files Browse the repository at this point in the history
Dev1.0.35
  • Loading branch information
zhangyiant authored Jul 27, 2021
2 parents 36b2ec1 + 79eb918 commit 9d26032
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 25 deletions.
Binary file modified excels/block1.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion register_printer/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.34
1.0.35
2 changes: 1 addition & 1 deletion register_printer/constants/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RW_TYPES = ['RW', 'RO', 'WO', 'RS', 'W1C', "W0C", 'RC', 'WRC', 'WRS', 'WSC', 'WC', '-']
RW_TYPES = ['RW', 'RWP', 'RO', 'WO', 'RS', 'W1C', "W0C", 'RC', 'WRC', 'WRS', 'WSC', 'WC', '-']

__all__ = [
RW_TYPES
Expand Down
4 changes: 4 additions & 0 deletions register_printer/generators/rtl_generator/print_rtl.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def print_rtl_block(block, out_path):
tmp_register["name"] = reg.name
tmp_register["fields"] = []
rw_flds = []
rwp_flds = []
ro_flds = []
rc_flds = []
rs_flds = []
Expand All @@ -40,6 +41,8 @@ def print_rtl_block(block, out_path):
tmp_register["fields"].append(fld)
if fld.access == "RW":
rw_flds.append(fld)
elif fld.access == "RWP":
rwp_flds.append(fld)
elif fld.access == "RC":
rc_flds.append(fld)
elif fld.access == "RO":
Expand All @@ -61,6 +64,7 @@ def print_rtl_block(block, out_path):
elif fld.access == "-":
ro_flds.append(fld)
tmp_register["rw_flds"] = rw_flds
tmp_register["rwp_flds"] = rwp_flds
tmp_register["ro_flds"] = ro_flds
tmp_register["rc_flds"] = rc_flds
tmp_register["rs_flds"] = rs_flds
Expand Down
4 changes: 4 additions & 0 deletions register_printer/templates/reg_model.sv
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ class {{ uvm_reg_type }} extends uvm_reg;
{% if field.name != "-" %}
{% set field_size = field.msb - field.lsb + 1 %}
{{ field.name | lower }} = uvm_reg_field::type_id::create("{{ field.name | lower }}");
{% if field.access == "RWP" %}
{{ field.name | lower }}.configure(this, {{ field_size }}, {{ field.lsb }}, "RW", 0, {{ field_size }}'h{{ '%x' | format(field.default) }}, 1, 1, 1);
{% else %}
{{ field.name | lower }}.configure(this, {{ field_size }}, {{ field.lsb }}, "{{ field.access }}", 0, {{ field_size }}'h{{ '%x' | format(field.default) }}, 1, 1, 1);
{% endif %}
{% endif %}
{% endfor %}
endfunction: build

Expand Down
54 changes: 31 additions & 23 deletions register_printer/templates/reg_rtl.sv
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ module {{ block.block_type }}_reg
(
input reg_clk ,
input reg_rstn ,
input wp_dis ,
{% for register in block.registers %}
{% for field in register.fields %}
{% set field_bits = field.msb - field.lsb %}
{% if field.access == "RW" %}
output logic[{{ '%2s' | format(field_bits) }}: 0] {{ "%-48s" | format(field.name) }},
{% elif field.access == "RWP" %}
output logic[{{ '%2s' | format(field_bits) }}: 0] {{ "%-48s" | format(field.name) }},
{% elif field.access == "RC" %}
input [{{ '%2s' | format(field_bits) }}: 0] {{ "%-48s" | format(field.name) }},
{% elif field.access == "RO" %}
Expand Down Expand Up @@ -54,7 +57,7 @@ localparam int {{ (register.name + "_addr") | upper }} = 'h{{ "%x" | format(regi
{% endfor %}

{% for register in registers %}
{% if (register.rw_flds | length ) + (register.rc_flds | length) + (register.rs_flds | length) + (register.w1c_flds | length) + (register.w0c_flds | length) + (register.wc_flds | length) + (register.wo_flds | length) + (register.wrc_flds | length) + (register.wrs_flds | length) > 0 %}
{% if (register.rw_flds | length ) + (register.rwp_flds | length ) + (register.rc_flds | length) + (register.rs_flds | length) + (register.w1c_flds | length) + (register.w0c_flds | length) + (register.wc_flds | length) + (register.wo_flds | length) + (register.wrc_flds | length) + (register.wrs_flds | length) > 0 %}
always @(posedge reg_clk or negedge reg_rstn) begin
if(~reg_rstn) begin
{% for field in register.fields %}
Expand All @@ -74,7 +77,7 @@ always @(posedge reg_clk or negedge reg_rstn) begin
{% endfor %}
end
{% endif %}
{% if (register.rw_flds | length) + (register.wo_flds | length) + (register.wrc_flds | length) + (register.wrs_flds | length) + (register.rc_flds | length) + (register.rs_flds | length) + (register.w1c_flds | length) + (register.w0c_flds | length) + (register.wc_flds | length) > 0 %}
{% if (register.rw_flds | length) + (register.rwp_flds | length) + (register.wo_flds | length) + (register.wrc_flds | length) + (register.wrs_flds | length) + (register.rc_flds | length) + (register.rs_flds | length) + (register.w1c_flds | length) + (register.w0c_flds | length) + (register.wc_flds | length) > 0 %}
else begin
{% for field in (register.rc_flds + register.rs_flds) %}
{{ register.name }}[{{ field.msb }}:{{ field.lsb }}] <= {{ field.name }}
Expand All @@ -91,7 +94,7 @@ always @(posedge reg_clk or negedge reg_rstn) begin
{% set pos = (field.msb / 8) | int %}
{{ register.name }}[{{ field.msb }}] <= {{ field.name | lower }}_set ? 1'b1 : ((reg_wr && reg_addr=={{ (register.name + "_addr") | upper }} && reg_we[{{ pos }}]) ? 1'b0 : {{ register.name }}[{{ field.msb }}]);
{% endfor %}
{% for field in (register.rw_flds + register.wrc_flds + register.wrs_flds + register.wo_flds) %}
{% for field in (register.rw_flds + register.rwp_flds + register.wrc_flds + register.wrs_flds + register.wo_flds) %}
{% set msb = field.msb %}
{% set lsb = field.lsb %}
{% set reg_name = register.name %}
Expand Down Expand Up @@ -135,41 +138,46 @@ always @(posedge reg_clk or negedge reg_rstn) begin
{% endif %}
{% endif %}
{% else %}
{% if field.access == "RWP" %}
{% set RWP_CONTENT = " && wp_dis" %}
{% else %}
{% set RWP_CONTENT = "" %}
{% endif %}
{% if msb < 8 %}
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{% elif msb < 16 %}
{% if lsb < 8 %}
{{ reg_name }}[{{ msb }}:8] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]) ? reg_wdat[{{ msb }}:8] : {{ reg_name }}[{{ msb }}:8];
{{ reg_name }}[7:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]) ? reg_wdat[7:{{ lsb }}] : {{ reg_name }}[7:{{ lsb }}];
{{ reg_name }}[{{ msb }}:8] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:8] : {{ reg_name }}[{{ msb }}:8];
{{ reg_name }}[7:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]{{ RWP_CONTENT }}) ? reg_wdat[7:{{ lsb }}] : {{ reg_name }}[7:{{ lsb }}];
{% else %}
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{% endif %}
{% elif msb < 24 %}
{% if lsb < 8 %}
{{ reg_name }}[{{ msb }}:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]) ? reg_wdat[{{ msb }}:16] : {{ reg_name }}[{{ msb }}:16];
{{ reg_name }}[{{ msb }}:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:16] : {{ reg_name }}[{{ msb }}:16];
{{ reg_name }}[15:8] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]) ? reg_wdat[15:8] : {{ reg_name }}[15:8];
{{ reg_name }}[7:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]) ? reg_wdat[7:{{ lsb }}] : {{ reg_name }}[7:{{ lsb }}];
{{ reg_name }}[7:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]{{ RWP_CONTENT }}) ? reg_wdat[7:{{ lsb }}] : {{ reg_name }}[7:{{ lsb }}];
{% elif lsb < 16 %}
{{ reg_name }}[{{ msb }}:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]) ? reg_wdat[{{ msb }}:16] : {{ reg_name }}[{{ msb }}:16];
{{ reg_name }}[15:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]) ? reg_wdat[15:{{ lsb }}] : {{ reg_name }}[15:{{ lsb }}];
{{ reg_name }}[{{ msb }}:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:16] : {{ reg_name }}[{{ msb }}:16];
{{ reg_name }}[15:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]{{ RWP_CONTENT }}) ? reg_wdat[15:{{ lsb }}] : {{ reg_name }}[15:{{ lsb }}];
{% else %}
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{% endif %}
{% else %}
{% if lsb < 8 %}
{{ reg_name }}[{{ msb }}:24] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]) ? reg_wdat[{{ msb }}:24] : {{ reg_name }}[{{ msb }}:24];
{{ reg_name }}[23:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]) ? reg_wdat[23:16] : {{ reg_name }}[23:16];
{{ reg_name }}[15:8] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]) ? reg_wdat[15:8] : {{ reg_name }}[15:8];
{{ reg_name }}[7:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]) ? reg_wdat[7:{{ lsb }}] : {{ reg_name }}[7:{{ lsb }}];
{{ reg_name }}[{{ msb }}:24] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:24] : {{ reg_name }}[{{ msb }}:24];
{{ reg_name }}[23:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]{{ RWP_CONTENT }}) ? reg_wdat[23:16] : {{ reg_name }}[23:16];
{{ reg_name }}[15:8] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]{{ RWP_CONTENT }}) ? reg_wdat[15:8] : {{ reg_name }}[15:8];
{{ reg_name }}[7:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[0]{{ RWP_CONTENT }}) ? reg_wdat[7:{{ lsb }}] : {{ reg_name }}[7:{{ lsb }}];
{% elif lsb < 16 %}
{{ reg_name }}[{{ msb }}:24] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]) ? reg_wdat[{{ msb }}:24] : {{ reg_name }}[{{ msb }}:24];
{{ reg_name }}[23:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]) ? reg_wdat[23:16] : {{ reg_name }}[23:16];
{{ reg_name }}[15:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]) ? reg_wdat[15:{{ lsb }}] : {{ reg_name }}[15:{{ lsb }}];
{{ reg_name }}[{{ msb }}:24] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:24] : {{ reg_name }}[{{ msb }}:24];
{{ reg_name }}[23:16] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]{{ RWP_CONTENT }}) ? reg_wdat[23:16] : {{ reg_name }}[23:16];
{{ reg_name }}[15:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[1]{{ RWP_CONTENT }}) ? reg_wdat[15:{{ lsb }}] : {{ reg_name }}[15:{{ lsb }}];
{% elif lsb < 24 %}
{{ reg_name }}[{{ msb }}:24] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]) ? reg_wdat[{{ msb }}:24] : {{ reg_name }}[{{ msb }}:24];
{{ reg_name }}[23:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]) ? reg_wdat[23:{{ lsb }}] : {{ reg_name }}[23:{{ lsb }}];
{{ reg_name }}[{{ msb }}:24] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:24] : {{ reg_name }}[{{ msb }}:24];
{{ reg_name }}[23:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[2]{{ RWP_CONTENT }}) ? reg_wdat[23:{{ lsb }}] : {{ reg_name }}[23:{{ lsb }}];
{% else %}
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{{ reg_name }}[{{ msb }}:{{ lsb }}] <= (reg_wr && reg_addr == {{ reg_offset }} && reg_we[3]{{ RWP_CONTENT }}) ? reg_wdat[{{ msb }}:{{ lsb }}] : {{ reg_name }}[{{ msb }}:{{ lsb }}];
{% endif %}
{% endif %}
{% endif %}
Expand All @@ -178,7 +186,7 @@ always @(posedge reg_clk or negedge reg_rstn) begin
end
end
{% endif %}
{% for field in (register.rw_flds + register.w1c_flds + register.w0c_flds + register.wc_flds + register.wo_flds + register.wrc_flds + register.wrs_flds) %}
{% for field in (register.rw_flds + register.rwp_flds + register.w1c_flds + register.w0c_flds + register.wc_flds + register.wo_flds + register.wrc_flds + register.wrs_flds) %}
assign {{ field.name }} = {{ register.name }}[{{ field.msb }}:{{ field.lsb }}];
{% endfor %}
{% for field in register.ro_flds %}
Expand Down

0 comments on commit 9d26032

Please sign in to comment.