0

I'm new to VHDL programming and stuck with the below operation:

           case fpga_dsi_csi_sel is
         when "10000100" => --csi0 enabled
            csi_mux_oe_n <= '0';
            dsi_mux_sel <= '1';
            csi_mux_csi0_csi2_sel <= '0';
            if (csi_mux_oe_n = '0') and (dsi_mux_sel = '1') and (csi_mux_csi0_csi2_sel = '0') then
                                    fpga_gpio_45 <= '0';
                                    fpga_gpio_45 <= '1';
                                    else fpga_gpio_45 <= '0';
            end if;    
         when "10000010" => --csi1 enabled
            csi_mux_oe_n <= '0';
            dsi_mux_sel <= '0';
            csi_mux_csi1_csi3_sel <= '1';
            if (csi_mux_oe_n = '0') and (dsi_mux_sel = '0') and (csi_mux_csi0_csi2_sel = '1') then
                        fpga_gpio_46 <= '0';
                        fpga_gpio_46 <= '1';
                        else fpga_gpio_46 <= '0';
            end if;

When csi0 is enabled ie. first case, first three operations are done sequentially. I want to keep a flag to make sure that the first 3 operations are executed so I have made a condition using If statement. If the first three statements are executed properly, fpga_gpio_45 should go high ie. 1 otherwise it should be 0.

When I execute the code, I can verify that first three statements are executed properly (because data flow is happening) but fpga_gpio_45 is not going high.

Can anyone pls help me here and let me know what is incorrect?

fpga_gpio_45 is defined as INOUT.

  • You have a misconception about how VHDL works. These statements are not executed sequentially, they are executed *simultaneously*. The conditions in the `if` refer to the values of the signals *at the beginning* of the process and do not yet reflect the assignments in the lines above. – mkrieger1 Jun 04 '20 at 09:22
  • 1
    Similarly, even if the `if` conditions were true, the first assignment in `fpga_gpio_45 <= '0'; fpga_gpio_45 <= '1';` is useless, writing this has the same effect as just `fpga_gpio_45 <= '1';`. – mkrieger1 Jun 04 '20 at 09:29
  • Thank you very much for your response @mkrieger1. I assume I'll have to create a process with the first 3 variables. Inside the process, I can make sequential statements. Also 'fpga_gpio_45 <= '0';' was kept to make sure that initial value of 'fpga_gpio_45' is always 0. Does it make sense to you? – Rahul Soni Jun 04 '20 at 11:00

0 Answers0