sseg_display_example

Config File:
1[global]
2clk_pin = E3
3reset_pin = U9
4sys_clk_freq = 100E6
5reset_polarity = '1'
6data_width = 32
7control_width = 32
8default_shared_register_polarity = '0'
9default_signal_polarity = '0'
10default_voltage_standard = 3.3V
11pinout_filename = PINOUT.xdc
12command_help = False
13voice_enabled = False
14default_time_units = ms
15alias srr is state_reg_rec(0);
16alias state_reg : integer is state_reg_rec(0).state_reg;
17
18[sseg_display]
19output anode(8) = N6, M6, M3, N5, N2, N4, L1, M1
20output sseg(7) = L3, N1, L5, L4, K3, M2, L6
21constant sseg_array : std_logic_vector_array := read_array_from_file("sseg_array.dat");
22
VHDL Code:
1library ieee; -- version: beta
2use ieee.std_logic_1164.all; -- lic: non-commercial
3use ieee.numeric_std.all; -- user: local
4use ieee.std_logic_unsigned.all;
5use work.user_defs_pkg.all;
6use work.speakhdl_api_pkg.all;
7
8--==============================================================================================
9entity sseg_display is
10
11 generic (this_sm : integer := -1);
12 port (
13 clk : in std_logic; -- clock: E3, 100MHz
14 reset : in std_logic; -- reset: U9, '1'
15 sm_input : in std_logic_vector(-1 downto 0); -- num inputs: 0
16 sm_output : out std_logic_vector(14 downto 0); -- num outputs: 15
17 sm_io : inout std_logic_vector(-1 downto 0); -- num io: 0
18 next_state_rec : out nsr_array(0 to 0);
19 state_reg_rec : in srr_array(0 to 0)
20 );
21
22end entity sseg_display;
23--==============================================================================================
24
25architecture arch of sseg_display is
26
27 alias anode : std_logic_vector(7 downto 0) is sm_output(7 downto 0); -- output N6,M6,..
28 alias sseg : std_logic_vector(6 downto 0) is sm_output(14 downto 8); -- output L3,N1,..
29 alias srr is state_reg_rec(0); -- alias (global)
30 alias state_reg : integer is state_reg_rec(0).state_reg; -- alias (global)
31 signal mux_counter_i : integer;
32
33 constant sseg_array : std_logic_vector_array :=
34 read_array_from_file("sseg_array.dat"); -- const (local)
35
36begin
37--==============================================================================================
38 -- output signals
39 anode(0) <= '0' when (srr.delay.value = 0) else
40 '1';
41 anode(1) <= '0' when (srr.delay.value = 1) else
42 '1';
43 anode(2) <= '0' when (srr.delay.value = 2) else
44 '1';
45 anode(7 downto 3) <= (others => '1');
46
47 sseg(6 downto 0) <= sseg_array(mux_counter_i)(6 downto 0);
48
49--==============================================================================================
50 -- local signals
51 mux_counter_i <= srr.counter(srr.delay.value + 1).value;
52
53--==============================================================================================
54 -- units: ms, '0'
55process(state_reg_rec) -- voice disabled
56
57begin -- Log Status: OK
58
59 --------------------------------------------------------------------------------------------
60 ---------------------------sys_clk 100MHz active resource 0 state -1------------------------
61 --------------------------------------------------------------------------------------------
62 RESOURCE_SELECT( sys_clk, next_state_rec, state_reg_rec );
63 --------------------------------------------------------------------------------------------
64 TIME_COUNTER( 3, ms(1), next_state_rec, state_reg_rec );
65 CONFIGURE_COUNTER( 0, ms(100), -1, next_state_rec, state_reg_rec );
66 CONFIGURE_COUNTER( 1, 10, no_trans, next_state_rec, state_reg_rec, chain );
67 CONFIGURE_COUNTER( 2, 10, no_trans, next_state_rec, state_reg_rec, chain );
68 CONFIGURE_COUNTER( 3, 10, no_trans, next_state_rec, state_reg_rec, chain );
69
70end process;
71
72end architecture arch;
73--==============================================================================================
Data File of Seven Segment Values:
11000000
21111001
30100100
40110000
50011001
60010010
70000010
81111000
90000000
100011000
See also
led_blink_example
uart_loopback_example
vga_controller_example