-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystem2dma.smv
124 lines (118 loc) · 3.5 KB
/
system2dma.smv
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
MODULE UART (proc, proc2UARTvalue, proc2UARTAddress, uart2CPU, uart2mem,
uart2memValue)
VAR
Rx : unsigned word [ 8 ]; -- receive from outside
Tx : array 0 .. 7 of unsigned word [ 8 ]; --array of words
ASSIGN
next (Tx[0]) :=
case
proc = write2UART & proc2UARTAddress = 0 : proc2UARTvalue;
TRUE : (Tx[0]);
esac;
next (Tx[1]) :=
case
proc = write2UART & proc2UARTAddress = 1 : proc2UARTvalue;
TRUE : (Tx[1]);
esac;
next (Tx[2]) :=
case
proc = write2UART & proc2UARTAddress = 2 : proc2UARTvalue;
TRUE : (Tx[2]);
esac;
next (Tx[3]) :=
case
proc = write2UART & proc2UARTAddress = 3 : proc2UARTvalue;
TRUE : (Tx[3]);
esac;
next (Tx[4]) :=
case
proc = write2UART & proc2UARTAddress = 4 : proc2UARTvalue;
TRUE : (Tx[4]);
esac;
next (Tx[5]) :=
case
proc = write2UART & proc2UARTAddress = 5 : proc2UARTvalue;
TRUE : (Tx[5]);
esac;
next (Tx[6]) :=
case
proc = write2UART & proc2UARTAddress = 6 : proc2UARTvalue;
TRUE : (Tx[6]);
esac;
next (Tx[7]) :=
case
proc = write2UART & proc2UARTAddress = 7 : proc2UARTvalue;
TRUE : (Tx[7]);
esac;
next (uart2CPU) :=
case
proc = read2UART : Rx;
TRUE : Rx;
esac;
MODULE MEM (proc, proc2memValue, proc2memAddress, mem2proc, uart2memValue,
DMAadress)
DEFINE
secureAddress := 1032;
VAR
data : array 0 .. 2047 of unsigned word [ 8 ];
ASSIGN
next (mem2proc) :=
case
proc = read & proc2memAddress = 0 : data[0];
proc = read & proc2memAddress = 1 : data[1];
proc = read & proc2memAddress = 2 : data[2];
proc = read & proc2memAddress = 3 : data[3];
proc = read & proc2memAddress = 4 : data[4];
proc = read & proc2memAddress = 5 : data[5];
proc = read & proc2memAddress = 6 : data[6];
proc = read & proc2memAddress = 7 : data[7];
TRUE : mem2proc;
esac;
next (data[0]) :=
case
proc = write & proc2memAddress = 0 : proc2memValue;
DMAadress = 0 : uart2memValue;
TRUE : data[0];
esac;
next (data[secureAddress]) :=
case
proc = write & proc2memAddress = secureAddress: proc2memValue;
DMAadress = secureAddress : uart2memValue;
TRUE : data[secureAddress];
esac;
MODULE DMA (proc, DMAmemAddress)
VAR
address : 0 .. 2047;
control : unsigned word [ 8 ];
ASSIGN
init (control) := 0ud8_31;
next (address) :=
case
proc = setDMAaddress : DMAmemAddress;
TRUE : address;
esac;
MODULE main
VAR
proc : {idle, read, write, read2UART, write2UART, setDMAaddress};
-- addresses are 64 bits
proc2memAddress : 0 .. 2047;
DMAmemAddress : 0 .. 2047;
proc2UARTAddress : 0 .. 2047;
-- data is array of words
mem2proc : unsigned word [ 8 ];
proc2memValue : unsigned word [ 8 ]; -- the data the CPU writes to memory
uart2CPU : unsigned word [ 8 ]; -- the data the UART writes to the CPU
uart2mem : unsigned word [ 8 ]; -- the data the UART writes to RAM (no DMA)
proc2UARTvalue : unsigned word [ 8 ]; -- when the CPU writes to the UART (no DMA)
uart2memValue : unsigned word [ 8 ]; -- external
memory : MEM (proc, proc2memValue, proc2memAddress, mem2proc, uart2mem,
DMAmemAddress);
uart0 : UART (proc, proc2UARTvalue, proc2UARTAddress, uart2CPU, uart2mem,
uart2memValue);
dma : DMA (proc, DMAmemAddress);
ASSIGN
-- prove that secure memory is constant with DMA
LTLSPEC G (proc = setDMAaddress & DMAmemAddress != memory.secureAddress) -> G (memory.data[memory.secureAddress] =
next (memory.data[memory.secureAddress]))
LTLSPEC G (proc = setDMAaddress & DMAmemAddress = memory.secureAddress) -> G (memory.data[memory.secureAddress] =
next (memory.data[memory.secureAddress])) -- should be false