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

Subversion Repositories light8080

[/] [light8080/] [trunk/] [vhdl/] [demos/] [c2sb/] [c2sb_soc_tb.vhdl] - Blame information for rev 85

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 85 ja_rd
--------------------------------------------------------------------------------
2
-- c2sb_soc_tb.vhdl -- Minimal test bench for c2sb_soc.
3
--
4
-- c2sb_soc is a light8080 SoC demo on a Cyclone 2 starter Board (C2SB). This
5
-- is a minimalistic simulation test bench. The test bench only drives the clock
6
-- and reset inputs.
7
--
8
-- This simulation test bench can be marginally useful for basic troubleshooting
9
-- of a C2SB board demo or as a starting point for a true test bench.
10
--------------------------------------------------------------------------------
11
 
12
library ieee;
13
use ieee.std_logic_1164.ALL;
14
use ieee.std_logic_unsigned.all;
15
use ieee.numeric_std.ALL;
16
 
17
entity c2sb_soc_tb is
18
end entity c2sb_soc_tb;
19
 
20
architecture behavior of c2sb_soc_tb is
21
 
22
--------------------------------------------------------------------------------
23
-- Simulation parameters
24
 
25
-- T: simulated clock period
26
constant T : time := 100 ns;
27
 
28
-- MAX_SIM_LENGTH: maximum simulation time
29
constant MAX_SIM_LENGTH : time := T*7000000; -- enough for most purposes
30
 
31
 
32
--------------------------------------------------------------------------------
33
 
34
signal clk :              std_logic := '0';
35
signal done :             std_logic := '0';
36
signal buttons :          std_logic_vector(3 downto 0);
37
signal green_leds :       std_logic_vector(7 downto 0);
38
signal txd :              std_logic;
39
 
40
begin
41
 
42
  -- Instantiate the Unit Under Test (UUT)
43
  -- The only mandatory signals are clk and buttons(3)
44
  uut: entity work.c2sb_soc
45
  port map (
46
    clk_50MHz =>        clk,
47
    buttons =>          buttons,
48
 
49
    rxd =>              txd,
50
    txd =>              txd,
51
    flash_data =>       (others => '0'),
52
    switches =>         (others => '0'),
53
    sd_data =>          '0',
54
    green_leds =>       green_leds
55
  );
56
 
57
 
58
  -- clock: run clock until test is done
59
  clock:
60
  process(done, clk)
61
  begin
62
    if done = '0' then
63
      clk <= not clk after T/2;
64
    end if;
65
  end process clock;
66
 
67
 
68
  -- Drive reset and done 
69
  main_test:
70
  process
71
  begin
72
    -- Assert reset for at least one full clk period
73
    buttons(0) <= '0';
74
    wait until clk = '1';
75
    wait for T/2;
76
    buttons(0) <= '1';
77
 
78
    -- Remember to 'cut away' the preceding 3 clk semiperiods from 
79
    -- the wait statement...
80
    wait for (MAX_SIM_LENGTH - T*1.5);
81
 
82
    -- Maximum sim time elapsed, stop the clk process asserting 'done' (which 
83
    -- will stop the simulation)
84
    done <= '1';
85
 
86
    assert (done = '1')
87
    report "Test timed out."
88
    severity failure;
89
 
90
    wait;
91
  end process main_test;
92
 
93
end;

powered by: WebSVN 2.1.0

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