Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Verilog modules

Altera_Forum
Honored Contributor II
1,475 Views

Hi all, 

 

I have recently purchased a DE1 which I have been playing round with and attempting to learn Verilog. I have a question in regards to modules. Currently I am using the DE1 to emulate a gameboy cartridge using the code below (not working): 

 

module gameboycartridge (RD, WR, CS, ADDR, DATA); //Inputs input RD; input WR; input CS; input ADDR; //Outputs output DATA; flash_rom rom (RD, ADDR, ADDR, DATA); endmodule module flash_rom (OE, CE, RM_ADDR, RM_DATA, FL_ADDR, FL_DQ, FL_OE_N, FL_WE_N, FL_RST_N); //Inputs input OE; input CE; input RM_ADDR; //Outputs output RM_DATA; //Flash output FL_ADDR; input FL_DQ; output FL_OE_N; output FL_WE_N; output FL_RST_N; assign FL_OE_N = RD || ADDR; assign FL_WE_N = 1; assign FL_RST_N = 1; assign FL_ADDR = RM_DATA; assign RM_DATA = FL_DQ; endmodule  

 

It's a very basic example, just routing address lines to the onboard flash. I know why it doesn't work, (leaving ports unconnected when instantiating the flash_rom module). I had hoped that it might work that way such that I could say create another module that accessed the sram instead and abstract away from those details in the higher level module, just passing address, data and control signals to the module. 

 

So my question is: Is there some way I can have a module that accesses ports not passed to it by a higher level module or is there some other way I can achieve it? 

 

Any help appreciated.
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
589 Views

No. Most synthesis tools require that all signals data pass through a module port. Hierarchical references that avoid ports are not allowed in RTL coding styles.  

 

SystemVerilog has an interface construct that allows you to bundle up common signals in a single port declaration. This avoids repeated declaration and connection of signals. 

 

SystemVerilog also has a .* (dot-star) construct that automatically connect signals with ports having the same name. 

Suppose your flash_rom declaration looked like this: 

module flash_rom ( //Inputs input OE, input CE, input ADDR, //Outputs output DATA, //Flash output FL_ADDR, input FL_DQ, output FL_OE_N, output FL_WE_N, output FL_RST_N ); assign FL_OE_N = RD || CS; assign FL_WE_N = 1; assign FL_RST_N = 1; assign FL_ADDR = RM_DATA; assign RM_DATA = FL_DQ; endmodule Then your higher level module would look like this: 

module gameboycartridge ( //Inputs input RD, input WR, input CS, input ADDR, //Outputs output DATA //Flash output FL_ADDR, input FL_DQ, output FL_OE_N, output FL_WE_N, output FL_RST_N ); flash_rom rom (.OE(RD), .CS(ADDR), .*); endmodule
0 Kudos
Altera_Forum
Honored Contributor II
589 Views

Thanks for taking the time to explain dave_59!

0 Kudos
Reply