aboutsummaryrefslogtreecommitdiff
path: root/fpga/src/HyperBus.bs
blob: b841a64d3c55b97b81e13947ef8f435cd3e36637 (plain)
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
-- | A controller for a HyperBus interface, allowing for I/O to four chips.
package HyperBus where

-- | The HyperBus output pins.
interface HyperBusOut =
  ck       :: Bit 1
  ck_n     :: Bit 1
  cs0_n    :: Bit 1
  cs1_n    :: Bit 1
  cs2_n    :: Bit 1
  cs3_n    :: Bit 1
  reset_n  :: Bit 1
  rwds_out :: Maybe (Bit 1)
  dq_out   :: Maybe (Bit 8)

mkHyperBus :: Bit 1 -> Bit 8 -> Module HyperBusOut
mkHyperBus rwds_in dq_in = module
  clockPin :: Reg (Bit 1) <- mkReg 0
  rules
    "update_clock_pin": when True ==> do
      clockPin := invert clockPin

  interface HyperBusOut
    ck = clockPin
    ck_n = invert clockPin
    cs0_n = 1
    cs1_n = 1
    cs2_n = 1
    cs3_n = 1
    reset_n = 1
    rwds_out = Nothing
    dq_out = Nothing

mkDividedHyperBus :: Integer -> Bit 1 -> Bit 8 -> Module HyperBusOut
mkDividedHyperBus _divisor rwds_in dq_in = module
  -- TODO
  mkHyperBus rwds_in dq_in

-- vim: set ft=haskell :