File: system.vhdl

package info (click to toggle)
faumachine 20100527-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 53,836 kB
  • ctags: 20,552
  • sloc: ansic: 179,550; asm: 3,645; makefile: 3,611; perl: 2,103; sh: 1,529; python: 600; xml: 563; lex: 210; vhdl: 204
file content (263 lines) | stat: -rw-r--r-- 8,208 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
-- $Id: system.vhdl,v 1.2 2009-03-02 17:26:37 potyra Exp $
-- vim:tabstop=8:shiftwidth=8:textwidth=72

-- Copyright (C) 2004-2009 FAUmachine Team <info@faumachine.org>.
-- This program is free software. You can redistribute it and/or modify it
-- under the terms of the GNU General Public License, either version 2 of
-- the License, or (at your option) any later version. See COPYING.

-- VHDL comment character is --, comments are until end of line
--
-- VHDL-description of a single virtual FAUmachine node
--

library expect;
use expect.types.ALL;
use expect.procedures.ALL;

-- node-internal things are prefixed with int_ in this example.
-- I have tried to avoid using names which are identical to keywords or
-- predefined components, so it is clear, which names can be freely
-- chosen and which cannot.
-- node-external things are prefixed with ext_. node-external things in
-- this case include interfaces, which other nodes can access.

-- ####################################################################
-- define an entity named 'node'
-- ####################################################################
-- define interface of entity 'node'
entity node is
	-- variable definitions, used later on.
	-- the 'generic' statement includes (in parentheses) a list of
	-- variable definitions separated by semicolons. name of
	-- variable, type and value are given.
	generic(
		version : integer := 0;
		memsize : integer := 128;
		disksize : integer := 2000
	);
	-- the interface (port) of this entity consists of its network
	-- interface "ext_eth0" which is connected to the ethernet 'ethbus'
	-- you could use this to connect several nodes to an ethernet
	-- cable.
	-- the 'port' statement includes (in parentheses) a list of
	-- port-names (e.g. "ext_eth0") and their types (e.g.
	-- "inout ethbus"). There is a colon between port-name and type.
	-- the port-name/type pairs are separated by semicolons.
	port(
		ext_eth0 : inout ethbus
		-- add more ports here (e.g. if you have more than one
		-- ethernet-card you should probably have a separate
		-- port here for each card. you'll also need a semicolon
		-- after the first card (and don't put a semicolon after
		-- the last definition before the closing parenthesis!)
		-- ext_eth1 : inout ethbus;
		-- ext_eth2 : inout ethbus
	);
end node;

-- define structural internals of entity 'node'
-- use whatever you want instead of "structural", it is ignored anyway
architecture structural of node is
	-- === internal busses ========================================
	-- there shouldn't be any need to change this definition of the
	-- busses

	-- for FAUmachine we use signals to model busses. the elements in
	-- the list are separated by semicolons. for each signal the
	-- name (e.g. int_mem) and the type (e.g. membus) must be given.

	-- define frontside bus. type membus is predefined.
	-- cpu, memory and mem2isa-bridge will be connected to this
	signal	int_mem : membus;

	-- define isa bus. type isabus is predefined.
	-- mem2isa-bridge, idectrl and ethcard will be connected to this
	signal	int_ps2_kbd : ps2bus;
	signal	int_ps2_mouse : ps2bus;
	signal	int_isa : isabus;
	signal	int_eth : ethbus;

	-- define ide bus. type ide_bus is predefined.
	-- idectrl and idedisk will be connected to this
	signal	int_ide : ide_bus;

	-- define serial bus. type serialbus is predefined.
	-- connect one serial component

	signal int_serial0 : serialbus;
	signal int_serial1 : serialbus;

	-- wire from monitor to gfx adapter

	signal int_gfx : gfxbus;

	-- === end of internal busses definition ======================

	-- === signals used by expect =================================
	signal	poweron, reset : boolean;
	signal  screen_shot : integer;

	SIGNAL	gfx_match : integer_array(1 TO 4);

	signal	output0 : character;

	signal	found0 : boolean;
	signal	found1 : boolean;
	signal	cdrom : boolean;

	signal	inject : boolean;

	signal	press, release : character;

	-- === end of signals used by expect ==========================

begin
	-- === expect interface =======================================
	pc : ctrl port map(
		isa =>int_isa,
		keyboard => int_ps2_kbd,
		mouse => int_ps2_mouse,
		poweron => poweron,
		reset => reset
	);
	-- === end expect interface ===================================

	cpu0 : cpu 
		port map( mem => int_mem );

	mem0 : memory generic map( size => memsize )
			port map( mem => int_mem );

	northsouth : mem2isa port map( mem => int_mem, isa => int_isa );

	--
	-- not really used in this example
	--
	kbd : keyboard
		port map( ps2 => int_ps2_kbd,
			press => press,
			release => release );
	mouse : mouse
		port map( ps2 => int_ps2_mouse);
	video : vga
		port map( mem => int_mem,
			gfx => int_gfx );
	mon : monitor
		port map(gfx => int_gfx, screen_shot => screen_shot);

	idectrl0 : idectrl
		port map( isa => int_isa,
			ide => int_ide );

	eth0 : ne2000
		port map( isa => int_isa,
			eth => ext_eth0 );

	bridge : network_router
		port map(eth => ext_eth0);

	hd0  : idedisk
		generic map ( unit => 0,
			size => disksize )
		port map( ide => int_ide );

	cdrom0  : idecdrom
		generic map(unit => 1)
		port map( ide => int_ide );

	serial0 : serial
		port map(isa => int_isa, serial => int_serial0);

	serial1 : serial
		port map(isa => int_isa,
			serial => int_serial1);

	terminal0 : serial_terminal
		port map( recv => output0,
			serial => int_serial0);

	-- internet_access : serial_ip
	--	port map(serial => int_serial1);

	-- === installation script =====================================

	installation_script : PROCESS
		VARIABLE result : boolean;
	BEGIN
		gfx_match(1) <= -1;
		WAIT FOR 1;
		
		ASSERT false REPORT "powering on node for initial installation" SEVERITY note;
		poweron <= true;

		-- wait for lilo prompt
                gfx_match'shortcut_in("/mon%match_rectangle/1");
		gfx_match'shortcut_in_activate("2/-1/-1/-1/-1/../screenshots/lilo.ppm");
		WAIT ON gfx_match(1) UNTIL 0 <= gfx_match(1) FOR 90000;
	
		IF gfx_match(1)'EVENT = 0 THEN
			screen_shot <= 1;
			WAIT FOR 1000;
			ASSERT false REPORT "timed out" SEVERITY failure;
		END IF;
		gfx_match'shortcut_in_deactivate;

		-- ready to boot
		found0'shortcut_in("/terminal0%match/0");

		
		ASSERT false REPORT "waiting for: login prompt" SEVERITY note;
		found0'shortcut_in_activate(" login: ");
		wait on found0 until found0 for 150000;
		found0'shortcut_in_deactivate;
		ASSERT found0 REPORT "timed out" SEVERITY failure;
		wait on found0 until not found0;

		
		ASSERT false REPORT "waiting for: shell prompt" SEVERITY note;
		found0'shortcut_in_activate(":~# ");
		send_string(output0, "root\0d", 100);
		wait on found0 until found0 for 30000;
		found0'shortcut_in_deactivate;
		ASSERT found0 REPORT "timed out" SEVERITY failure;
		wait on found0 until not found0;


		ASSERT false REPORT "configure nic" SEVERITY note;
		found0'shortcut_in_activate("1:~# ");	--FEHLER
		send_string(output0, "ifconfig eth0 inet 10.1.1.10 netmask 255.255.255.0 broadcast 10.1.1.255\0d", 100);
		send_string(output0, "cat /etc/network/interfaces\0d", 100);
		wait on found0 until found0 for 3000000;
		found0'shortcut_in_deactivate;
		ASSERT found0 REPORT "timed out" SEVERITY failure;
		wait on found0 until not found0;


		ASSERT false REPORT "ping me" SEVERITY note;
		found0'shortcut_in_activate(" 0% packet loss");
		send_string(output0, "ping -c 4 10.1.1.10\0d", 100);
		wait on found0 until found0 for 30000;
		found0'shortcut_in_deactivate;
		ASSERT found0 REPORT "timed out" SEVERITY failure;
		wait on found0 until not found0;


		ASSERT false REPORT "waiting for: power down" SEVERITY note;
		found0'shortcut_in_activate("Power down.");
		send_string(output0, "halt\0d", 100);
		wait on found0 until found0 for 60000;
		found0'shortcut_in_deactivate;
		ASSERT found0 REPORT "timed out" SEVERITY failure;
		wait on found0 until not found0;

		ASSERT false REPORT "powering system off" SEVERITY note;
		poweron <= false;

		ASSERT false REPORT "test finished" SEVERITY note;
		WAIT;
	END PROCESS installation_script;
end structural;
-- ####################################################################
-- end of definition of entity 'node'
-- ####################################################################