use 3-bit transmit state, add header/footer around data, skip debounce for now
This commit is contained in:
@@ -27,13 +27,11 @@ module top #(parameter WIDTH=24)(
|
||||
.i_clk (i_clk));
|
||||
/* verilator lint_on PINMISSING */
|
||||
reg db_start, db_stop;
|
||||
// skipping the debouncing in simulation
|
||||
`ifdef VERILATOR
|
||||
always @(posedge clk_100MHz) begin
|
||||
db_start <= ~i_startN;
|
||||
db_stop <= ~i_stopN;
|
||||
end
|
||||
`else
|
||||
`ifdef DEBOUNCE
|
||||
debounce db1 (
|
||||
// Outputs
|
||||
.db (db_start),
|
||||
@@ -50,7 +48,7 @@ module top #(parameter WIDTH=24)(
|
||||
.sw (~i_stopN));
|
||||
`endif
|
||||
|
||||
tdc #(.COUNTER_WIDTH(TDC_COUNTER_WIDTH)) tdc0 (
|
||||
tdc #(.COUNTER_WIDTH(32)) tdc0 (
|
||||
// Outputs
|
||||
.o_ready (buf_ready),
|
||||
.o_data (buf_data),
|
||||
@@ -81,21 +79,21 @@ module top #(parameter WIDTH=24)(
|
||||
reg [7:0] tx_data;
|
||||
|
||||
// there are 4bytes to transmit
|
||||
initial tx_index = 3'h0;
|
||||
initial tx_index = 3'd0;
|
||||
always @(posedge clk_100MHz) begin
|
||||
if ((tx_stb)&&(!tx_busy)) begin
|
||||
if (tx_index < 3'd4)
|
||||
tx_index <= tx_index + 1'b1;
|
||||
else
|
||||
tx_index <= 0;
|
||||
end
|
||||
if ((tx_stb)&&(!tx_busy))
|
||||
tx_index <= tx_index + 1'b1;
|
||||
end
|
||||
always @(posedge clk_100MHz) begin
|
||||
case(tx_index)
|
||||
3'd1: tx_data <= buf_data[31:24];
|
||||
3'd2: tx_data <= buf_data[23:16];
|
||||
3'd3: tx_data <= buf_data[15:8];
|
||||
3'd4: tx_data <= buf_data[7:0];
|
||||
3'd0: tx_data <= "f";
|
||||
3'd1: tx_data <= "f";
|
||||
3'd2: tx_data <= buf_data[31:24];
|
||||
3'd3: tx_data <= buf_data[23:16];
|
||||
3'd4: tx_data <= buf_data[15:8];
|
||||
3'd5: tx_data <= buf_data[7:0];
|
||||
3'd6: tx_data <= "f";
|
||||
3'd7: tx_data <= "f";
|
||||
endcase
|
||||
end
|
||||
initial tx_stb = 1'b0;
|
||||
@@ -103,7 +101,7 @@ module top #(parameter WIDTH=24)(
|
||||
always @(posedge clk_100MHz) begin
|
||||
if (tx_start)
|
||||
tx_stb <= 1'b1;
|
||||
else if ((tx_stb)&&(!tx_busy)&&(tx_index==3'd4))
|
||||
else if ((tx_stb)&&(!tx_busy)&&(tx_index==3'd7))
|
||||
tx_stb <= 1'b0;
|
||||
end
|
||||
|
||||
|
||||
@@ -61,6 +61,8 @@ int main(int argc, char **argv) {
|
||||
|
||||
for (int k = 0; k < 394; k++)
|
||||
tick(++tickcount, tb, tfp);
|
||||
for (int k = 0; k < (1<<17); k++)
|
||||
tick(++tickcount, tb, tfp);
|
||||
|
||||
// stop pulse
|
||||
tb->i_stopN = 0;
|
||||
|
||||
Reference in New Issue
Block a user