-
Notifications
You must be signed in to change notification settings - Fork 1
/
ISAPostCard.v
134 lines (117 loc) · 3.41 KB
/
ISAPostCard.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
module ISAPostCard
(
input wire IOW, //Falling edge = SD latch
input wire AEN, //LOW (non-DMA transactions)
input wire BALE, //Falling edge = SA latch
input wire [19:0] SA,
input wire [7:0] SD,
input wire Button,
input wire Clock,
input wire SBHE,
output wire [6:0] FirstDigit, //Common cathode
output wire [6:0] SecondDigit, //Common anode
output wire AliveIndicator,
output wire ActivityIndicator,
output wire OKIndicator,
output wire [7:0] DummyOut
);
wire DivClock;
wire [7:0] CurrentData;
wire [19:0] CurrentAddress;
wire [6:0] FirstDigitCommonAnode;
reg [7:0] OutputData;
reg [3:0] DivReg;
reg TempAlive;
initial begin
TempAlive <= 1'b1;
end
ISA_Port80h my_port(.SBHE(SBHE), .IOW(IOW), .AEN(AEN), .BALE(BALE), .SA(SA), .SD(SD), .LastData(CurrentData),
.LastAddr(CurrentAddress), .ActivityIndicator(ActivityIndicator), .OKIndicator(OKIndicator));
BCD_Decoder my_decoder(.BCD(OutputData), .FirstDigit(FirstDigitCommonAnode), .SecondDigit(SecondDigit));
Dummy my_mem(.Current(CurrentData), .Clock(DivClock), .DummyOut(DummyOut));
parameter Divisor = 4'd10;
assign FirstDigit = ~FirstDigitCommonAnode;
assign AliveIndicator = TempAlive;
assign DivClock = (DivReg < Divisor / 2) ? 1'b0 : 1'b1;
always @(posedge Clock) begin
DivReg <= DivReg + 4'b0001;
if (DivReg >= Divisor) DivReg <= 4'd0;
end
always @(CurrentData, Button) begin
if (Button == 1'b1) begin
OutputData <= CurrentData;
TempAlive <= 1'b0;
end
else begin
OutputData <= CurrentAddress[7:0];
TempAlive <= 1'b1;
end
end
endmodule
module ISA_Port80h
(
input wire SBHE, //LOW = 16-bit transfer
input wire IOW, //Falling edge = SD latch
input wire AEN, //LOW (non-DMA transactions)
input wire BALE, //Falling edge = SA latch
input wire [19:0] SA,
input wire [7:0] SD,
output reg [7:0] LastData,
output reg [19:0] LastAddr,
output reg ActivityIndicator,
output reg OKIndicator
);
reg [19:0] TempAddr;
initial begin
ActivityIndicator <= 1'b1;
OKIndicator <= 1'b1;
end
always @(negedge BALE) begin
if (~AEN && SBHE) begin
TempAddr <= SA;
end
end
always @(negedge IOW) begin
ActivityIndicator <= 1'b0;
if (~AEN && SBHE) begin
LastAddr <= TempAddr;
if (LastAddr == 20'h80) begin
LastData <= SD;
if (LastData == 8'b00000000) OKIndicator <= 1'b0;
else OKIndicator <= 1'b0;
end
end
end
endmodule
module BCD_Decoder //Common anode!!
(
input wire [7:0] BCD,
output reg [6:0] FirstDigit,
output reg [6:0] SecondDigit
);
function [6:0] SevenSegTable(input [3:0] halfbyte);
case(halfbyte)
4'b0000: SevenSegTable = 7'b1000000; // "0"
4'b0001: SevenSegTable = 7'b1111100; // "1"
4'b0010: SevenSegTable = 7'b0100100; // "2"
4'b0011: SevenSegTable = 7'b0110000; // "3"
4'b0100: SevenSegTable = 7'b0011001; // "4"
4'b0101: SevenSegTable = 7'b0010010; // "5"
4'b0110: SevenSegTable = 7'b0000010; // "6"
4'b0111: SevenSegTable = 7'b1111000; // "7"
4'b1000: SevenSegTable = 7'b0000000; // "8"
4'b1001: SevenSegTable = 7'b0010000; // "9"
4'b1010: SevenSegTable = 7'b0001000; // "a"
4'b1011: SevenSegTable = 7'b0000011; // "b"
4'b1100: SevenSegTable = 7'b1000110; // "c"
4'b1101: SevenSegTable = 7'b0100001; // "d"
4'b1110: SevenSegTable = 7'b0000110; // "e"
4'b1111: SevenSegTable = 7'b0001110; // "f"
default: SevenSegTable = 7'b1111111; // nothing
endcase
endfunction
always @(BCD) begin
FirstDigit <= SevenSegTable(BCD[3:0]);
SecondDigit <= SevenSegTable(BCD[7:4]);
end
endmodule