阅读:1321回复:6
大虾帮忙,双向口能写不能读
我的fpga与sram打交道,本想写入再读出,结果发现读出的全是0。我任取了一位d1往回读,结果能读出来,而且是正确的。不知为何8位同时读读不回来?我将双向口改为单向,也读不回来。下面是程序:
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity data_arbitration is port( clk : in std_logic; ior : in std_logic; iow : in std_logic; run : in std_logic; en_data : in std_logic; bus_sram_data : inout std_logic_vector(7 downto 0); sram_ph_data : out std_logic_vector(7 downto 0); data : inout std_logic_vector(7 downto 0) ); end data_arbitration; architecture a of data_arbitration is signal data_temp1 : std_logic_vector(7 downto 0); signal data_temp2 : std_logic_vector(7 downto 0); begin process (clk) begin if clk\'event and clk=\'1\' then if run=\'1\' then sram_ph_data<=data; elsif en_data=\'1\' and ior=\'0\' then data_temp1<=data; elsif en_data=\'1\' and iow=\'0\' then data_temp2<=bus_sram_data; end if; end if; end process; data<=data_temp2 when en_data=\'1\' and iow=\'0\' else \"ZZZZZZZZ\"; bus_sram_data<=data_temp1 when en_data=\'1\' and ior=\'0\' else \"ZZZZZZZZ\"; end a; |
|
沙发#
发布于:2003-08-01 07:59
没有作具体的仿真,你在process前加一句data_temp<=data;试试看,原来我的双向口都是这么用的
|
|
板凳#
发布于:2003-08-01 10:10
楼上大虾,如果data_temp1<=data;的话,报错,编译都不通过。如果另设一新的signal:data_temp的话,按照你的说法做,则没什么效果。我又分别读了d0,d1,d2,d3,采用(d0 or d1) and (d2 or d3)然后送出,得到的也是正确的值。但读出的d[3..0]就不对。我实在想不出问题出在哪里,仿真时都是正常的。我都在担心是不是我的板卡设计有问题,导致不能正常读内存。
|
|
地板#
发布于:2003-08-01 11:37
我得意思是你加了那句后(肯定要定义),把所有读data变成读data_temp
|
|
地下室#
发布于:2003-08-01 12:03
我知道你的意思,是不是下面的写法?不起作用。
library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity data_arbitration is port( clk : in std_logic; ior : in std_logic; iow : in std_logic; run : in std_logic; en_data : in std_logic; bus_sram_data : inout std_logic_vector(7 downto 0); sram_ph_data : out std_logic_vector(7 downto 0); data : inout std_logic_vector(7 downto 0) ); end data_arbitration; architecture a of data_arbitration is signal data_temp1 : std_logic_vector(7 downto 0); signal data_temp2 : std_logic_vector(7 downto 0); signal temp : std_logic_vector(7 downto 0); begin temp<=data; process (clk) begin if clk\'event and clk=\'1\' then if run=\'1\' then sram_ph_data<=temp;--data; elsif en_data=\'1\' and ior=\'0\' then data_temp1<=temp;--data; elsif en_data=\'1\' and iow=\'0\' then data_temp2<=bus_sram_data; end if; end if; end process; data<=data_temp2 when en_data=\'1\' and iow=\'0\' else \"ZZZZZZZZ\"; bus_sram_data<=data_temp1 when en_data=\'1\' and ior=\'0\' else \"ZZZZZZZZ\"; end a; |
|
5楼#
发布于:2003-08-01 12:37
那就不太清楚了,可能不是程序的问题
|
|
6楼#
发布于:2003-08-01 17:57
你有没有考虑到SRAM的速度和你的FPGA是否匹配
|
|