|
| 1 | +:tabs-sync-option: |
| 2 | + |
| 3 | +[#csrs-<%= csr.name.gsub('.', '_') %>,reftext=<%= csr.name %>] |
| 4 | += <%= csr.name %> |
| 5 | + |
| 6 | +*<%= csr.long_name %>* |
| 7 | + |
| 8 | +<%= csr.description %> |
| 9 | + |
| 10 | +== Attributes |
| 11 | +[%autowidth] |
| 12 | +|=== |
| 13 | +h| CSR Address | <%= "0x#{csr.address.to_s(16)}" %> |
| 14 | +<%- if csr.priv_mode == 'VS' -%> |
| 15 | +h| Virtual CSR Address | <%= "0x#{csr.virtual_address.to_s(16)}" %> |
| 16 | +<%- end -%> |
| 17 | +<%- if csr.dynamic_length?(arch_def) -%> |
| 18 | +h| Length | <%= csr.length_pretty(arch_def) %> |
| 19 | +<%- else -%> |
| 20 | +h| Length | <%= csr.length_pretty(arch_def) %>-bit |
| 21 | +<%- end -%> |
| 22 | +h| Privilege Mode | <%= csr.priv_mode %> |
| 23 | +|=== |
| 24 | + |
| 25 | +== Format |
| 26 | +<%- unless csr.dynamic_length?(arch_def) || csr.fields.any? { |f| f.dynamic_location?(arch_def) } -%> |
| 27 | +<%# CSR has a known static length, so there is only one format to display -%> |
| 28 | +.<%= csr.name %> format |
| 29 | +[wavedrom, ,svg,subs='attributes',width="100%"] |
| 30 | +.... |
| 31 | +<%= JSON.dump csr.wavedrom_desc(arch_def, 64) %> |
| 32 | +.... |
| 33 | +<%- else -%> |
| 34 | +<%# CSR has a dynamic length, or a field has a dynamic location, |
| 35 | + so there is more than one format to display -%> |
| 36 | +This CSR format changes dynamically. |
| 37 | + |
| 38 | +.<%= csr.name %> Format when <%= csr.length_cond32 %> |
| 39 | +[wavedrom, ,svg,subs='attributes',width="100%"] |
| 40 | +.... |
| 41 | +<%= JSON.dump csr.wavedrom_desc(arch_def, 32) %> |
| 42 | +.... |
| 43 | + |
| 44 | +.<%= csr.name %> Format when <%= csr.length_cond64 %> |
| 45 | +[wavedrom, ,svg,subs='attributes',width="100%"] |
| 46 | +.... |
| 47 | +<%= JSON.dump csr.wavedrom_desc(arch_def, 64) %> |
| 48 | +.... |
| 49 | +<%- end -%> |
| 50 | + |
| 51 | +== Field Summary |
| 52 | + |
| 53 | +[%autowidth,float="center",align="center",cols="^,<,<,<",options="header",role="stretch"] |
| 54 | +|=== |
| 55 | +|Name | Location | Type | Reset Value |
| 56 | + |
| 57 | +<%- csr.fields.each do |field| -%> |
| 58 | +| xref:<%=csr.name%>-<%=field.name%>-def[`<%= field.name %>`] |
| 59 | +| <%= field.location_pretty(arch_def) %> |
| 60 | +| <%= field.type_pretty(arch_def) %> |
| 61 | +| <%= field.reset_value_pretty(arch_def) %> |
| 62 | + |
| 63 | +<%- end -%> |
| 64 | +|=== |
| 65 | + |
| 66 | +== Fields |
| 67 | + |
| 68 | +<%- if csr.fields.empty? -%> |
| 69 | +This CSR has no fields. However, it must still exist (not cause an `Illegal Instruction` trap) and always return zero on a read. |
| 70 | +<%- else -%> |
| 71 | + |
| 72 | +<%- csr.fields.each do |field| -%> |
| 73 | +[[<%=csr.name%>-<%=field.name%>-def]] |
| 74 | +=== `<%= field.name %>` |
| 75 | + |
| 76 | +[example] |
| 77 | +**** |
| 78 | +Location:: |
| 79 | +<%= field.location_pretty(arch_def) %> |
| 80 | + |
| 81 | +Description:: |
| 82 | +<%= field.description %> |
| 83 | + |
| 84 | +Type:: |
| 85 | +<%= field.type_pretty(arch_def) %> |
| 86 | + |
| 87 | +Reset value:: |
| 88 | +<%= field.reset_value_pretty(arch_def) %> |
| 89 | + |
| 90 | +**** |
| 91 | + |
| 92 | +<%- end -%> |
| 93 | +<%- end -%> |
| 94 | + |
| 95 | +<%- if csr.fields.map(&:has_custom_sw_write?).any? -%> |
| 96 | +== Software write |
| 97 | + |
| 98 | +This CSR may store a value that is different from what software attempts to write. |
| 99 | + |
| 100 | +When a software write occurs (_e.g._, through `csrrw`), the following determines the |
| 101 | +written value: |
| 102 | + |
| 103 | +[idl] |
| 104 | +---- |
| 105 | +<%- csr.fields.each do |field| -%> |
| 106 | +<%- if field.has_custom_sw_write? -%> |
| 107 | +<%= field.name %> = <%= field["sw_write(csr_value)"] %> |
| 108 | +<%- else -%> |
| 109 | +<%= field.name %> = csr_value.<%= field.name %> |
| 110 | +<%- end -%> |
| 111 | +<%- end -%> |
| 112 | +---- |
| 113 | +<%- end -%> |
| 114 | + |
| 115 | +<%- if csr.has_custom_sw_read? -%> |
| 116 | +== Software read |
| 117 | + |
| 118 | +This CSR may return a value that is different from what is stored in hardware. |
| 119 | + |
| 120 | +[source,idl,subs="specialchars,macros"] |
| 121 | +---- |
| 122 | +<%= csr.sw_read_ast(arch_def.idl_compiler).gen_adoc %> |
| 123 | +---- |
| 124 | +<%- end -%> |
| 125 | + |
0 commit comments