root/hiersort/sim/InterfaceTypes.hs

Revision 1, 2.7 kB (checked in by thesz, 2 years ago)

Initial commit

Line 
1 -- | InterfaceTypes.hs
2 --
3 -- Module that contains types for other parts to manipulate.
4 --
5 -- Copytight (C) 2007, 2008 Serguey Zefirov
6 --
7 -- This program is free software; you can redistribute it and/or modify
8 -- it under the terms of the GNU General Public License as published by
9 -- the Free Software Foundation; either version 3, or (at your option)
10 -- any later version.
11 -- See file COPYING or visit http://www.gnu.org/licenses for details.
12
13
14 module InterfaceTypes where
15
16 -------------------------------------------------------------------------------
17 -- Types for processor execution and "assembler" commands.
18
19 -- Processor thread window execution policies.
20 data ProcShedulingPolicy =
21                 SheduleAllWorkBack
22         |       SheduleSheduledBack
23         |       SheduleWindow
24         deriving (Read,Show,Enum,Eq,Ord)
25
26 -- Processor execution unit resources.
27 data ProcResource =
28                 IAdder
29         |       ILogic
30         |       IMultiplier
31         |       FAdder
32         |       FMultiplier
33         |       FDivider
34         deriving (Ord,Eq,Show)
35
36 -- All processor resources - execution and communication.
37 data ProcExtResource =
38                 MessageChannel  MsgChannel
39         |       OtherResource   ProcResource
40         deriving (Ord,Eq,Show)
41
42 -- Message channels resources (there was two message channels once upon a time).
43 data MsgChannel =
44         MsgChannelMatch
45         deriving (Ord,Eq,Show)
46
47 -- And what kind of commands processor can "execute."
48 data ProcessorCommand m =
49                 ProcNop
50         |       ProcMessage     m
51         |       ProcResource    ProcResource
52         deriving Show
53
54 -------------------------------------------------------------------------------
55 -- Types for messages, matchers and sorters.
56
57 -- Message type.
58 data Message o t =
59         Msg {
60                  msgOrder       :: o
61                 ,msgArity       :: Arity
62                 ,msgToken       :: t
63                 ,msgModuleAddr  :: TokenModuleAddr
64         }
65         deriving Show
66
67 -- The arity type. Consists of HeadArity1, Arity1 and Arity2.
68 -- Tokens with HeadArity1 and Arity1 match with themselves, Arity2 tokens
69 -- need another token to be paired.
70 data Arity =
71                 HdA1    -- For those who should be least in the queue.
72         |       A1
73         |       A2
74         deriving Show
75
76 -- A pair token.
77 data Pair i =
78                 P1      i
79         |       P2      i       i
80         deriving Show
81
82 -- Destination descriptor.
83 data TokenModuleAddr =
84                 -- Token is a result token.
85                 HostTok
86                 -- Token is an execution token. And it should be
87                 -- delivered into specified processor module (modulo
88                 -- number of processors).
89         |       ModTok  Int
90         deriving (Show,Eq)
91
92 tokenToMod n = ModTok n
93
94 -- Token order parts.
95 data Order group node =
96                 OrdI    group   [Int]
97         |       OrdN    node
98         deriving (Eq,Ord,Show)
99
100 oIndexes g l = [OrdI g l]
101 oNode      n = [OrdN n]
102
103
104 -------------------------------------------------------------------------------
105 -- An extra type to control widths of buses.
106
107 data Width = Width { fromWidth :: Int } deriving (Show,Eq,Ord)
108 mkWidth pos n
109         | n < 1 = error $ unwords ["improper width",show n,"pos",pos]
110         | otherwise = Width n
Note: See TracBrowser for help on using the browser.