Skip to content
Snippets Groups Projects
Commit b59a8e3b authored by Solveig Langbakk's avatar Solveig Langbakk
Browse files

fikset ting

parent e7b9be7f
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ entity Controller is ...@@ -12,7 +12,7 @@ entity Controller is
Data_bus : inout std_logic_vector(7 downto 0); Data_bus : inout std_logic_vector(7 downto 0);
parity_sel: in std_logic_vector(1 downto 0); parity_sel: in std_logic_vector(1 downto 0);
adresse: out std_logic_vector(2 downto 0); adresse: out std_logic_vector(2 downto 0);
Rd_sig, Wr_sig: inout std_logic Rd_sig, Wr_sig: out std_logic
); );
end Controller; end Controller;
...@@ -20,88 +20,75 @@ end Controller; ...@@ -20,88 +20,75 @@ end Controller;
architecture RTL of Controller is architecture RTL of Controller is
--Arkitekturen begynner type reader_status is (reading, idle);
signal status : reader_status := idle;
signal internal_baud : std_logic_vector(2 downto 0); -- Internal signal for baud
signal internal_parity : std_logic_vector(1 downto 0); -- Internt signal for parity
signal internal_z : std_logic_vector(2 downto 0);
--Arkitekturen begynner
begin begin
-- Rd_sig <= '1' when status = reading else '0';
-- prosessen begynner -- prosessen begynner
p_clk : process(clk, rst_n, msg_key, baud_rate_sel, parity_sel) p_clk : process(clk, rst_n, msg_key, Baud_rate_sel, parity_sel, Data_bus)
begin begin
Wr_sig <= '0';
Rd_sig <= '0';
LED_msg <= '0';
-- Hvis det ikke er konfigurasjonstid, da gjør vi slik:
if rising_edge(clk) then
-- Reset er starten av oppdraget. Her sendes config-informasjon. -- Reset er starten av oppdraget. Her sendes config-informasjon.
if rst_n = '0' then if rst_n = '0' then
case Baud_rate_sel is case Baud_rate_sel is
when "000" => internal_baud(2 downto 0) <= "000";
when "000" => Data_bus(2 downto 0) <= "000"; when "001" => internal_baud(2 downto 0) <= "001";
when "010" => internal_baud(2 downto 0) <= "010";
when "001" => Data_bus(2 downto 0) <= "001"; when "011" => internal_baud(2 downto 0) <= "011";
when "100" => internal_baud(2 downto 0) <= "100";
when "010" => Data_bus(2 downto 0) <= "010"; when others => internal_baud(2 downto 0) <= "111";
when "011" => Data_bus(2 downto 0) <= "011";
when "100" => Data_bus(2 downto 0) <= "100";
when others => Data_bus(2 downto 0) <= "111";
end case; end case;
case parity_sel is case parity_sel is
when "00" => internal_parity(1 downto 0) <= "00";
when "00" => Data_bus(4 downto 3) <= "00"; when "01" => internal_parity(1 downto 0) <= "01";
when "10" => internal_parity(1 downto 0) <= "10";
when "01" => Data_bus(4 downto 3) <= "01"; when "11" => internal_parity(1 downto 0) <= "11";
when others => internal_parity(1 downto 0) <= "00"; -- Default
when "10" => Data_bus(4 downto 3) <= "10";
when "11" => Data_bus(4 downto 3) <= "11";
when others => Data_bus(4 downto 3) <= "00"; -- Velger dette til default
end case; end case;
internal_z(2 downto 0) <= "000";
Data_bus(7 downto 5) <= "ZZZ"; Data_bus(7 downto 0) <= internal_z & internal_parity & internal_baud;
--Sender config info til TX config adresse.
adresse <= "000";
Rd_sig <= '0';
Wr_sig <= '1'; Wr_sig <= '1';
--Sender config info til RX config adresse. adresse <= "000";
adresse <= "100"; elsif rising_edge(clk) then
-- Write settes til null. Ingenting skal sendes fra CTRL altså. --status <= idle;
Wr_sig <='0'; --Wr_sig <= '0';
else if rst_n = '1' then
-- Hvis meldingsknappen trykkes, da sender vi en pre-definert bokstav til TX for videresending. Bokstaven er A. -- Hvis meldingsknappen trykkes, da sender vi en pre-definert bokstav til TX for videresending.
if msg_key = '1' then if msg_key = '1' then
adresse <= "001"; Data_bus <= "01000101";
Data_bus <= "01000001";
Wr_sig <= '1'; Wr_sig <= '1';
Wr_sig <= '0'; adresse <= "001";
end if; end if;
--Hvis RX har mottatt noe data, så skal vi sende videre. Vi skal også skru på led-paeren. --Hvis RX har mottatt noe data, så skal vi sende videre. Vi skal også skru på led-paeren.
if adresse = "101" then if adresse = "101" and msg_key = '0' then
Rd_sig <= '1'; status <= reading;
LED_msg <= '1'; LED_msg <= '1';
LED_msg <= '0';
adresse <= "001"; adresse <= "001";
Wr_sig <= '1'; Wr_sig <= '1';
Rd_sig <= '0'; --status <= idle;
Wr_sig <= '0';
else
Data_bus <= "ZZZZZZZZ";
adresse <= "ZZZ";
Wr_sig <= '0';
Rd_sig <= '0';
--status <= idle;
end if; end if;
end if; --end if;
end if;
end if; end if;
end process p_clk; end process p_clk;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment