OpenCores
URL https://opencores.org/ocsvn/onewire/onewire/trunk

Subversion Repositories onewire

[/] [onewire/] [trunk/] [HDL/] [ow_idram.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 skeptonomi
----------------------------------------------------------------------------------
2
--  <c>2018 william b hunter
3
--    This file is part of ow2rtd.
4
--
5
--    ow2rtd is free software: you can redistribute it and/or modify
6
--    it under the terms of the GNU Lessor General Public License as published by
7
--    the Free Software Foundation, either version 3 of the License, or
8
--    (at your option) any later version.
9
--
10
--    ow2rtd is distributed in the hope that it will be useful,
11
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
--    GNU General Public License for more details.
14
--
15
--    You should have received a copy of the GNU Lessor General Public License
16
--    along with ow2rtd.  If not, see <https://www.gnu.org/licenses/>.
17
-----------------------------------------------------------------------------------  
18
--  Create Date: 5/15/2018
19
--  file: ow_idram.vhd
20
--  description: stores the list of one wire ids. Each id is 64 bits long. holds upto 32 ids.
21
--  controls reset the bit counter, inc the bit counter, and write to the current location
22
--
23
-----------------------------
24
 
25
library IEEE;
26
use IEEE.STD_LOGIC_1164.ALL;
27
use IEEE.numeric_std.all;
28
library work;
29
 
30
-------------------------------------------------------------------------------------
31
-- Entity declaration
32
-------------------------------------------------------------------------------------
33
entity ow_idram is
34
  port (
35
    --global signals
36
    clk              : in    std_logic;
37
    --srst             : in    std_logic;  --synchronous reset
38
    mode             : in    std_logic;  --mode, 1=search, 0=other, used to calc read addr
39
    idnum            : in    std_logic_vector(4 downto 0); --index of the id to read or write
40
    idbit            : in    std_logic_vector(5 downto 0); --index of the bit within the id to read or write
41
    we               : in    std_logic;  --write the currently indexed bit
42
    wdat             : in    std_logic;  --bit value to write to the currently indexed bit
43
    rdat             : out   std_logic   --bit value of the currently indexed bit
44
  );
45
end ow_idram;
46
 
47
 
48
-------------------------------------------------------------------------------------
49
-- Architecture declaration
50
-------------------------------------------------------------------------------------
51
architecture rtl of ow_idram is
52
 
53
  type mem_type is array (2047 downto 0) of std_logic;
54
  signal mem : mem_type ;
55
  attribute syn_ramstyle: string;
56
  attribute syn_ramstyle of mem: signal is "no_rw_check";
57
 
58
  signal rd_addr    : integer range 0 to 2047;
59
  signal wr_addr    : integer range 0 to 2047;
60
  signal mem_rdat   : std_logic;
61
begin
62
 
63
 
64
  ------------------------------------------------------
65
  --                    ADDRESSES                    ---
66
  ------------------------------------------------------
67
  --the read idnum has to be calculated for the search mode. In search, we write to the current id,
68
  --  but read from the previous id. The previous id is needed in order to decide certain branches
69
  --  in the search algorithm. When we are at the 0th id, there is no previous id, so we just override
70
  --  this with zeros.
71
  wr_addr <= to_integer(  unsigned(idnum) & unsigned(idbit)  );
72
  rd_addr <= to_integer(  unsigned(idnum) & unsigned(idbit)  ) when mode = '0'
73
        else to_integer(  (unsigned(idnum)-1) & unsigned(idbit)  );
74
 
75
        --if in search mode and there is no previous id, then return '0'
76
  rdat <= '0' when mode = '1' and  idnum = "00000" else mem_rdat;
77
 
78
 
79
  ------------------------------------------------------
80
  ---                     WRITE                      ---
81
  ------------------------------------------------------
82
  process (clk) -- Write memory.
83
  begin
84
    if rising_edge(clk) then
85
      if (we = '1') then
86
        --mem(to_integer(unsigned(idnum & idbit))) <= wdat;
87
        mem(wr_addr) <= wdat;
88
      end if;
89
    end if;
90
  end process;
91
 
92
  ------------------------------------------------------
93
  ---                     READ                       ---
94
  ------------------------------------------------------
95
  process (clk) -- Read memory.
96
  begin
97
    if rising_edge(clk) then
98
      mem_rdat <= mem(rd_addr);
99
    end if;
100
  end process;
101
 
102
end rtl;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.