sandy3129
Member level 3
- Joined
- Nov 7, 2014
- Messages
- 56
- Helped
- 1
- Reputation
- 2
- Reaction score
- 1
- Trophy points
- 8
- Activity points
- 445
hai every one , my question is , normally in a fifo we write into the fifo and then read it from the fifo in the next cycle, so datacount will be '1', but what if i want to write 5 data serially and then read it from fifo , i want dataout to be read as 5 bunches at a time . here is my code
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;
Last edited by a moderator: