Wired-0.1: Libs/Simple130nm/Wired.hs
module Libs.Simple130nm.Wired
( Simple130nm (..)
, low
, high
, rowHeight
, guideN
, guideS
, guideW
, guideE
, Libs.Simple130nm.Wired.and2
, Libs.Simple130nm.Wired.halfAdd
, Libs.Simple130nm.Wired.fullAdd
) where
import Data.Hardware.Internal
import Lava
import Wired.Model
import Wired
import Libs.Simple130nm.Lava as Lava
instance WiredLibrary Simple130nm
where
lambda = const 65
rowHeight :: Height
rowHeight = 4920
guideLength :: Length
guideLength = 600 -- To satisfy minimum area of metal segments
guide_
:: PortStruct p Signal t
=> Direction -> Layer -> Width -> (p -> Wired Simple130nm p)
guide_ dir lay pitch
| lay >= 6 = error
"Libs.Simple130nm.Wired.guide_: Only supporting layers 1-5"
-- Because layer 6 has different properties.
| lay==1 = guide dir guideLength 1 pitch
| Vertical <- directionAngle dir, odd lay = error $
"Layer " ++ show (toInt lay) ++ " doesn't support vertical wires"
| Horizontal <- directionAngle dir, even lay = error $
"Layer " ++ show (toInt lay) ++ " doesn't support horizontal wires"
| otherwise = guide dir guideLength lay pitch
guideN, guideS, guideW, guideE
:: PortStruct p Signal t => Layer -> Width -> (p -> Wired Simple130nm p)
guideN = guide_ Upwards
guideS = guide_ Downwards
guideW = guide_ Leftwards
guideE = guide_ Rightwards
and2 :: (Signal,Signal) -> Wired Simple130nm Signal
and2 (a,b) = stacked $ do
guidePos Rightwards 0 1 (1000,2665) a
guidePos Rightwards 0 1 (1200,2255) b
mkCell "AN2HSP" 2050 4920 $ Lava.and2 (a,b)
>>= guidePos Rightwards 0 1 (200,1400)
halfAdd :: (Signal,Signal) -> Wired Simple130nm (Signal,Signal)
halfAdd (a,b) = stacked $ do
guidePos Rightwards 0 1 (1345,3895) a
guidePos Rightwards 0 1 (1310,2255) b
(s,co) <- mkCell "HA1HSP" 4510 4920 $ Lava.halfAdd (a,b)
guidePos Rightwards 0 1 (4265,1500) s
guidePos Rightwards 0 1 (205,1500) co
return (s,co)
fullAdd :: (Signal,(Signal,Signal)) -> Wired Simple130nm (Signal,Signal)
fullAdd (ci,(a,b)) = stacked $ do
guidePos Rightwards 0 1 (1310,2255) ci
guidePos Rightwards 0 1 (3800,2255) a
guidePos Rightwards 0 1 (1500,2665) b
(z,co) <- mkCell "FA1HSP" 7790 4920 $ Lava.fullAdd (ci,(a,b))
guidePos Rightwards 0 1 (7560,1500) z
guidePos Rightwards 0 1 (205,1500) co
return (z,co)