From a50049ae050c625e66b5f9280929cbf2f98cdec4 Mon Sep 17 00:00:00 2001 From: Nathan Ringo Date: Wed, 2 Oct 2024 15:28:46 -0500 Subject: Adds tristates for HyperBus. This might need to be remodularized; Bluesim doesn't support Inouts, so this fails to build there for now. It probably makes sense to split out the board to its own package, then go back to having Top and TopSim packages, where only Top wires it up to Tristates. --- fpga/src/Top.bs | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'fpga/src/Top.bs') diff --git a/fpga/src/Top.bs b/fpga/src/Top.bs index 924b19a..7740c4b 100644 --- a/fpga/src/Top.bs +++ b/fpga/src/Top.bs @@ -4,6 +4,7 @@ package Top where import Connectable import CPU import GetPut +import TriState import Uart -- | The interface to the iCEBreaker. @@ -28,24 +29,23 @@ interface Top = 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_i :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [P1B1] #-} - -- hyperBus_DQ0 :: Inout (Bit 1) {-# always_ready, result = P1B1 #-} - -- hyperBus_DQ1 :: Bit 1 {-# always_ready, result = P1B2 #-} - -- hyperBus_DQ2 :: Bit 1 {-# always_ready, result = P1B3 #-} - -- hyperBus_DQ3 :: Bit 1 {-# always_ready, result = P1B4 #-} - -- hyperBus_DQ7 :: Bit 1 {-# always_ready, result = P1B7 #-} - -- hyperBus_DQ6 :: Bit 1 {-# always_ready, result = P1B8 #-} - -- hyperBus_DQ5 :: Bit 1 {-# always_ready, result = P1B9 #-} - -- hyperBus_DQ4 :: Bit 1 {-# always_ready, result = P1B10 #-} + 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 = LED1 #-} - led2 :: Bit 1 {-# always_ready, result = LED2 #-} - led3 :: Bit 1 {-# always_ready, result = LED3 #-} - led4 :: Bit 1 {-# always_ready, result = LED4 #-} - led5 :: Bit 1 {-# always_ready, result = LED5 #-} - btn1 :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [BTN1] #-} - btn2 :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [BTN2] #-} - btn3 :: Bit 1 -> Action {-# always_enabled, always_ready, prefix = "", arg_names = [BTN3] #-} + 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 @@ -59,6 +59,15 @@ mkTop = 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 @@ -79,6 +88,15 @@ mkTop = 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 -- cgit v1.2.3