romel_emperado
Advanced Member level 2
- Joined
- Jul 23, 2009
- Messages
- 606
- Helped
- 45
- Reputation
- 132
- Reaction score
- 65
- Trophy points
- 1,318
- Location
- philippines
- Activity points
- 6,061
Hi all I have two modules and I want to call module a to my module b but I dont know how to do that.. any hint it's my first day of verilog.
I know it's possible. just like in C/C++ we include other files and call functions inside that file.. e.g. #include "test.h"
I want to use this method in verilog also.. I search in google but I cant find the answer..
---------- Post added at 12:27 ---------- Previous post was at 12:25 ----------
by the way here are the modules I want to combine..
segmentrial.v
decoder.v
I know it's possible. just like in C/C++ we include other files and call functions inside that file.. e.g. #include "test.h"
I want to use this method in verilog also.. I search in google but I cant find the answer..
---------- Post added at 12:27 ---------- Previous post was at 12:25 ----------
by the way here are the modules I want to combine..
segmentrial.v
PHP:
module segmentTrial(clk,clk2,min1,seg,seg_sel);
input clk;
output [7:0]seg;
output [3:0]seg_sel;
output clk2;
output min1;
reg [7:0]seg;
reg [3:0]seg_sel;
reg clk2;
reg min1;
integer i;
//parameter out = 8'b00000010;//6
parameter out = 8'b100_1111_0;
initial seg_sel = 4'b0001;
always@(posedge clk)
begin
if(i==8000000) //divide by 80000 => 16MHz to 200Hz
begin
clk2=~clk2;
i=1;
end
else
begin
i=i+1'b1;
end
end
/*always@(posedge clk2)
begin
seg_sel={seg_sel[2:0],seg_sel[3]};
if(seg_sel==4'b1000) seg = out;
else if(seg_sel==4'b0100)seg = out;
else if(seg_sel==4'b0010)seg = out;
else if(seg_sel==4'b0001)seg = out;
end
*/
endmodule
decoder.v
PHP:
//this module allows numbes to be displayed in the 7 segment display.
//parameters declared like zero, one... are the numbers displayed in the 7segment.
module decoder(in,out);
parameter zero =8'b000_0001_1; // 3
parameter one =8'b100_1111_1; //159
parameter two =8'b001_0010_1; // 37
parameter three=8'b000_0110_1; // 13
parameter four =8'b100_1100_1; //153
parameter five =8'b010_0100_1; // 73
parameter six =8'b010_0000_1; // 65
parameter seven=8'b000_1111_1; // 31
parameter eight=8'b000_0000_1; // 1
parameter nine =8'b000_0100_1; // 9
parameter blank=8'b111_1111_1; //255
input [3:0]in;
output [7:0]out;
reg [7:0]out;
always@(in)begin
case(in)
0:out=zero;
1:out=one;
2:out=two;
3:out=three;
4:out=four;
5:out=five;
6:out=six;
7:out=seven;
8:out=eight;
9:out=nine;
default:out=blank;
endcase
end
endmodule