Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Sys (KEY, LEDR, SW, HEX1,HEX2,HEX3,HEX0 );
- input[0:2] KEY;
- input [9:0] SW ;
- output [9:0] LEDR;
- output[6:0] HEX0;
- output[6:0] HEX1;
- output[6:0] HEX2;
- output[6:0] HEX3;
- reg [9:0]out;
- reg [6:0]o;
- assign LEDR = out;
- assign HEX3 = o;
- always
- begin
- if (KEY[0] == 0)
- begin
- out <= SW[9:5] + SW[4:0];
- o <= 7'b1111111;
- end
- else if (KEY[1]== 0 && SW[9:5] > SW[4:0])
- begin
- out <= SW[9:5] - SW[4:0];
- o <= 7'b1111111;
- end
- else if (KEY[1]== 0 && SW[9:5] < SW[4:0])
- begin
- out <= SW[4:0] - SW[9:5];
- o <= 7'b0111111;
- end
- else if (KEY[2] == 0)
- begin
- out <= SW[9:5] * SW[4:0];
- o <= 7'b1111111;
- end
- end
- zamiana ((LEDR / 10) % 10, HEX1);
- zamiana ((LEDR /100) % 10, HEX2);
- zamiana (LEDR % 10, HEX0);
- endmodule
- module zamiana (in,ou);
- input [3:0] in;
- output reg [6:0] ou;
- always
- begin
- if (in == 4'd0)
- ou = 7'b1000000;
- else if (in == 4'd1)
- ou = 7'b1111001;
- else if (in == 4'd2)
- ou = 7'b0100100;
- else if (in == 4'd3)
- ou = 7'b0110000;
- else if (in == 4'd4)
- ou = 7'b0011001;
- else if (in == 4'd5)
- ou = 7'b0010010;
- else if (in == 4'd6)
- ou = 7'b0000010;
- else if (in == 4'd7)
- ou = 7'b1111000;
- else if (in == 4'd8)
- ou = 7'b0000000;
- else if (in == 4'd9)
- ou = 7'b0010000;
- end
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement