Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //CircuitA ze schematu
- module Circuit_zad_4(input [3:0] a, b,
- input cin,
- output reg [3:0] out);
- always@*
- begin
- out = (a + b + cin) % 10;
- end
- endmodule
- //Multiplekser
- module mux21 (
- input x,y,s,
- output m
- );
- assign m = (~s & x) | (s & y);
- endmodule
- //Moduł odpowiedzialny za dodawanie
- module adder_BCD_2_digits_zad5(input [3:0] a, b,
- input cin,
- output [3:0]s0,
- output reg [3:0]s1,
- output reg err1, err2);
- wire[3:0] out_a, x;
- reg[3:0] z, temp;
- always @*
- begin
- s1 = 0;
- err1 = 0;
- err2 = 0;
- if (a > 9)
- err1 = 1;
- if(b > 9)
- err2 = 2;
- else
- begin
- temp = a + b + cin;
- if (temp > 9)
- begin
- z = 1;
- s1 = 1;
- end
- else
- begin
- z = 0;
- s1 = 0;
- end
- end
- end
- Circuit_zad_4 ex(a, b, cin, out_a);
- mux214 ex2(temp, out_a, z[0], x);
- assign s0 = x;
- endmodule
- //Główny na plytke
- module symulacja_zad_4(
- input [8:0]SW,
- output [0:6]HEX0, HEX1, HEX3, HEX5,
- output [9:0]LEDR);
- wire [3:0] out1, out2;
- assign LEDR[7:0] = SW[7:0];
- adder_BCD_2_digits_zad5(SW[3:0], SW[7:4], SW[8], out1, out2, LEDR[8], LEDR[9]);
- decoder_hex_10 ex2(out2, HEX1);
- decoder_hex_10 ex3(out1, HEX0);
- decoder_hex_10 ex4(SW[7:4], HEX5);
- decoder_hex_10 ex5(SW[3:0], HEX3);
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement