manta/dev/memory_core/index.html

1286 lines
37 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="description" content="Manta Documentation">
<meta name="author" content="Fischer Moseley">
<link rel="canonical" href="https://fischermoseley.github.io/manta/dev/memory_core/">
<link rel="prev" href="../logic_analyzer_core/">
<link rel="next" href="../uart_interface/">
<link rel="icon" href="../assets/logo_ray_only_with_shadow.png">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.6.11">
<title>Memory Core - Manta Documentation</title>
<link rel="stylesheet" href="../assets/stylesheets/main.4af4bdda.min.css">
<link rel="stylesheet" href="../assets/stylesheets/palette.06af60db.min.css">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,700,700i%7CRoboto+Mono:400,400i,700,700i&display=fallback">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<link rel="stylesheet" href="../assets/_mkdocstrings.css">
<link rel="stylesheet" href="../stylesheets/extra.css">
<script>__md_scope=new URL("..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
</head>
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#overview" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<div data-md-color-scheme="default" data-md-component="outdated" hidden>
<aside class="md-banner md-banner--warning">
<div class="md-banner__inner md-grid md-typeset">
You're not viewing the latest version.
<a href="../..">
<strong>Click here to go to latest.</strong>
</a>
</div>
<script>var el=document.querySelector("[data-md-component=outdated]"),base=new URL(".."),outdated=__md_get("__outdated",sessionStorage,base);!0===outdated&&el&&(el.hidden=!1)</script>
</aside>
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href=".." title="Manta Documentation" class="md-header__button md-logo" aria-label="Manta Documentation" data-md-component="logo">
<img src="../assets/logo_minimal_border.png" alt="logo">
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
Manta Documentation
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Memory Core
</span>
</div>
</div>
</div>
<form class="md-header__option" data-md-component="palette">
<input class="md-option" data-md-color-media="(prefers-color-scheme)" data-md-color-scheme="default" data-md-color-primary="indigo" data-md-color-accent="indigo" aria-label="Switch to light mode" type="radio" name="__palette" id="__palette_0">
<label class="md-header__button md-icon" title="Switch to light mode" for="__palette_1" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 8a4 4 0 0 0-4 4 4 4 0 0 0 4 4 4 4 0 0 0 4-4 4 4 0 0 0-4-4m0 10a6 6 0 0 1-6-6 6 6 0 0 1 6-6 6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
</label>
<input class="md-option" data-md-color-media="(prefers-color-scheme: light)" data-md-color-scheme="default" data-md-color-primary="blue" data-md-color-accent="custom" aria-label="Switch to dark mode" type="radio" name="__palette" id="__palette_1">
<label class="md-header__button md-icon" title="Switch to dark mode" for="__palette_2" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 18c-.89 0-1.74-.2-2.5-.55C11.56 16.5 13 14.42 13 12s-1.44-4.5-3.5-5.45C10.26 6.2 11.11 6 12 6a6 6 0 0 1 6 6 6 6 0 0 1-6 6m8-9.31V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12z"/></svg>
</label>
<input class="md-option" data-md-color-media="(prefers-color-scheme: dark)" data-md-color-scheme="slate" data-md-color-primary="black" data-md-color-accent="custom" aria-label="Switch to system preference" type="radio" name="__palette" id="__palette_2">
<label class="md-header__button md-icon" title="Switch to system preference" for="__palette_0" hidden>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="m14.3 16-.7-2h-3.2l-.7 2H7.8L11 7h2l3.2 9zM20 8.69V4h-4.69L12 .69 8.69 4H4v4.69L.69 12 4 15.31V20h4.69L12 23.31 15.31 20H20v-4.69L23.31 12zm-9.15 3.96h2.3L12 9z"/></svg>
</label>
</form>
<script>var palette=__md_get("__palette");if(palette&&palette.color){if("(prefers-color-scheme)"===palette.color.media){var media=matchMedia("(prefers-color-scheme: light)"),input=document.querySelector(media.matches?"[data-md-color-media='(prefers-color-scheme: light)']":"[data-md-color-media='(prefers-color-scheme: dark)']");palette.color.media=input.getAttribute("data-md-color-media"),palette.color.scheme=input.getAttribute("data-md-color-scheme"),palette.color.primary=input.getAttribute("data-md-color-primary"),palette.color.accent=input.getAttribute("data-md-color-accent")}for(var[key,value]of Object.entries(palette.color))document.body.setAttribute("data-md-color-"+key,value)}</script>
<div class="md-header__source">
<a href="https://github.com/fischermoseley/manta/" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
</div>
<div class="md-source__repository">
fischermoseley/manta
</div>
</a>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href=".." title="Manta Documentation" class="md-nav__button md-logo" aria-label="Manta Documentation" data-md-component="logo">
<img src="../assets/logo_minimal_border.png" alt="logo">
</a>
Manta Documentation
</label>
<div class="md-nav__source">
<a href="https://github.com/fischermoseley/manta/" title="Go to repository" class="md-source" data-md-component="source">
<div class="md-source__icon md-icon">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--! Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2024 Fonticons, Inc.--><path d="M439.55 236.05 244 40.45a28.87 28.87 0 0 0-40.81 0l-40.66 40.63 51.52 51.52c27.06-9.14 52.68 16.77 43.39 43.68l49.66 49.66c34.23-11.8 61.18 31 35.47 56.69-26.49 26.49-70.21-2.87-56-37.34L240.22 199v121.85c25.3 12.54 22.26 41.85 9.08 55a34.34 34.34 0 0 1-48.55 0c-17.57-17.6-11.07-46.91 11.25-56v-123c-20.8-8.51-24.6-30.74-18.64-45L142.57 101 8.45 235.14a28.86 28.86 0 0 0 0 40.81l195.61 195.6a28.86 28.86 0 0 0 40.8 0l194.69-194.69a28.86 28.86 0 0 0 0-40.81"/></svg>
</div>
<div class="md-source__repository">
fischermoseley/manta
</div>
</a>
</div>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href=".." class="md-nav__link">
<span class="md-ellipsis">
Home
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../installation/" class="md-nav__link">
<span class="md-ellipsis">
Installation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../getting_started/" class="md-nav__link">
<span class="md-ellipsis">
Getting Started
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../use_cases/" class="md-nav__link">
<span class="md-ellipsis">
Use Cases
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../architecture/" class="md-nav__link">
<span class="md-ellipsis">
Architecture
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../similar_tools/" class="md-nav__link">
<span class="md-ellipsis">
Similar Tools
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_7" checked>
<label class="md-nav__link" for="__nav_7" id="__nav_7_label" tabindex="">
<span class="md-ellipsis">
Cores
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_7_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_7">
<span class="md-nav__icon md-icon"></span>
Cores
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../io_core/" class="md-nav__link">
<span class="md-ellipsis">
IO Core
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../logic_analyzer_core/" class="md-nav__link">
<span class="md-ellipsis">
Logic Analyzer Core
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
Memory Core
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Memory Core
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#overview" class="md-nav__link">
<span class="md-ellipsis">
Overview
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#on-chip-implementation" class="md-nav__link">
<span class="md-ellipsis">
On-Chip Implementation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#configuration" class="md-nav__link">
<span class="md-ellipsis">
Configuration
</span>
</a>
<nav class="md-nav" aria-label="Configuration">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#verilog-based-workflows" class="md-nav__link">
<span class="md-ellipsis">
Verilog-Based Workflows
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#amaranth-native-designs" class="md-nav__link">
<span class="md-ellipsis">
Amaranth-Native Designs
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#operation" class="md-nav__link">
<span class="md-ellipsis">
Operation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#python-api-documentation" class="md-nav__link">
<span class="md-ellipsis">
Python API Documentation
</span>
</a>
<nav class="md-nav" aria-label="Python API Documentation">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#manta.MemoryCore" class="md-nav__link">
<span class="md-ellipsis">
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code>&nbsp;MemoryCore
</span>
</a>
<nav class="md-nav" aria-label=" MemoryCore">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#manta.MemoryCore.read" class="md-nav__link">
<span class="md-ellipsis">
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code>&nbsp;read
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#manta.MemoryCore.write" class="md-nav__link">
<span class="md-ellipsis">
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code>&nbsp;write
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_8" >
<label class="md-nav__link" for="__nav_8" id="__nav_8_label" tabindex="">
<span class="md-ellipsis">
Interfaces
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_8_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_8">
<span class="md-nav__icon md-icon"></span>
Interfaces
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../uart_interface/" class="md-nav__link">
<span class="md-ellipsis">
UART Interface
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../ethernet_interface/" class="md-nav__link">
<span class="md-ellipsis">
Ethernet Interface
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--section md-nav__item--nested">
<input class="md-nav__toggle md-toggle md-toggle--indeterminate" type="checkbox" id="__nav_9" >
<label class="md-nav__link" for="__nav_9" id="__nav_9_label" tabindex="">
<span class="md-ellipsis">
For Developers
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_9_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_9">
<span class="md-nav__icon md-icon"></span>
For Developers
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="https://github.com/fischermoseley/manta/milestones" class="md-nav__link">
<span class="md-ellipsis">
Roadmap
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#overview" class="md-nav__link">
<span class="md-ellipsis">
Overview
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#on-chip-implementation" class="md-nav__link">
<span class="md-ellipsis">
On-Chip Implementation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#configuration" class="md-nav__link">
<span class="md-ellipsis">
Configuration
</span>
</a>
<nav class="md-nav" aria-label="Configuration">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#verilog-based-workflows" class="md-nav__link">
<span class="md-ellipsis">
Verilog-Based Workflows
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#amaranth-native-designs" class="md-nav__link">
<span class="md-ellipsis">
Amaranth-Native Designs
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#operation" class="md-nav__link">
<span class="md-ellipsis">
Operation
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#python-api-documentation" class="md-nav__link">
<span class="md-ellipsis">
Python API Documentation
</span>
</a>
<nav class="md-nav" aria-label="Python API Documentation">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#manta.MemoryCore" class="md-nav__link">
<span class="md-ellipsis">
<code class="doc-symbol doc-symbol-toc doc-symbol-class"></code>&nbsp;MemoryCore
</span>
</a>
<nav class="md-nav" aria-label=" MemoryCore">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#manta.MemoryCore.read" class="md-nav__link">
<span class="md-ellipsis">
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code>&nbsp;read
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#manta.MemoryCore.write" class="md-nav__link">
<span class="md-ellipsis">
<code class="doc-symbol doc-symbol-toc doc-symbol-method"></code>&nbsp;write
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1>Memory Core</h1>
<h2 id="overview">Overview</h2>
<p>Memory is used to store data when the space needed exceeds a few registers. As a result, Manta provides a Memory core, which instantiates a dual-port RAM on the FPGA. One port is provided to the host, and the other is connected to your logic with a simple <code>addr</code>/<code>data_in</code>/<code>data_out</code>/<code>write_enable</code> interface. This allows the host machine to exchange larger amounts of data with your logic on the FPGA.</p>
<p>This is a very, very simple task - however it's surprisingly useful in practice. Both the <a href="../use_cases">Use Cases</a> page and the repository's <a href="https://github.com/fischermoseley/manta/tree/main/examples">examples</a> folder contain examples of the Memory Core for your reference.</p>
<p>Manta won't impose any limit on the width or depth of the memory you instantiate, but you will be limited by the available resources and timing properties of your FPGA.</p>
<div class="admonition warning">
<p class="admonition-title">Words update 16 bits at a time!</p>
<p>Due to the structure of Manta's internal bus, the Memory core only updates 16 bits of a word at a time. For instance, writing a new value to a 33-bit wide memory would update bits 0-15 on one clock cycle, bits 16-31 on another, and bit 32 on another still. Manta makes no guarantees about the time taken between each of these updates. If this is a problem for your application, consider using an IO Core as a doorbell to signal when the memory is valid, or ping-pong between two Memory Cores.</p>
</div>
<h2 id="on-chip-implementation">On-Chip Implementation</h2>
<p>Manta will make a best-effort attempt to implement the memory in Block RAM, if it is available on the device. This is done by exporting Verilog that synthesis tools should infer as Block RAMs, however this inference is not guaranteed. Depending on your toolchain and the FPGA's architecture, the Verilog produced by Manta may be implemented as FF RAM, LUT (Distributed) RAM, or something else. These memory types are well explained in the <a href="https://yosyshq.readthedocs.io/projects/yosys/en/latest/using_yosys/synthesis/memory.html">Yosys documentation</a>, but be sure to check your toolchain's documentation as well.</p>
<h2 id="configuration">Configuration</h2>
<p>As explained in the <a href="../getting_started">getting started</a> page, the Memory Core must be configured and included in the FPGA design before it can be operated. Configuration is performed differently depending on if you're using a traditional Verilog-based workflow, or if you're building an Amaranth-native design.</p>
<h3 id="verilog-based-workflows">Verilog-Based Workflows</h3>
<p>The Memory Core is used by adding an entry in a <code>cores</code> section of a configuration file. This is best shown by example:</p>
<div class="language-yaml highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nn">---</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a><span class="nt">cores</span><span class="p">:</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="w"> </span><span class="nt">my_memory</span><span class="p">:</span>
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a><span class="w"> </span><span class="nt">type</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">memory</span>
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a><span class="w"> </span><span class="nt">mode</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">bidirectional</span>
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a><span class="w"> </span><span class="nt">width</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">12</span>
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a><span class="w"> </span><span class="nt">depth</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">16384</span>
</span></code></pre></div>
<p>Inside this configuration, the following parameters may be set:</p>
<ul>
<li><code>name</code>: The name of the Memory core, which is used when working with the API.</li>
<li><code>type</code>: This denotes that this is a Memory core. All cores contain a <code>type</code> field, which must be set to <code>memory</code> to be recognized as an Memory core.</li>
<li><code>mode</code>: The mode for the Memory core to operate in. This must be one of <code>bidirectional</code>, <code>host_to_fpga</code>, or <code>fpga_to_host</code>. Bidirectional memories can be both read or written to by the host and FPGA, but they require the use of a True Dual Port RAM, which is not available on all platforms (most notably, the ice40). Host-to-fpga and fpga-to-host RAMs only require a Simple Dual Port RAM, which is available on nearly all platforms.</li>
<li><code>width</code>: The width of the Memory core, in bits.</li>
<li><code>depth</code>: The depth of the Memory core, in entries.</li>
</ul>
<h3 id="amaranth-native-designs">Amaranth-Native Designs</h3>
<p>Since Amaranth modules are Python objects, the configuration of the Memory Core is given by the arguments given during initialization. See the documentation for the <code>MemoryCore</code> <a href="#manta.MemoryCore">class constructor</a> below, as well as the Amaranth <a href="https://github.com/fischermoseley/manta/tree/main/examples/amaranth">examples</a> in the repo.</p>
<h2 id="operation">Operation</h2>
<p>Regardless of the technique you used to configure your Memory Core, it is operated using the <a href="#manta.MemoryCore.read"><code>read()</code></a> and <a href="#manta.MemoryCore.write"><code>write()</code></a> methods. Documentation for these methods is available below.</p>
<p>These methods are members of the <code>MemoryCore</code> class, so if you're using Manta in a Verilog-based workflow, you'll first need to obtain a <code>Manta</code> object that contains an <code>MemoryCore</code> member. This is done with <code>Manta.from_config()</code>, as shown in the Verilog <a href="https://github.com/fischermoseley/manta/tree/main/examples/verilog">examples</a>.</p>
<h2 id="python-api-documentation">Python API Documentation</h2>
<div class="doc doc-object doc-class">
<h3 id="manta.MemoryCore" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-class"></code> <span class="doc doc-object-name doc-class-name">manta.MemoryCore</span>
</h3>
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">MemoryCore</span><span class="p">(</span><span class="n">mode</span><span class="p">,</span> <span class="n">width</span><span class="p">,</span> <span class="n">depth</span><span class="p">)</span>
</span></code></pre></div>
<div class="doc doc-contents first">
<p>A synthesizable module for accessing a memory. This is accomplished by
instantiating a dual-port memory with one end tied to Manta's internal bus,
and the other provided to user logic.</p>
<p>Create a Memory Core with the given width and depth.</p>
<p>This function is the main mechanism for configuring a Memory Core in an
Amaranth-native design.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<ul>
<li class="doc-section-item field-body">
<b><code>mode</code></b>
(<code><span title="str">str</span></code>)
<div class="doc-md-description">
<p>Must be one of <code>bidirectional</code>, <code>host_to_fpga</code>, or
'fpga_to_host'. Bidirectional memories can be both read or
written to by the host and FPGA, but they require the use
of a True Dual Port RAM, which is not available on all
platforms (most notably, the ice40). Host-to-fpga and
fpga-to-host RAMs only require a Simple Dual Port RAM, which
is available on nearly all platforms.</p>
</div>
</li>
<li class="doc-section-item field-body">
<b><code>width</code></b>
(<code><span title="int">int</span></code>)
<div class="doc-md-description">
<p>The width of the memory, in bits.</p>
</div>
</li>
<li class="doc-section-item field-body">
<b><code>depth</code></b>
(<code><span title="int">int</span></code>)
<div class="doc-md-description">
<p>The depth of the memory, in entries.</p>
</div>
</li>
</ul>
<div class="doc doc-children">
<div class="doc doc-object doc-function">
<h4 id="manta.MemoryCore.read" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">read</span>
</h4>
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">read</span><span class="p">(</span><span class="n">addrs</span><span class="p">)</span>
</span></code></pre></div>
<div class="doc doc-contents ">
<p>Read the data stored in the Memory Core at one or many address.</p>
<p>This function can read from either one or multiple addresses at a time.
Due to the the IO latency in most OSes, a single multi-address read is
significantly faster than multiple single-address reads. Prefer their
usage where possible. This method is blocking.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<ul>
<li class="doc-section-item field-body">
<b><code>addrs</code></b>
(<code><span title="int">int</span> | <span title="List">List</span>[<span title="int">int</span>]</code>)
<div class="doc-md-description">
<p>The memory address (or addresses) to read
from.</p>
</div>
</li>
</ul>
<p><span class="doc-section-title">Returns:</span></p>
<ul>
<li class="doc-section-item field-body">
<b><code>datas</code></b> ( <code><span title="int">int</span> | <span title="List">List</span>[<span title="int">int</span>]</code>
)
<div class="doc-md-description">
<p>The data stored at the address (or
addresses), represented as an unsigned integer.</p>
</div>
</li>
</ul>
<p><span class="doc-section-title">Raises:</span></p>
<ul>
<li class="doc-section-item field-body">
<code><span title="TypeError">TypeError</span></code>
<div class="doc-md-description">
<p>addrs is not an integer or list of integers.</p>
</div>
</li>
</ul>
</div>
</div>
<div class="doc doc-object doc-function">
<h4 id="manta.MemoryCore.write" class="doc doc-heading">
<code class="doc-symbol doc-symbol-heading doc-symbol-method"></code> <span class="doc doc-object-name doc-function-name">write</span>
</h4>
<div class="language-python doc-signature highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nf">write</span><span class="p">(</span><span class="n">addrs</span><span class="p">,</span> <span class="n">datas</span><span class="p">)</span>
</span></code></pre></div>
<div class="doc doc-contents ">
<p>Write data to the Memory core at one or many addresses.</p>
<p>This function can write to either one or multiple addresses at a time.
Due to the the IO latency in most OSes, a single multi-address write is
significantly faster than multiple single-address write. Prefer their
usage where possible. This method is blocking.</p>
<p><span class="doc-section-title">Parameters:</span></p>
<ul>
<li class="doc-section-item field-body">
<b><code>addrs</code></b>
(<code><span title="int">int</span> | <span title="List">List</span>[<span title="int">int</span>]</code>)
<div class="doc-md-description">
<p>The memory address (or addresses) to write
to.</p>
</div>
</li>
<li class="doc-section-item field-body">
<b><code>datas</code></b>
(<code><span title="int">int</span> | <span title="List">List</span>[<span title="int">int</span>]</code>)
<div class="doc-md-description">
<p>The data to store at the address (or
addresses). This may be either positive or negative, but must
fit within the width of the memory.</p>
</div>
</li>
</ul>
<p><span class="doc-section-title">Returns:</span></p>
<ul>
<li class="doc-section-item field-body">
<div class="doc-md-description">
<p>None</p>
</div>
</li>
</ul>
<p><span class="doc-section-title">Raises:</span></p>
<ul>
<li class="doc-section-item field-body">
<code><span title="TypeError">TypeError</span></code>
<div class="doc-md-description">
<p>addrs or datas is not an integer or list of integers.</p>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"base": "..", "features": ["content.code.copy", "content.code.annotate", "navigation.sections", "navigation.expand"], "search": "../assets/javascripts/workers/search.f8cc74c7.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": {"provider": "mike"}}</script>
<script src="../assets/javascripts/bundle.c8b220af.min.js"></script>
<script src="../javascripts/mathjax.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
</body>
</html>