Skip to content

Commit

Permalink
all done
Browse files Browse the repository at this point in the history
  • Loading branch information
shawntsai0312 committed Dec 16, 2024
1 parent 184ef2d commit f7f1ff0
Show file tree
Hide file tree
Showing 25 changed files with 3,064 additions and 1,994 deletions.
40 changes: 32 additions & 8 deletions Final/src/DE2_115/DE2_115.sv
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module DE2_115 (
);

logic key0down, key1down, key2down, key3down;
logic clk_108m;
logic clk_108m, clk_12m, clk_100k;

wire [31:0] frame_counter;
wire [31:0] timer;
Expand All @@ -151,6 +151,8 @@ module DE2_115 (

qsys u_qsys (
.altpll_108m_clk (clk_108m),
.altpll_12m_clk (clk_12m),
.altpll_100k_clk (clk_100k),
.clk_clk (CLOCK_50),
.reset_reset_n (rst_n),

Expand Down Expand Up @@ -202,20 +204,42 @@ module DE2_115 (
assign o_SRAM_LB_N = 1'b0;
assign o_SRAM_UB_N = 1'b0;

assign AUD_XCK = clk_12m;

// wire signed [game_pkg::ANG_WIDTH-1:0] o_car1_angle, o_car2_angle;
wire [game_pkg::VELOCITY_OUTPUT_WIDTH-1:0] car1_v_m, car2_v_m;

wire next_state;
assign next_state = key0down & key1down;
wire [2:0] car1_acc, car2_acc;
assign car2_acc = SW[2:0];
assign car1_acc = SW[15:13];

wire [1:0] car1_omega, car2_omega;
assign car2_omega = SW[4:3];
assign car1_omega = SW[17:16];

wire [2:0] game_state;
assign LEDG[0] = (game_state == 0);
assign LEDG[1] = (game_state == 1);
assign LEDG[2] = (game_state == 2);
assign LEDG[3] = (game_state == 3);
assign LEDG[4] = (game_state == 4);

Main u_Main (
.i_clk (clk_108m),
.i_rst_n (rst_n),
.i_next_state (next_state),
.i_car2_acc (SW[2:0]),
.i_car1_acc (SW[15:13]),
.i_car2_omega (SW[4:3]),
.i_car1_omega (SW[17:16]),
.i_start (SW[8]),
.i_restart (SW[9]),
.i_I2C_clk (clk_100k),
.o_I2C_sclk (I2C_SCLK),
.io_I2C_sdat (I2C_SDAT),
.i_AUD_BCLK (AUD_BCLK),
.i_AUD_DACLRCK (AUD_DACLRCK),
.o_AUD_DACDAT (AUD_DACDAT),
.i_car2_acc (car2_acc),
.i_car1_acc (car1_acc),
.i_car2_omega (car2_omega),
.i_car1_omega (car1_omega),
.o_game_state (game_state),
.o_car1_v_m (car1_v_m),
.o_car2_v_m (car2_v_m),
.o_SRAM_ADDR (SRAM_ADDR),
Expand Down
35 changes: 17 additions & 18 deletions Final/src/frameDecoder/palette/car1Palette.sv
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,25 @@
// end
// endmodule

// gray
// yellow
module car1_palette(output reg [23:0] color_map [0:15]);
initial begin
// use pure black(0,0,0) as the transparent color
color_map[0] = 24'h000000; // Transparent color
color_map[1] = 24'h025d29;
color_map[2] = 24'h272827;
color_map[3] = 24'h3c3e3c;
color_map[4] = 24'h8bb29d;
color_map[5] = 24'h17703a;
color_map[6] = 24'h418462;
color_map[7] = 24'h183424;
color_map[8] = 24'h4b4c4b;
color_map[9] = 24'h195733;
color_map[10] = 24'h046b37;
color_map[11] = 24'h619b7e;
color_map[12] = 24'h0e4528;
color_map[13] = 24'h257a4d;
color_map[14] = 24'h0b6732;
color_map[15] = 24'h244131;
color_map[1] = 24'h827a1d;
color_map[2] = 24'h353231;
color_map[3] = 24'hebcd13;
color_map[4] = 24'hf4eb9d;
color_map[5] = 24'hc3b720;
color_map[6] = 24'hf9ee08;
color_map[7] = 24'hf7e234;
color_map[8] = 24'ha8971a;
color_map[9] = 24'h4d4721;
color_map[10] = 24'h484646;
color_map[11] = 24'hf8e65c;
color_map[12] = 24'hefb509;
color_map[13] = 24'h282322;
color_map[14] = 24'hd7a20c;
color_map[15] = 24'h665e21;
end
endmodule

endmodule
32 changes: 16 additions & 16 deletions Final/src/frameDecoder/palette/car2Palette.sv
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@
// endmodule


// red
// white
module car2_palette(output reg [23:0] color_map [0:15]);
initial begin
// use pure black(0,0,0) as the transparent color
color_map[0] = 24'h000000; // Transparent color
color_map[1] = 24'hc40203;
color_map[2] = 24'h2b2521;
color_map[3] = 24'h9a3b3a;
color_map[4] = 24'h840b0a;
color_map[5] = 24'hdc9494;
color_map[6] = 24'hd35152;
color_map[7] = 24'h58100e;
color_map[8] = 24'h181511;
color_map[9] = 24'hc92829;
color_map[10] = 24'h9f0809;
color_map[11] = 24'h4a1f1c;
color_map[12] = 24'ha72626;
color_map[13] = 24'hcc6a6c;
color_map[14] = 24'ha75253;
color_map[15] = 24'h852726;
color_map[1] = 24'h3b2d44;
color_map[2] = 24'ha296ac;
color_map[3] = 24'h695e72;
color_map[4] = 24'hcdc4d2;
color_map[5] = 24'h83798e;
color_map[6] = 24'h493d51;
color_map[7] = 24'hc0b8c9;
color_map[8] = 24'h978da2;
color_map[9] = 24'hb3acbd;
color_map[10] = 24'h574b60;
color_map[11] = 24'h736a7e;
color_map[12] = 24'haaa1b5;
color_map[13] = 24'h8d8397;
color_map[14] = 24'hdddadf;
color_map[15] = 24'h9d93a6;
end
endmodule
Loading

0 comments on commit f7f1ff0

Please sign in to comment.