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

Subversion Repositories vg_z80_sbc

[/] [vg_z80_sbc/] [trunk/] [rtl/] [wb_fpb.v] - Blame information for rev 28

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

Line No. Rev Author Line
1 28 hharte
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  $Id: wb_fpb.v,v 1.1 2008-12-15 06:40:29 hharte Exp $        ////
4
////  wb_fpb.v - "Front Panel Board" with Wishbone                ////
5
////             Slave interface.                                 ////
6
////                                                              ////
7
////  This file is part of the Vector Graphic Z80 SBC Project     ////
8
////  http://www.opencores.org/projects/vg_z80_sbc/               ////
9
////                                                              ////
10
////  Author:                                                     ////
11
////      - Howard M. Harte (hharte@opencores.org)                ////
12
////                                                              ////
13
//////////////////////////////////////////////////////////////////////
14
////                                                              ////
15
//// Copyright (C) 2008 Howard M. Harte                           ////
16
////                                                              ////
17
//// This source file may be used and distributed without         ////
18
//// restriction provided that this copyright statement is not    ////
19
//// removed from the file and that any derivative work contains  ////
20
//// the original copyright notice and the associated disclaimer. ////
21
////                                                              ////
22
//// This source file is free software; you can redistribute it   ////
23
//// and/or modify it under the terms of the GNU Lesser General   ////
24
//// Public License as published by the Free Software Foundation; ////
25
//// either version 2.1 of the License, or (at your option) any   ////
26
//// later version.                                               ////
27
////                                                              ////
28
//// This source is distributed in the hope that it will be       ////
29
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
30
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
31
//// PURPOSE.  See the GNU Lesser General Public License for more ////
32
//// details.                                                     ////
33
////                                                              ////
34
//// You should have received a copy of the GNU Lesser General    ////
35
//// Public License along with this source; if not, download it   ////
36
//// from http://www.opencores.org/lgpl.shtml                     ////
37
////                                                              ////
38
//////////////////////////////////////////////////////////////////////
39
 
40
//+---------------------------------------------------------------------------+
41
//|
42
//|
43
//+---------------------------------------------------------------------------+
44
module wb_fpb(
45
    clk_i, nrst_i, wbs_adr_i, wbs_dat_o, wbs_dat_i, wbs_sel_i, wbs_we_i,
46
    wbs_stb_i, wbs_cyc_i, wbs_ack_o,
47
    prog_out_port,
48
    sense_sw_i,
49
    lcd_e,
50
    lcd_rs,
51
    lcd_rw,
52
    lcd_dat
53
);
54
 
55
    // Wishbone Slave Interface
56
    input          clk_i;
57
    input          nrst_i;
58
    input    [4:0] wbs_adr_i;
59
    output reg [7:0] wbs_dat_o;
60
    input    [7:0] wbs_dat_i;
61
    input    [3:0] wbs_sel_i;
62
    input          wbs_we_i;
63
    input          wbs_stb_i;
64
    input          wbs_cyc_i;
65
    output reg     wbs_ack_o;
66
 
67
    output         lcd_e;
68
    output         lcd_rs;
69
    output         lcd_rw;
70
    output reg [3:0] lcd_dat;
71
 
72
    // Programmed Output Port (8-bit)
73
    output reg [7:0] prog_out_port;
74
 
75
    // Sense Switches
76
    input      [7:0] sense_sw_i;
77
 
78
    //
79
    // generate wishbone register bank writes
80
    wire wbs_acc = wbs_cyc_i & wbs_stb_i;    // WISHBONE access
81
    wire wbs_wr  = wbs_acc & wbs_we_i;       // WISHBONE write access
82
    wire wbs_rd  = wbs_acc & !wbs_we_i;      // WISHBONE read access
83
 
84
    assign lcd_e = wbs_acc;
85
    assign lcd_rw = 1'b0;
86
    assign lcd_rs = wbs_adr_i[0];
87
 
88
    always @(posedge clk_i or negedge nrst_i)
89
        if(~nrst_i) // Reset
90
        begin
91
            wbs_ack_o <= 1'b0;
92
            prog_out_port <= 8'hFF;
93
            lcd_dat <= 4'h0;
94
        end
95
        else begin
96
 
97
            if(wbs_wr)  // Wishbone Write, decode address to determine register offset.
98
                case(wbs_adr_i)
99
                    5'h00: begin   //
100
                        lcd_dat <= wbs_dat_i[3:0];
101
                    end
102
                    5'h01: begin   //
103
                        lcd_dat <= wbs_dat_i[3:0];
104
                    end
105
                    5'h02: begin   //
106
                    end
107
                    5'h1F: begin   // Programmed Output Port
108
                        prog_out_port <= wbs_dat_i;
109
                    end
110
                endcase
111
 
112
            if(wbs_rd) begin
113
                case(wbs_adr_i) // Wishbone Read, decode address to determine register offset.
114
                    5'h00: begin   //
115
                        wbs_dat_o <= 8'hE0;
116
                    end
117
                    5'h01: begin   //
118
                        wbs_dat_o <= 8'hE1;
119
                    end
120
                    5'h02: begin   //
121
                        wbs_dat_o <= 8'hE2;
122
                    end
123
                    5'h1F: begin   // Sense Switches Input Port
124
                        wbs_dat_o <= sense_sw_i;
125
                    end
126
                endcase
127
            end
128
 
129
            wbs_ack_o <= wbs_acc & !wbs_ack_o;
130
        end
131
 
132
endmodule
133
 
134
 

powered by: WebSVN 2.1.0

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