1
|
open Vhdl_ast
|
2
|
|
3
|
let design1 = {
|
4
|
packages = [{name = "typedef"; shared_defs = [Subtype{name = "byte"; definition = Bit_vector (7, 0)}]}];
|
5
|
libraries = [Use ["work";"typedef";"all"]];
|
6
|
entities = [{ name = "data_path";
|
7
|
generics = [];
|
8
|
ports = [
|
9
|
{name = "clk"; kind = InPort; typ = Base "boolean"};
|
10
|
{name = "rst"; kind = InPort; typ = Base "boolean"};
|
11
|
{name = "s_1"; kind = InPort; typ = Base "boolean"};
|
12
|
{name = "s0"; kind = InPort; typ = Base "bit"};
|
13
|
{name = "s1"; kind = InPort; typ = Base "bit"};
|
14
|
{name = "d0"; kind = InPort; typ = Base "byte"};
|
15
|
{name = "d1"; kind = InPort; typ = Base "byte"};
|
16
|
{name = "d2"; kind = InPort; typ = Base "byte"};
|
17
|
{name = "d3"; kind = InPort; typ = Base "byte"};
|
18
|
{name = "q"; kind = OutPort; typ = Base "byte"};
|
19
|
|
20
|
];
|
21
|
}];
|
22
|
architectures = [{
|
23
|
name = "behavior";
|
24
|
entity = "data_path";
|
25
|
declarations = [
|
26
|
SigDecl { name = "reg"; typ = Base "byte"; init_val = None};
|
27
|
SigDecl { name = "shft"; typ = Base "byte"; init_val = None};
|
28
|
SigDecl { name = "sel"; typ = Bit_vector(1,0); init_val = None};
|
29
|
|
30
|
];
|
31
|
body = [
|
32
|
Process {
|
33
|
id = None;
|
34
|
active_sigs = ["clk"; "rst"];
|
35
|
body = [
|
36
|
If {
|
37
|
if_cases = [
|
38
|
{
|
39
|
if_cond = Sig{ name = "rst"; att = None };
|
40
|
if_block = [
|
41
|
SigSeqAssign { lhs = "req"; rhs = Cst (CstBV("x", "00"))};
|
42
|
SigSeqAssign { lhs = "shft"; rhs = Cst (CstBV("x", "00"))};
|
43
|
];
|
44
|
};
|
45
|
{
|
46
|
if_cond = Op {id = "and"; args = [Sig{ name = "clk"; att = None };
|
47
|
Sig{ name = "clk"; att = Some (SigAtt "event") }]};
|
48
|
if_block = [
|
49
|
SigSeqAssign { lhs = "req"; rhs = Op { id = "&"; args = [
|
50
|
Sig{ name = "s0"; att = None };
|
51
|
Sig{ name = "s1"; att = None }
|
52
|
]
|
53
|
}
|
54
|
};
|
55
|
Case {
|
56
|
guard = Sig{ name = "sel"; att = None };
|
57
|
branches = [
|
58
|
{
|
59
|
when_cond = Cst (CstBV("b", "00"));
|
60
|
when_stmt = SigSeqAssign { lhs = "req"; rhs = Sig{ name = "d0"; att = None }};
|
61
|
};
|
62
|
{
|
63
|
when_cond = Cst (CstBV("b", "10"));
|
64
|
when_stmt = SigSeqAssign { lhs = "req"; rhs = Sig{ name = "d1"; att = None }};
|
65
|
};
|
66
|
{
|
67
|
when_cond = Cst (CstBV("b", "01"));
|
68
|
when_stmt = SigSeqAssign { lhs = "req"; rhs = Sig{ name = "d2"; att = None }};
|
69
|
};
|
70
|
{
|
71
|
when_cond = Cst (CstBV("b", "11"));
|
72
|
when_stmt = SigSeqAssign { lhs = "req"; rhs = Sig{ name = "d3"; att = None }};
|
73
|
};
|
74
|
|
75
|
]
|
76
|
|
77
|
};
|
78
|
If {
|
79
|
if_cases = [
|
80
|
{
|
81
|
if_cond = Sig{ name = "s_1"; att = None };
|
82
|
if_block = [
|
83
|
SigSeqAssign {
|
84
|
lhs = "shft";
|
85
|
rhs = Op { id = "&";
|
86
|
args = [
|
87
|
SuffixMod {
|
88
|
expr = Sig{ name = "shft"; att = None };
|
89
|
selection = Range (6,0);
|
90
|
};
|
91
|
SuffixMod {
|
92
|
expr = Sig{ name = "shft"; att = None };
|
93
|
selection = Idx 7;
|
94
|
}
|
95
|
]
|
96
|
}
|
97
|
};
|
98
|
];
|
99
|
};
|
100
|
];
|
101
|
default = Some [
|
102
|
SigSeqAssign { lhs = "shft"; rhs = Var "reg"};
|
103
|
]
|
104
|
};
|
105
|
];
|
106
|
};
|
107
|
|
108
|
];
|
109
|
default = None;
|
110
|
}
|
111
|
];
|
112
|
};
|
113
|
SigAssign {
|
114
|
lhs = "q";
|
115
|
rhs = Var "shft";
|
116
|
cond = None;
|
117
|
}
|
118
|
|
119
|
];
|
120
|
}];
|
121
|
configuration = None;
|
122
|
}
|
123
|
|