Hi fightingdreamer,
I did what you told like creating a register to store the interrupt and associated avalon mm slave to the register but still having the problem
Here is the C-code:
//Write 1 to address 0 to start counter
//Write 2 to address 0 to stop counter
//Write 0 to address 0 to reset counter
//Read address 1 to get count value
module counter (
//Avalon MM
clk, reset, address, chipselect, read, readdata, write, writedata,
//Interrupt_handler
irq,readdata_irq,writedata_irq,write_irq);
input clk, reset, chipselect, read, write ;
input write_irq ;
input address;
input writedata;
output readdata;
output irq;
input writedata_irq;
output readdata_irq;
reg readdata;
reg count;
reg control;
reg readdata_irq;
reg irq;
//wire irq;
always @ (posedge clk)
begin
if (control==2'b01) count <= count + 1;
else if (control==2'b00) count <= 0;
else count <= count;
end
//assign irq=(count==32'd1000000000)?1:0;
always @ (posedge clk)
begin
if (count>=32'd1000000000) irq<=1;
else irq<=0;
end
always @( posedge clk)
begin
if (irq) begin readdata_irq<=1; end
else if (write_irq && writedata_irq) begin readdata_irq<=0; end
else readdata_irq<=0;
end
always @ (posedge clk)
begin
if (chipselect && write && (address==0)) control <= writedata;
else if (chipselect && read && (address==1)) readdata <= count;
else if (!chipselect) readdata <= 32'hZ;
end
endmodule
I still having problem with the error showing Associated Addresablepoint out of range.