From 58cb726726c8e0c171e1a79454a0932ff81833f3 Mon Sep 17 00:00:00 2001
From: Solveig <solvlang@stud.ntnu.no>
Date: Thu, 14 Nov 2024 14:06:55 +0100
Subject: [PATCH] trekker ut funksjoner

---
 controller.vhd | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/controller.vhd b/controller.vhd
index 945f2e9..b8c45c2 100644
--- a/controller.vhd
+++ b/controller.vhd
@@ -65,6 +65,25 @@ architecture RTL of Controller is
 		end if;
 	 end function statusCheck;
 	 
+	 function getStatusFromRx(databus: std_logic_vector(7 downto 0))return std_logic is
+	 begin
+	 Rd_sig <= '1';
+	 adress <= "101";
+	 end function getStatusFromRx;
+	 
+	 function sendDataToTx(databus: std_logic_vector(7 downto 0)) return std_logic is
+	 begin 
+	 if txBusy = '0' then 
+			adress <= "001";
+			Data_bus <= databus;
+			Wr_sig <= '1';
+	 else 
+	 Rd_sig <= '1';
+	 Data_bus <= databus;
+	 end if;
+		
+	end function sendDataToTx;
+	 
 
 	 --Arkitekturen begynner
 begin
@@ -104,19 +123,22 @@ begin
 				 
 				statusChecker(turnTaker);
 				if Data_bus = "ZZZZZZZZ" then
-					--do nothing
+					Rd_sig <= '0'; 
+				else if Rd_sig = '1' then
+					sendDataToTx(Data_bus);
 				else
 					if turnTaker = '1' then -- da skal vi sjekke om TX er busy
 						if Data_bus(0 downto 0) = "1" then 
 							txBusy <= '1';
 					elsif turnTaker = '0' then -- Skal sjekke om Rx har data til oss, status på fifo osv.
-						--if Data_bus()
+						getStatusFromRx(Data_bus);
+						else
 					end if;
 					end if;
 					end if;
 		  
 		  end if;
-		  --end if;
+		  end if;
 	
 	
     end process p_clk;
-- 
GitLab