File: phystypes.vhdl

package info (click to toggle)
fauhdlc 20100325-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,724 kB
  • ctags: 3,646
  • sloc: cpp: 22,017; ansic: 5,778; yacc: 806; lex: 744; makefile: 546; python: 461; xml: 381; sh: 61
file content (56 lines) | stat: -rw-r--r-- 1,206 bytes parent folder | download | duplicates (4)
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
-- $Id: phystypes.vhdl 4330 2009-01-27 14:50:08Z potyra $ 

-- test for physical types

-- Copyright (C) 2007-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.


library std;
use std.standard.all;
package types is
	type length is range -2147483647 to 2147483647
		units 
			mm;
			cm = 10 mm;
			m = 100 cm;
			km = 1000 m;
			
			inch = 254 mm;
		end units; 
		
	type data is range -2147483647 to 2147483647
		units 
			bit;
			nibble = 4 bit;
			byte = 8 bit;
			word = 2 byte;
			kbit = 1000 bit;
			mbit = 1000 kbit;
			kb = 1024 byte;
			mb = 1024 kb;
			gb = 1024 mb;
			--meterbit = 10 mm; -- should throw an error.
		end units;
end package types;

library std;
use std.standard.all;
use types.all;
entity nullentity is
end entity nullentity;

architecture implementation of nullentity is
begin	
	x : process 
		variable foo : length;
		variable bar : length;
	begin
		foo := 48 mm;
		bar := 2 * foo + 3 cm;
		foo := bar - 5 km;
		bar := foo + 100 inch;
	end process;
end implementation;