Skip to content

Commit

Permalink
found bug with calculating dt in buffer_serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Berg committed Nov 29, 2015
1 parent d642288 commit 3b8c8d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
15 changes: 10 additions & 5 deletions Nexys4Game/src/hdl/SC_buffer_serializer.v
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
module SC_buffer_serializer(
input clk,
input song_time,
input [15:0] song_time,
input [36:0] match_trigger,
input [37*16-1:0] match_time,

output reg match_en,
output reg [15:0] match_dt

output reg [15:0] match_dt,
output [15:0] queue
);

reg [17*6-1:0] match_queue; //represents a shift register with 6 shifts of 17 bits each, where the MSB means a valid match needs to be scored, and the next 16 bits are the dt

initial match_queue = 0;

assign queue = match_queue[15:0];

always @(posedge clk) begin

Expand Down Expand Up @@ -97,7 +99,10 @@ module SC_buffer_serializer(
match_queue[17*5-1:0] <= match_queue[17*6-1:17]; //Shift the queue

match_en <= match_queue[16]; //shift out a match
match_dt <= song_time - match_queue[15:0]; //SIGNED ISSUES : NEED FIXING

if(song_time >= match_queue[15:0])
match_dt <= song_time - match_queue[15:0];
else
match_dt <= match_queue[15:0] - song_time;

end
endmodule
8 changes: 5 additions & 3 deletions Nexys4Game/src/test/SC_buffer_serializer_tb.v
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module SC_buffer_serializer_tb;
// Outputs
wire match_en;
wire [15:0] match_dt;
wire [15:0] queue;

// Instantiate the Unit Under Test (UUT)
SC_buffer_serializer uut (
Expand All @@ -19,11 +20,12 @@ module SC_buffer_serializer_tb;
.match_trigger(match_trigger),
.match_time(match_time),
.match_en(match_en),
.match_dt(match_dt)
.match_dt(match_dt),
.queue(queue)
);

always #5 clk = !clk;
always #10 song_time = song_time + 1;
always #100 song_time = song_time + 1;
initial begin
// Initialize Inputs
clk = 0;
Expand All @@ -34,7 +36,7 @@ module SC_buffer_serializer_tb;
#100;

//Stimulus

#1000
match_trigger = 1; //match e2
match_time[15:0] = 7;
#10
Expand Down

0 comments on commit 3b8c8d9

Please sign in to comment.