Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Verilog : how to use module as global module

Status
Not open for further replies.

ghazalaz

Newbie level 2
Newbie level 2
Joined
May 1, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,297
Verilog : how can i use a module as global module?

hi,
i wanna use some 2d array of registers as global in some module and change them sometime , i define them in module named memory like this:
PHP:
module memory();
  reg [31:0]Inst_Mem[31:0];
  reg [31:0]Data_Mem[31:0];
  reg [31:0]RF[31:0];
  reg [5:0]PC;
end module

now i want to use these memories in another module (named run) and make changes to them,

PHP:
module run( input [31:0]Ins );
  reg clk;
   ...
  initial begin
   clk = 0;
    ...
  end
  initial repeat(100)#5 clk = ~clk;
  always @(posedge clk)
  begin
    memory.PC[5:0] = memory.PC + 6'b000001 ;
    ...
  end
  
endmodule

i even can't pass them as inout parameter because they're 2d reg array

so what can i do? :-/

how can i initialize and make change to them in any module?
i will be so thankful if anybody can help (please:D) :)
 
Last edited:

Re: Verilog : how can i use a module as global module?

i wanna use some 2d array of registers as global in some module and change them sometime , i define them in module named memory like this:

Code Verilog - [expand]
1
2
3
4
5
6
module memory();
  reg [31:0]Inst_Mem[31:0];
  reg [31:0]Data_Mem[31:0];
  reg [31:0]RF[31:0];
  reg [5:0]PC;
end module


Well, your "memory" module has no input or output ports. In HDL country that is the equivalent of a black box ... which you then throw in a black hole, never to be seen again. Nothing goes in, nothing comes out.

For a two in one educational moment, see for example this: https://www.asic-world.com/verilog/para_modules1.html

One, you get to see how to do inputs/outputs for your modules. Two, you get parameterization thrown in for free. Woohoo!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top