阅读:2229回复:2
请教FPGA中如何实现这张常数表?
各位侠客:
我用xilinx的FPGA设计,想实现一个算法,该算法用到一个常数数组,在c语言中是这样表示的: M[0] = 10; M[1] = 201; M[2] = 28; M[3] = 31; M[4] = 125; ...... M[510] = 3; M[511] = 2; 一共有512个这样的数据,我不知道在FPGA设计中,这张表该如何实现,同事告诉我说用rom实现,但不知具体如何写Verilog代码,请各位大侠不吝赐教! 多谢! |
|
沙发#
发布于:2004-04-09 22:39
你可以用xilinx的core generator生成一个ram,
在ram中可以选择初始化文件 按照初始化文件的格式把你的数据加到文件中就好了 |
|
板凳#
发布于:2004-04-29 23:25
library IEEE;
use IEEE.STD_LOGIC_1164.all; use IEEE.STD_LOGIC_ARITH.all; entity ROM is port(rst : in STD_LOGIC; clk : in STD_LOGIC; addr : in UNSIGNED (11 downto 0); data : out UNSIGNED (7 downto 0); rd : in STD_LOGIC); end ROM; architecture BHV of ROM is type ROM_TYPE is array (0 to 541) of UNSIGNED (7 downto 0); constant PROGRAM : ROM_TYPE := ( \"00000010\", \"00000000\", \"11001010\", \"11110010\", \"00100010\"); begin process(rst, clk) begin if( rst = \'1\' ) then data <= (others=>\'0\'); elsif( clk\'event and clk = \'1\' ) then if( rd = \'1\' ) then data <= PROGRAM(conv_integer(addr)); else data <= (others=>\'0\'); end if; end if; end process; end BHV; [编辑 - 4/29/04 by gavinux] |
|
|