OpenCores
URL https://opencores.org/ocsvn/natalius_8bit_risc/natalius_8bit_risc/trunk

Subversion Repositories natalius_8bit_risc

[/] [natalius_8bit_risc/] [trunk/] [pong_top_level.v] - Blame information for rev 11

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 fabioandre
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company:       Universidad Pontificia Bolivariana
4
// Engineer:      Fabio Andres Guzman Figueroa
5
// 
6
// Create Date:    11:31:15 05/17/2012 
7
// Design Name:    
8
// Module Name:    pong_top_level
9
// Project Name: 
10
// Target Devices: 
11
// Tool versions: 
12
// Description: 
13
//
14
// Dependencies: 
15
//
16
// Revision: 
17
// Revision 0.01 - File Created
18
// Additional Comments: 
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
module pong_top_level(
22
    input clk,
23
    input rst,
24
         input up1, down1, up2, down2,
25
         output hs,vs,
26
         output r,g,b
27
    );
28
 
29
 
30
wire [7:0] data_in;
31
wire [7:0] port_addr;
32
wire [7:0] data_out;
33
wire write_e;
34
 
35
reg [3:0] sw;
36
reg rst_ext;
37
reg [6:0] col;
38
reg [5:0] row;
39
reg [2:0] color;
40
reg we;
41
 
42
wire [12:0] addr_write, addr_read;
43
wire [3:0] doutb;
44
wire [2:0] color_out;
45
wire [7:0] mem_out;
46
 
47
 
48
always@(posedge clk)
49
        if (rst_ext==1 || rst==1)
50
                sw<=0;
51
        else
52
                begin
53
                        if (up1)        sw[0]<=1'b1;
54
                        if (down1)  sw[1]<=1'b1;
55
                        if (up2)    sw[2]<=1'b1;
56
                        if (down2)  sw[3]<=1'b1;
57
                end
58
 
59
//col register  (addr=32)
60
always@(posedge clk or posedge rst)
61
        if (rst)
62
                col<=0;
63
        else
64
                if (port_addr[7:5]==3'b001 && write_e==1)
65
                        col<=data_out[6:0];
66
 
67
 
68
//row register (addr=64)
69
always@(posedge clk or posedge rst)
70
        if (rst)
71
                row<=0;
72
        else
73
                if (port_addr[7:5]==3'b010 && write_e==1)
74
                        row<=data_out[5:0];
75
 
76
 
77
//color register (addr=96)
78
always@(posedge clk or posedge rst)
79
        if (rst)
80
                color<=0;
81
        else
82
                if (port_addr[7:5]==3'b011 && write_e==1)
83
                        color<=data_out[2:0];
84
 
85
//we register (addr=160)
86
always@(posedge clk or posedge rst)
87
        if (rst)
88
                we<=0;
89
        else
90
                if (port_addr[7:5]==3'b101 && write_e==1)
91
                        we<=data_out[0];
92
 
93
//rst_ext register (addr=128)
94
always@(posedge clk or posedge rst)
95
        if (rst)
96
                rst_ext<=0;
97
        else
98
                if (port_addr[7:5]==3'b100 && write_e==1)
99
                        rst_ext<=data_out[0];
100
 
101
assign data_in=(port_addr[7:5]==000) ? mem_out : {4'b0000,sw};
102
 
103
assign addr_write={row, col};
104
 
105
natalius_processor processor(clk,rst,port_addr,read_e,write_e,data_in,data_out);
106
memram ram_memory(clk,data_out,port_addr[4:0],mem_out,write_e);
107
mem_video video_mem(clk,we,addr_write,addr_read,{1'b0,color},doutb);
108
vga_control video_cntrl(clk,rst,doutb[2:0],hs,vs,color_out,addr_read);
109
 
110
assign r=color_out[2];
111
assign g=color_out[1];
112
assign b=color_out[0];
113
 
114
endmodule

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.