Altera_Forum
Honored Contributor
12 years agoDefault latched outputs values
Hi guys,
I'm working on a multi deck elevator controller using niosII and i thought it's better to relief the processor from handling the displays (floors + car motors display : up,down,1,2...etc u get it ;)). so i came up with this display controller code you see bellow to test it on the 7 segments displays of my DE2 board, it works fine but i'm seeking perfection :p, the only problem i get is at the moment the system get powered up. floor indicators gives random values at first until the floor sensors actualise the block to give a correct reading. the up/down indicators works great cuz the output is unlatched unlike that of the floors. so that's it, i'm looking for a manner to initialize LATCHED outputs (say to '0') for power up readings library ieee; use ieee.std_logic_1164.all; entity display_controller is port ( reset_n : in std_logic; mc1, mc2 : in std_logic_vector(1 downto 0); fsensor1,fsensor2 : in std_logic_vector(2 downto 0); floor1_a, floor1_b : out std_logic_vector(6 downto 0); floor2_a, floor2_b : out std_logic_vector(6 downto 0); mc1_a,mc1_b,mc2_a,mc2_b : out std_logic_vector(6 downto 0)); end entity display_controller; architecture behavioral of display_controller is signal f1,f2 : std_logic_vector (6 downto 0); signal m1,m2 : std_logic_vector (13 downto 0); begin process (mc1,reset_n) begin if (reset_n = '0') then m1 <="11111111111111"; -- clear display elsif (mc1="10") then m1 <= "01000010101011"; -- display: dn elsif (mc1="11") then m1 <= "10000010001100"; -- display: up else m1 <= "01111110111111"; -- display: -- end if; end process; process (mc2,reset_n) begin if (reset_n = '0') then m2 <="11111111111111"; -- clear display elsif (mc2="10") then m2 <= "01000010101011"; -- display: dn elsif (mc2="11") then m2 <= "10000010001100"; -- display: up else m2 <= "01111110111111"; -- display: -- end if; end process; process (fsensor1,reset_n) begin if (reset_n = '0') then f1 <="1111111"; -- clear display elsif (fsensor1="001") then f1 <= "1111001"; -- display: 1 elsif (fsensor1="010") then f1 <= "0100100"; -- display: 2 elsif (fsensor1="011") then f1 <= "0110000"; -- display: 3 elsif (fsensor1="100") then f1 <= "0011001"; -- display: 4 else f1 <= f1; -- latch the output end if; end process; process (fsensor2,reset_n) begin if (reset_n = '0') then f2 <="1111111"; -- clear display elsif (fsensor2="001") then f2 <= "1111001"; -- display: 1 elsif (fsensor2="010") then f2 <= "0100100"; -- display: 2 elsif (fsensor2="011") then f2 <= "0110000"; -- display: 3 elsif (fsensor2="100") then f2 <= "0011001"; -- display: 4 else f2 <= f2; -- latch the output end if; end process; mc1_a <= m1(6 downto 0); mc1_b <= m1(13 downto 7); mc2_a <= m2(6 downto 0); mc2_b <= m2(13 downto 7); floor1_a <= f1; floor1_b <= "1111111"; floor2_a <= f2; floor2_b <= "1111111"; end architecture behavioral;
any suggestions, tips, ideas, jokes, efforts.....aaanything would realy be appreciated. bring it up, let's see what u get :) thx in advance you guys, take care :cool: