Reputation: 535
I am storing a sequence of values in a memory array. When it comes time to output this sequence to an LED display, I am running into an error with multiple drivers.
Here are code snippets that I'm working with:
reg [3:0] p[0:63]; // pattern sequence
....
led = p[playcnt]; // display current pattern; playcnt loops from 0 to 63
It seems like Verilog is trying to connect each register in the memory array to the led output, which results in a "multiple driver" error. Is there any easy way to connect only a single output from the memory array to the led output, and use the playcnt variable as an address into the memory array?
Thanks for your help! It's much appreciated.
Upvotes: 1
Views: 657
Reputation: 16228
Please provide all the code which is relevant to "led" and show what do you mean by "playcnt loops from 0 to 63".
If you have code similar to this:
always_comb
for (int playcnt=0; playcnt<64; playcnt++)
led = p[playcnt];
then you indeed connected all your registers to a single port.
If I understood your intent correctly, then you should have code similar to this (not tested):
reg [3:0] p [0:63];
reg [5:0] playcnt;
wire [3:0] led;
always @ (posedge clk or negedge rst)
if (!rst)
playcnt[5:0] <= 6'h0;
else
playcnt[5:0] <= playcnt[5:0] + 6'h1;
assign led[3:0] = p[playcnt];
Upvotes: 1