3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-07-31 08:23:19 +00:00

kernel/mem: Add sub_addr helpers.

This commit is contained in:
Marcelina Kościelnicka 2021-05-26 02:49:50 +02:00
parent 57ca51be76
commit 83a218141c
3 changed files with 32 additions and 26 deletions

View file

@ -34,7 +34,16 @@ struct MemRd {
Const arst_value, srst_value, init_value;
bool transparent;
SigSpec clk, en, arst, srst, addr, data;
MemRd() : removed(false), cell(nullptr) {}
// Returns the address of given subword index accessed by this port.
SigSpec sub_addr(int sub) {
SigSpec res = addr;
for (int i = 0; i < wide_log2; i++)
res[i] = State(sub >> i & 1);
return res;
}
};
struct MemWr {
@ -45,7 +54,16 @@ struct MemWr {
bool clk_enable, clk_polarity;
std::vector<bool> priority_mask;
SigSpec clk, en, addr, data;
MemWr() : removed(false), cell(nullptr) {}
// Returns the address of given subword index accessed by this port.
SigSpec sub_addr(int sub) {
SigSpec res = addr;
for (int i = 0; i < wide_log2; i++)
res[i] = State(sub >> i & 1);
return res;
}
};
struct MemInit {