集成电路技术分享

 找回密码
 我要注册

QQ登录

只需一步,快速开始

搜索
查看: 2182|回复: 4

请教vhdl中ram原理和语句的问题

[复制链接]
interige 发表于 2010-6-28 00:38:05 | 显示全部楼层 |阅读模式
这个程序请懂的高手给我讲下原理好吗?
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity sram is
generic(width:integer:=8;(generic是怎么用的啊,在什么情况下用啊)
  depth:integer:=8;
  adder:integer:=3);
port(datain:in std_logic_vector(width-1 downto 0);
  dataout
       
ut std_logic_vector(width-1 downto 0);
  clock:in std_logic;
  we,re:in std_logic;
   wadd:in std_logic_vector(adder-1 downto 0);
   radd:in std_logic_vector(adder-1 downto 0));
end sram;
architecture art of sram is
type men is array(0 to depth-1)of
std_logic_vector(width-1 downto 0);
signal ramtmp:men;
begin
process(clock)
begin
if(clock'event and clock='1')then
if(we='1')then
  ramtmp(conv_integer(wadd))<=datain;(这句话是什么意思)
end if;
end if;
end process;
process(clock)
begin
if(clock'event and clock='1')then
if(re='1')then
dataout<=ramtmp(conv_integer(radd));
  end if;
end if;
end process;
end art;
有大侠能帮忙吗?
tim 发表于 2010-6-28 02:10:48 | 显示全部楼层
关于&ldquo;generic(width:integer:=8;(generic是怎么用的啊,在什么情况下用啊)&rdquo;<br>
<br>
generic的作用相当于C中的 宏定义常量,用了提高程序可移值性的,只要修改generic中的参数就可以达到修改(改进)程序的目的。
longt 发表于 2010-6-28 03:53:12 | 显示全部楼层
conv_integer 是td_logic_arith.all;中的一个函数,用来实现数据类型转换,可以把相关类型转换成&ldquo;integer"型!
HANG 发表于 2010-6-28 04:47:30 | 显示全部楼层
谢谢楼上的大虾,我还是不太明白 ramtmp(conv_integer(wadd))&lt;=datain这句的意识啊  能具体举个例子吗?比如3-8译码器的里的句子,outp
       
ut bit_vector(7downto0)&nbsp; &nbsp;&nbsp; &nbsp;inp: in std_logic_vector(2downto0)&nbsp;&nbsp;        outp(covn_integer(inp))&lt;='1'这句的功能是把inp转化为整形, 但是不知道这个1是赋值给几个单元的.covn_integer(inp)代表几个数啊.希望大家帮帮我啊 我是刚开始学的.
yihui 发表于 2011-1-14 14:40:53 | 显示全部楼层
O(∩_∩)O谢谢
您需要登录后才可以回帖 登录 | 我要注册

本版积分规则

关闭

站长推荐上一条 /1 下一条

QQ|小黑屋|手机版|Archiver|集成电路技术分享 ( 京ICP备20003123号-1 )

GMT+8, 2024-5-3 07:18 , Processed in 0.144873 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表