LogIn E-mail
¼³°èÀ̾߱â
[VHDL]ram8x4x8
# 75 JMJS    08.12.1 14:42

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;

entity        ram8x4x8 is
        port(
                  rst  : in std_logic;
                data : inout std_logic_vector (7 downto 0);
                addr : in    std_logic_vector (4 downto 0);
                wr   : in    std_logic
        );
end        ram8x4x8;

architecture logic of ram8x4x8 is
        type table8x4x8 is array (31 downto 0) of std_logic_vector (7 downto 0);

        function v2i (bv: std_logic_vector (4 downto 0)) return integer is
                variable result, abit : integer := 0;
                variable count : integer := 0;
        begin
                bits : for I in bv'low to bv'high loop
                        abit        := 0;
                        if bv(I) = '1' then
                                abit := 2**(I - bv'low);
                        end if;
                        result        := result + abit;
                        count        := count  + 1;
                        exit bits when count = 5;
                end loop bits;
                return (result);
        end v2i;

        signal acell : table8x4x8;
        signal iaddr : integer := 0;
begin

        iaddr <= v2i(addr);

        data_in: process (rst, wr, iaddr) begin
                if(wr = '1') then
                        data <= "ZZZZZZZZ";
                else
                        data <= acell (iaddr);
                end if;
        end process;

        data_out: process (rst, wr, data, iaddr) begin
                  if(rst = '1') then
                            for I in 0 to 31 loop
                                acell (I) <= "00000000";
                            end loop;
                if(wr = '1') then
                        acell (iaddr) <= data;
                end if;
        end process;

end logic;

----------------------------------------------------------------------

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_arith.all;
use IEEE.std_logic_unsigned.all;

entity        ram8x4x8_tb is
end        ram8x4x8_tb;

architecture logic of ram8x4x8_tb is
        component ram8x4x8
                port(
                           rst : in std_logic;
                           data: inout std_logic_vector (7 downto 0);
                        addr: in std_logic_vector (4 downto 0);
                        wr: in std_logic
                );
        end component;

         signal rst : std_logic;
        signal data: std_logic_vector (7 downto 0);
        signal addr: std_logic_vector (4 downto 0);
        signal wr  : std_logic;

begin
        mem0 : ram8x4x8 port map (
                  rst  => rst,
                data => data,
                addr => addr,
                 wr   => wr
        );

        process begin
                  rst       <= '0';
                  wait for 3 ns;
                  rst       <= '1';
                addr        <= "00000";
                data        <= "01010101";
                wr        <= '0';
                wait for 5 ns;

                  rst      <= '0';
                  wait for 2 ns;

                addr        <= "00001";
                data        <= "01010101";
                wr        <= '1';
                wait for 10 ns;

                addr        <= "00010";
                data        <= "01010101";
                wr        <= '1';
                wait for 10 ns;

                addr        <= "00100";
                data        <= "01010101";
                wr        <= '1';
                wait for 10 ns;

                addr        <= "01000";
                data        <= "01010101";
                wr        <= '1';
                wait for 10 ns;

                addr        <= "01100";
                data        <= "ZZZZZZZZ";
                wr        <= '0';
                wait for 10 ns;

                addr        <= "01000";
                data        <= "ZZZZZZZZ";
                wr        <= '0';
                wait for 10 ns;
        end process;

end logic;

°Ô½Ã¹°: 96 °Ç, ÇöÀç: 1 / 1 ÂÊ
¹øÈ£ Á¦       ¸ñ ÀÛ¼ºÀÚ µî·ÏÀÏ ¹æ¹®
98  interface JMJS 25.1.20 162
97  test plusargs value plusargs JMJS 24.9.5 226
96  color text JMJS 24.7.13 234
95  draw_hexa.v JMJS 10.6.17 2433
94  jmjsxram3.v JMJS 10.4.9 2160
93  Verilog document JMJS 11.1.24 2755
92  [verilog]o=(c1)? (c2)? 0:1 : (c3)? 2:3; JMJS 09.3.31 2295
91  [verilog]forever, repeat, strobe, realtime, ... JMJS 09.7.6 3772
90  gtkwave PC version JMJS 09.3.30 2094
89  ncsim option example JMJS 08.12.1 4489
88  [¿µ»ó]keywords for web search JMJS 08.12.1 2098
87  [Verilog]fdisplay fopen fscanf JMJS 11.1.24 6428
86  ncverilog option example JMJS 10.6.8 7910
85  [Verilog]Latch example JMJS 08.12.1 2707
84  Pad verilog example JMJS 01.3.16 4630
83  [ModelSim] vector JMJS 01.3.16 2306
82  RTL Code ºÐ¼®¼ø¼­ JMJS 09.4.29 2602
81  [temp]PIPE JMJS 08.10.2 1962
80  [temp]always-forever ¹«ÇÑ·çÇÁ JMJS 08.10.2 2046
79  YCbCr2RGB.v JMJS 10.5.12 2262
78  [VHDL]rom64x8 JMJS 09.3.27 1862
77  [function]vector_compare JMJS 02.6.19 1812
76  [function]vector2integer JMJS 02.6.19 1883
75  [VHDL]ram8x4x8 JMJS 08.12.1 1776
74  [¿¹]shift JMJS 02.6.19 2134
73  test JMJS 09.7.20 1920
72  test JMJS 09.7.20 1707
71  test JMJS 09.7.20 1636
70  test JMJS 09.7.20 1732
69  test JMJS 09.7.20 1780
68  test JMJS 09.7.20 1709
67  test JMJS 09.7.20 1629
66  test JMJS 09.7.20 1586
65  test JMJS 09.7.20 1702
64  test JMJS 09.7.20 1931
63  test JMJS 09.7.20 1936
62  test JMJS 09.7.20 1856
61  VHDLÀÇ ¿¬»êÀÚ ¿ì¼±¼øÀ§ JMJS 09.7.20 3660
60  test JMJS 09.7.20 1640
59  test JMJS 09.7.20 1726
58  test JMJS 09.7.20 1702
57  test JMJS 09.7.20 1643
56  test JMJS 09.7.20 1697
55  verilog Çаú »ùÇð­ÀÇ JMJS 16.5.30 2312
54  [verilog]create_generated_clock JMJS 15.4.28 2300
53  [Verilog]JDIFF JMJS 14.7.4 1565
52  [verilog]parameter definition JMJS 14.3.5 1829
51  [verilog]sformat fopen fscanf fwrite fclose JMJS 12.1.31 4789
50  Verilog File I/0,Verilog file handling JMJS 12.1.30 2566
49  Verdi JMJS 10.4.22 3244
48  draw hexa JMJS 10.4.9 1914
47  asfifo - Async FIFO JMJS 10.4.8 1730
46  VHDLÀ» ÀÌ¿ëÇÑ È¸·Î¼³°èÀÇ ÀåÁ¡ JMJS 02.3.14 3388
45  synplify batch JMJS 10.3.8 2490
44  ÀüÀڽðè Type A JMJS 08.11.28 2002
43  I2C Webpage JMJS 08.2.25 1853
42  PC¿¡¼­ °£´ÜÈ÷ Verilog ½ÇÇàÇØº¸±â (Icarus Verilog) JMJS 13.1.14 6014
41  [Verilog]vstring JMJS 17.9.27 2095
40  Riviera Simple Case JMJS 09.4.29 3224
39  [VHDL]DES Example JMJS 07.6.15 2982
38  [verilog]RAM example JMJS 09.6.5 2747
37  ROM example [VerilogHDL, RTL] JMJS 04.5.27 2027
36  Jamie's VHDL Handbook JMJS 08.11.28 2681
35  Dualport RAM example [VerilogHDL, RTL] JMJS 04.5.27 3331
34  RTL Job JMJS 09.4.29 2163
33  [VHDL]type example - package TYPES JMJS 06.2.2 1837
32  [verilog]`define `ifdef `elsif `else `endif ... JMJS 10.5.11 9367
30  [verilog]array_module JMJS 05.12.8 2307
29  [verilog-2001]generate JMJS 05.12.8 3399
28  protected JMJS 05.11.18 2065
27  design¿¡ latch°¡ ÀÖÀ¸¸é ¾ÈµÇ³ª¿ä? JMJS 09.7.20 2876
26  busÀÇ µ¥ÀÌŸ¸¦ °¢ bitº°·Î Ãâ·ÂÇÏ´Â ¹æ¹ýÀº? JMJS 04.11.9 1905
25  component¸¦ »ý¼ºÇؼ­ ´Ù¸¥ °÷¿¡¼­ È£ÃâÇÏ´Â ¹æ¹ý JMJS 04.11.4 2497
23  Array Of Array JMJS 04.8.16 1999
22  dumpfile, dumpvars JMJS 04.7.19 3619
21  Vending Machine Jamie 02.12.16 10092
20  Mini Vending Machine1 Jamie 02.12.10 6970
19  Mini Vending Machine Jamie 02.12.6 9800
18  Key Jamie 02.11.29 4993
17  Stop Watch Jamie 02.11.25 5691
16  Mealy Machine Jamie 02.8.29 6740
15  Moore Machine Jamie 02.8.29 17973
14  Up Down Counter Jamie 02.8.29 4081
13  Up Counter Jamie 02.8.29 2782
12  Edge Detecter Jamie 02.8.29 2985
11  Concept4 Jamie 02.8.28 2122
10  Concept3 Jamie 02.8.28 2072
9  Concept2_1 Jamie 02.8.28 1960
8  Concept2 Jamie 02.8.28 2030
7  Concept1 Jamie 02.8.26 2250
6  Tri State Buffer Jamie 02.8.26 3553
5  8x3 Encoder Jamie 02.8.28 4167
4  3x8 Decoder Jamie 02.8.28 3845
3  4bit Comparator Jamie 02.8.26 3223
2  °¡À§ ¹ÙÀ§ º¸ °ÔÀÓ Jamie 02.8.26 5565
1  Two Input Logic Jamie 02.8.26 2468
[1]