From 73c351ec6c7314aacbe29396d7fe4abae09de617 Mon Sep 17 00:00:00 2001 From: Igor Debastiani Date: Mon, 28 Feb 2022 18:07:54 -0300 Subject: [PATCH] feat: modifica sint p/ contemplar lcd --- .DS_Store | Bin 0 -> 6148 bytes .gitignore | 4 + peripherals/.DS_Store | Bin 0 -> 6148 bytes peripherals/lcd_hd44780/.DS_Store | Bin 0 -> 6148 bytes peripherals/lcd_hd44780/lcd_hd44780.vhd | 489 +++++++++--------- .../lcd_hd44780/sint2/de10_lite/de0_lite.vhd | 38 ++ .../lcd_hd44780/sint2/de10_lite/de10_lite.qsf | 4 +- 7 files changed, 301 insertions(+), 234 deletions(-) create mode 100644 .DS_Store create mode 100644 .gitignore create mode 100644 peripherals/.DS_Store create mode 100644 peripherals/lcd_hd44780/.DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..549d1b59fd6bcf82b061e880d17efb8f1654927b GIT binary patch literal 6148 zcmeHK!AiqG5S_JEqayYo*yCQj_0X!d^&o^=58i}`9#qTUlpUCTv%51J=E3e{0D!fIy&6CX04!9(;vx=T2Nvs4A9+Of`PoX0pk1pO}s1_c%ksn{X#6wxJmP_zXJ2)KY0GJMWr@c$Vdje4WPYqcuT(QG0ejmFRDm`L;! z5wFx4oHhpZC9#&KEisdiVZbo(YX<0j;HZSQ#$2I%I&hFJ03!WHNI{!=35wwwZH>7? z+(BU~6j6mT-C{5mj_X|e*&1_&Djb+@KA8S8(;W(vU&r&gbO&ZDG^1g_Fz}Iqf|{17 z{_lU^|9=cJGsA#kV5%5k#kSLKVM@BTP9#UQmZNr2Nysl(C_`}2o@k($B) literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..99b222d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +output_files/ +simulation/ +db/ +incremental_db/ diff --git a/peripherals/.DS_Store b/peripherals/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1b5619e84b424ca01512a7ec9dd1b402ad230155 GIT binary patch literal 6148 zcmeHK!A`;{XbX2a^W%;LW5)4{D&b1e(+?fg(}F^f&a6`~rW+ zncanm$ia&-WT%;Vv%52G<|Vt^0RUF(2StD!0NAL6)*6~0gw{!CWJ%9hh>YIh4|*Lx z5ccn4{2G!+>F6nt_ZO=IH)Eo!|dYCz+99z%Z~-3^41&J*iCjcYgDM5rI5~)p##ABBpqL*4NrN$lfj?#76Z{62 AbpQYW literal 0 HcmV?d00001 diff --git a/peripherals/lcd_hd44780/.DS_Store b/peripherals/lcd_hd44780/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..57a07df309df4dea9fcaf70f98aa5b4e11f75183 GIT binary patch literal 6148 zcmeHK%}N6?5Kj7|TSV+ZsK;Eq_0S5ny$DOK2XDfP9#q<0w%CPrQ@UG=t}FW(`bNHi zuj5RTmX<1b644o$e3QvcLcU!x31f_Rr+$;MDr3w7MJ!aH`9yFWbxjJ!gUHn!2i`0m zd!h8!V#)D48NhE>W-$v`#1gjr{ocHB7{p1V@y-jyQh8(3LfN)%oROS4iJMI0t~JY%0r87^$sy9kD}es%X)Mu{6l!-+}`{2_!~Uj~scXI(js{8-K7=z$7KzgkPv zR=ZOdomN&CX{Xbui+1}k%PLlFzj<^zxO;d^pR(r{O)Q5$P|1$LIlO|gw8ML65`{9l z1@Am#9!W?H5Cg=(e__C!f7aH2*)Z*s7$63|%>bSc0u<3Um}^u=2Q+wn#PJd$3fTCT zKokaTgSkc+0pU6oP^WV9#Nav|{KCZ926K%%opH4?%wtyO=7qx5>fjeDoN-$twZs51 zu*yJDcdJp3C27Z)*5AP6AeE '0'); + power_state <= LCD_OFF; + startup_counter <= 0; + time_counter <= 0; + enable_counter <= 0; + lcd_data <= "00000000"; + lcd_e <= '0'; + lcd_rs <= '0'; + + elsif rising_edge(clk) then + if (d_we = '1') and (dcsel = MY_CHIPSELECT) then + startup_counter <= startup_counter + 1; + time_counter <= time_counter + 1; + enable_counter <= enable_counter + 1; - elsif rising_edge(clk) then - startup_counter <= startup_counter + 1; - time_counter <= time_counter + 1; - enable_counter <= enable_counter + 1; + case power_state is + when LCD_OFF => + lcd_is_busy <= '0'; + if (hd44780_register(LCD_INIT_BIT) = '1') then + power_state <= LCD_STARTUP; + end if; + when LCD_STARTUP => + lcd_is_busy <= '1'; + if (startup_counter >= t0_startup_time) then + startup_counter <= 0; + power_state <= LCD_ON; + end if; - case power_state is - when LCD_OFF => - lcd_is_busy <= '0'; - if (lcd_init = '1') then - power_state <= LCD_STARTUP; - end if; - when LCD_STARTUP => - lcd_is_busy <= '1'; - if (startup_counter >= t0_startup_time) then - startup_counter <= 0; - power_state <= LCD_ON; - end if; + when LCD_ON => + --! Busy flag control + if (command = LCD_CMD_IDLE) then + lcd_is_busy <= '0'; + else + lcd_is_busy <= '1'; + end if; + end case; + case command is + when LCD_CMD_IDLE => + --! Fetch bit instructions to internal "command" signal + if (hd44780_register(LCD_INIT_BIT) = '1') then + command <= LCD_CMD_INITIALIZE; + elsif (hd44780_register(LCD_WRITE_CHAR_BIT) = '1') then + command <= LCD_CMD_WRITE_CHAR; + elsif (hd44780_register(LCD_CLEAR_BIT) = '1') then + command <= LCD_CMD_CLEAR_RETURN_HOME; + elsif (hd44780_register(LCD_LINE1_BIT) = '1') then + command <= LCD_CMD_GOTO_LINE_1; + elsif (hd44780_register(LCD_LINE2_BIT) = '1') then + command <= LCD_CMD_GOTO_LINE_2; + else + command <= LCD_CMD_IDLE; + end if; + --! Initialization state machine + when LCD_CMD_INITIALIZE => + lcd_rs <= '0'; + case lcd_cmd_init_state is + when LCD_INIT_0 => + lcd_data <= "00110000"; --! Special function set 3x times + if (time_counter >= t2_long_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + lcd_cmd_init_state <= LCD_INIT_1; + end if; + when LCD_INIT_1 => + lcd_data <= "00110000"; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + lcd_cmd_init_state <= LCD_INIT_2; + end if; + when LCD_INIT_2 => + lcd_data <= "00110000"; --! Function sets if Nlines = 1 or 2 + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + lcd_cmd_init_state <= LCD_INIT_3; + end if; + when LCD_INIT_3 => + lcd_data <= "00001000"; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + lcd_cmd_init_state <= LCD_INIT_4; + end if; + when LCD_INIT_4 => + lcd_data <= "00000001"; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + lcd_cmd_init_state <= LCD_INIT_5; + end if; + when LCD_INIT_5 => + lcd_data <= "00000101"; + lcd_e <= '0'; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + lcd_cmd_init_state <= LCD_INIT_6; + end if; + when LCD_INIT_6 => + lcd_data <= "00001101"; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + lcd_cmd_init_state <= LCD_INIT_0; + command <= LCD_CMD_IDLE; + end if; + end case; + --! Write char + when LCD_CMD_WRITE_CHAR => + lcd_rs <= '1'; + lcd_data <= "01000001"; --! 'A' 01000001 // 00000000 + -- db7 db0 - when LCD_ON => - --! Busy flag control - if (command = LCD_CMD_IDLE) then - lcd_is_busy <= '0'; - else - lcd_is_busy <= '1'; - end if; - end case; - case command is - when LCD_CMD_IDLE => - --! Fetch bit instructions to internal "command" signal - if (lcd_init = '1') then - command <= LCD_CMD_INITIALIZE; - elsif (lcd_write_char = '1') then - command <= LCD_CMD_WRITE_CHAR; - elsif (lcd_clear = '1') then - command <= LCD_CMD_CLEAR_RETURN_HOME; - elsif (lcd_goto_l1 = '1') then - command <= LCD_CMD_GOTO_LINE_1; - elsif (lcd_goto_l2 = '1') then - command <= LCD_CMD_GOTO_LINE_2; - else - command <= LCD_CMD_IDLE; - end if; - --! Initialization state machine - when LCD_CMD_INITIALIZE => - lcd_rs <= '0'; - case lcd_cmd_init_state is - when LCD_INIT_0 => - lcd_data <= "00110000"; --! Special function set 3x times - if (time_counter >= t2_long_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - lcd_cmd_init_state <= LCD_INIT_1; - end if; - when LCD_INIT_1 => - lcd_data <= "00110000"; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - lcd_cmd_init_state <= LCD_INIT_2; - end if; - when LCD_INIT_2 => - lcd_data <= "00110000"; --! Function sets if Nlines = 1 or 2 - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - lcd_cmd_init_state <= LCD_INIT_3; - end if; - when LCD_INIT_3 => - lcd_data <= "00001000"; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - lcd_cmd_init_state <= LCD_INIT_4; - end if; - when LCD_INIT_4 => - lcd_data <= "00000001"; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - lcd_cmd_init_state <= LCD_INIT_5; - end if; - when LCD_INIT_5 => - lcd_data <= "00000101"; - lcd_e <= '0'; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - lcd_cmd_init_state <= LCD_INIT_6; - end if; - when LCD_INIT_6 => - lcd_data <= "00001101"; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - lcd_cmd_init_state <= LCD_INIT_0; - command <= LCD_CMD_IDLE; - end if; - end case; - --! Write char - when LCD_CMD_WRITE_CHAR => - lcd_rs <= '1'; - lcd_data <= "01000001"; --! 'A' - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - end if; - command <= LCD_CMD_IDLE; - --! Position cursor in 0x80 (L1) and clear DDRAM - when LCD_CMD_CLEAR_RETURN_HOME => - lcd_rs <= '0'; - lcd_data <= "00000001"; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - end if; - command <= LCD_CMD_IDLE; - --! Position cursor in 0x40 -> 0x80 (L1) - when LCD_CMD_GOTO_LINE_1 => - lcd_rs <= '0'; - lcd_data <= "10000000"; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - end if; - command <= LCD_CMD_IDLE; - --! Position cursor in 0x40 -> 0xC0 (L2) - when LCD_CMD_GOTO_LINE_2 => - lcd_rs <= '0'; - lcd_data <= "11000000"; - if (time_counter >= t1_short_wait) then - time_counter <= 0; - lcd_e <= '1'; - if (enable_counter >= t3_enable_pulse) then - enable_counter <= 0; - lcd_e <= '0'; - end if; - end if; - command <= LCD_CMD_IDLE; - end case; - end if; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + end if; + command <= LCD_CMD_IDLE; + --! Position cursor in 0x80 (L1) and clear DDRAM + when LCD_CMD_CLEAR_RETURN_HOME => + lcd_rs <= '0'; + lcd_data <= "00000001"; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + end if; + command <= LCD_CMD_IDLE; + --! Position cursor in 0x40 -> 0x80 (L1) + when LCD_CMD_GOTO_LINE_1 => + lcd_rs <= '0'; + lcd_data <= "10000000"; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + end if; + command <= LCD_CMD_IDLE; + --! Position cursor in 0x40 -> 0xC0 (L2) + when LCD_CMD_GOTO_LINE_2 => + lcd_rs <= '0'; + lcd_data <= "11000000"; + if (time_counter >= t1_short_wait) then + time_counter <= 0; + lcd_e <= '1'; + if (enable_counter >= t3_enable_pulse) then + enable_counter <= 0; + lcd_e <= '0'; + end if; + end if; + command <= LCD_CMD_IDLE; + end case; + end if; + end if; - end process; + end process; end controller; diff --git a/peripherals/lcd_hd44780/sint2/de10_lite/de0_lite.vhd b/peripherals/lcd_hd44780/sint2/de10_lite/de0_lite.vhd index da76f68b..2e0a195e 100644 --- a/peripherals/lcd_hd44780/sint2/de10_lite/de0_lite.vhd +++ b/peripherals/lcd_hd44780/sint2/de10_lite/de0_lite.vhd @@ -120,6 +120,7 @@ architecture rtl of de0_lite is signal ddata_r_i2c : std_logic_vector(31 downto 0); signal ddata_r_dig_fil : std_logic_vector(31 downto 0); signal ddata_r_stepmot : std_logic_vector(31 downto 0); + signal ddata_r_hd44780 : std_logic_vector(31 downto 0); signal data_in_dig_fil : std_logic_vector(15 downto 0); @@ -297,6 +298,43 @@ begin hex6 => open, hex7 => open ); + + lcd : entity work.lcd_hd44780 + port map( + clk => clk_1k, + rst => SW(9), + -- + daddress => daddress, + ddata_w => ddata_w, + ddata_r => ddata_r_segments, + d_we => d_we, + d_rd => d_rd, + dcsel => dcsel, + dmask => dmask, + -- + lcd_data(7) => ARDUINO_IO(0), + lcd_data(6) => ARDUINO_IO(1), + lcd_data(5) => ARDUINO_IO(2), + lcd_data(4) => ARDUINO_IO(3), + lcd_data(3) => ARDUINO_IO(4), + lcd_data(2) => ARDUINO_IO(5), + lcd_data(1) => ARDUINO_IO(6), + lcd_data(0) => ARDUINO_IO(7), + lcd_rs => ARDUINO_IO(9), + lcd_e => ARDUINO_IO(8), + lcd_is_busy => LEDR(8) + ); + + -- daddress : in unsigned(DADDRESS_BUS_SIZE - 1 downto 0); + -- ddata_w : in std_logic_vector(31 downto 0); + -- ddata_r : out std_logic_vector(31 downto 0); + -- d_we : in std_logic; + -- d_rd : in std_logic; + -- dcsel : in std_logic_vector(1 downto 0); --! Chip select + -- -- ToDo: Module should mask bytes (Word, half word and byte access) + -- dmask : in std_logic_vector(3 downto 0); --! Byte enable mask + + -- Connect input hardware to gpio data gpio_input(3 downto 0) <= SW(3 downto 0); diff --git a/peripherals/lcd_hd44780/sint2/de10_lite/de10_lite.qsf b/peripherals/lcd_hd44780/sint2/de10_lite/de10_lite.qsf index 3a818ad4..afb36950 100644 --- a/peripherals/lcd_hd44780/sint2/de10_lite/de10_lite.qsf +++ b/peripherals/lcd_hd44780/sint2/de10_lite/de10_lite.qsf @@ -216,7 +216,6 @@ set_global_assignment -name STRATIX_DEVICE_IO_STANDARD "2.5 V" set_global_assignment -name TIMING_ANALYZER_MULTICORNER_ANALYSIS ON set_global_assignment -name NUM_PARALLEL_PROCESSORS ALL -set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top set_global_assignment -name VHDL_FILE ../../lcd_hd44780.vhd set_global_assignment -name VHDL_FILE ../../../gpio/gpio.vhd set_global_assignment -name VHDL_FILE ../../../gpio/led_displays.vhd @@ -242,4 +241,5 @@ set_global_assignment -name VHDL_FILE ../../../../alu/alu_types.vhd set_global_assignment -name VHDL_FILE ../../../../alu/alu.vhd set_global_assignment -name VHDL_FILE de0_lite.vhd set_global_assignment -name QIP_FILE pll.qip -set_global_assignment -name SOURCE_FILE db/de10_lite.cmp.rdb \ No newline at end of file +set_global_assignment -name SOURCE_FILE db/de10_lite.cmp.rdb +set_instance_assignment -name PARTITION_HIERARCHY root_partition -to | -section_id Top \ No newline at end of file