first commit
This commit is contained in:
115
rtl/baseball_datapath.sv
Normal file
115
rtl/baseball_datapath.sv
Normal file
@@ -0,0 +1,115 @@
|
||||
module baseball_datapath (
|
||||
input logic clock,
|
||||
input logic reset,
|
||||
|
||||
input logic [1:0] strike_mut_sel,
|
||||
input logic [1:0] ball_mut_sel,
|
||||
input logic [1:0] out_mut_sel,
|
||||
input logic inning_mut_sel,
|
||||
input logic team_toggle,
|
||||
|
||||
output logic strikeout,
|
||||
output logic walk,
|
||||
output logic three_outs,
|
||||
output logic game_ended,
|
||||
|
||||
output logic [1:0] strike_count,
|
||||
output logic [2:0] ball_count,
|
||||
output logic [1:0] out_count,
|
||||
output logic [3:0] inning_count,
|
||||
output logic team_active
|
||||
);
|
||||
|
||||
logic [1:0] strike_next;
|
||||
logic [2:0] ball_next;
|
||||
logic [1:0] out_next;
|
||||
logic [3:0] inning_next;
|
||||
logic team_next;
|
||||
|
||||
assign strikeout = (strike_count >= 3);
|
||||
assign walk = (ball_count >= 4);
|
||||
assign three_outs = (out_count >= 3);
|
||||
assign game_ended = (inning_count >= 10);
|
||||
|
||||
multiplexer4 #(.WIDTH(2)) strike_mut (
|
||||
.sel(strike_mut_sel),
|
||||
.in0(strike_count),
|
||||
.in1('b0),
|
||||
.in2(strike_count + 1),
|
||||
.in3('bx),
|
||||
.out(strike_next)
|
||||
);
|
||||
|
||||
multiplexer4 #(.WIDTH(3)) ball_mut (
|
||||
.sel(ball_mut_sel),
|
||||
.in0(ball_count),
|
||||
.in1('b0),
|
||||
.in2(ball_count + 1),
|
||||
.in3('bx),
|
||||
.out(ball_next)
|
||||
);
|
||||
|
||||
multiplexer4 #(.WIDTH(2)) out_mut (
|
||||
.sel(out_mut_sel),
|
||||
.in0(out_count),
|
||||
.in1('b0),
|
||||
.in2(out_count + 1),
|
||||
.in3('bx),
|
||||
.out(out_next)
|
||||
);
|
||||
|
||||
multiplexer2 #(.WIDTH(4)) inning_mut (
|
||||
.sel(inning_mut_sel),
|
||||
.in0(inning_count),
|
||||
.in1(inning_count + 1),
|
||||
.out(inning_next)
|
||||
);
|
||||
|
||||
multiplexer2 #(.WIDTH(1)) team_mut (
|
||||
.sel(team_toggle),
|
||||
.in0(team_active),
|
||||
.in1(~team_active),
|
||||
.out(team_next)
|
||||
);
|
||||
|
||||
register #(.WIDTH(2)) strike_register (
|
||||
.clock(clock),
|
||||
.reset(reset),
|
||||
.write_en('1),
|
||||
.next(strike_next),
|
||||
.value(strike_count)
|
||||
);
|
||||
|
||||
register #(.WIDTH(3)) ball_register (
|
||||
.clock(clock),
|
||||
.reset(reset),
|
||||
.write_en('1),
|
||||
.next(ball_next),
|
||||
.value(ball_count)
|
||||
);
|
||||
|
||||
register #(.WIDTH(2)) out_register (
|
||||
.clock(clock),
|
||||
.reset(reset),
|
||||
.write_en('1),
|
||||
.next(out_next),
|
||||
.value(out_count)
|
||||
);
|
||||
|
||||
register #(.WIDTH(4), .RESET(1)) inning_register (
|
||||
.clock(clock),
|
||||
.reset(reset),
|
||||
.write_en('1),
|
||||
.next(inning_next),
|
||||
.value(inning_count)
|
||||
);
|
||||
|
||||
register #(.WIDTH(1)) team_register (
|
||||
.clock(clock),
|
||||
.reset(reset),
|
||||
.write_en('1),
|
||||
.next(team_next),
|
||||
.value(team_active)
|
||||
);
|
||||
|
||||
endmodule
|
||||
Reference in New Issue
Block a user