-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathasciidecoder.v
More file actions
33 lines (25 loc) · 744 Bytes
/
asciidecoder.v
File metadata and controls
33 lines (25 loc) · 744 Bytes
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
///////////// aus LAB /////////////////////////
module asciidecoder (ascii_in, hex_out);
input [7:0] ascii_in;
output [3:0] hex_out;
reg [3:0] hex_reg;
always @ (ascii_in)
case (ascii_in)
8'h30: hex_reg[3:0] = 4'h0; // 0
8'h31: hex_reg[3:0] = 4'h1; // 1
8'h32: hex_reg[3:0] = 4'h2; // 2
8'h33: hex_reg[3:0] = 4'h3; // 3
8'h34: hex_reg[3:0] = 4'h4; // 4
8'h35: hex_reg[3:0] = 4'h5; // 5
8'h36: hex_reg[3:0] = 4'h6; // 6
8'h37: hex_reg[3:0] = 4'h7; // 7
8'h38: hex_reg[3:0] = 4'h8; // 8
8'h39: hex_reg[3:0] = 4'h9; // 9
8'h57: hex_reg[3:0] = 4'h1; // W
8'h41: hex_reg[3:0] = 4'h2; // A
8'h53: hex_reg[3:0] = 4'h3; // S
8'h44: hex_reg[3:0] = 4'h4; // D
default: hex_reg[3:0] = 4'h0; // default 0
endcase
assign hex_out = hex_reg;
endmodule