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

Subversion Repositories blue

[/] [blue/] [trunk/] [blue8/] [FrontPanel.v] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 wd5gnr
/*
2
    This file is part of Blue8.
3
 
4
    Foobar is free software: you can redistribute it and/or modify
5
    it under the terms of the GNU Lesser General Public License as published by
6
    the Free Software Foundation, either version 3 of the License, or
7
    (at your option) any later version.
8
 
9
    Foobar is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU Lesser General Public License for more details.
13
 
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with Blue8.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
    Blue8 by Al Williams alw@al-williams.com
18
*/
19
 
20
`timescale 1ns / 1ps
21
`default_nettype none
22
////////////////////////////////////////////////////////////////////////////////
23
// Company: 
24
// Engineer:
25
//
26
// Create Date:    20:52:58 12/21/05
27
// Design Name:    
28
// Module Name:    FrontPanel
29
// Project Name:   
30
// Target Device:  
31
// Tool versions:  
32
// Description:
33
//
34
// Dependencies:
35
// 
36
// Revision:
37
// Revision 0.01 - File Created
38
// Additional Comments:
39
// 
40
 
41
////////////////////////////////////////////////////////////////////////////////
42
// I rearranged these from version 1
43
`define p_sw 4'b100      // when points==4 show switches
44
`define p_acc 4'b10    // when points==2 show acc
45
`define p_ir 4'b1000    // when points==8 show ir
46
`define p_pc 4'b1   // when points==1 show pc
47
 
48
 
49
// after operating for awhile I'm not sure the original order was best
50
// Seems like regsel should be #1 followed by loadpc, exam, deposit, step, start
51
`define i_lpc 6'b10    // load pc
52
`define i_exam 6'b100  // examine
53
`define i_deposit 6'b1000 // deposit
54
`define i_regsel 6'b1  // register select
55
`define i_step 6'b10000   // single step
56
`define i_start 6'b100000  // run/stop
57
 
58
 
59
module FrontPanel(input wire clockin, input wire pb0, input wire pb1, input wire pb2, input wire pb3,
60
    input wire [7:0] sw, output wire [7:0] led, output wire [6:0] display, output dp,
61
         output [3:0] digsel, output wire clear, output wire start, output wire stop,
62
         output wire lpc, output wire exam, output wire dep, input wire xrun,
63
         output wire [15:0] swreg, input wire [15:0] irin, input wire [15:0] acin, input wire [11:0] pcin,
64
         input wire Q, input wire setswreg, input wire [15:0] databus);
65
 
66
    wire select;  // select input buttons
67
         reg [5:0] inselect;  // state
68
 
69
    wire [15:0] ledbus;
70
         reg [3:0] points;
71
         wire [3:0] pts;   // decimal points
72
         wire act, ent;
73
         wire step;
74
 
75
 
76
         assign pts=(pb0?`p_sw:points);
77
 
78
 
79
 
80
 
81
 
82
    DisplayHex hexdisp(clockin,clear,ledbus[7:0],ledbus[15:8],~pts,display[0],display[1],
83
           display[2],display[3],display[4],display[5],display[6],dp,digsel[0],digsel[1],digsel[2],digsel[3]);
84
 
85
         // switches get latched in 8 bits at a time
86
         reg [15:0] switches;
87
    assign swreg=switches;
88
 
89
// very strange. This gave unpredicatble results with setswreg controling the mux but works
90
// with ent controlling!
91
         always @(posedge clockin or posedge clear) begin
92
             if (clear) switches<=0;
93
                  else if (setswreg | ent)
94
                   begin
95
                     switches[15:8]<=ent?switches[7:0]:databus[15:8];
96
                     switches[7:0]<=ent?sw:databus[7:0];
97
                          end
98
         end
99
 
100
    assign ledbus=((points==`p_sw||pb0==1'b1)?switches:((points==`p_acc)?acin:((points==`p_ir)?irin:((points==`p_pc)?pcin:0))));
101
 
102
         //reg pb3s0, pb3s1;
103
 
104
         assign clear=pb3;
105
//      assign clear=pb3s0 | pb3s1;
106
//      always @(posedge clockin)
107
//         begin
108
//              pb3s1<=pb3s0;
109
//         pb3s0<=pb3;
110
  //    end
111
 
112
         Debouncer dselect(clockin,clear,pb2,,select,);
113
         Debouncer daction(clockin, clear, pb1,,act,);
114
         Debouncer denter(clockin, clear, pb0,,ent,);
115
 
116
         assign led[7]=Q;
117
    assign led[6]=xrun;
118
         assign led[5]=inselect[5];
119
         assign led[4]=inselect[4];
120
         assign led[3]=inselect[3];
121
         assign led[2]=inselect[2];
122
         assign led[1]=inselect[1];
123
         assign led[0]=inselect[0];
124
 
125
         // I don't want to use the cycle names here because we always 
126
         // want them to go 1, 2, 3, 4... even if the meanings of 1, 2, 3, 4 change
127
         always @(posedge clockin or posedge clear) begin
128
           if (clear) inselect<=6'b1;
129
                else if (select) case (inselect)
130
                  6'b1:  inselect<=6'b10;
131
                  6'b10:  inselect<=6'b100;
132
                  6'b100:  inselect<=6'b1000;
133
                  6'b1000:  inselect<=6'b10000;
134
                  6'b10000:  inselect<=6'b100000;
135
                  6'b100000:  inselect<=6'b1;
136
                  default: inselect<=6'b1;
137
      endcase
138
     end
139
 
140
 
141
assign lpc=act&(inselect==`i_lpc);
142
assign exam=act&(inselect==`i_exam);
143
assign dep=act&(inselect==`i_deposit);
144
// state 1000 is register display select
145
// Note we use 1 here and not a particular define because we always want to start at 1
146
always @(posedge clockin or posedge clear) begin
147
  if (clear) points=4'b1;
148
  else
149
    if (act & (inselect==`i_regsel)) begin
150
    points=points<<1;
151
    if (points==4'b0) points=4'b1;
152
    end
153
end
154
 
155
 
156
// state 10000 is step 
157
assign step=(inselect==`i_step) & act;
158
 
159
assign start=((~xrun) & act & (inselect==`i_start)) | step;
160
assign stop=(xrun & act & (inselect==`i_start)) | step;  // potential for harmless stop before start glitch?
161
 
162
 
163
 
164
 
165
 
166
endmodule

powered by: WebSVN 2.1.0

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