Forum Discussion
Altera_Forum
Honored Contributor
14 years agoI did verilog ages ago, I used the following template, I hope it will help but may need considerable updating:
// A sample Verilog program structure
‘include “file1.v” // lower module macro
‘define “my_line” 16’hBB7F // line macro
//design IF
module my_design (a,b,c,d)
input a,b; //direction,width,name
input c;
output d;
//internal design declarations
//
reg d; //output registered
wire w1,w2 //for instantiation or node wiring
integer I; //general use e.g. loop index
parameter k = 4’b1 //literal
‘include “file2.v” //macro replacement
function f1;
input a;
parameter k = 8’10001110”;
integer n;
begin
Sequential statements...
end
endfunction
task t1;
input a;
output b;
parameter k = ‘8b11110000”;
begin
Sequential statements...
end
endtask
//start of design
//instantiations
Lower_mod1# (5,8) mod_1(w1,w2); //positional association
Lower_mod2 mod2 (
.a (w1),
.b ()
); //named association
//wiring
assign w3 = ~(a & b); //continuous assignment
//intial values
initial begin
...
end
//seq like process of vhdl
always @ (a or b) begin
...
end
endmodule