Hi everyone. I am also designing an counter with interrupt. This is my 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 (clk, reset, address, chipselect, read, readdata, write, writedata,irq);
input clk, reset, chipselect, read, write;
input address;
input writedata;
output readdata;
output irq;
reg readdata;
reg count;
reg control;
reg irq;
//wire done;
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'd10)?1:0;
always @ (posedge clk)
begin
if (count>=32'd1000000000) irq<=1;
else 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
And this code functions perfectly as wanted. But when want to add custom hardware in SOPC having trouble to select the interface and signal type. It shows an error Associated Addresablepoint out of range. :cry:
Is it correct how i design the counter with interrupt? and how to add to SOPC builder? Any suggestions please.
Thank you.