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 - PC, MSR, CTR, LR, TAR, SRR1, SRR2
12 Note: this should NOT have name conventions hard-coded (dedicated ports per
13 regname). However it is convenient for now.
17 * https://bugs.libre-soc.org/show_bug.cgi?id=345
18 * https://bugs.libre-soc.org/show_bug.cgi?id=351
19 * https://libre-soc.org/3d_gpu/architecture/regfile/
20 * https://libre-soc.org/openpower/isatables/sprs.csv
25 from soc
.regfile
.regfile
import RegFile
, RegFileArray
26 from soc
.regfile
.virtual_port
import VirtualRegPort
27 from soc
.decoder
.power_enums
import SPR
31 class IntRegs(RegFileArray
):
34 * QTY 32of 64-bit registers
36 * Array-based unary-indexed (not binary-indexed)
37 * write-through capability (read on same cycle as write)
40 super().__init
__(64, 32)
41 self
.w_ports
= {'o': self
.write_port("dest1"),
42 'o1': self
.write_port("dest2")} # for now (LD/ST update)
43 self
.r_ports
= {'ra': self
.read_port("src1"),
44 'rb': self
.read_port("src2"),
45 'rc': self
.read_port("src3")}
49 class FastRegs(RegFileArray
):
52 FAST regfile - PC, MSR, CTR, LR, TAR, SRR1, SRR2
54 * QTY 8of 64-bit registers
56 * Array-based unary-indexed (not binary-indexed)
57 * write-through capability (read on same cycle as write)
67 super().__init
__(64, 8)
68 self
.w_ports
= {'nia': self
.write_port("dest1"),
69 'msr': self
.write_port("dest2"),
70 'spr1': self
.write_port("dest3"),
71 'spr2': self
.write_port("dest3")}
72 self
.r_ports
= {'cia': self
.read_port("src1"),
73 'msr': self
.read_port("src2"),
74 'spr1': self
.read_port("src3"),
75 'spr2': self
.read_port("src3")}
79 class CRRegs(VirtualRegPort
):
80 """Condition Code Registers (CR0-7)
82 * QTY 8of 8-bit registers
83 * 3R1W 4-bit-wide with additional 1R1W for the "full" 32-bit width
84 * Array-based unary-indexed (not binary-indexed)
85 * write-through capability (read on same cycle as write)
88 super().__init
__(32, 8)
89 self
.w_ports
= {'full_cr': self
.full_wr
, # 32-bit (masked, 8-en lines)
90 'cr_a': self
.write_port("dest1"), # 4-bit, unary-indexed
91 'cr_b': self
.write_port("dest2")} # 4-bit, unary-indexed
92 self
.r_ports
= {'full_cr': self
.full_rd
, # 32-bit (masked, 8-en lines)
93 'cr_a': self
.read_port("src1"),
94 'cr_b': self
.read_port("src2"),
95 'cr_c': self
.read_port("src3")}
99 class XERRegs(VirtualRegPort
):
100 """XER Registers (SO, CA/CA32, OV/OV32)
102 * QTY 3of 2-bit registers
103 * 3R3W 2-bit-wide with additional 1R1W for the "full" 6-bit width
104 * Array-based unary-indexed (not binary-indexed)
105 * write-through capability (read on same cycle as write)
107 SO
=0 # this is actually 2-bit but we ignore 1 bit of it
111 super().__init
__(6, 3)
112 self
.w_ports
= {'full_xer': self
.full_wr
, # 6-bit (masked, 3-en lines)
113 'xer_so': self
.write_port("dest1"),
114 'xer_ca': self
.write_port("dest2"),
115 'xer_ov': self
.write_port("dest3")}
116 self
.r_ports
= {'full_xer': self
.full_rd
, # 6-bit (masked, 3-en lines)
117 'xer_so': self
.read_port("src1"),
118 'xer_ca': self
.read_port("src2"),
119 'xer_ov': self
.read_port("src3")}
123 class SPRRegs(RegFile
):
126 * QTY len(SPRs) 64-bit registers
128 * binary-indexed but REQUIRES MAPPING
129 * write-through capability (read on same cycle as write)
133 super().__init
__(64, n_sprs
)
134 self
.w_ports
= {'spr': self
.write_port(name
="dest")}
135 self
.r_ports
= {'spr': self
.read_port("src")}
138 # class containing all regfiles: int, cr, xer, fast, spr
142 for (name
, kls
) in [('int', IntRegs
),
147 rf
= self
.rf
[name
] = kls()
148 setattr(self
, name
, rf
)
150 def elaborate_into(self
, m
, platform
):
151 for (name
, rf
) in self
.rf
.items():
152 setattr(m
.submodules
, name
, rf
)