1
|
|
2
|
-- Copyright (C) 1996 Morgan Kaufmann Publishers, Inc
|
3
|
|
4
|
-- This file is part of VESTs (Vhdl tESTs).
|
5
|
|
6
|
-- VESTs is free software; you can redistribute it and/or modify it
|
7
|
-- under the terms of the GNU General Public License as published by the
|
8
|
-- Free Software Foundation; either version 2 of the License, or (at
|
9
|
-- your option) any later version.
|
10
|
|
11
|
-- VESTs is distributed in the hope that it will be useful, but WITHOUT
|
12
|
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
13
|
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
14
|
-- for more details.
|
15
|
|
16
|
-- You should have received a copy of the GNU General Public License
|
17
|
-- along with VESTs; if not, write to the Free Software Foundation,
|
18
|
-- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19
|
|
20
|
-- ---------------------------------------------------------------------
|
21
|
--
|
22
|
-- $Id: ch_07_fg_07_03.vhd,v 1.3 2001-10-26 16:29:34 paw Exp $
|
23
|
-- $Revision: 1.3 $
|
24
|
--
|
25
|
-- ---------------------------------------------------------------------
|
26
|
|
27
|
entity fg_07_03 is
|
28
|
end entity fg_07_03;
|
29
|
|
30
|
library bv_utilities;
|
31
|
|
32
|
architecture interpreter of fg_07_03 is
|
33
|
|
34
|
subtype word is bit_vector(31 downto 0);
|
35
|
|
36
|
signal address_bus, data_bus_in : word := X"0000_0000";
|
37
|
signal mem_read, mem_request, mem_ready : bit := '0';
|
38
|
|
39
|
begin
|
40
|
|
41
|
-- code from book
|
42
|
|
43
|
instruction_interpreter : process is
|
44
|
|
45
|
variable mem_address_reg, mem_data_reg,
|
46
|
prog_counter, instr_reg, accumulator, index_reg : word;
|
47
|
-- . . .
|
48
|
-- not in book
|
49
|
type opcode_type is (load_mem);
|
50
|
constant opcode : opcode_type := load_mem;
|
51
|
constant displacement : word := X"0000_0010";
|
52
|
use bv_utilities.bv_arithmetic.all;
|
53
|
-- end not in book
|
54
|
|
55
|
procedure read_memory is
|
56
|
begin
|
57
|
address_bus <= mem_address_reg;
|
58
|
mem_read <= '1';
|
59
|
mem_request <= '1';
|
60
|
wait until mem_ready = '1';
|
61
|
mem_data_reg := data_bus_in;
|
62
|
mem_request <= '0';
|
63
|
wait until mem_ready = '0';
|
64
|
end procedure read_memory;
|
65
|
|
66
|
begin
|
67
|
-- . . . -- initialization
|
68
|
loop
|
69
|
-- fetch next instruction
|
70
|
mem_address_reg := prog_counter;
|
71
|
read_memory; -- call procedure
|
72
|
instr_reg := mem_data_reg;
|
73
|
-- . . .
|
74
|
case opcode is
|
75
|
-- . . .
|
76
|
when load_mem =>
|
77
|
mem_address_reg := index_reg + displacement;
|
78
|
read_memory; -- call procedure
|
79
|
accumulator := mem_data_reg;
|
80
|
-- . . .
|
81
|
end case;
|
82
|
end loop;
|
83
|
end process instruction_interpreter;
|
84
|
|
85
|
-- end code from book
|
86
|
|
87
|
|
88
|
memory : process is
|
89
|
begin
|
90
|
wait until mem_request = '1';
|
91
|
data_bus_in <= X"1111_1111";
|
92
|
mem_ready <= '1';
|
93
|
wait until mem_request = '0';
|
94
|
mem_ready <= '0';
|
95
|
end process memory;
|
96
|
|
97
|
end architecture interpreter;
|