Useing Basic arrays

W

weizbox

Guest
Hello,

Im trying to set up a program to do basic storage of data on my fpga.
I want to be able to flip my switches in a certain way in order to see
the LEDs in the same way, but by getting the LED values from the
registers that i initialy set them to.
So far this is what I have and for some reason when I run PACE it only
gives me the LEDs to assign, but not the clock or the switches.

module main(clk, switch, led);

input clk;
input [7:0] switch;
output reg [7:0] led;

reg [7:0] array [7:0]; //--my array 8x8

initial //--Set defualt values in my array
begin
array[0] = 8'b00000001 ;
array[1] = 8'b00000011 ;
array[2] = 8'b00000111 ;
array[3] = 8'b00001111 ;
array[4] = 8'b00011111 ;
array[5] = 8'b00111111 ;
array[6] = 8'b01111111 ;
array[7] = 8'b11111111 ;
end

always @(posedge clk)
begin
case (switch) //--Reads Switch status and applys led value from array
8'b00000001 : led = array[0];
8'b00000011 : led = array[1];
8'b00000111 : led = array[2];
8'b00001111 : led = array[3];
8'b00011111 : led = array[4];
8'b00111111 : led = array[5];
8'b01111111 : led = array[6];
8'b11111111 : led = array[7];
default : led = 8'b00000000;
endcase
end

endmodule


Besides the array situation, why isnt this accepting the clk and
switch values as inputs in PACE when they are clearly used in the
program?

Thanks as always!
-Mark
 
The intial block you've specified for the array values isn't synthesizeable.
The synthesis sees the array values as all zeros and does appropriate
optimization. Consider using an always @(*) case(index) to define your
array[index] values, effectively building a ROM. Your simulation and
synthesis will then agree.


"weizbox" <mwiesbock@gmail.com> wrote in message
news:335c6753.0410130851.49e2dd1a@posting.google.com...
Hello,

Im trying to set up a program to do basic storage of data on my fpga.
I want to be able to flip my switches in a certain way in order to see
the LEDs in the same way, but by getting the LED values from the
registers that i initialy set them to.
So far this is what I have and for some reason when I run PACE it only
gives me the LEDs to assign, but not the clock or the switches.

module main(clk, switch, led);

input clk;
input [7:0] switch;
output reg [7:0] led;

reg [7:0] array [7:0]; //--my array 8x8

initial //--Set defualt values in my array
begin
array[0] = 8'b00000001 ;
array[1] = 8'b00000011 ;
array[2] = 8'b00000111 ;
array[3] = 8'b00001111 ;
array[4] = 8'b00011111 ;
array[5] = 8'b00111111 ;
array[6] = 8'b01111111 ;
array[7] = 8'b11111111 ;
end

always @(posedge clk)
begin
case (switch) //--Reads Switch status and applys led value from array
8'b00000001 : led = array[0];
8'b00000011 : led = array[1];
8'b00000111 : led = array[2];
8'b00001111 : led = array[3];
8'b00011111 : led = array[4];
8'b00111111 : led = array[5];
8'b01111111 : led = array[6];
8'b11111111 : led = array[7];
default : led = 8'b00000000;
endcase
end

endmodule


Besides the array situation, why isnt this accepting the clk and
switch values as inputs in PACE when they are clearly used in the
program?

Thanks as always!
-Mark
 

Welcome to EDABoard.com

Sponsor

Back
Top