Hey badOmen my code doenst work at all. i got following problems.
1. when i read data the user_data_available signal toogle to high. thats right but when i read my 8 byte of data it dont go low. And when i try a second read control_done_read never goes high again.
2. when i now write data to my write master fifo and i toogle control_go the control_done signal sometimes dont goes from low to high again but the system write data in my ddr3 that i can read. but the data is not always the same sometimes it is the wanted data somtimes it is a zero or sometimes it is the first 4 byte i read from the memory.
it seems that my my code doesnt read correct 8 byte (sometimes seems to be more sometimes less) Overall i think the error must be in reading/writing to fifo.
do u have any help for me i dont know where to search.
wire data ; // 4 Byte Data
wire control_fixed_location;
wire control_write_base;
wire control_write_length;
wire control_read_base;
wire control_read_length;
wire control_go_write;
wire control_go_read;
wire data_to_buffer; // write data to fifo
wire control_done_write;
wire control_done_read;
wire read_buffer_done; // read value from fifo -> next value
wire read_data_available; // data in fifo
wire button_pio_deb; // debouced buttons
assign control_fixed_location = 1'b0;
assign control_write_base = 32'h08FFFFAC;
assign control_write_length = 32'h00000004;
assign control_read_base = 32'h08FFFFB8;
assign control_read_length = 32'h00000008;
reg control_go_reg =1'b0; //write command
reg control_go_reg_read =1'b0; // read command
reg data_to_buffer_reg=1'b0; // write data to fifo
reg read_buffer_done_reg = 1'b0; // read value from fifo -> next value
reg led_pio_reg_1=1'b1; // ledflag
reg led_pio_reg_2=1'b1; // ledflag
reg button_old_1=1'b1;
reg button_new_1=1'b1;
reg button_old_2=1'b1;
reg button_new_2=1'b1;
reg read_or_write=1'b0; // toogle between read and write with buttons (read init)
reg data_read_reg = 32'h00000000; // Read data to Write data
reg data_read_reg_2 = 32'h00000000; // Read data to Write data
reg flag =1'b0;
reg flag2 =1'b0;
Debounce Debounce_1(
.clk(clkin_100),
.keyin(button_pio),
.keyout(button_pio_deb)
);
Debounce Debounce_2(
.clk(clkin_100),
.keyin(button_pio),
.keyout(button_pio_deb)
);
always @(posedge clkin_100)
begin
button_old_1 <= button_new_1;
button_new_1 <= button_pio_deb;
button_old_2 <= button_new_2;
button_new_2 <= button_pio_deb;
if(read_or_write==1'b0) begin
if ( button_new_1==1'b0 && button_old_1==1'b1) begin
control_go_reg_read <= 1'b1 ;
control_go_reg<= 1'b0;
data_to_buffer_reg <= 1'b0;
end
else begin
control_go_reg_read<= 1'b0;
end
if ( button_new_2==1'b0 && button_old_2==1'b1 && read_data_available==1'b1) begin
if((flag==1'b0) & (flag2==1'b0)) begin
data_read_reg <= data;
read_buffer_done_reg <= 1'b1 ;
flag<=1'b1;
led_pio_reg_1<= 1'b1;
end
else if ((flag==1'b1) & (flag2==1'b0)) begin
data_read_reg_2 <= data;
read_buffer_done_reg <= 1'b1 ;
led_pio_reg_1<= 1'b0;
read_or_write<=1'b1;
flag2<=1'b1;
end
end
else begin
read_buffer_done_reg <= 1'b0;
end
end // if read_or_write
if(read_or_write==1'b1) begin
if ( button_new_1==1'b0 && button_old_1==1'b1) begin
control_go_reg <= 1'b1 ;
read_or_write<=1'b0;
flag<=1'b0;
flag2<=1'b0;
end
else begin
control_go_reg<= 1'b0;
read_buffer_done_reg <= 1'b0;
control_go_reg_read<= 1'b0;
end
if ( button_new_2==1'b0 && button_old_2==1'b1) begin
data_to_buffer_reg <= 1'b1 ;
end
else begin
data_to_buffer_reg <= 1'b0;
end
end // if read_or_write
end
assign data_to_buffer = data_to_buffer_reg;
assign control_go_write = control_go_reg;
assign control_go_read=control_go_reg_read;
assign read_buffer_done=read_buffer_done_reg;
assign data = data_read_reg_2;
assign led_pio = control_done_read;
assign led_pio = read_data_available;
assign led_pio = read_or_write;
assign led_pio = control_done_write;
the simulation of my code brings the right behaviour every signal i set is 1 cycle high. is this right? I think maybe the fifos are running out of memery but i dont know why this can happen. Do you think that its possible that i get the trouble cause i use that buttons?
Thanks for ur help