1 # POWER9 Register Files
4 Defines the following register files:
6 * INT regfile - 32x 64-bit
7 * SPR regfile - 110x 64-bit
9 * XER regfile - XER.so, XER.ca/ca32, XER.ov/ov32
10 * FAST regfile - CTR, LR, TAR, SRR1, SRR2
11 * STATE regfile - PC, MSR, (SimpleV VL later)
13 Note: this should NOT have name conventions hard-coded (dedicated ports per
14 regname). However it is convenient for now.
18 * https://bugs.libre-soc.org/show_bug.cgi?id=345
19 * https://bugs.libre-soc.org/show_bug.cgi?id=351
20 * https://libre-soc.org/3d_gpu/architecture/regfile/
21 * https://libre-soc.org/openpower/isatables/sprs.csv
26 from soc
.regfile
.regfile
import RegFile
, RegFileArray
, RegFileMem
27 from soc
.regfile
.virtual_port
import VirtualRegPort
28 from soc
.decoder
.power_enums
import SPR
32 class StateRegs(RegFileArray
):
35 State regfile - PC, MSR, DEC, TB and later SimpleV VL
37 * QTY 4of 64-bit registers
39 * Array-based unary-indexed (not binary-indexed)
40 * write-through capability (read on same cycle as write)
42 Note: d_wr1 d_rd1 are for use by the decoder, to get at the PC.
43 will probably have to also add one so it can get at the MSR as well.
46 Note: r/w state are used by SPR for MTSPR / MFSPR.
47 Note: r/w issue are used by issuer to increment/decrement TB/DEC.
54 super().__init
__(64, 4)
55 self
.w_ports
= {'nia': self
.write_port("nia"),
56 'msr': self
.write_port("msr"),
57 'state': self
.read_port("state"), # writing DEC/TB
58 'issue': self
.read_port("issue"), # writing DEC/TB
59 'd_wr1': self
.write_port("d_wr1")} # writing PC (issuer)
60 self
.r_ports
= {'cia': self
.read_port("cia"), # reading PC (issuer)
61 'msr': self
.read_port("msr"), # reading MSR (issuer)
62 'state': self
.read_port("state"), # reading DEC/TB
63 'issue': self
.read_port("issue"), # reading DEC/TB
68 class IntRegs(RegFileMem
): #class IntRegs(RegFileArray):
71 * QTY 32of 64-bit registers
73 * Array-based unary-indexed (not binary-indexed)
74 * write-through capability (read on same cycle as write)
77 super().__init
__(64, 32)
78 self
.w_ports
= {'o': self
.write_port("dest1"),
79 #'o1': self.write_port("dest2") # for now (LD/ST update)
81 self
.r_ports
= {'ra': self
.read_port("src1"),
82 'rb': self
.read_port("src2"),
83 'rc': self
.read_port("src3"),
84 'dmi': self
.read_port("dmi")} # needed for Debug (DMI)
88 class FastRegs(RegFileMem
): #RegFileArray):
91 FAST regfile - CTR, LR, TAR, SRR1, SRR2, XER
93 * QTY 6of 64-bit registers
95 * Array-based unary-indexed (not binary-indexed)
96 * write-through capability (read on same cycle as write)
103 XER
= 5 # non-XER bits
105 super().__init
__(64, 6)
106 self
.w_ports
= {'fast1': self
.write_port("dest1"),
108 self
.r_ports
= {'fast1': self
.read_port("src1"),
109 'fast2': self
.read_port("src2"),
114 class CRRegs(VirtualRegPort
):
115 """Condition Code Registers (CR0-7)
117 * QTY 8of 8-bit registers
118 * 3R1W 4-bit-wide with additional 1R1W for the "full" 32-bit width
119 * Array-based unary-indexed (not binary-indexed)
120 * write-through capability (read on same cycle as write)
123 super().__init
__(32, 8, rd2
=True)
124 self
.w_ports
= {'full_cr': self
.full_wr
, # 32-bit (masked, 8-en lines)
125 'cr_a': self
.write_port("dest1"), # 4-bit, unary-indexed
126 'cr_b': self
.write_port("dest2")} # 4-bit, unary-indexed
127 self
.r_ports
= {'full_cr': self
.full_rd
, # 32-bit (masked, 8-en lines)
128 'full_cr_dbg': self
.full_rd2
, # for DMI
129 'cr_a': self
.read_port("src1"),
130 'cr_b': self
.read_port("src2"),
131 'cr_c': self
.read_port("src3")}
135 class XERRegs(VirtualRegPort
):
136 """XER Registers (SO, CA/CA32, OV/OV32)
138 * QTY 3of 2-bit registers
139 * 3R3W 2-bit-wide with additional 1R1W for the "full" 6-bit width
140 * Array-based unary-indexed (not binary-indexed)
141 * write-through capability (read on same cycle as write)
143 SO
=0 # this is actually 2-bit but we ignore 1 bit of it
147 super().__init
__(6, 3)
148 self
.w_ports
= {'full_xer': self
.full_wr
, # 6-bit (masked, 3-en lines)
149 'xer_so': self
.write_port("dest1"),
150 'xer_ca': self
.write_port("dest2"),
151 'xer_ov': self
.write_port("dest3")}
152 self
.r_ports
= {'full_xer': self
.full_rd
, # 6-bit (masked, 3-en lines)
153 'xer_so': self
.read_port("src1"),
154 'xer_ca': self
.read_port("src2"),
155 'xer_ov': self
.read_port("src3")}
159 class SPRRegs(RegFileMem
):
162 * QTY len(SPRs) 64-bit registers
164 * binary-indexed but REQUIRES MAPPING
165 * write-through capability (read on same cycle as write)
169 super().__init
__(width
=64, depth
=n_sprs
)
170 self
.w_ports
= {'spr1': self
.write_port("spr1")}
171 self
.r_ports
= {'spr1': self
.read_port("spr1")}
174 # class containing all regfiles: int, cr, xer, fast, spr
178 for (name
, kls
) in [('int', IntRegs
),
182 ('state', StateRegs
),
184 rf
= self
.rf
[name
] = kls()
185 setattr(self
, name
, rf
)
187 def elaborate_into(self
, m
, platform
):
188 for (name
, rf
) in self
.rf
.items():
189 setattr(m
.submodules
, name
, rf
)