I used the same display for both the fpga. I checked the waveforms using the scope.
here is the code
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.STD_LOGIC_UNSIGNED.all;
entity display is
port (
clk : in std_logic;
sclk : out std_logic;
din : out std_logic;
cs : out std_logic );
end display;
architecture Behavioral of display is
signal sclk_clk_div : std_logic_vector (10 downto 0):="00000000000"; -- counter for serial clock
signal dig_count : std_logic_vector (3 downto 0):="0000"; --counter for display select
signal sclk_s : std_logic:='0';
signal cs_s : std_logic:='0' ;
signal din_s : std_logic:='0' ;
signal st :std_logic:='0';
signal dig_data : std_logic_vector (7 downto 0):="00000000"; --data to the display
signal dig_add : std_logic_vector (7 downto 0):="00000000"; -- address to the display
signal dig_data_add : std_logic_vector (15 downto 0):="0000000000000000";
signal c :std_logic_vector(4 downto 0):="00000";
begin
process(clk)
begin
if clk'event and clk = '1' then
if sclk_clk_div = "11000000000" then
sclk_clk_div <= (others => '0');
else
sclk_clk_div <= sclk_clk_div+1;
end if;
end if;
sclk_s<= not sclk_clk_div(5);
-- cs_s <= sclk_clk_div(10);
end process;
dig : process(cs_s)
-- variable dig_count: integer := 0;
type digit is array ( 0 to 7 ) of std_logic_vector(7 downto 0);
constant dig_data_array : digit := ("00001000","00000111","00000110","00000101","00000100","00000011","00000010","00000001");
begin
if cs_s'event and cs_s = '1' then
dig_count <= dig_count + 1;
case dig_count is
when "0000" => dig_data <= x"01" ; dig_add <= x"0C" ; --set to normal mode
when "0001" => dig_data <= x"FF" ; dig_add <= x"09" ; -- set to codeB decode
when "0010" => dig_data <= x"07" ; dig_add <= x"0B" ; -- set to scan all
when "0011"=> dig_data <= x"0A" ; dig_add <= x"0A" ; -- set to 21/32 intensity
when "0100" => dig_data <= dig_data_array(0) ; dig_add <= x"01" ;
when "0101" => dig_data <= dig_data_array(1) ; dig_add <= x"02" ;
when "0110" => dig_data <= dig_data_array(2) ; dig_add <= x"03" ;
when "0111" => dig_data <= dig_data_array(3) ; dig_add <= x"04" ;
when "1000" => dig_data <= dig_data_array(4) ; dig_add <= x"05" ;
when "1001" => dig_data <= dig_data_array(5) ; dig_add <= x"06" ;
when "1010" => dig_data <= dig_data_array(6) ; dig_add <= x"07" ;
when "1011" => dig_data <= dig_data_array(7) ; dig_add <= x"08" ;
when others => dig_data <= x"00" ; dig_add <= x"FF" ;
end case ;
end if;
if dig_count = "1100" then
dig_count <= "0100";
end if;
end process ;
-- start : process (cs_s)
-- begin
-- if cs_s'event and cs_s = '0' then
-- st <= '1';
-- elsif cs_s'event and cs_s = '1' then
-- st <= '0';
-- end if;
-- end process ;
ser : process (sclk_s)
begin
if sclk_s'event and sclk_s = '0' then
-- if st = '1' then
if c <= 15 then
din_s <= dig_data_add(15);
dig_data_add(15 downto 1) <= dig_data_add(14 downto 0);
dig_data_add(0) <= '0';
c <= c + 1 ;
end if;
if c = "10000" then
cs_s<='1';
c <= c+ 1;
dig_data_add <= dig_add & dig_data;
end if;
if c= "10001" then
c <= (others => '0');
cs_s<='0';
end if;
end if;
end process;
sclk <= ((sclk_s));
din <= din_s;
cs <= cs_s;
end Behavioral;