sandy3129
Member level 3
- Joined
- Nov 7, 2014
- Messages
- 56
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 445
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_arith.ALL; use IEEE.STD_LOGIC_misc.ALL; use IEEE.STD_LOGIC_unsigned.ALL; entity danger1 is Port ( clk : in STD_LOGIC; reset : in STD_LOGIC; dataout : out STD_LOGIC_vector(31 downto 0); a: out STD_LOGIC; b : out STD_LOGIC; full:out std_logic; almost_full: out std_logic; empty : out std_logic; almost_empty: out std_logic; data_count: out STD_LOGIC_vector(10 downto 0); prog_full: out std_logic; prog_empty: out std_logic ); end danger1; architecture Behavioral of danger1 is signal dout : std_logic_vector(31 downto 0 ); signal count : std_logic_vector(31 downto 0 ); signal din : std_logic_vector(31 downto 0 ); signal wr_en : std_logic; signal rd_en : std_logic; type state_type is (rst1,write1,read1); signal state : state_type; component fifo_generator_v6_2 port ( clk: in std_logic; rst: in std_logic; din: in std_logic_vector(31 downto 0); wr_en: in std_logic; rd_en: in std_logic; dout: out std_logic_vector(31 downto 0); full: out std_logic; almost_full: out std_logic; empty: out std_logic; almost_empty: out std_logic; data_count: out std_logic_vector(10 downto 0); prog_full: out std_logic; prog_empty: out std_logic); end component; begin a<=wr_en; b<=rd_en; process(clk,reset) begin if(clk'event and clk='1') then if(reset ='1') then count <= (others=>'0'); elsif(wr_en= '1') then count<= count + 1; end if; end if; end process; process(clk) begin if(clk'event and clk='1') then if (reset='1') then wr_en<= '0'; rd_en<='0'; state<= write1; else case (state) is when rst1=> wr_en<= '0'; rd_en<='0'; state<=write1; when write1=> wr_en<='1'; rd_en<='0'; state<=read1; when read1=> wr_en<='0'; rd_en<='1'; state<=rst1; end case; end if; end if; end process; U0 : fifo_generator_v6_2 port map ( clk => clk, rst => reset, din => count, wr_en => wr_en, rd_en => rd_en, dout => dataout, full => full, almost_full => almost_full, empty => empty, almost_empty => almost_empty, data_count => data_count, prog_full => prog_full, prog_empty => prog_empty); end Behavioral;
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 process(clk) begin if(clk'event and clk='1') then if (reset='1') then wr_en<= '0'; rd_en<='0'; state<= write1; else case (state) is when rst1=> wr_en<= '0'; rd_en<='0'; state<=write1; when write1=> wr_en<='1'; rd_en<='0'; state<=write2; when write2=> wr_en<='1'; rd_en<='0'; state<=write3; when write3=> wr_en<='1'; rd_en<='0'; state<=write4; when write4=> wr_en<='1'; rd_en<='0'; state<=write5; when write5=> wr_en<='1'; rd_en<='0'; state<=read1; when read1=> wr_en<='0'; rd_en<='1'; state<=rst1; end case; end if; end if; end process;
You are supposed to write using wr_clk and read using the rd_clk. What do you mean by it's not happening? You still haven't made it clear what the problem is, or provided the code and testbench that you are running that has a problem that you can't figure out.no if we use independent clocks in xilinx coregen fifo generator , i thinking we need to create a state machines on all writes states at the process(wr_clk) , and reading all the states at the process(rd_clk) ,is that it?? i thought but its not happening.
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_arith.ALL;
use IEEE.STD_LOGIC_misc.ALL;
use IEEE.STD_LOGIC_unsigned.ALL;
entity fifo_5r is
port( reset: in std_logic;
wr_clk: in std_logic;
rd_clk: in std_logic;
a: out std_logic;
b: out std_logic;
dataout: out std_logic_vector(31 downto 0);
full: out std_logic;
almost_full: out std_logic;
empty: out std_logic;
almost_empty: out std_logic;
rd_data_count: out std_logic_vector(10 downto 0);
wr_data_count: out std_logic_vector(10 downto 0);
prog_full: out std_logic;
prog_empty: out std_logic
);
end fifo_5r;
architecture Behavioral of fifo_5r is
signal count : std_logic_vector(31 downto 0 );
signal din : std_logic_vector(31 downto 0 );
signal wr_en : std_logic;
signal rd_en : std_logic;
type state_type is (rst1,write1,write2,write3,write4,write5,read1);
signal state,state2 : state_type;
component fifo_generator_v6_2
port (
rst: in std_logic;
wr_clk: in std_logic;
rd_clk: in std_logic;
din: in std_logic_vector(31 downto 0);
wr_en: in std_logic;
rd_en: in std_logic;
dout: out std_logic_vector(31 downto 0);
full: out std_logic;
almost_full: out std_logic;
empty: out std_logic;
almost_empty: out std_logic;
rd_data_count: out std_logic_vector(10 downto 0);
wr_data_count: out std_logic_vector(10 downto 0);
prog_full: out std_logic;
prog_empty: out std_logic);
end component;
begin
a<=wr_en;
b<=rd_en;
process(wr_clk,reset)
begin
if(wr_clk'event and wr_clk='1') then
if(reset ='1') then
count <= (others=>'0');
elsif(wr_en= '1') then
count<= count + 1;
end if;
end if;
end process;
process(wr_clk)
begin
if(wr_clk'event and wr_clk='1') then
if (reset='1') then
wr_en<= '0';
rd_en<='0';
state<= write1;
else
case (state) is
when rst1=>
wr_en<= '0';
rd_en<='0';
state<=write1;
when write1=>
wr_en<='1';
rd_en<='0';
state<=write2;
when write2=>
wr_en<='1';
rd_en<='0';
state<=write3;
when write3=>
wr_en<='1';
rd_en<='0';
state<=write4;
when write4=>
wr_en<='1';
rd_en<='0';
state<=write5;
when write5=>
wr_en<='1';
rd_en<='0';
state<=rst1;
when others=>
state <= rst1;
end case;
end if;
end if;
end process;
process(rd_clk)
begin
if(rd_clk'event and rd_clk='1') then
if (reset='1') then
wr_en<= '0';
rd_en<='0';
state2<= write1;
else
case (state2) is
when rst1=>
wr_en<= '0';
rd_en<='0';
state2<=read1;
when read1=>
wr_en<='1';
rd_en<='0';
state2<=rst1;
when others=>
state2 <= rst1;
end case;
end if;
end if;
end process;
U0 : fifo_generator_v6_2
port map (
rst => reset,
wr_clk => wr_clk,
rd_clk => rd_clk,
din => count,
wr_en => wr_en,
rd_en => rd_en,
dout => dataout,
full => full,
almost_full => almost_full,
empty => empty,
almost_empty => almost_empty,
rd_data_count => rd_data_count,
wr_data_count => wr_data_count,
prog_full => prog_full,
prog_empty => prog_empty);
end Behavioral;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?