mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-16 19:06:18 +00:00
add support for memories to c++ and smtlib functional backends
This commit is contained in:
parent
76371d177f
commit
7b29d177ac
5 changed files with 226 additions and 50 deletions
|
@ -363,4 +363,23 @@ Signal<n> $sign_extend(Signal<m> const& a)
|
|||
return ret;
|
||||
}
|
||||
|
||||
template<size_t a, size_t d>
|
||||
struct Memory {
|
||||
std::array<Signal<d>, 1<<a> contents;
|
||||
};
|
||||
|
||||
template<size_t a, size_t d>
|
||||
Signal<d> $memory_read(Memory<a, d> memory, Signal<a> addr)
|
||||
{
|
||||
return memory.contents[as_int(addr)];
|
||||
}
|
||||
|
||||
template<size_t a, size_t d>
|
||||
Memory<a, d> $memory_write(Memory<a, d> memory, Signal<a> addr, Signal<d> data)
|
||||
{
|
||||
Memory<a, d> ret = memory;
|
||||
ret.contents[as_int(addr)] = data;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue