Forum Discussion
Altera_Forum
Honored Contributor
17 years agoif condition for modules? (verilog question)
Hello there!
I don't know if this is a simple question or not. Basically I want to switch view of my lcd panel input from software and hardware (camera input) by using a switch. The thing is, i want to switch the use of modules with an if statement, but it doesn't seem to work like that: always @ (posedge iCLK_50) begin if(iSW[1]) begin touch_panel tp1 ( //<---module declaration .iCLK(ltm_nclk), .iRST_n(DLY_RST_2), // sdram side .iREAD_DATA1(Read_DATA1), .iREAD_DATA2(Read_DATA2), .oREAD_SDRAM_EN(Read), // lcd side .oLCD_R(ltm_r), .oLCD_G(ltm_g), .oLCD_B(ltm_b), .oHD(ltm_hd), .oVD(ltm_vd), .oDEN(ltm_den) ); end else begin //different module for touch panel end end so this definitely doesn't work. Any tips on how to implement this? Thanks in advance!!!!2 Replies
- Altera_Forum
Honored Contributor
Thanks I will try that out :)
- Altera_Forum
Honored Contributor
Hi ayhoung,
verilog does not allow to instanciate a module (here touch_panel) based on the value of a signal (here iSW[1]). --- Quote Start --- always @ (posedge iCLK_50) begin if(iSW[1]) begin touch_panel tp1 ( //<---module declaration .iCLK(ltm_nclk), --- Quote End --- In real hardware it would mean that depending a logic input signal on a printed circuit board you would magically add (or remove) an integrated circuit component. You can however use a multiplexer to select these signals that you want to enter to another module. e.g.
When working with video signals you should of course be careful that the signals you are connecting are compatible in format and timing. Otherwise this will not work. Hope this helps...if (iSW) begin lcd_R = camera1_buffer_R; lcd_G = camera1_buffer_G; lcd_B = camera1_buffer_B; end else begin lcd_R = camera2_buffer_R; lcd_G = camera2_buffer_G; lcd_B = camera2_buffer_B; end