Altera_Forum
Honored Contributor
12 years agoVerilog modules
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.