Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module drawCar(input clk,reset, leftEnable,rightEnable, midEnable, output reg [7:0] x, [6:0] y, [2:0] colour);
- reg [4:0]xCounter,yCounter;
- reg [9:0]addressCounter;
- if (reset)
- begin
- xCounter=5'b0;
- yCounter=5'b0;
- addressCounter=10'b0;
- end
- playerCar(.address(addressCounter),.clk(clk),.q(colour));//iterate through adress and read colour from memory
- always@(posedge clk)
- begin
- if (leftEnable) //draw in left lane
- begin
- if (xCounter == 5'd20)
- begin
- xCounter <= 0;
- yCounter <= yCounter+1;
- end
- else
- xCounter<=xCounter+1;
- x<=6'b100001+xCounter; //Output x starting from left lane
- y<=7'1011000+yCounter; //Output y
- addressCounter<=addressCounter+1;
- end
- if (midEnable) //draw in left lane
- begin
- if (xCounter == 5'd20)
- begin
- xCounter <= 0;
- yCounter <= yCounter+1;
- end
- else
- xCounter<=xCounter+1;
- x<=6'b1000101+xCounter;
- y<=7'1011000+yCounter;
- end
- if (rightEnable)
- begin
- if (xCounter == 5'd20)
- begin
- xCounter <= 0;
- yCounter <= yCounter+1;
- end
- else
- xCounter<=xCounter+1;
- x<=6'b1101010+xCounter;
- y<=7'1011000+yCounter;
- end
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement