Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `timescale 1ns / 1ps
- module count_free_tb;
- reg clock, reset, start_req, start_data, ready;
- wire res_resp, busy;
- reg [31:0] time_to_start;
- count_free cfree(
- .clk(clock),
- .rst(reset),
- .start_req_i(start_req),
- .start_data_i(start_data),
- .ready_i(ready),
- .result_rsp_o(res_resp),
- .busy_o(busy)
- );
- integer i;
- initial begin
- i = 0;
- start_req = 0;
- start_data = 0;
- ready = 0;
- clock = 0;
- reset = 1;
- #5 clock = ~clock;
- #5 reset = 0;
- #5 clock = ~clock;
- #5
- while (!res_resp) begin
- i = i + 1;
- if (i == 15) begin
- time_to_start = i;
- start_req = 1;
- end
- if (start_req && i != 15) begin
- if (time_to_start != 0) begin
- start_data <= time_to_start[0];
- time_to_start <= time_to_start >> 1;
- end else begin
- start_req = 0;
- start_data = 0;
- end
- end
- if (cfree.count_of_ticks == 15) begin
- ready = 1;
- end else begin
- ready = 0;
- end
- $display("Current state: %d", cfree.state);
- $display("Cur data to send: %b", time_to_start);
- $display("Read data: %d", cfree.data);
- $display("--------------------------------");
- #5 clock = ~clock;
- #5 clock = ~clock;
- end
- $display("Read data: %d", cfree.data);
- $stop;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement