【正文】
1 when clr_display, 10000000 when set_addr, 0011amp。counter_play1h when max_degree_1, 0011amp。counter_play1l when max_degree_2, 00100000 when blank1, 0011amp。counter_play2h when temperature_1, 0011amp。counter_play2l when temperature_2, 00100000 when blank2, 00100000 when degree_1, 00100000 when degree_2, 00100000 when blank3, 00100000 when others。 main state machine display: process(clk, rst_n) begin if(rst_n=39。039。) then cur_state = function_set。 elsif(clk=39。139。 and clk39。event) then case cur_state is refer to intialize state machine below when init = if(init_done = 39。139。) then cur_state = function_set。 else cur_state = init。 end if。 every other state but pause uses the transmit state machine 17 when function_set = if(i2 = 2021) then cur_state = entry_set。 else cur_state = function_set。 end if。 when entry_set = if(i2 = 2021) then cur_state = set_display。 else cur_state = entry_set。 end if。 when set_display = if(i2 = 2021) then cur_state = clr_display。 else cur_state = set_display。 end if。 when clr_display = i3 = 0。 if(i2 = 2021) then cur_state = pause。 else cur_state = clr_display。 end if。 when pause = if(i3 = 82021) then cur_state = set_addr。 i3 = 0。 else cur_state = pause。 i3 = i3 + 1。 end if。 when set_addr = if(i2 = 2021) then cur_state = max_degree_1。 else cur_state = set_addr。 end if。 when max_degree_1 = if(i2 = 2021) then cur_state = max_degree_2。 else 18 cur_state = max_degree_1。 end if。 when max_degree_2 = if(i2 = 2021) then cur_state = blank1。 else cur_state = max_degree_2。 end if。 when blank1 = if(i2 = 2021) then cur_state = temperature_1。 else cur_state = blank1。 end if。 when temperature_1 = if(i2 = 2021) then cur_state = temperature_2。 else cur_state = temperature_1。 end if。 when temperature_2 = if(i2 = 2021) then cur_state = blank2。 else cur_state = temperature_2。 end if。 when blank2 = if(i2 = 2021) then cur_state = degree_1。 else cur_state = blank2。 end if。 when degree_1 = if(i2 = 2021) then cur_state = degree_2。 else cur_state = degree_1。 end if。 when degree_2 = if(i2 = 2021) then cur_state = blank3。 else cur_state = degree_2。 end if。 19 when blank3 = if(i2 = 2021) then cur_state =set_addr 。 else cur_state = blank3。 end if。 end case。 end if。 end process display。 with mux select SF_D = SF_D0 when 39。039。, transmit SF_D1 when others。 initialize with mux select LCD_E = LCD_E0 when 39。039。, transmit LCD_E1 when others。 initialize specified by datasheet transmit : process(clk, rst_n, tx_init) begin if(rst_n=39。039。) then tx_state = done。 elsif(clk=39。139。 and clk39。event) then case tx_state is when high_setup = 40ns LCD_E0 = 39。039。 SF_D0 = tx_byte(7 downto 4)。 if(i2 = 2) then tx_state = high_hold。 i2 = 0。 else tx_state = high_setup。 i2 = i2 + 1。 end if。 when high_hold = 230ns LCD_E0 = 39。139。 SF_D0 = tx_byte(7 downto 4)。 if(i2 = 12) then tx_state = oneus。 i2 = 0。 else tx_state = high_hold。 i2 = i2 + 1。 end if。 when oneus = LCD_E0 = 39。039。 20 if(i2 = 50) then tx_state = low_setup。 i2 = 0。 else tx_state = oneus。 i2 = i2 + 1。 end if。 when low_setup = LCD_E0 = 39。039。 SF_D0 = tx_byte(3 downto 0)。 if(i2 = 2) then tx_state = low_hold。 i2 = 0。 else tx_state = low_setup。 i2 = i2 + 1。 end if。 when low_hold = LCD_E0 = 39。139。 SF_D0 = tx_byte(3 downto 0)。 if(i2 = 12) then tx_state = fortyus。 i2 = 0。 else tx_state = low_hold。 i2 = i2 + 1。 end if。 when fortyus = LCD_E0 = 39。039。 if(i2 = 2021) then tx_state = done。 i2 = 0。 else tx_state = fortyus。 i2 = i2 + 1。 end if。 when done = LCD_E0 = 39。039。 if(tx_init = 39。139。) then tx_state = high_setup。 i2 = 0。 else tx_state = done。 i2 = 0。 21 end if。 end case。 end if。 end process transmit。 specified by datasheet power_on_initialize: process(clk, rst_n, init_init) power on initialization sequence begin if(rst_n=39。039。) then init_state = idle。 init_done = 39。039。 elsif(clk=39。139。 and clk39。event) then case init_state is when idle = init_done = 39。039。 if(init_init = 39。139。) then init_state = fifteenms。 i = 0。 else init_state = idle。 i = i + 1。 end if。 when fifteenms = init_done = 39。039。 if(i = 750000) then init_state = one。 i = 0。 else init_state = fifteenms。 i = i + 1。 end if。 when one = SF_D1 = 0011。 LCD_E1 = 39。139。 init_done = 39。039。 if(i = 11) then init_state=two。 i = 0。 else init_state=one。 i = i + 1。 end if。 when two = LCD_E1 = 39。039。 init_done = 3