J
JeffC
Guest
I have created some Verilog code which appears to work in the hardware.
The idea is to generate two custom waveforms which repeat/are periodic.
The code is below.
The problem is, I wish to insert a one off waveform sequence at startup
immediately before the periodic sequence begins. That is to say, I want
to produce a digital waveform which occurs only once at startup after
which the continuous periodic waveform begins to run. I was thinking of
using a loop in the initial block (see 2nd chunk of code), but from what
I can tell, the initial block executes in parallel with the always block
or so I have read in which case this will not work. Perhaps I am asking
how to control the execution order?
[screen grab http://img155.imageshack.us/img155/9850/verilograbqn7.jpg]
module waveforms(clock, linesout);
input clock;
output [1:0] linesout; //FPGA lines out
reg [1:0] lines;
reg [4:0] clkdiv; //Clock divider
reg [31:0] wf; //Waveform 1
reg [31:0] wfb; //Waveform 2
reg [31:0] index; //Index to waveform vectors
assign linesout = lines;
initial begin
wf = 32'b00001111111111111111111111111111; //Initialize
waveform vectors
wfb = 32'b00001110000011111111111111111111;
end
always @(posedge clock)
begin
clkdiv <= clkdiv - 1;
if (clkdiv == 0) begin
index <= index + 1;
lines[0] <= wf[index]; //Assign indexed waveform
element to lines
lines[1] <= wfb[index];
end
end
endmodule
Using the initial block to create a one off digital sequence at startup-
will not work correctly?
initial begin
wf = 32'b00001111111111111111111111111111;
wfb = 32'b00001110000011111111111111111111;
wfini = 32'b11111111111001111001111100011111;
wfbini = 32'b11111111111001111000000000011111;
for (i = 0; i < 32; i = i +1) begin
lines[0] <= wfini;
lines[1] <= wfbini;
end
end
The idea is to generate two custom waveforms which repeat/are periodic.
The code is below.
The problem is, I wish to insert a one off waveform sequence at startup
immediately before the periodic sequence begins. That is to say, I want
to produce a digital waveform which occurs only once at startup after
which the continuous periodic waveform begins to run. I was thinking of
using a loop in the initial block (see 2nd chunk of code), but from what
I can tell, the initial block executes in parallel with the always block
or so I have read in which case this will not work. Perhaps I am asking
how to control the execution order?
[screen grab http://img155.imageshack.us/img155/9850/verilograbqn7.jpg]
module waveforms(clock, linesout);
input clock;
output [1:0] linesout; //FPGA lines out
reg [1:0] lines;
reg [4:0] clkdiv; //Clock divider
reg [31:0] wf; //Waveform 1
reg [31:0] wfb; //Waveform 2
reg [31:0] index; //Index to waveform vectors
assign linesout = lines;
initial begin
wf = 32'b00001111111111111111111111111111; //Initialize
waveform vectors
wfb = 32'b00001110000011111111111111111111;
end
always @(posedge clock)
begin
clkdiv <= clkdiv - 1;
if (clkdiv == 0) begin
index <= index + 1;
lines[0] <= wf[index]; //Assign indexed waveform
element to lines
lines[1] <= wfb[index];
end
end
endmodule
Using the initial block to create a one off digital sequence at startup-
will not work correctly?
initial begin
wf = 32'b00001111111111111111111111111111;
wfb = 32'b00001110000011111111111111111111;
wfini = 32'b11111111111001111001111100011111;
wfbini = 32'b11111111111001111000000000011111;
for (i = 0; i < 32; i = i +1) begin
lines[0] <= wfini;
lines[1] <= wfbini;
end
end