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

Subversion Repositories mlite

[/] [mlite/] [trunk/] [vhdl/] [tbench.vhd] - Blame information for rev 47

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 rhoads
---------------------------------------------------------------------
2
-- TITLE: Test Bench
3
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 4/21/01
5
-- FILENAME: tbench.vhd
6 43 rhoads
-- PROJECT: Plasma CPU core
7 2 rhoads
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10 43 rhoads
--    This entity provides a test bench for testing the Plasma CPU core.
11 2 rhoads
---------------------------------------------------------------------
12
library ieee;
13
use ieee.std_logic_1164.all;
14 39 rhoads
use work.mlite_pack.all;
15 2 rhoads
 
16
entity tbench is
17 47 rhoads
   port(write_pin : out std_logic;
18
        read_pin  : in std_logic);
19 2 rhoads
end; --entity tbench
20
 
21
architecture logic of tbench is
22 47 rhoads
   constant memory_type : string := "GENERIC";
23
--   constant memory_type : string := "ALTERA";
24
--   constant memory_type : string := "XILINX";
25 7 rhoads
   signal clk         : std_logic := '1';
26
   signal reset       : std_logic := '1';
27 2 rhoads
   signal interrupt   : std_logic := '0';
28
   signal mem_write   : std_logic;
29 47 rhoads
   signal mem_read    : std_logic;
30 2 rhoads
   signal mem_address : std_logic_vector(31 downto 0);
31 47 rhoads
   signal mem_data    : std_logic_vector(31 downto 0);
32
   signal mem_pause   : std_logic := '0';
33 2 rhoads
   signal mem_byte_sel: std_logic_vector(3 downto 0);
34 47 rhoads
   signal uart_sel    : std_logic;
35 2 rhoads
begin  --architecture
36
   clk <= not clk after 50 ns;
37 7 rhoads
   reset <= '0' after 320 ns;
38 47 rhoads
--   mem_pause <= '0';
39
   mem_read <= not mem_write;
40
   uart_sel <= '1' when mem_address(12 downto 0) = ONES(12 downto 0) and mem_byte_sel /= "0000" else
41
               '0';
42 2 rhoads
 
43 6 rhoads
   --Uncomment the line below to test interrupts
44 39 rhoads
--   interrupt <= '1' after 20 us when interrupt = '0' else '0' after 400 ns;
45 6 rhoads
 
46 47 rhoads
   u1: mlite_cpu
47
      generic map (memory_type => memory_type)
48
      PORT MAP (
49
         clk          => clk,
50
         reset_in     => reset,
51
         intr_in      => interrupt,
52
 
53
         mem_address  => mem_address,
54
         mem_data_w   => mem_data,
55
         mem_data_r   => mem_data,
56
         mem_byte_sel => mem_byte_sel,
57
         mem_write    => mem_write,
58
         mem_pause    => mem_pause);
59 2 rhoads
 
60 47 rhoads
   generic_ram:
61
   if memory_type /= "ALTERA" generate
62
      u2: ram
63
         generic map ("code.txt")
64
         PORT MAP (
65
            clk          => clk,
66
            mem_byte_sel => mem_byte_sel,
67
            mem_write    => mem_write,
68
            mem_address  => mem_address(15 downto 0),
69
            mem_data_w   => mem_data,
70
            mem_data_r   => mem_data);
71
   end generate; --generic_ram
72 2 rhoads
 
73 47 rhoads
   altera_ram:
74
   if memory_type = "ALTERA" generate
75
      uart_component: uart
76
         generic map ("output.txt")
77
         port map(
78
            clk       => clk,
79
            reset     => reset,
80
            uart_sel  => uart_sel,
81
            data      => mem_data(7 downto 0),
82
            write_pin => write_pin,
83
            read_pin  => read_pin,
84
            pause     => mem_pause);
85 2 rhoads
 
86 47 rhoads
      lpm_ram_io_component0 : lpm_ram_io
87
         GENERIC MAP (
88
            intended_device_family => "UNUSED",
89
            lpm_width => 8,
90
            lpm_widthad => 11,
91
            lpm_indata => "REGISTERED",
92
            lpm_address_control => "UNREGISTERED",
93
            lpm_outdata => "UNREGISTERED",
94
            lpm_file => "code0.hex",
95
            use_eab => "ON",
96
            lpm_type => "LPM_RAM_DQ")
97
         PORT MAP (
98
            outenab => mem_read,
99
            address => mem_address(12 downto 2),
100
            inclock => clk,
101
            we      => mem_byte_sel(3),
102
            dio     => mem_data(31 downto 24));
103
 
104
      lpm_ram_io_component1 : lpm_ram_io
105
         GENERIC MAP (
106
            intended_device_family => "UNUSED",
107
            lpm_width => 8,
108
            lpm_widthad => 11,
109
            lpm_indata => "REGISTERED",
110
            lpm_address_control => "UNREGISTERED",
111
            lpm_outdata => "UNREGISTERED",
112
            lpm_file => "code1.hex",
113
            use_eab => "ON",
114
            lpm_type => "LPM_RAM_DQ")
115
         PORT MAP (
116
            outenab => mem_read,
117
            address => mem_address(12 downto 2),
118
            inclock => clk,
119
            we      => mem_byte_sel(2),
120
            dio     => mem_data(23 downto 16));
121
 
122
      lpm_ram_io_component2 : lpm_ram_io
123
         GENERIC MAP (
124
            intended_device_family => "UNUSED",
125
            lpm_width => 8,
126
            lpm_widthad => 11,
127
            lpm_indata => "REGISTERED",
128
            lpm_address_control => "UNREGISTERED",
129
            lpm_outdata => "UNREGISTERED",
130
            lpm_file => "code2.hex",
131
            use_eab => "ON",
132
            lpm_type => "LPM_RAM_DQ")
133
         PORT MAP (
134
            outenab => mem_read,
135
            address => mem_address(12 downto 2),
136
            inclock => clk,
137
            we      => mem_byte_sel(1),
138
            dio     => mem_data(15 downto 8));
139
 
140
      lpm_ram_io_component3 : lpm_ram_io
141
         GENERIC MAP (
142
            intended_device_family => "UNUSED",
143
            lpm_width => 8,
144
            lpm_widthad => 11,
145
            lpm_indata => "REGISTERED",
146
            lpm_address_control => "UNREGISTERED",
147
            lpm_outdata => "UNREGISTERED",
148
            lpm_file => "code3.hex",
149
            use_eab => "ON",
150
            lpm_type => "LPM_RAM_DQ")
151
         PORT MAP (
152
            outenab => mem_read,
153
            address => mem_address(12 downto 2),
154
            inclock => clk,
155
            we      => mem_byte_sel(0),
156
            dio     => mem_data(7 downto 0));
157
   end generate; --altera_ram
158
 
159 2 rhoads
end; --architecture logic

powered by: WebSVN 2.1.0

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