⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch12.8.htm

📁 介绍asci设计的一本书
💻 HTM
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML EXPERIMENTAL 970324//EN">

<HTML>

<HEAD>

<META NAME="GENERATOR" CONTENT="Adobe FrameMaker 5.5/HTML Export Filter">



<TITLE> 12.8&nbsp;Memory Synthesis</TITLE></HEAD><!--#include file="top.html"--><!--#include file="header.html"-->



<DIV>

<P>[&nbsp;<A HREF="CH12.htm">Chapter&nbsp;start</A>&nbsp;]&nbsp;[&nbsp;<A HREF="CH12.7.htm">Previous&nbsp;page</A>&nbsp;]&nbsp;[&nbsp;<A HREF="CH12.9.htm">Next&nbsp;page</A>&nbsp;]</P><!--#include file="AmazonAsic.html"--><HR></DIV>

<H1 CLASS="Heading1">

<A NAME="pgfId=4460">

 </A>

12.8&nbsp;<A NAME="30625">

 </A>

Memory Synthesis</H1>

<P CLASS="BodyAfterHead">

<A NAME="pgfId=294190">

 </A>

There are several approaches to <A NAME="marker=395362">

 </A>

memory synthesis:</P>

<OL>

<LI CLASS="NumberFirst">

<A NAME="pgfId=294191">

 </A>

Random logic using flip-flops or latches</LI>

<LI CLASS="NumberList">

<A NAME="pgfId=294198">

 </A>

Register files in datapaths</LI>

<LI CLASS="NumberList">

<A NAME="pgfId=294199">

 </A>

RAM standard components</LI>

<LI CLASS="NumberList">

<A NAME="pgfId=294200">

 </A>

RAM compilers</LI>

</OL>

<P CLASS="Body">

<A NAME="pgfId=294203">

 </A>

The first approach uses large vectors or arrays in the HDL code. The synthesizer will map these elements to arrays of flip-flops or latches depending on how the timing of the assignments is handled. This approach is independent of any software or type of ASIC and is the easiest to use but inefficient in terms of area. A flip-flop may take up 10 to 20 times the area of a six-transistor static RAM cell.</P>

<P CLASS="Body">

<A NAME="pgfId=294204">

 </A>

The second approach uses a synthesis directive or hand instantiation to synthesize a memory to a datapath component. Usually the datapath components are constructed from latches in a regular array. These are slightly more efficient than a random arrangement of logic cells, but the way we create the memory then depends on the software and the ASIC technology we are using.</P>

<P CLASS="Body">

<A NAME="pgfId=294205">

 </A>

The third approach uses standard components supplied by an ASIC vendor. For example, we can instantiate a small RAM using CLBs in a Xilinx FPGA. This approach is very dependent on the technology. For example, we could not easily transfer a design that uses Xilinx CLBs as SRAM to an Actel FPGA.</P>

<P CLASS="Body">

<A NAME="pgfId=294208">

 </A>

The last approach, using a custom RAM compiler, is the most area-efficient approach. It depends on having the capability to call a compiler from within the synthesis tool or to instantiate a component that has already been compiled.</P>

<DIV>

<H2 CLASS="Heading2">

<A NAME="pgfId=294193">

 </A>

12.8.1&nbsp;Memory Synthesis in Verilog</H2>

<P CLASS="BodyAfterHead">

<A NAME="pgfId=293226">

 </A>

Most synthesizers implement a Verilog memory array, such as the one shown in the following code, as an array of latches or flip-flops.</P>

<P CLASS="ComputerOneLine">

<A NAME="pgfId=293227">

 </A>

<B CLASS="Keyword">

reg</B>

 [31:0] MyMemory [3:0]; // a 4 x 32-bit register</P>

<P CLASS="Body">

<A NAME="pgfId=293228">

 </A>

For example, the following code models a small RAM, and the synthesizer maps the memory array to sequential logic:</P>

<P CLASS="ComputerFirstLabelV">

<A NAME="pgfId=293229">

 </A>

<B CLASS="Keyword">

module</B>

 RAM_1(A, CEB, WEB, OEB, INN, OUTT);</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293230">

 </A>

<B CLASS="Keyword">

	input</B>

 [6:0] A; <B CLASS="Keyword">

input</B>

 CEB,WEB,OEB; <B CLASS="Keyword">

input</B>

 [4:0]INN;</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293231">

 </A>

<B CLASS="Keyword">

	output</B>

 [4:0] OUTT; </P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293232">

 </A>

<B CLASS="Keyword">

	reg</B>

 [4:0] OUTT; <B CLASS="Keyword">

reg</B>

 [4:0] int_bus; <B CLASS="Keyword">

reg</B>

 [4:0] memory [127:0]; </P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293233">

 </A>

<B CLASS="Keyword">

always</B>

@(<B CLASS="Keyword">

negedge</B>

 CEB) <B CLASS="Keyword">

begin</B>

</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293234">

 </A>

	<B CLASS="Keyword">

if</B>

 (CEB == 0) <B CLASS="Keyword">

begin</B>

</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293235">

 </A>

		<B CLASS="Keyword">

if</B>

 (WEB == 1) int_bus = memory[A];</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293236">

 </A>

		<B CLASS="Keyword">

else</B>

 <B CLASS="Keyword">

if</B>

 (WEB == 0) <B CLASS="Keyword">

begin </B>

memory[A] = INN; int_bus = INN; <B CLASS="Keyword">

end</B>

</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293237">

 </A>

		<B CLASS="Keyword">

else</B>

 int_bus = 5'bxxxxx;</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293238">

 </A>

	<B CLASS="Keyword">

end</B>

</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293239">

 </A>

<B CLASS="Keyword">

end </B>

</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293240">

 </A>

<B CLASS="Keyword">

always</B>

@(OEB <B CLASS="Keyword">

or</B>

 int_bus) <B CLASS="Keyword">

begin</B>

</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293241">

 </A>

	<B CLASS="Keyword">

case</B>

 (OEB) 0 : OUTT = int_bus;</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293242">

 </A>

		<B CLASS="Keyword">

default</B>

 : OUTT = 5'bzzzzz; <B CLASS="Keyword">

endcase</B>

</P>

<P CLASS="ComputerLabelV">

<A NAME="pgfId=293243">

 </A>

<B CLASS="Keyword">

end </B>

</P>

<P CLASS="ComputerLastLabelV">

<A NAME="pgfId=293244">

 </A>

<B CLASS="Keyword">

endmodule </B>

</P>

<P CLASS="Body">

<A NAME="pgfId=293245">

 </A>

Memory synthesis using random control logic and transparent latches for each bit is reasonable only for small, fast register files, or for local RAM on an MGA or CBIC. For large RAMs synthesized memory becomes very expensive and instead you should normally use a dedicated RAM compiler. </P>

<P CLASS="Body">

<A NAME="pgfId=319528">

 </A>

Typically there will be restrictions on synthesizing RAM with multiple read/writes:</P>

<UL>

<LI CLASS="BulletFirst">

<A NAME="pgfId=293246">

 </A>

If you write to the same memory in two different processes, be careful to avoid address contention.</LI>

<LI CLASS="BulletList">

<A NAME="pgfId=293247">

 </A>

You need a multiport RAM if you read or write to multiple locations simultaneously. </LI>

<LI CLASS="BulletLast">

<A NAME="pgfId=293248">

 </A>

If you write and read the same memory location, you have to be very careful. To mimic hardware you need to read before you write so that you read the old memory value. If you attempt to write before reading, the difference between blocking and nonblocking assignments can lead to trouble.</LI>

</UL>

<P CLASS="Body">

<A NAME="pgfId=293249">

 </A>

You cannot make a memory access that depends on another memory access in the same clock cycle. For example, you cannot do this:</P>

<P CLASS="ComputerOneLine">

<A NAME="pgfId=293250">

 </A>

memory[i + 1] = memory[i]; // needs two clock cycles</P>

<P CLASS="BodyAfterHead">

<A NAME="pgfId=293251">

 </A>

or this:</P>

<P CLASS="ComputerOneLine">

<A NAME="pgfId=293252">

 </A>

pointer = memory[memory[i]]; // needs two clock cycles</P>

<P CLASS="Body">

<A NAME="pgfId=293253">

 </A>

For the same reason (but less obviously) we cannot do this:</P>

<P CLASS="ComputerOneLine">

<A NAME="pgfId=293254">

 </A>

pc = memory[addr1]; memory[addr2] = pc + 1; // not on the same cycle</P>

</DIV>

<DIV>

<H2 CLASS="Heading2">

<A NAME="pgfId=293222">

 </A>

12.8.2&nbsp;Memory Synthesis in VHDL</H2>

<P CLASS="BodyAfterHead">

<A NAME="pgfId=4464">

 </A>

VHDL allows multidimensional arrays so that we can synthesize a memory as an array of latches by declaring a two-dimensional array as follows:</P>

<P CLASS="ComputerOneLine">

<A NAME="pgfId=4468">

 </A>

<B CLASS="Keyword">

type</B>

 memStor <B CLASS="Keyword">

is</B>

 array(3 <B CLASS="Keyword">

downto</B>

 0) <B CLASS="Keyword">

of</B>

 <B CLASS="Keyword">

integer</B>

; -- This is OK.</P>

<P CLASS="ComputerFirst">

<A NAME="pgfId=4472">

 </A>

<B CLASS="Keyword">

subtype</B>

 MemReg <B CLASS="Keyword">

is</B>

 STD_LOGIC_VECTOR(15 <B CLASS="Keyword">

downto</B>

 0); -- So is this.</P>

<P CLASS="Computer">

<A NAME="pgfId=4474">

 </A>

<B CLASS="Keyword">

type</B>

 memStor <B CLASS="Keyword">

is</B>

 array(3 <B CLASS="Keyword">

downto</B>

 0) <B CLASS="Keyword">

of</B>

 MemReg;</P>

<P CLASS="Computer">

<A NAME="pgfId=4476">

 </A>

-- other code...</P>

<P CLASS="ComputerLast">

<A NAME="pgfId=4478">

 </A>

<B CLASS="Keyword">

signal</B>

 Mem1 : memStor;</P>

<P CLASS="Body">

<A NAME="pgfId=173408">

 </A>

As an example, the following code models a standard-cell RAM:</P>

<P CLASS="ComputerFirstLabel">

<A NAME="pgfId=288630">

 </A>

<B CLASS="Keyword">

library</B>

 IEEE; </P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=288665">

 </A>

<B CLASS="Keyword">

use</B>

 IEEE.STD_LOGIC_1164.<B CLASS="Keyword">

all</B>

;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4488">

 </A>

<B CLASS="Keyword">

package</B>

 RAM_package <B CLASS="Keyword">

is</B>

</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=288633">

 </A>

constant numOut : INTEGER := 8;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=288639">

 </A>

constant wordDepth: INTEGER := 8;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=288643">

 </A>

constant numAddr : INTEGER := 3;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4490">

 </A>

<B CLASS="Keyword">

subtype</B>

 MEMV <B CLASS="Keyword">

is</B>

 STD_LOGIC_VECTOR(numOut-1 <B CLASS="Keyword">

downto</B>

 0);</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4492">

 </A>

<B CLASS="Keyword">

type</B>

 MEM <B CLASS="Keyword">

is</B>

 <B CLASS="Keyword">

array</B>

 (wordDepth-1 <B CLASS="Keyword">

downto</B>

 0) <B CLASS="Keyword">

of</B>

 MEMV;</P>

<P CLASS="ComputerLastLabel">

<A NAME="pgfId=4494">

 </A>

<B CLASS="Keyword">

end</B>

 RAM_package;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=288626">

 </A>

<B CLASS="Keyword">

library</B>

 IEEE; </P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=288678">

 </A>

<B CLASS="Keyword">

use</B>

 IEEE.STD_LOGIC_1164.<B CLASS="Keyword">

all</B>

; <B CLASS="Keyword">

use</B>

 IEEE.NUMERIC_STD.<B CLASS="Keyword">

all</B>

;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4498">

 </A>

<B CLASS="Keyword">

use</B>

 work.RAM_package.<B CLASS="Keyword">

all</B>

;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4500">

 </A>

<B CLASS="Keyword">

entity</B>

 RAM_1 <B CLASS="Keyword">

is</B>

</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4502">

 </A>

	<B CLASS="Keyword">

port</B>

 (signal A : <B CLASS="Keyword">

in</B>

 STD_LOGIC_VECTOR(numAddr-1 <B CLASS="Keyword">

downto</B>

 0);</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4504">

 </A>

	<B CLASS="Keyword">

signal</B>

 CEB, WEB, OEB : <B CLASS="Keyword">

in</B>

 STD_LOGIC;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4506">

 </A>

	<B CLASS="Keyword">

signal</B>

 INN : <B CLASS="Keyword">

in</B>

  MEMV;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4508">

 </A>

	<B CLASS="Keyword">

signal</B>

 OUTT : <B CLASS="Keyword">

out</B>

 MEMV);</P>

<P CLASS="ComputerLastLabel">

<A NAME="pgfId=4510">

 </A>

<B CLASS="Keyword">

end </B>

RAM_1;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4514">

 </A>

<B CLASS="Keyword">

architecture</B>

 Synthesis_1 <B CLASS="Keyword">

of</B>

 RAM_1 <B CLASS="Keyword">

is</B>

</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4516">

 </A>

	<B CLASS="Keyword">

signal</B>

 i_bus : MEMV; -- RAM internal data latch</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4518">

 </A>

	<B CLASS="Keyword">

signal</B>

 mem : MEM;  -- RAM data </P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4524">

 </A>

	<B CLASS="Keyword">

begin</B>

</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4526">

 </A>

	<B CLASS="Keyword">

process</B>

 <B CLASS="Keyword">

begin</B>

</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4528">

 </A>

		<B CLASS="Keyword">

wait</B>

 <B CLASS="Keyword">

until</B>

 CEB = '0';</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4530">

 </A>

			<B CLASS="Keyword">

if</B>

 WEB = '1' <B CLASS="Keyword">

then</B>

 i_bus &lt;= mem(TO_INTEGER(UNSIGNED(A)));</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4534">

 </A>

			<B CLASS="Keyword">

elsif</B>

 WEB = '0' <B CLASS="Keyword">

then</B>

</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4536">

 </A>

				mem(TO_INTEGER(UNSIGNED(A))) &lt;= INN;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4538">

 </A>

				i_bus &lt;= INN;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4540">

 </A>

			<B CLASS="Keyword">

else</B>

 i_bus &lt;= (<B CLASS="Keyword">

others</B>

 =&gt; 'X');</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4542">

 </A>

			<B CLASS="Keyword">

end</B>

 <B CLASS="Keyword">

if</B>

;</P>

<P CLASS="ComputerLastLabel">

<A NAME="pgfId=4544">

 </A>

	<B CLASS="Keyword">

end</B>

 <B CLASS="Keyword">

process</B>

;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4550">

 </A>

	<B CLASS="Keyword">

process</B>

(OEB, int_bus) <B CLASS="Keyword">

begin </B>

-- control output drivers:</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4552">

 </A>

		<B CLASS="Keyword">

case</B>

 (OEB) <B CLASS="Keyword">

is</B>

</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4554">

 </A>

		<B CLASS="Keyword">

when</B>

 '0'     =&gt; OUTT &lt;= i_bus; </P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4556">

 </A>

		<B CLASS="Keyword">

when</B>

 '1'     =&gt; OUTT &lt;= (<B CLASS="Keyword">

others</B>

 =&gt; 'Z');</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4558">

 </A>

		<B CLASS="Keyword">

when</B>

 <B CLASS="Keyword">

others</B>

 =&gt; OUTT &lt;= (<B CLASS="Keyword">

others</B>

 =&gt; 'X');</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4560">

 </A>

		<B CLASS="Keyword">

end</B>

 <B CLASS="Keyword">

case</B>

;</P>

<P CLASS="ComputerLabel">

<A NAME="pgfId=4562">

 </A>

	<B CLASS="Keyword">

end</B>

 <B CLASS="Keyword">

process</B>

;</P>

<P CLASS="ComputerLastLabel">

<A NAME="pgfId=4564">

 </A>

<B CLASS="Keyword">

end</B>

 Synthesis_1; </P>

</DIV>

<HR><P>[&nbsp;<A HREF="CH12.htm">Chapter&nbsp;start</A>&nbsp;]&nbsp;[&nbsp;<A HREF="CH12.7.htm">Previous&nbsp;page</A>&nbsp;]&nbsp;[&nbsp;<A HREF="CH12.9.htm">Next&nbsp;page</A>&nbsp;]</P></BODY>



<!--#include file="Copyright.html"--><!--#include file="footer.html"-->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -