K
Konx
Guest
Hi everyone.
I'm here again with another small problem ^_^
I want to design a module that performs a simple operation: store
synchronous serial data inside an array. This is my idea of the
design:
module gossipo_out(clk_40, data_array, token, data_ready_flag,
pixel_out);
input clk_40;
input pixel_out; //Serial data
input token;
output [47:0] data_array;
output data_ready_flag;
//Wire declaration
wire clk_40;
wire pixel_out;
wire token;
//Registered output
reg [47:0] data_array;
reg data_ready_flag;
//counter
reg [5:0] clk_counter;
//Cycle to fill the array.
always @ (posedge clk_40)
if(token)
begin
data_array[clk_counter] <= pixel_out;
clk_counter <= clk_counter + 6'd1;
end
always@(negedge token)
begin
data_ready_flag <= 1'b1; //This data is set to zero externally after
the read-out of the data_array
clk_counter <= 6'b000000;
end
endmodule
This solution is not working, because the clk_counter cannot be used
inside the data_array[clk_counter] (at least, the compiler gives me
problem with this signal so I suppose the problem is there. This is
the error for reference:
Multi-source in Unit <gossipo_out> on signal
<Mcount_clk_counter_cy<0>>; this signal is connected to multiple
drivers)
The "computer-programming oriented" solution would be to use a simple
integer variable to count, something like:
integer i;
always @ (posedge clk_40)
if(token)
begin
clk_counter <= clk_counter + 6'd1;
i = i+1;
end
always@(negedge token)
begin
data_ready_flag <= 1'b1;
i = 0;
end
This solution is actually "working" (to me, "working" means that the
synthesizer doesn't show any error).
Any hint about the correct solution (and most important: why is the
correct solution?).
Sorry for these basic questions (I need to take a verilog course, I
know ).
Thanks in advance for any help
Francesco.
I'm here again with another small problem ^_^
I want to design a module that performs a simple operation: store
synchronous serial data inside an array. This is my idea of the
design:
module gossipo_out(clk_40, data_array, token, data_ready_flag,
pixel_out);
input clk_40;
input pixel_out; //Serial data
input token;
output [47:0] data_array;
output data_ready_flag;
//Wire declaration
wire clk_40;
wire pixel_out;
wire token;
//Registered output
reg [47:0] data_array;
reg data_ready_flag;
//counter
reg [5:0] clk_counter;
//Cycle to fill the array.
always @ (posedge clk_40)
if(token)
begin
data_array[clk_counter] <= pixel_out;
clk_counter <= clk_counter + 6'd1;
end
always@(negedge token)
begin
data_ready_flag <= 1'b1; //This data is set to zero externally after
the read-out of the data_array
clk_counter <= 6'b000000;
end
endmodule
This solution is not working, because the clk_counter cannot be used
inside the data_array[clk_counter] (at least, the compiler gives me
problem with this signal so I suppose the problem is there. This is
the error for reference:
Multi-source in Unit <gossipo_out> on signal
<Mcount_clk_counter_cy<0>>; this signal is connected to multiple
drivers)
The "computer-programming oriented" solution would be to use a simple
integer variable to count, something like:
integer i;
always @ (posedge clk_40)
if(token)
begin
clk_counter <= clk_counter + 6'd1;
i = i+1;
end
always@(negedge token)
begin
data_ready_flag <= 1'b1;
i = 0;
end
This solution is actually "working" (to me, "working" means that the
synthesizer doesn't show any error).
Any hint about the correct solution (and most important: why is the
correct solution?).
Sorry for these basic questions (I need to take a verilog course, I
know ).
Thanks in advance for any help
Francesco.