I've been following the guides in this repo because I was assigned a project consisting in programming a DE10-Nano as a photon counter. The way it should work would be, connecting a photon detector to the board and then having it count the TTL pulses fired by the detector. I tried several things before finding this repo, but I think I'm closer by using a SoC project approach. So far, the guides have been really helpful. I completed the simple_adder project without much trouble, and since it has some things I would need for my project, I'm using it as a base project. For now, I'm interested in doing just a simple_counter project, that counts intervals of time. It has two parameters, a total_time_interval, and a time_interval. I want to return the counting when the time_interval is completed. I used this System Verilog code:
module simple_counter(
input logic clk,
input logic reset,
input logic [63:0] time_interval,
input logic [63:0] total_time_interval,
output logic [63:0] count
);
logic [31:0] timer;
logic interval_done;
always_ff @(posedge clk or posedge reset) begin
if (reset) begin
timer <= 32'h0;
count <= 32'h0;
interval_done <= 1'b0;
end else begin
if (timer == time_interval) begin
timer <= 32'h0;
interval_done <= 1'b1;
if (count < total_time_interval) begin
count <= count + 1'b1;
end
end else begin
timer <= timer + 1'b1;
interval_done <= 1'b0;
end
end
end
endmodule
I changed the names of the pio IPs in the Platform Designer, and I instantiated the module in the Top Level Entity. I compiled the project succesfully, and I tried modifying the C code provided in the guide:
Hello,
I've been following the guides in this repo because I was assigned a project consisting in programming a DE10-Nano as a photon counter. The way it should work would be, connecting a photon detector to the board and then having it count the TTL pulses fired by the detector. I tried several things before finding this repo, but I think I'm closer by using a SoC project approach. So far, the guides have been really helpful. I completed the simple_adder project without much trouble, and since it has some things I would need for my project, I'm using it as a base project. For now, I'm interested in doing just a simple_counter project, that counts intervals of time. It has two parameters, a total_time_interval, and a time_interval. I want to return the counting when the time_interval is completed. I used this System Verilog code:
I changed the names of the pio IPs in the Platform Designer, and I instantiated the module in the Top Level Entity. I compiled the project succesfully, and I tried modifying the C code provided in the guide:
As you can see, all I'm doing is repeteadly obtain the interval_counting value, but when I compile it, all I get is 0s.
I don't have experience with this. What could be going on? How would be the correct way to have a counter project.