Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module convert (input [3:0] in,
- output reg [3:0] out);
- // Converts 0-15 into the 0th - 15th character of "AAC0FFEEA15A900D" respectively
- always @ * begin
- case (in) // AAC0FFEEA15A900D, we are using 'A' as space
- 4'd0: out = 4'hA;
- 4'd1: out = 4'hA;
- 4'd2: out = 4'hC;
- 4'd3: out = 4'h0;
- 4'd4: out = 4'hF;
- 4'd5: out = 4'hF;
- 4'd6: out = 4'hE;
- 4'd7: out = 4'hE;
- 4'd8: out = 4'hA;
- 4'd9: out = 4'h1;
- 4'd10: out = 4'h4;
- 4'd11: out = 4'hA;
- 4'd12: out = 4'h9;
- 4'd13: out = 4'h0;
- 4'd14: out = 4'h0;
- 4'd15: out = 4'hD;
- default: out = 4'hA;
- endcase
- end
- endmodule
- module scroll(input clk, rst,
- output [15:0] display);
- reg [3:0] count;
- always @ (posedge clk) begin
- if (rst)
- count <= 4'd0;
- else
- count <= count + 1'b1;
- end
- // Count goes from 0 to 15, 1 step per clock cycle
- wire [3:0] a, b, c, d;
- assign a = count;
- assign b = count+1;
- assign c = count+2;
- assign d = count+3;
- // a,b,c,d is 4 consecutive numbers starting from count (with loop-around so 16->0)
- convert c1 (a, display[15:12]);
- convert c2 (b, display[11:8]);
- convert c3 (c, display[7:4]);
- convert c4 (d, display[3:0]);
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement