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

Subversion Repositories ahbmaster

[/] [ahbmaster/] [trunk/] [test79_AHBmaster/] [component/] [work/] [top/] [CoreUARTapb_0/] [rtl/] [vhdl/] [test/] [user/] [testbench.vhd] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 uson
-- ********************************************************************
2
-- Actel Corporation Proprietary and Confidential
3
--  Copyright 2009 Actel Corporation.  All rights reserved.
4
--
5
-- ANY USE OR REDISTRIBUTION IN PART OR IN WHOLE MUST BE HANDLED IN
6
-- ACCORDANCE WITH THE ACTEL LICENSE AGREEMENT AND MUST BE APPROVED
7
-- IN ADVANCE IN WRITING.
8
--
9
-- Description: User testbench for CoreAI (Analog Interface)
10
--
11
-- Revision Information:
12
-- Date                 Description
13
-- ----                 -----------------------------------------
14
-- 03Mar09              Initial Version 2.0
15
--
16
-- SVN Revision Information:
17
-- SVN $Revision: $
18
-- SVN $Date: $
19
--
20
-- Resolved SARs
21
-- SAR      Date     Who   Description
22
--
23
-- Notes:
24
-- 1. best viewed with tabstops set to "4"
25
-- 2. Most of the behavior is driven from the BFM scripts for the APB master.
26
--    Consult the Actel AMBA BFM documentation for more information.
27
--
28
-- History:             04/22/09  - AS created
29
--
30
-- *********************************************************************
31
 
32
library ieee;
33
use ieee.std_logic_1164.all;
34
use ieee.numeric_std.all;
35
use work.coreparameters.all;
36
use work.top_CoreUARTapb_0_bfM_packAGE.all;
37
 
38
entity testbench is
39
generic (
40
-- vector file for driving the APB master BFM
41
-- NOTE: location of the following files can be overridden at run time
42
APB_MASTER_VECTFILE   : string := "coreuart_usertb_apb_master.vec";
43
-- propagation delay in ns
44
TPD                   : integer := 3
45
);
46
end entity testbench;
47
 
48
architecture testbench_arch of testbench is
49
 
50
-----------------------------------------------------------------------------
51
-- components
52
-----------------------------------------------------------------------------
53
component top_CoreUARTapb_0_COREUARTAPB
54
   GENERIC (
55
      RX_LEGACY_MODE                 :  integer := 0;
56
      -- DEVICE FAMILY 
57
      FAMILY                         :  integer := 15;
58
      -- UART configuration parameters
59
      TX_FIFO                        :  integer := 0;    --  1 = with tx fifo, 0 = without tx fifo
60
      RX_FIFO                        :  integer := 0;    --  1 = with rx fifo, 0 = without rx fifo
61
      BAUD_VALUE                     :  integer := 0;    --  Baud value is set only when fixed buad rate is selected 
62
      FIXEDMODE                      :  integer := 0;    --  fixed or programmable mode, 0: programmable; 1:fixed
63
      PRG_BIT8                       :  integer := 0;    --  This bit value is selected only when FIXEDMODE is set to 1 
64
      PRG_PARITY                     :  integer := 0;    --  This bit value is selected only when FIXEDMODE is set to 1 
65
      BAUD_VAL_FRCTN                 :  integer := 0;    --  0 = +0.0, 1 = +0.125, 2 = +0.25, 3 = +0.375, 4 = +0.5, 5 = +0.625, 6 = +0.75, 7 = +0.875,
66
      BAUD_VAL_FRCTN_EN              :  integer := 0    --  1 = enable baud fraction, 0 = disable baud fraction
67
);
68
   PORT (
69
      -- Inputs and Outputs
70
-- APB signals
71
 
72
      PCLK                    : IN std_logic;   --  APB system clock
73
      PRESETN                 : IN std_logic;   --  APB system reset
74
      PADDR                   : IN std_logic_vector(4 DOWNTO 0);   --  Address
75
      PSEL                    : IN std_logic;   --  Peripheral select signal
76
      PENABLE                 : IN std_logic;   --  Enable (data valid strobe)
77
      PWRITE                  : IN std_logic;   --  Write/nRead signal
78
      PWDATA                  : IN std_logic_vector(7 DOWNTO 0);   --  8 bit write data
79
      PRDATA                  : OUT std_logic_vector(7 DOWNTO 0);   --  8 bit read data
80
 
81
      -- AS: Added PREADY and PSLVERR
82
      PREADY                  : OUT std_logic;   -- APB READY signal (tied to 1)
83
      PSLVERR                 : OUT std_logic;  -- APB slave error signal (tied to 0)
84
 
85
      -- transmit ready and receive full indicators
86
 
87
      TXRDY                   : OUT std_logic;
88
      RXRDY                   : OUT std_logic;
89
      -- FLAGS 
90
 
91
      FRAMING_ERR             : OUT std_logic;
92
      PARITY_ERR              : OUT std_logic;
93
      OVERFLOW                : OUT std_logic;
94
      -- Serial receive and transmit data
95
 
96
      RX                      : IN std_logic;
97
      TX                      : OUT std_logic
98
);
99
end component;
100
 
101
-------------------------------------------------------------------------------
102
-- constants
103
-------------------------------------------------------------------------------
104
constant APB_MASTER_CLK_CYCLE:                  integer := 100;
105
constant APB_MASTER_CLK_CYCLE_LO_TIME:  integer := (APB_MASTER_CLK_CYCLE/2);
106
-- add 1 if APB_MASTER_CLK_CYCLE is odd number to compensate for PCLK period
107
constant APB_MASTER_CLK_CYCLE_HI_TIME:  integer := (APB_MASTER_CLK_CYCLE/2) +
108
 to_integer(to_unsigned(APB_MASTER_CLK_CYCLE,10) and to_unsigned(1,10));
109
 
110
constant ADDR_IN    :   std_logic_vector(31 downto 0) :=  X"00000000";
111
constant ADDR_OUT   :   std_logic_vector(31 downto 0) :=  X"00000001";
112
constant ADDR_INT   :   std_logic_vector(31 downto 0) :=  X"00000002";
113
constant ADDR_OE    :   std_logic_vector(31 downto 0) :=  X"00000003";
114
 
115
------------------------------------------------------------------------------
116
-- signals
117
-------------------------------------------------------------------------------
118
 
119
-- system
120
signal SYSRSTN_apb          : std_logic;
121
signal SYSCLK_apb           : std_logic;
122
 
123
-- APB
124
signal PCLK                 : std_logic;
125
signal PRESETN              : std_logic;
126
signal PADDR_apb_bfm_wide   : std_logic_vector(31 downto 0);
127
signal PADDR                : std_logic_vector(4 downto 0);
128
signal PSEL_apb_bfm_wide    : std_logic_vector(15 downto 0);
129
signal PSEL1                : std_logic; -- DUT1 PSEL
130
signal PSEL2                : std_logic; -- DUT2 PSEL
131
signal PENABLE              : std_logic;
132
signal PWRITE               : std_logic;
133
signal PWDATA_apb_bfm_wide  : std_logic_vector(31 downto 0);
134
signal PWDATA               : std_logic_vector(7 downto 0);
135
 
136
-- BFM
137
signal PRDATA_apb_bfm_wide  : std_logic_vector(31 downto 0);
138
signal PRDATA               : std_logic_vector(7 downto 0);
139
signal PRDATA1              : std_logic_vector(7 downto 0);
140
signal PRDATA2              : std_logic_vector(7 downto 0);
141
signal PREADY               : std_logic;
142
signal PSLVERR              : std_logic;
143
 
144
signal GP_IN_apb_bfm        : std_logic_vector(31 downto 0);
145
signal GP_OUT_apb_bfm       : std_logic_vector(31 downto 0);
146
signal FINISHED_apb_bfm     : std_logic;
147
signal FAILED_apb_bfm       : std_logic;
148
 
149
-- DUT1
150
signal TXRDY1               : std_logic;
151
signal RXRDY1               : std_logic;
152
signal TX1                  : std_logic;
153
signal RX1                  : std_logic;
154
signal PARITY_ERR1          : std_logic;
155
signal OVERFLOW1            : std_logic;
156
signal FRAMING_ERR1         : std_logic;
157
 
158
-- DUT2
159
signal TXRDY2               : std_logic;
160
signal RXRDY2               : std_logic;
161
signal TX2                  : std_logic;
162
signal RX2                  : std_logic;
163
signal PARITY_ERR2          : std_logic;
164
signal OVERFLOW2            : std_logic;
165
signal FRAMING_ERR2         : std_logic;
166
 
167
signal RX_SEL               : std_logic;
168
 
169
-- BFM memory interface
170
-- not used
171
signal BFM_ADDR             : std_logic_vector(31 downto 0);
172
signal BFM_DATA             : std_logic_vector(31 downto 0);
173
signal BFM_DATA_i           : std_logic_vector(31 downto 0);
174
signal BFM_RD               : std_logic;
175
signal BFM_WR               : std_logic;
176
 
177
-- misc. signals
178
signal GND256:                                  std_logic_vector(255 downto 0)   :=(others=>'0');
179
signal GND32:                                     std_logic_vector(31 downto 0)  :=(others=>'0');
180
signal GND8:                                      std_logic_vector(7 downto 0)   :=(others=>'0');
181
signal GND5:                                      std_logic_vector(4 downto 0)   :=(others=>'0');
182
signal GND4:                                      std_logic_vector(3 downto 0)   :=(others=>'0');
183
signal GND1:                                      std_logic                                             :='0';
184
signal stopsim:                                 integer range 0 to 1                     := 0;
185
 
186
begin
187
 
188
  -- APB ASSIGNS
189
  PADDR                         <= PADDR_apb_bfm_wide(4 downto 0);
190
  PSEL1                         <= PSEL_apb_bfm_wide(0);
191
  PSEL2                         <= PSEL_apb_bfm_wide(1);
192
  PWDATA                  <= PWDATA_apb_bfm_wide(7 downto 0);
193
  PRDATA      <= PRDATA1 when (PSEL1 = '1') else
194
                 PRDATA2 when (PSEL2 = '1') else
195
                 X"00";
196
  PRDATA_apb_bfm_wide(31 downto 0) <= X"000000" & PRDATA(7 downto 0);
197
  -- PREADY and PSLVERR not used, tie off
198
  PREADY      <= '1';
199
  PSLVERR     <= '0';
200
 
201
  -- DUT
202
  -- pull-down for Framing Error Test
203
  RX2         <= TX1 when (RX_SEL = '0') else '0';
204
 
205
  -- monitor flags / select signals in BFM
206
  GP_IN_apb_bfm <= X"000000" &
207
                   OVERFLOW2 & PARITY_ERR2 & TXRDY2 & RXRDY2 &
208
                   OVERFLOW1 & PARITY_ERR1 & TXRDY1 & RXRDY1;
209
  RX_SEL        <= GP_OUT_apb_bfm(0);
210
 
211
  -- System clock
212
  sysclk_apb_proc: process
213
  begin
214
        SYSCLK_apb <= '0';
215
        wait for APB_MASTER_CLK_CYCLE_LO_TIME*1 ns;
216
        SYSCLK_apb <= '1';
217
        wait for APB_MASTER_CLK_CYCLE_HI_TIME*1 ns;
218
        if (stopsim=1) then
219
                wait;   -- end simulation
220
        end if;
221
  end process sysclk_apb_proc;
222
 
223
  -- Main simulation
224
  process
225
  begin
226
        SYSRSTN_apb <= '0';
227
        wait until rising_edge(SYSCLK_apb); wait for (TPD)*1 ns;
228
        SYSRSTN_apb <= '1';
229
        wait until rising_edge(SYSCLK_apb); wait for (TPD)*1 ns;
230
 
231
        -- wait until BFM is finished
232
        while (not(FINISHED_apb_bfm = '1') and not(FAILED_apb_bfm = '1')) loop
233
                wait until rising_edge(SYSCLK_apb); wait for (TPD)*1 ns;
234
        end loop;
235
        stopsim <= 1;
236
        wait;
237
  end process;
238
 
239
-- ------------------------------------------------------
240
-- BFM register interface
241
 
242
-- not used for this core
243
 
244
-- End BFM register interface RTL
245
-- ------------------------------------------------------
246
 
247
  -- BFM instantiation
248
  u_apb_master: top_CoreUARTapb_0_BFM_APB
249
  generic map (
250
        VECTFILE   =>   APB_MASTER_VECTFILE,
251
        TPD   =>   TPD,
252
        -- passing testbench parameters to BFM ARGVALUE* parameters
253
        ARGVALUE0   =>   FAMILY,
254
  ARGVALUE1   =>   TX_FIFO,
255
  ARGVALUE2   =>   RX_FIFO,
256
  ARGVALUE3   =>   FIXEDMODE,
257
  ARGVALUE4   =>   BAUD_VALUE,
258
  ARGVALUE5   =>   PRG_BIT8,
259
  ARGVALUE6   =>   PRG_PARITY,
260
  ARGVALUE7   =>   RX_LEGACY_MODE,
261
  ARGVALUE8   =>   USE_SOFT_FIFO
262
)
263
port map (
264
        SYSCLK   =>   SYSCLK_apb,
265
        SYSRSTN   =>   SYSRSTN_apb,
266
        PCLK   =>   PCLK,
267
        PRESETN   =>   PRESETN,
268
        PADDR   =>   PADDR_apb_bfm_wide,
269
        PSEL   =>   PSEL_apb_bfm_wide,
270
        PENABLE   =>   PENABLE,
271
        PWRITE   =>   PWRITE,
272
        PWDATA   =>   PWDATA_apb_bfm_wide,
273
        PRDATA   =>   PRDATA_apb_bfm_wide,
274
        PREADY   =>   PREADY,
275
        PSLVERR   =>   PSLVERR,
276
        INTERRUPT   =>   GND256,
277
  -- NEED TO ADD GPIN
278
        GP_OUT   =>   GP_OUT_apb_bfm,
279
        GP_IN   =>   GP_IN_apb_bfm,
280
        EXT_WR   =>   BFM_WR,
281
        EXT_RD   =>   BFM_RD,
282
        EXT_ADDR   =>   BFM_ADDR,
283
        EXT_DATA   =>   BFM_DATA,
284
        EXT_WAIT   =>   GND1,
285
        FINISHED   =>   FINISHED_apb_bfm,
286
        FAILED   =>   FAILED_apb_bfm
287
);
288
 
289
-- DUT1 (TX)
290
DUT1: top_CoreUARTapb_0_COREUARTAPB
291
  generic map (
292
  FAMILY      => FAMILY,
293
  TX_FIFO     => TX_FIFO,
294
  RX_FIFO     => RX_FIFO,
295
  FIXEDMODE   => FIXEDMODE,
296
  BAUD_VALUE  => BAUD_VALUE,
297
  PRG_BIT8    => PRG_BIT8,
298
  PRG_PARITY  => PRG_PARITY,
299
  RX_LEGACY_MODE => RX_LEGACY_MODE,
300
  BAUD_VAL_FRCTN => BAUD_VAL_FRCTN,
301
  BAUD_VAL_FRCTN_EN => BAUD_VAL_FRCTN_EN
302
)
303
port map (
304
  PRESETN     => PRESETN,
305
  PCLK        => PCLK,
306
  PSEL        => PSEL1,
307
  PENABLE     => PENABLE,
308
  PWRITE      => PWRITE,
309
  PADDR       => PADDR,
310
  PWDATA      => PWDATA,
311
  PRDATA      => PRDATA1,
312
-- other signals
313
  TXRDY       => TXRDY1,
314
  RXRDY       => RXRDY1,
315
  PARITY_ERR  => PARITY_ERR1,
316
  FRAMING_ERR => FRAMING_ERR1,
317
  OVERFLOW    => OVERFLOW1,
318
  RX          => RX1,
319
  TX          => TX1
320
);
321
 
322
 
323
-- DUT2 (RX)
324
DUT2: top_CoreUARTapb_0_COREUARTAPB
325
  generic map (
326
  FAMILY      => FAMILY,
327
  TX_FIFO     => TX_FIFO,
328
  RX_FIFO     => RX_FIFO,
329
  FIXEDMODE   => FIXEDMODE,
330
  BAUD_VALUE  => BAUD_VALUE,
331
  PRG_BIT8    => PRG_BIT8,
332
  PRG_PARITY  => PRG_PARITY,
333
  RX_LEGACY_MODE => RX_LEGACY_MODE,
334
  BAUD_VAL_FRCTN => BAUD_VAL_FRCTN,
335
  BAUD_VAL_FRCTN_EN => BAUD_VAL_FRCTN_EN
336
)
337
port map (
338
  PRESETN     => PRESETN,
339
  PCLK        => PCLK,
340
  PSEL        => PSEL2,
341
  PENABLE     => PENABLE,
342
  PWRITE      => PWRITE,
343
  PADDR       => PADDR,
344
  PWDATA      => PWDATA,
345
  PRDATA      => PRDATA2,
346
-- other signals
347
  TXRDY       => TXRDY2,
348
  RXRDY       => RXRDY2,
349
  PARITY_ERR  => PARITY_ERR2,
350
  FRAMING_ERR => FRAMING_ERR2,
351
  OVERFLOW    => OVERFLOW2,
352
  RX          => RX2,
353
  TX          => TX2
354
);
355
 
356
end testbench_arch; -- testbench

powered by: WebSVN 2.1.0

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