-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSimulation.hs
More file actions
41 lines (32 loc) · 922 Bytes
/
Copy pathSimulation.hs
File metadata and controls
41 lines (32 loc) · 922 Bytes
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
module Simulation where
import CLaSH.Prelude
import Types
import Stimuli
--
-- Simulation
--
-- Stimuli
-- Synchronous logic simulation and testbench generation
testInput = stimuliGenerator $(listToVecTH instrs)
expectedOutput = outputVerifier expResults
-- Combinatorial logic simulation
-- Simulation function that just stores the output
sim_o f s [] = []
sim_o f s (x:xs) = o:sim_o f s' xs
where
(s', o) = f s x
-- Simulation function that stores the internal state and the output
sim_full f s [] = []
sim_full f s (x:xs) = (s', o):sim_full f s' xs
where
(s', o) = f s x
-- Simulation function that only stores the state of the memory
sim_mem f s [] = []
sim_mem f s (x:xs) = mem:sim_mem f s' xs
where
(s'@(mem, sp), o) = f s x
-- Simulation function that only stores the state of the stack pointer
sim_sp f s [] = []
sim_sp f s (x:xs) = sp:sim_sp f s' xs
where
(s'@(_, sp), o) = f s x