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
| module ALU_4bit_template(clock_50,key0,key1,hex5,hex4,sw0,sw1,sw2,sw3,sw4,sw5,sw6,led_clk_reg,led_clr, led_sw, led_add_cout, led_sub_cout); //(don't change)
// Define Port Declarations with pin numbers (don't change)
(* chip_pin = "E22"*) output led_clr; // LED G1
(* chip_pin = "E21"*) output led_clk_reg; // LED G0
(* chip_pin = "E25"*) output led_add_cout; // LED G2
(* chip_pin = "E24"*) output led_sub_cout; // LED G3
(* chip_pin = "J19,E18,F18,F21,E19,F19,G19"*) output [6:0]led_sw; // LED R0 - R6
/////////////////////////////////////////////////////////////////////////////////////
// you need to add the pin numbesr to these ones!
input clock_50;
input key0;
input key1;
input sw0;
input sw1;
input sw2;
input sw3;
input sw4;
input sw5;
input sw6;
output [6:0] hex4;
output [6:0] hex5;
/////////////////////////////////////////////////////////////////////////////////////
// define internal signals (don't change)
wire clk_reg, nclr;
wire [3:0] aux_bus, acc_bus;
wire [2:0] instr_bus;
/////////////////////////////////////////////////////////////////////////////////////
// define your own internal wires here
/////////////////////////////////////////////////////////////////////////////////////
// connect switches to aux bus (don't change)
assign aux_bus[0] = sw0;
assign aux_bus[1] = sw1;
assign aux_bus[2] = sw2;
assign aux_bus[3] = sw3;
// connect switches to instr_bus (don't change)
assign instr_bus[0] = sw4;
assign instr_bus[1] = sw5;
assign instr_bus[2] = sw6;
// connect leds to switches and keys (don't change)
assign led_sw[0] = sw0;
assign led_sw[1] = sw1;
assign led_sw[2] = sw2;
assign led_sw[3] = sw3;
assign led_sw[4] = sw4;
assign led_sw[5] = sw5;
assign led_sw[6] = sw6;
assign nclr = key1;
assign led_clk_reg = clk_reg;
assign led_clr = nclr;
/////////////////////////////////////////////////////////////////////////////////////
// define clk_gen
clk_gen u1 (.clk(clock_50),.nclr(nclr), .sw_press(key0),.clk_reg(clk_reg));
/////////////////////////////////////////////////////////////////////////////////////
// define 7 seg drivers for hex4, hex5 (don't change)
seven_seg u2(.data_in(acc_bus), .data_out(hex4)); // acc_bus output
seven_seg u3(.data_in(aux_bus), .data_out(hex5)); // aux_bus output
/////////////////////////////////////////////////////////////////////////////////////
// define your logic units here
// Note connect the cout signal from the adder and subtraction unit to the following signals led_add_cout, led_sub_cout respectively.
// To set a signal to logic-1 you can use 1’b1, or to logic-0 you can use 1’b0.
/////////////////////////////////////////////////////////////////////////////////////
// define your mux here
/////////////////////////////////////////////////////////////////////////////////////
// define acc register here
endmodule |