1 -----------------------------------------------------------------------------
3 -- Copyright (c) 1997 by Synplicity, Inc. All rights reserved. --
5 -- This source file may be used and distributed without restriction --
6 -- provided that this copyright statement is not removed from the file --
7 -- and that any derivative work contains this copyright notice. --
9 -- Primitive library for post synthesis simulation --
10 -- These models are not intended for efficient synthesis --
12 -----------------------------------------------------------------------------
14 use ieee.std_logic_1164.all;
15 entity prim_counter is
16 generic (w : integer := 8);
18 q : buffer std_logic_vector(w - 1 downto 0);
20 d : in std_logic_vector(w - 1 downto 0);
30 architecture beh of prim_counter is
31 signal nextq : std_logic_vector(w - 1 downto 0);
33 nxt: process (q, cin, updn)
35 variable nextc, c : std_logic;
38 for i in 0 to w - 1 loop
40 nextq(i) <= c xor (not updn) xor q(i);
41 nextc := (c and (not updn)) or
43 ((not updn) and q(i));
48 ff : process (clk, rst)
52 elsif rising_edge(clk) then
59 use ieee.std_logic_1164.all;
61 port (q : out std_logic;
64 r : in std_logic := '0';
65 s : in std_logic := '0');
68 architecture beh of prim_dff is
70 ff : process (clk, r, s)
76 elsif rising_edge(clk) then
83 use ieee.std_logic_1164.all;
85 port (q : out std_logic;
88 r : in std_logic := '0';
89 s : in std_logic := '0');
92 architecture beh of prim_latch is
94 q <= '0' when r = '1' else
101 use ieee.std_logic_1164.all;
102 use ieee.std_logic_unsigned.all;
106 data_width : integer := 4;
107 addr_width : integer := 5);
109 dout : out std_logic_vector(data_width-1 downto 0);
110 aout : in std_logic_vector(addr_width-1 downto 0);
111 din : in std_logic_vector(data_width-1 downto 0);
112 ain : in std_logic_vector(addr_width-1 downto 0);
117 architecture beh of prim_ramd is
119 constant depth : integer := 2** addr_width;
120 type mem_type is array (depth-1 downto 0) of std_logic_vector (data_width-1 downto 0);
121 signal mem: mem_type;
125 dout <= mem(conv_integer(aout));
129 if rising_edge(clk) then
131 mem(conv_integer(ain)) <= din;
140 use ieee.std_logic_1164.all;
141 package components is
142 component prim_counter
143 generic (w : integer);
145 q : buffer std_logic_vector(w - 1 downto 0);
146 cout : out std_logic;
147 d : in std_logic_vector(w - 1 downto 0);
157 port (q : out std_logic;
160 r : in std_logic := '0';
161 s : in std_logic := '0');
164 port (q : out std_logic;
167 r : in std_logic := '0';
168 s : in std_logic := '0');
171 component prim_ramd is
173 data_width : integer := 4;
174 addr_width : integer := 5);
176 dout : out std_logic_vector(data_width-1 downto 0);
177 aout : in std_logic_vector(addr_width-1 downto 0);
178 din : in std_logic_vector(data_width-1 downto 0);
179 ain : in std_logic_vector(addr_width-1 downto 0);