Line 42... |
Line 42... |
//// ////
|
//// ////
|
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
|
|
`include "timescale.v"
|
`include "timescale.v"
|
|
|
module video(clk, reset_n, io_lines, enable, mem_rw, address, data);
|
module video(clk, reset_n, io_lines, enable, mem_rw, address, data, pixel);
|
parameter [3:0] DATA_SIZE = 4'd8;
|
parameter [3:0] DATA_SIZE = 4'd8;
|
parameter [3:0] ADDR_SIZE = 4'd10; // this is the *local* addr_size
|
parameter [3:0] ADDR_SIZE = 4'd10; // this is the *local* addr_size
|
|
|
localparam [3:0] DATA_SIZE_ = DATA_SIZE - 4'd1;
|
localparam [3:0] DATA_SIZE_ = DATA_SIZE - 4'd1;
|
localparam [3:0] ADDR_SIZE_ = ADDR_SIZE - 4'd1;
|
localparam [3:0] ADDR_SIZE_ = ADDR_SIZE - 4'd1;
|
Line 56... |
Line 56... |
input [15:0] io_lines; // inputs from the keyboard controller
|
input [15:0] io_lines; // inputs from the keyboard controller
|
input enable; // since the address bus is shared an enable signal is used
|
input enable; // since the address bus is shared an enable signal is used
|
input mem_rw; // read == 0, write == 1
|
input mem_rw; // read == 0, write == 1
|
input [ADDR_SIZE_:0] address; // system address bus
|
input [ADDR_SIZE_:0] address; // system address bus
|
inout [DATA_SIZE_:0] data; // controler <=> riot data bus
|
inout [DATA_SIZE_:0] data; // controler <=> riot data bus
|
|
output [11:0] pixel;
|
|
|
reg [DATA_SIZE_:0] data_drv; // wrapper for the data bus
|
reg [DATA_SIZE_:0] data_drv; // wrapper for the data bus
|
|
|
assign data = (mem_rw || !reset_n) ? 8'bZ : data_drv; // if under writing the bus receives the data from cpu, else local data.
|
assign data = (mem_rw || !reset_n) ? 8'bZ : data_drv; // if under writing the bus receives the data from cpu, else local data.
|
|
|
reg VSYNC; // vertical sync set-clear
|
reg VSYNC; // vertical sync set-clear
|
reg [2:0] VBLANK; // vertical blank set-clear
|
reg [2:0] VBLANK; // vertical blank set-clear
|
reg WSYNC; // s t r o b e wait for leading edge of horizontal blank
|
reg WSYNC; // SEMI-strobe wait for leading edge of horizontal blank
|
reg RSYNC; // s t r o b e reset horizontal sync counter
|
reg RSYNC; // s t r o b e reset horizontal sync counter
|
reg [5:0] NUSIZ0; // number-size player-missile 0
|
reg [5:0] NUSIZ0; // number-size player-missile 0
|
reg [5:0] NUSIZ1; // number-size player-missile 1
|
reg [5:0] NUSIZ1; // number-size player-missile 1
|
reg [6:0] COLUP0; // color-lum player 0
|
reg [6:0] COLUP0; // color-lum player 0
|
reg [6:0] COLUP1; // color-lum player 1
|
reg [6:0] COLUP1; // color-lum player 1
|
Line 125... |
Line 126... |
reg INPT2; // read pot port
|
reg INPT2; // read pot port
|
reg INPT3; // read pot port
|
reg INPT3; // read pot port
|
reg INPT4; // read input
|
reg INPT4; // read input
|
reg INPT5; // read input
|
reg INPT5; // read input
|
|
|
|
reg [5:0] hor_counter; // this counter is the "current pixel". when it reaches 39 the wsync register must be driven to zero
|
|
|
|
always @(posedge clk or negedge reset_n) begin
|
|
if (reset_n == 1'b0) begin
|
|
hor_counter <= 6'd0;
|
|
end
|
|
else begin
|
|
if (hor_counter == 6'd39) begin
|
|
hor_counter <= 6'd0;
|
|
WSYNC <= 1'b0;
|
|
end
|
|
else begin
|
|
hor_counter <= hor_counter + 6'd1;
|
|
end
|
|
end
|
|
end
|
|
|
always @(posedge clk or negedge reset_n) begin
|
always @(posedge clk or negedge reset_n) begin
|
if (reset_n == 1'b0) begin
|
if (reset_n == 1'b0) begin
|
data_drv <= 8'h00;
|
data_drv <= 8'h00;
|
|
WSYNC <= 1'b0;
|
end
|
end
|
else begin
|
else begin
|
if (mem_rw == 1'b0) begin // reading!
|
if (mem_rw == 1'b0) begin // reading!
|
case (address)
|
case (address)
|
6'h00: data_drv <= {CXM0P, 6'b000000};
|
6'h00: data_drv <= {CXM0P, 6'b000000};
|