OpenCores
URL https://opencores.org/ocsvn/am9080_cpu_based_on_microcoded_am29xx_bit-slices/am9080_cpu_based_on_microcoded_am29xx_bit-slices/trunk

Subversion Repositories am9080_cpu_based_on_microcoded_am29xx_bit-slices

[/] [am9080_cpu_based_on_microcoded_am29xx_bit-slices/] [trunk/] [ipcore_dir/] [rom4kx8/] [simulation/] [bmg_stim_gen.vhd] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 zpekic
 
2
 
3
    --------------------------------------------------------------------------------
4
--
5
-- BLK MEM GEN v7_3 Core - Stimulus Generator For Single Port ROM
6
--
7
--------------------------------------------------------------------------------
8
--
9
-- (c) Copyright 2006_3010 Xilinx, Inc. All rights reserved.
10
--
11
-- This file contains confidential and proprietary information
12
-- of Xilinx, Inc. and is protected under U.S. and
13
-- international copyright and other intellectual property
14
-- laws.
15
--
16
-- DISCLAIMER
17
-- This disclaimer is not a license and does not grant any
18
-- rights to the materials distributed herewith. Except as
19
-- otherwise provided in a valid license issued to you by
20
-- Xilinx, and to the maximum extent permitted by applicable
21
-- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
22
-- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
23
-- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
24
-- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
25
-- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
26
-- (2) Xilinx shall not be liable (whether in contract or tort,
27
-- including negligence, or under any other theory of
28
-- liability) for any loss or damage of any kind or nature
29
-- related to, arising under or in connection with these
30
-- materials, including for any direct, or any indirect,
31
-- special, incidental, or consequential loss or damage
32
-- (including loss of data, profits, goodwill, or any type of
33
-- loss or damage suffered as a result of any action brought
34
-- by a third party) even if such damage or loss was
35
-- reasonably foreseeable or Xilinx had been advised of the
36
-- possibility of the same.
37
--
38
-- CRITICAL APPLICATIONS
39
-- Xilinx products are not designed or intended to be fail-
40
-- safe, or for use in any application requiring fail-safe
41
-- performance, such as life-support or safety devices or
42
-- systems, Class III medical devices, nuclear facilities,
43
-- applications related to the deployment of airbags, or any
44
-- other applications that could lead to death, personal
45
-- injury, or severe property or environmental damage
46
-- (individually and collectively, "Critical
47
-- Applications"). Customer assumes the sole risk and
48
-- liability of any use of Xilinx products in Critical
49
-- Applications, subject only to applicable laws and
50
-- regulations governing limitations on product liability.
51
--
52
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
53
-- PART OF THIS FILE AT ALL TIMES.
54
 
55
--------------------------------------------------------------------------------
56
--
57
-- Filename: bmg_stim_gen.vhd
58
--
59
-- Description:
60
--  Stimulus Generation For SROM
61
--
62
--------------------------------------------------------------------------------
63
-- Author: IP Solutions Division
64
--
65
-- History: Sep 12, 2011 - First Release
66
--------------------------------------------------------------------------------
67
--
68
--------------------------------------------------------------------------------
69
-- Library Declarations
70
--------------------------------------------------------------------------------
71
LIBRARY IEEE;
72
USE IEEE.STD_LOGIC_1164.ALL;
73
USE IEEE.STD_LOGIC_ARITH.ALL;
74
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
75
USE IEEE.STD_LOGIC_MISC.ALL;
76
 
77
 LIBRARY work;
78
USE work.ALL;
79
USE work.BMG_TB_PKG.ALL;
80
 
81
 
82
ENTITY REGISTER_LOGIC_SROM IS
83
  PORT(
84
    Q   : OUT STD_LOGIC;
85
    CLK   : IN STD_LOGIC;
86
    RST : IN STD_LOGIC;
87
    D   : IN STD_LOGIC
88
    );
89
END REGISTER_LOGIC_SROM;
90
 
91
ARCHITECTURE REGISTER_ARCH OF REGISTER_LOGIC_SROM IS
92
   SIGNAL Q_O : STD_LOGIC :='0';
93
BEGIN
94
  Q <= Q_O;
95
FF_BEH: PROCESS(CLK)
96
BEGIN
97
   IF(RISING_EDGE(CLK)) THEN
98
      IF(RST /= '0' ) THEN
99
        Q_O <= '0';
100
     ELSE
101
        Q_O <= D;
102
      END IF;
103
    END IF;
104
  END PROCESS;
105
END REGISTER_ARCH;
106
 
107
LIBRARY STD;
108
USE STD.TEXTIO.ALL;
109
 
110
LIBRARY IEEE;
111
USE IEEE.STD_LOGIC_1164.ALL;
112
USE IEEE.STD_LOGIC_ARITH.ALL;
113
--USE IEEE.NUMERIC_STD.ALL;
114
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
115
USE IEEE.STD_LOGIC_MISC.ALL;
116
 
117
 LIBRARY work;
118
USE work.ALL;
119
USE work.BMG_TB_PKG.ALL;
120
 
121
 
122
ENTITY BMG_STIM_GEN IS
123
      GENERIC ( C_ROM_SYNTH : INTEGER := 0
124
      );
125
      PORT (
126
            CLK : IN STD_LOGIC;
127
            RST : IN STD_LOGIC;
128
            ADDRA: OUT  STD_LOGIC_VECTOR(11 DOWNTO 0) := (OTHERS => '0');
129
            DATA_IN : IN STD_LOGIC_VECTOR (7 DOWNTO 0);   --OUTPUT VECTOR         
130
            STATUS : OUT STD_LOGIC:= '0'
131
          );
132
END BMG_STIM_GEN;
133
 
134
 
135
ARCHITECTURE BEHAVIORAL OF BMG_STIM_GEN IS
136
 
137
    FUNCTION hex_to_std_logic_vector(
138
    hex_str       : STRING;
139
    return_width  : INTEGER)
140
  RETURN STD_LOGIC_VECTOR IS
141
    VARIABLE tmp        : STD_LOGIC_VECTOR((hex_str'LENGTH*4)+return_width-1
142
                                           DOWNTO 0);
143
 
144
  BEGIN
145
    tmp := (OTHERS => '0');
146
    FOR i IN 1 TO hex_str'LENGTH LOOP
147
      CASE hex_str((hex_str'LENGTH+1)-i) IS
148
        WHEN '0' => tmp(i*4-1 DOWNTO (i-1)*4) := "0000";
149
        WHEN '1' => tmp(i*4-1 DOWNTO (i-1)*4) := "0001";
150
        WHEN '2' => tmp(i*4-1 DOWNTO (i-1)*4) := "0010";
151
        WHEN '3' => tmp(i*4-1 DOWNTO (i-1)*4) := "0011";
152
        WHEN '4' => tmp(i*4-1 DOWNTO (i-1)*4) := "0100";
153
        WHEN '5' => tmp(i*4-1 DOWNTO (i-1)*4) := "0101";
154
        WHEN '6' => tmp(i*4-1 DOWNTO (i-1)*4) := "0110";
155
        WHEN '7' => tmp(i*4-1 DOWNTO (i-1)*4) := "0111";
156
        WHEN '8' => tmp(i*4-1 DOWNTO (i-1)*4) := "1000";
157
        WHEN '9' => tmp(i*4-1 DOWNTO (i-1)*4) := "1001";
158
        WHEN 'a' | 'A' => tmp(i*4-1 DOWNTO (i-1)*4) := "1010";
159
        WHEN 'b' | 'B' => tmp(i*4-1 DOWNTO (i-1)*4) := "1011";
160
        WHEN 'c' | 'C' => tmp(i*4-1 DOWNTO (i-1)*4) := "1100";
161
        WHEN 'd' | 'D' => tmp(i*4-1 DOWNTO (i-1)*4) := "1101";
162
        WHEN 'e' | 'E' => tmp(i*4-1 DOWNTO (i-1)*4) := "1110";
163
        WHEN 'f' | 'F' => tmp(i*4-1 DOWNTO (i-1)*4) := "1111";
164
        WHEN OTHERS  =>  tmp(i*4-1 DOWNTO (i-1)*4) := "1111";
165
      END CASE;
166
    END LOOP;
167
    RETURN tmp(return_width-1 DOWNTO 0);
168
  END hex_to_std_logic_vector;
169
 
170
CONSTANT ZERO : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
171
SIGNAL READ_ADDR_INT : STD_LOGIC_VECTOR(11 DOWNTO 0) := (OTHERS => '0');
172
SIGNAL READ_ADDR : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
173
SIGNAL CHECK_READ_ADDR : STD_LOGIC_VECTOR(31 DOWNTO 0) := (OTHERS => '0');
174
SIGNAL EXPECTED_DATA : STD_LOGIC_VECTOR(7 DOWNTO 0) := (OTHERS => '0');
175
SIGNAL DO_READ : STD_LOGIC := '0';
176
SIGNAL CHECK_DATA : STD_LOGIC := '0';
177
SIGNAL CHECK_DATA_R : STD_LOGIC := '0';
178
SIGNAL CHECK_DATA_2R : STD_LOGIC := '0';
179
SIGNAL DO_READ_REG: STD_LOGIC_VECTOR(4 DOWNTO 0) :=(OTHERS => '0');
180
CONSTANT DEFAULT_DATA  : STD_LOGIC_VECTOR(7 DOWNTO 0):= hex_to_std_logic_vector("76",8);
181
 
182
BEGIN
183
 
184
 
185
SYNTH_COE:  IF(C_ROM_SYNTH =0 ) GENERATE
186
 
187
type mem_type is array (4095 downto 0) of std_logic_vector(7 downto 0);
188
 
189
  FUNCTION bit_to_sl(input: BIT) RETURN STD_LOGIC IS
190
    VARIABLE temp_return : STD_LOGIC;
191
  BEGIN
192
    IF (input = '0') THEN
193
      temp_return := '0';
194
    ELSE
195
      temp_return := '1';
196
    END IF;
197
    RETURN temp_return;
198
  END bit_to_sl;
199
 
200
     function char_to_std_logic (
201
      char : in character)
202
      return std_logic is
203
 
204
      variable data : std_logic;
205
 
206
   begin
207
      if char = '0' then
208
         data := '0';
209
 
210
      elsif char = '1' then
211
         data := '1';
212
 
213
      elsif char = 'X' then
214
         data := 'X';
215
 
216
      else
217
         assert false
218
            report "character which is not '0', '1' or 'X'."
219
            severity warning;
220
 
221
         data := 'U';
222
      end if;
223
 
224
      return data;
225
 
226
   end char_to_std_logic;
227
 
228
impure FUNCTION init_memory( C_USE_DEFAULT_DATA : INTEGER;
229
                       C_LOAD_INIT_FILE : INTEGER ;
230
                                           C_INIT_FILE_NAME : STRING ;
231
                       DEFAULT_DATA   :  STD_LOGIC_VECTOR(7 DOWNTO 0);
232
                       width : INTEGER;
233
                       depth         : INTEGER)
234
  RETURN mem_type IS
235
  VARIABLE init_return   : mem_type := (OTHERS => (OTHERS => '0'));
236
  FILE     init_file     : TEXT;
237
  VARIABLE mem_vector    : BIT_VECTOR(width-1 DOWNTO 0);
238
  VARIABLE bitline     : LINE;
239
  variable bitsgood    : boolean := true;
240
  variable bitchar     : character;
241
  VARIABLE i             : INTEGER;
242
  VARIABLE j             : INTEGER;
243
  BEGIN
244
 
245
    --Display output message indicating that the behavioral model is being
246
    --initialized
247
    ASSERT (NOT (C_USE_DEFAULT_DATA=1 OR C_LOAD_INIT_FILE=1)) REPORT " Block Memory Generator CORE Generator module loading initial data..." SEVERITY NOTE;
248
 
249
    -- Setup the default data
250
    -- Default data is with respect to write_port_A and may be wider
251
    -- or narrower than init_return width.  The following loops map
252
    -- default data into the memory
253
    IF (C_USE_DEFAULT_DATA=1) THEN
254
      FOR i IN 0 TO depth-1 LOOP
255
          init_return(i) := DEFAULT_DATA;
256
        END LOOP;
257
    END IF;
258
 
259
    -- Read in the .mif file
260
    -- The init data is formatted with respect to write port A dimensions.
261
    -- The init_return vector is formatted with respect to minimum width and
262
    -- maximum depth; the following loops map the .mif file into the memory
263
    IF (C_LOAD_INIT_FILE=1) THEN
264
      file_open(init_file, C_INIT_FILE_NAME, read_mode);
265
      i := 0;
266
      WHILE (i < depth AND NOT endfile(init_file)) LOOP
267
        mem_vector := (OTHERS => '0');
268
        readline(init_file, bitline);
269
--        read(file_buffer, mem_vector(file_buffer'LENGTH-1 DOWNTO 0));
270
 
271
        FOR j IN 0 TO width-1 LOOP
272
                  read(bitline,bitchar,bitsgood);
273
          init_return(i)(width-1-j) := char_to_std_logic(bitchar);
274
        END LOOP;
275
        i := i + 1;
276
    END LOOP;
277
      file_close(init_file);
278
    END IF;
279
    RETURN init_return;
280
 
281
  END FUNCTION;
282
 
283
 
284
  --***************************************************************
285
  -- convert bit to STD_LOGIC
286
  --***************************************************************
287
 
288
constant c_init : mem_type := init_memory(1,
289
                                          0,
290
                                                                                  "no_coe_file_loaded",
291
                                           DEFAULT_DATA,
292
                                          8,
293
                                          4096);
294
 
295
 
296
constant rom : mem_type := c_init;
297
BEGIN
298
 
299
 EXPECTED_DATA <= rom(conv_integer(unsigned(check_read_addr)));
300
 
301
  CHECKER_RD_ADDR_GEN_INST:ENTITY work.ADDR_GEN
302
    GENERIC MAP( C_MAX_DEPTH =>4096 )
303
 
304
     PORT MAP(
305
        CLK => CLK,
306
        RST => RST,
307
            EN  => CHECK_DATA_2R,
308
        LOAD => '0',
309
        LOAD_VALUE => ZERO,
310
        ADDR_OUT => CHECK_READ_ADDR
311
       );
312
 
313
 
314
  PROCESS(CLK)
315
   BEGIN
316
     IF(RISING_EDGE(CLK)) THEN
317
       IF(CHECK_DATA_2R ='1') THEN
318
         IF(EXPECTED_DATA = DATA_IN) THEN
319
                STATUS<='0';
320
         ELSE
321
                STATUS <= '1';
322
         END IF;
323
       END IF;
324
         END IF;
325
  END PROCESS;
326
END GENERATE;
327
-- Simulatable ROM 
328
 
329
--Synthesizable ROM
330
SYNTH_CHECKER: IF(C_ROM_SYNTH = 1) GENERATE
331
  PROCESS(CLK)
332
  BEGIN
333
     IF(RISING_EDGE(CLK)) THEN
334
           IF(CHECK_DATA_2R='1') THEN
335
                 IF(DATA_IN=DEFAULT_DATA) THEN
336
                   STATUS <= '0';
337
             ELSE
338
                   STATUS <= '1';
339
                 END IF;
340
           END IF;
341
         END IF;
342
  END PROCESS;
343
 
344
END GENERATE;
345
 
346
 
347
    READ_ADDR_INT(11 DOWNTO 0) <= READ_ADDR(11 DOWNTO 0);
348
    ADDRA <= READ_ADDR_INT ;
349
 
350
   CHECK_DATA <= DO_READ;
351
 
352
 
353
 
354
 
355
  RD_ADDR_GEN_INST:ENTITY work.ADDR_GEN
356
    GENERIC MAP( C_MAX_DEPTH => 4096 )
357
 
358
     PORT MAP(
359
        CLK => CLK,
360
        RST => RST,
361
            EN  => DO_READ,
362
        LOAD => '0',
363
        LOAD_VALUE => ZERO,
364
        ADDR_OUT => READ_ADDR
365
       );
366
 
367
RD_PROCESS: PROCESS (CLK)
368
       BEGIN
369
     IF (RISING_EDGE(CLK)) THEN
370
          IF(RST='1') THEN
371
             DO_READ <= '0';
372
                  ELSE
373
             DO_READ <= '1';
374
            END IF;
375
         END IF;
376
END PROCESS;
377
 
378
  BEGIN_SHIFT_REG: FOR I IN 0 TO 4 GENERATE
379
  BEGIN
380
    DFF_RIGHT: IF I=0 GENERATE
381
     BEGIN
382
     SHIFT_INST_0: ENTITY work.REGISTER_LOGIC_SROM
383
        PORT MAP(
384
                 Q  => DO_READ_REG(0),
385
                 CLK =>CLK,
386
                 RST=>RST,
387
                 D  =>DO_READ
388
                );
389
     END GENERATE DFF_RIGHT;
390
    DFF_OTHERS: IF ((I>0) AND (I<=4)) GENERATE
391
     BEGIN
392
       SHIFT_INST: ENTITY work.REGISTER_LOGIC_SROM
393
         PORT MAP(
394
                 Q  => DO_READ_REG(I),
395
                 CLK =>CLK,
396
                 RST=>RST,
397
                 D  =>DO_READ_REG(I-1)
398
                );
399
      END GENERATE DFF_OTHERS;
400
   END GENERATE BEGIN_SHIFT_REG;
401
 
402
 
403
CHECK_DATA_REG_1: ENTITY work.REGISTER_LOGIC_SROM
404
        PORT MAP(
405
                 Q  => CHECK_DATA_2R,
406
                 CLK =>CLK,
407
                 RST=>RST,
408
                 D  =>CHECK_DATA_R
409
                );
410
 
411
CHECK_DATA_REG: ENTITY work.REGISTER_LOGIC_SROM
412
        PORT MAP(
413
                 Q  => CHECK_DATA_R,
414
                 CLK =>CLK,
415
                 RST=>RST,
416
                 D  =>CHECK_DATA
417
                );
418
 
419
 
420
 
421
 
422
 
423
 
424
END ARCHITECTURE;
425
 
426
 

powered by: WebSVN 2.1.0

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