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
|
-- | The top-level module, for the iCEBreaker.
package Top where
import Connectable
import CPU
import GetPut
import TriState
import Uart
-- | The interface to the iCEBreaker.
interface Top =
-- RS232
rx :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [RX] #-}
tx :: Bit 1 {-# always_ready, result = TX #-}
-- Onboard LEDs
ledR_N :: Bit 1 {-# always_ready, result = LEDR_N #-}
ledG_N :: Bit 1 {-# always_ready, result = LEDG_N #-}
-- RGB LED driver
ledRed_N :: Bit 1 {-# always_ready, result = LED_RED_N #-}
ledGrn_N :: Bit 1 {-# always_ready, result = LED_GRN_N #-}
ledBlu_N :: Bit 1 {-# always_ready, result = LED_BLU_N #-}
-- HyperBus 1 (PMOD 1A)
hyperBus_CS2_N :: Bit 1 {-# always_ready, result = P1A1 #-}
hyperBus_CS0_N :: Bit 1 {-# always_ready, result = P1A2 #-}
hyperBus_CK :: Bit 1 {-# always_ready, result = P1A3 #-}
hyperBus_CK_N :: Bit 1 {-# always_ready, result = P1A4 #-}
hyperBus_CS3_N :: Bit 1 {-# always_ready, result = P1A7 #-}
hyperBus_CS1_N :: Bit 1 {-# always_ready, result = P1A8 #-}
hyperBus_RESET_N :: Bit 1 {-# always_ready, result = P1A9 #-}
hyperBus_RWDS :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [P1A10] #-}
-- HyperBus 2 (PMOD 1B)
hyperBus_DQ0 :: Inout (Bit 1) {-# prefix = "P1B1" #-}
hyperBus_DQ1 :: Inout (Bit 1) {-# prefix = "P1B2" #-}
hyperBus_DQ2 :: Inout (Bit 1) {-# prefix = "P1B3" #-}
hyperBus_DQ3 :: Inout (Bit 1) {-# prefix = "P1B4" #-}
hyperBus_DQ7 :: Inout (Bit 1) {-# prefix = "P1B7" #-}
hyperBus_DQ6 :: Inout (Bit 1) {-# prefix = "P1B8" #-}
hyperBus_DQ5 :: Inout (Bit 1) {-# prefix = "P1B9" #-}
hyperBus_DQ4 :: Inout (Bit 1) {-# prefix = "P1B10" #-}
-- LEDs and buttons (PMOD 2)
led1 :: Bit 1 {-# always_ready, result = P2_7 #-}
led2 :: Bit 1 {-# always_ready, result = P2_1 #-}
led3 :: Bit 1 {-# always_ready, result = P2_2 #-}
led4 :: Bit 1 {-# always_ready, result = P2_8 #-}
led5 :: Bit 1 {-# always_ready, result = P2_3 #-}
btn1 :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [P2_9] #-}
btn2 :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [P2_4] #-}
btn3 :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [P2_10] #-}
clockFreqHz :: Integer
clockFreqHz = 12_000_000
mkTop :: Module Top
mkTop =
module
cpu <- mkCPU
uart <- mkUart (clockFreqHz / 9600)
mkConnection cpu.uart_tx uart.send
mkConnection cpu.uart_rx uart.recv
hyperBus_data0 <- mkTriState True 1
hyperBus_data1 <- mkTriState True 1
hyperBus_data2 <- mkTriState True 1
hyperBus_data3 <- mkTriState True 1
hyperBus_data4 <- mkTriState True 1
hyperBus_data5 <- mkTriState True 1
hyperBus_data6 <- mkTriState True 1
hyperBus_data7 <- mkTriState True 1
interface Top
-- RS232
rx = uart.rxPin
tx = uart.txPin
-- Onboard LEDs
ledR_N = uart.txPin
ledG_N = 1
-- RGB LED driver
ledRed_N = 1
ledGrn_N = 1
ledBlu_N = 1
-- HyperBus 1 (PMOD 1A)
hyperBus_CS2_N = 1
hyperBus_CS0_N = 1
hyperBus_CK = 0
hyperBus_CK_N = 1
hyperBus_CS3_N = 1
hyperBus_CS1_N = 1
hyperBus_RESET_N = 1
hyperBus_RWDS _ = noAction
-- HyperBus 2 (PMOD 1B)
hyperBus_DQ0 = hyperBus_data0.io
hyperBus_DQ1 = hyperBus_data1.io
hyperBus_DQ2 = hyperBus_data2.io
hyperBus_DQ3 = hyperBus_data3.io
hyperBus_DQ4 = hyperBus_data4.io
hyperBus_DQ5 = hyperBus_data5.io
hyperBus_DQ6 = hyperBus_data6.io
hyperBus_DQ7 = hyperBus_data7.io
-- LEDs and buttons (PMOD 2)
led1 = 0
led2 = 0
led3 = 0
led4 = 0
led5 = 0
btn1 _ = noAction
btn2 _ = noAction
btn3 _ = noAction
{-# verilog mkTop #-}
{-# properties mkTop = { RSTN = BTN_N } #-}
-- vim: set ft=haskell :
|