working stop watch

This commit is contained in:
2020-10-26 17:35:52 -05:00
parent 4886fad4b2
commit a0b211338c
4 changed files with 47 additions and 39 deletions

View File

@@ -1,15 +1,17 @@
# For iceFUN board
set_io --warn-no-port i_clk P7
# set_io --warn-no-port i_request A5
set_io --warn-no-port i_startN C11
set_io --warn-no-port i_stopN A11
set_io --warn-no-port i_resetN C6
set_io --warn-no-port o_led_row_0 A12
set_io --warn-no-port o_led C10
# set_io --warn-no-port o_led[0] C10
# set_io --warn-no-port o_led[1] A10
# set_io --warn-no-port o_led[2] D7
# set_io --warn-no-port o_led[3] D6
# set_io --warn-no-port o_led[4] A7
# set_io --warn-no-port o_led[5] C7
# set_io --warn-no-port o_led[6] A4
# set_io --warn-no-port o_busy C4
set_io --warn-no-port o_dataN[0] C10
set_io --warn-no-port o_dataN[1] A10
set_io --warn-no-port o_dataN[2] D7
set_io --warn-no-port o_dataN[3] D6
set_io --warn-no-port o_dataN[4] A7
set_io --warn-no-port o_dataN[5] C7
set_io --warn-no-port o_ledN A4
set_io --warn-no-port o_readyN C4

View File

@@ -1,11 +1,17 @@
`default_nettype none
// dummy clock generator, should be replaced by a PLL clock gen eventually
module clk_gen(
module clk_gen #(parameter DIVISION=22)(
input wire i_clk,
output wire o_clk
);
assign o_clk = i_clk;
reg [DIVISION-1:0] counter = 0;
always @(posedge i_clk) begin
counter <= counter + 1;
end
assign o_clk = counter[DIVISION-1];
endmodule
// Local Variables:

View File

@@ -2,41 +2,42 @@
module top #(parameter WIDTH=24)(
input wire i_clk,
output wire o_led,
input wire i_start,
input wire i_stop,
input wire i_startN,
input wire i_stopN,
input wire i_resetN,
output wire o_ready,
output wire [15:0] o_data,
output wire o_ledN,
output wire o_readyN,
output wire [5:0] o_dataN,
output wire o_led_row_0
);
wire clk_12MHz;
wire clk_3Hz;
reg buf_led = 0;
wire buf_ready;
wire [5:0] buf_data;
assign o_readyN = ~buf_ready;
assign o_dataN = ~buf_data;
clk_gen clk_gen_0 (/*autoinst*/
clk_gen #(.DIVISION(22)) clk_gen0 (/*autoinst*/
// Outputs
.o_clk (clk_12MHz),
.o_clk (clk_3Hz),
// Inputs
.i_clk (i_clk));
tdc tdc0(/*autoinst*/
tdc #(.COUNTER_WIDTH(6)) tdc0 (/*autoinst*/
// Outputs
.o_ready (o_ready),
.o_data (o_data[15:0]),
.o_ready (buf_ready),
.o_data (buf_data),
// Inputs
.i_clk (clk_12MHz),
.i_start (i_start),
.i_stop (i_stop),
.i_clk (clk_3Hz),
.i_start (~i_startN),
.i_stop (~i_stopN),
.i_reset (~i_resetN));
reg [WIDTH-1:0] counter;
always @(posedge clk_12MHz) begin
counter <= counter + 1'b1;
buf_led <= counter[WIDTH-1];
always @(posedge clk_3Hz) begin
buf_led <= ~buf_led;
end
assign o_led = ~buf_led;
assign o_ledN = ~buf_led;
assign o_led_row_0 = 1'b0;
endmodule

View File

@@ -33,10 +33,9 @@ int main(int argc, char **argv) {
tfp->open("build/waveform.vcd");
tb->i_resetN = 1;
tb->i_start = 0;
tb->i_stop = 0;
tb->i_startN = 1;
tb->i_stopN = 1;
unsigned tickcount = 0;
int last_led = tb->o_led;
for (int k = 0; k < 2; k++)
tick(++tickcount, tb, tfp);
@@ -47,16 +46,16 @@ int main(int argc, char **argv) {
for (int k = 0; k < 3; k++)
tick(++tickcount, tb, tfp);
tb->i_start = 1;
tb->i_startN = 0;
tick(++tickcount, tb, tfp);
tb->i_start = 0;
tb->i_startN = 1;
for (int k = 0; k < 15; k++)
tick(++tickcount, tb, tfp);
tb->i_stop = 1;
tb->i_stopN = 0;
tick(++tickcount, tb, tfp);
tb->i_stop = 0;
tb->i_stopN = 1;
for (int k = 0; k < 3; k++)
tick(++tickcount, tb, tfp);