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

Subversion Repositories ag_6502

[/] [ag_6502/] [trunk/] [juke-box/] [chip1.v] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 olegodints
`timescale 1ns / 1ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company:   BMSTU
4
// Engineer:  Oleg Odintsov
5
// 
6
// Create Date:    18:21:00 01/17/2012 
7
// Design Name: 
8
// Project Name:    Agat Hardware Project
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
 
22
 
23
 
24
module rot_driver(input clk,
25
                                input rot_a, input rot_b,
26
                                output wire rot_dir, output wire rot_event_out);
27
 
28
        reg rot_a_latch = 0, rot_b_latch = 0;
29
        assign rot_dir = rot_b_latch, rot_event_out = rot_a_latch;
30
        always @(posedge clk) begin
31
                case ({rot_a, rot_b})
32
                2'b00: rot_a_latch <= 1;
33
                2'b11: rot_a_latch <= 0;
34
                2'b10: rot_b_latch <= 1;
35
                2'b01: rot_b_latch <= 0;
36
                endcase
37
        end
38
endmodule
39
 
40
module btn_driver(input clk, input btn, output reg sig = 0);
41
        parameter nskip = 'hfff;
42
        integer counter = 0;
43
        wire lock = counter?1:0;
44
 
45
        always @(posedge clk) begin
46
                if (counter) counter <= counter - 1;
47
                if (!lock && sig != btn) begin
48
                        sig <= btn;
49
                        counter <= nskip;
50
                end
51
        end
52
endmodule
53
 
54
 
55
module chip1(
56
         input clk,
57
    input b1,
58
    input b2,
59
    input b3,
60
    input b4,
61
         input rot_a, rot_b, rot_center,
62
    output[7:0] led,
63
    output vga_red,
64
    output vga_green,
65
    output vga_blue,
66
    output vga_hsync,
67
    output vga_vsync,
68
         output [3:0]j4,
69
         input spi_miso, output spi_mosi, output spi_sck, output dac_cs, output dac_clr,
70
         output spi_rom_cs,
71
         output spi_amp_cs,
72
         output spi_adc_conv,
73
         output strataflash_oe,
74
         output strataflash_ce,
75
    output strataflash_we,
76
         output platformflash_oe,
77
         input  ps2_clk,
78
         input  ps2_data
79
    );
80
 
81
 
82
 
83
         // access to DAC
84
         assign spi_mosi = 0, spi_sck = 0, dac_cs = 0, dac_clr = 0;
85
         // block other devices to access to DAC
86
         assign spi_rom_cs = 1, spi_amp_cs = 1, spi_adc_conv = 0;
87
         assign strataflash_oe = 1, strataflash_ce = 1, strataflash_we = 1;
88
         assign platformflash_oe = 0;
89
 
90
         wire[4:0] vga_bus;
91
         assign {vga_red, vga_green, vga_blue, vga_hsync, vga_vsync} = vga_bus;
92
         wire[1:0] ps2_bus = {ps2_clk, ps2_data};
93
 
94
         wire rot_dir, rot_event;
95
 
96
         wire clk_cpu;
97
         wire b1v, b2v, b3v, b4v, brc;
98
         rot_driver rot(clk_cpu, rot_a, rot_b, rot_dir, rot_event);
99
         btn_driver b1d(clk_cpu, b1, b1v);
100
         btn_driver b2d(clk_cpu, b2, b2v);
101
         btn_driver b3d(clk_cpu, b3, b3v);
102
         btn_driver b4d(clk_cpu, b4, b4v);
103
         btn_driver rrd(clk_cpu, rot_center, brc);
104
         reg rot_v = 0;
105
 
106
         always @(posedge rot_event) begin
107
                rot_v <= rot_dir;
108
         end
109
 
110
 
111
//       assign j4 = 0, vga_bus = 0;
112
 
113
         wire[3:0] btns = {b4v | (rot_event & ~rot_v), b3v | brc, b2v, b1v | (rot_event & rot_v)};
114
         ag_main agate(clk, btns, led, j4, vga_bus, ps2_bus, clk_cpu);
115
 
116
endmodule

powered by: WebSVN 2.1.0

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