nikhilsigma
Full Member level 2
- Joined
- Jun 19, 2010
- Messages
- 142
- Helped
- 17
- Reputation
- 34
- Reaction score
- 16
- Trophy points
- 1,298
- Location
- Delhi, India
- Activity points
- 2,584
Code VHDL - [expand] 1 2 3 type pbyte is array (0 to 511) of std_logic_vector (7 downto 0); --pbyte is no of bytes in a page, each byte having 8 bits.... type mem_page is array (0 to 1023) of pbyte; -- total memory data type signal page : mem_page :=(others=>(others =>(others => '0'))); -- TOTAL MEMORY !!
I would just drop in a tiny processor (picoblaze on Xilinx) to handle the complexity this is likely to require. Now wait, this does not look like a real design problem. Is this your homework?:lol:Hi,
In my project i need to model an SSD Controller but for that to do something i think that i should also implement the Flash memory on FPGA. so how can i create a memory of 512 bytes(a page)....
I would just drop in a tiny processor (picoblaze on Xilinx) to handle the complexity this is likely to require. Now wait, this does not look like a real design problem. Is this your homework?:lol:
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 ---------------------------------------------------------------------------------- -- Company: -- Engineer: -- -- Create Date: 18:44:36 09/15/2012 -- Design Name: -- Module Name: memory - Behavioral -- Project Name: -- Target Devices: -- Tool versions: -- Description: -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; ---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. --library UNISIM; --use UNISIM.VComponents.all; entity memory is Port ( rw,clk : in STD_LOGIC; add : in STD_LOGIC_VECTOR (9 downto 0); data : inout STD_LOGIC_VECTOR (63 downto 0); busy1 : out STD_LOGIC:='0'); -- aaa : inout integer ); end memory; architecture Behavioral of memory is type pbyte is array (0 to 511) of std_logic_vector (7 downto 0); --pbyte is no of bytes in a page type mem_page is array (0 to 1023) of pbyte; -- total memory type signal page : mem_page :=(others=>(others =>(others => '0'))); -- TOTAL MEMORY !! -- Temporary buffer signal cu_add : std_logic_vector (9 downto 0); signal cu_rw : std_logic; signal count,add_int: integer :=0; signal rep,busy : std_logic :='0'; begin add_int<= CONV_INTEGER(cu_add); --converting adderess to integer.. busy1<=busy; assign : process(clk) begin if(rising_edge(clk)) then if(busy='0') then cu_add<=add; cu_rw<=rw; end if; end if; end process assign; main : process(clk) begin if(rising_edge(clk)) then if(rep='1') then if(count<64) then if(cu_rw='1') -- Reading DATA then data <= page(add_int)(count) & page(add_int)(count+1) & page(add_int)(count+2) & page(add_int)(count+3) & page(add_int)(count+4) & page(add_int)(count+5) & page(add_int)(count+6) & page(add_int)(count+7); -- else -- Writing DATA -- page(add_int)<=data; end if; count<=count+8; if(count=64) then rep<='0'; count<=0; busy<='0'; end if; end if; else busy <= '1'; rep<='1'; if(cu_rw='1') -- Reading DATA then data <= page(add_int)(0) & page(add_int)(1) & page(add_int)(2) & page(add_int)(3) & page(add_int)(4) & page(add_int)(5) & page(add_int)(6) & page(add_int)(7); -- else -- Writing DATA -- page(add_int)<=data; end if; end if; end if; end process; end Behavioral;
Reading design: memory.prj
=========================================================================
* HDL Compilation *
=========================================================================
Compiling vhdl file "C:/Xilinx92i/Programs/Mem/memory.vhd" in Library work.
Architecture behavioral of Entity memory is up to date.
=========================================================================
* Design Hierarchy Analysis *
=========================================================================
Analyzing hierarchy for entity <memory> in library <work> (architecture <behavioral>).
=========================================================================
* HDL Analysis *
=========================================================================
Analyzing Entity <memory> in library <work> (Architecture <behavioral>).
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 80: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
WARNING:Xst:790 - "C:/Xilinx92i/Programs/Mem/memory.vhd" line 97: Index value(s) does not match array range, simulation mismatch.
data <= page(add_int)(count) & page(add_int)(count+1) & page(add_int)(count+2) & page(add_int)(count+3) & page(add_int)(count+4) & page(add_int)(count+5) & page(add_int)(count+6) & page(add_int)(count+7);
No, 8 bytes are concatenated to 64 bit, that's correct so far. I wonder however, why the memory hasn't been defined with 64-Bit words?isn't data 64-bit vector? If so, the offending lines only stuff an 8-bit vector into that 64-bit vector.
No, 8 bytes are concatenated to 64 bit, that's correct so far. I wonder however, why the memory hasn't been defined with 64-Bit words?
The compiler may have problems to recognize the index range, I'm not sure about. Without enabling writes to the memory or giving it a default nonzero content, the design is pretty useless.
No, 8 bytes are concatenated to 64 bit, that's correct so far. I wonder however, why the memory hasn't been defined with 64-Bit words?
If you read more than the original post, you'll notice that nikhilsigma already did some work himself. In so far your comment doesn't fit the present thread well, but in fact many others.This is not a real project, but a contrived homework, obviously. The whole point of homework is to do the work yourself, not ask an engineer to do it for you. Ask for pointers, or specific issues you get into with syntax or whatever... Otherwise you or your parents are paying a lot of money for nothing.
Wut? Are we still talking about this?nikhilsigma said:I was just asking you guys how to make a 3D array or an VECTOR of VECTOR, thats it !!
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 type ddr_model_t is protected impure function read( addr : unsigned(25 downto 0) ) return std_logic_vector; procedure write( addr : unsigned(25 downto 0); data : std_logic_vector(31 downto 0) ); end protected ddr_model_t; type ddr_model_t is protected body type bank_t; type row_t; type row_ptr_t is access row_t; type bank_ptr_t is access bank_t; type row_t is array(0 to 1023) of std_logic_vector(31 downto 0); type bank_t is array(0 to 8191) of row_ptr_t; --------------------------------------------------------------------- --Total mem is 8 banks x 8192 rows x 1024 columns x 32 bits/word -- -- = 256 Mbyte --------------------------------------------------------------------- type mem_t is array(0 to 7) of bank_ptr_t; variable mem : mem_t; impure function read(addr : unsigned(25 downto 0) ) return std_logic_vector is variable bank : integer; variable row : integer; variable column : integer; variable ret : std_logic_vector(31 downto 0); begin bank := to_integer( addr(25 downto 23) ); row := to_integer( addr(22 downto 10) ); column := to_integer( addr( 9 downto 0) ); --------------------------------------------------------- --Bank has not been written to, therefore not created --------------------------------------------------------- if mem(bank) = null then ret := (others => 'X'); --------------------------------------------------------- --Row has not been written to, therefore not created --------------------------------------------------------- elsif mem(bank)(row) = null then ret := (others => 'X'); ------------------------------------------ --Return what has been written already ------------------------------------------ else ret := mem(bank)(row)(column); end if; return ret; end function read; procedure write( addr : unsigned(25 downto 0); data : std_logic_vector(31 downto 0) ) is variable bank : integer; variable row : integer; variable column : integer; begin bank := to_integer( addr(25 downto 23) ); row := to_integer( addr(22 downto 10) ); column := to_integer( addr( 9 downto 0) ); -------------------------------------------------- --Create the bank if it doesnt already exist -------------------------------------------------- if mem(bank) = null then mem(bank) := new bank_t; end if; --------------------------------------------- --Create the row if it doesnt already exist --------------------------------------------- if mem(bank)(row) = null then mem(bank)(row) := new row_t; mem(bank)(row).all := (row_t'range => (others => 'X')); end if; mem(bank)(row)(column) := data; end procedure write; end protected body ddr_model_t;
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?