1 |
4 |
sssayeekum |
`timescale 1ns / 1ps
|
2 |
|
|
//////////////////////////////////////////////////////////////////////////////////
|
3 |
|
|
// Company:
|
4 |
|
|
// Engineer:
|
5 |
|
|
//
|
6 |
|
|
// Create Date: 20:43:16 06/12/2022
|
7 |
|
|
// Design Name:
|
8 |
|
|
// Module Name: M3CPU8
|
9 |
|
|
// Project Name:
|
10 |
|
|
// Target Devices:
|
11 |
|
|
// Tool versions:
|
12 |
|
|
// Description:
|
13 |
|
|
//
|
14 |
|
|
// Dependencies:
|
15 |
|
|
//
|
16 |
|
|
// Revision:
|
17 |
|
|
// Revision 0.01 - File Created
|
18 |
|
|
// Additional Comments:
|
19 |
|
|
//
|
20 |
|
|
//////////////////////////////////////////////////////////////////////////////////
|
21 |
|
|
module M3CPU8(input clk , input rst , output [3:0] PC_o , output [3:0] MAR_o , output [8:0] SRAM_o , output [4:0] IR_o_1 , output [3:0] IR_o_2 , output [3:0] AR_o , output [3:0] PRE_o , output [4:0] ROM_o , output [4:0] NANO_PRE_o , output [16:0] NANO_ROM_o, output EP_o , output CP_o , output LM_o , output CE_o , output LI_o , output EI_o , output CS_o , output LA_o , output EA_o , output SU_o , output AD_o , output EU_o , output LB_o , output LO_o , output LOAD_MICRO_o , output CLEAR_MICRO_o , output INC_MICRO_o , output [8:0] B_out , output [8:0] ALU_out , output [8:0] A_out , output [8:0] OR_out);
|
22 |
|
|
wire [3:0] bus_4 , bus_4_1 , SRAM_IN;
|
23 |
|
|
wire [8:0] bus_8 , bus_8_1 , bus_8_2 , ALU_IN_A , ALU_IN_B, OREG_IN;
|
24 |
|
|
wire [4:0] AR_IN , MICRO_ROM_IN , PRE_IN;
|
25 |
|
|
wire [5:0] NANO_PRE_IN , NANO_ROM_IN;
|
26 |
|
|
wire [16:0] NANO_DEC_IN;
|
27 |
|
|
wire EP_w , CP_w , LM_w , CE_w , LI_w , EI_w , CS_w , LA_w , EA_w , SU_w , AD_w , EU_w , LB_w , LO_w , LOAD_MICRO_w , INC_MICRO_w , CLEAR_MICRO_w;
|
28 |
|
|
assign PC_o = bus_4;
|
29 |
|
|
assign MAR_o = SRAM_IN;
|
30 |
|
|
assign SRAM_o = bus_8;
|
31 |
|
|
assign IR_o_1 = AR_IN;
|
32 |
|
|
assign IR_o_2 = bus_4_1;
|
33 |
|
|
assign AR_o = PRE_IN;
|
34 |
|
|
assign PRE_o = MICRO_ROM_IN;
|
35 |
|
|
assign ROM_o = NANO_PRE_IN;
|
36 |
|
|
assign NANO_PRE_o = NANO_ROM_IN;
|
37 |
|
|
assign NANO_ROM_o = NANO_DEC_IN;
|
38 |
|
|
assign EP_o = EP_w;
|
39 |
|
|
assign CP_o = CP_w;
|
40 |
|
|
assign LM_o = LM_w;
|
41 |
|
|
assign CE_o = CE_w;
|
42 |
|
|
assign LI_o = LI_w;
|
43 |
|
|
assign EI_o = EI_w;
|
44 |
|
|
assign CS_o = CS_w;
|
45 |
|
|
assign LA_o = LA_w;
|
46 |
|
|
assign EA_o = EA_w;
|
47 |
|
|
assign SU_o = SU_w;
|
48 |
|
|
assign AD_o = AD_w;
|
49 |
|
|
assign EU_o = EU_w;
|
50 |
|
|
assign LB_o = LB_w;
|
51 |
|
|
assign LO_o = LO_w;
|
52 |
|
|
assign LOAD_MICRO_o = LOAD_MICRO_w;
|
53 |
|
|
assign INC_MICRO_o = INC_MICRO_w;
|
54 |
|
|
assign CLEAR_MICRO_o = CLEAR_MICRO_w;
|
55 |
|
|
assign B_out = ALU_IN_B;
|
56 |
|
|
assign A_out = ALU_IN_A;
|
57 |
|
|
assign ALU_out = bus_8_1;
|
58 |
|
|
assign OR_out = OREG_IN;
|
59 |
|
|
|
60 |
|
|
PC UUT1(.clk(clk) , .rst(rst) , .EP(EP_w) , .CP(CP_w) , .PC_OUT(bus_4));
|
61 |
|
|
MAR UUT2(.clk(clk) , .LM(LM_w) , .PC_IN(bus_4 | bus_4_1) , .MAR_OUT(SRAM_IN));
|
62 |
|
|
SRAM UUT3(.CE(CE_w) , .MAR_IN(SRAM_IN) , .SRAM_OUT(bus_8));
|
63 |
|
|
IR UUT4(.clk(clk) , .LI(LI_w) , .EI(EI_w) , .SRAM_IN(bus_8) , .IR_OUT_1(AR_IN) , .IR_OUT_2(bus_4_1));
|
64 |
|
|
ADDR_ROM UUT5(.IR_OUT(AR_IN) , .CS(CS_w) , .AR_OUT(PRE_IN));
|
65 |
|
|
MICRO_PROG_COUNTER UUT6(.clk(clk) , .rst(rst) , .AR_ROM_IN(PRE_IN) , .LOAD_MICRO(LOAD_MICRO_w) , .INC_MICRO(INC_MICRO_w) , .CLEAR_MICRO(CLEAR_MICRO_w) , .PRE_OUT(MICRO_ROM_IN));
|
66 |
|
|
MICROCODE_ROM UUT7(.PRE_IN(MICRO_ROM_IN) , .ROM_OUT(NANO_PRE_IN));
|
67 |
|
|
NANO_PROG_COUNTER UUT8(.MCR_IN(NANO_PRE_IN),.NANO_PRE_OUT(NANO_ROM_IN));
|
68 |
|
|
NANOCODE_ROM UUT9 (.NANO_PRE_IN(NANO_ROM_IN) , .NANO_ROM_OUT(NANO_DEC_IN));
|
69 |
|
|
NANOCODE_DECODER UUT10(.NANO_ROM_IN(NANO_DEC_IN) , .EP_o(EP_w), .CP_o(CP_w) , .LM_o(LM_w) , .CE_o(CE_w) , .LI_o(LI_w) , .EI_o(EI_w) , .CS_o(CS_w) , .LA_o(LA_w) , .EA_o(EA_w) , .SU_o(SU_w) , .AD_o(AD_w) , .EU_o(EU_w) , .LB_o(LB_w) , .LO_o(LO_w) , .LOAD_MICRO_o(LOAD_MICRO_w) , .CLEAR_MICRO_o(CLEAR_MICRO_w) , .INC_MICRO_o(INC_MICRO_w));
|
70 |
|
|
ACC UUT11(.clk(clk) , .ACC_IN(bus_8 | bus_8_1) , .LA(LA_w) , .EA(EA_w) , .ACC_ALU(ALU_IN_A) , .ACC_BUS(bus_8_2));
|
71 |
|
|
BREG UUT12(.clk , .B_IN(bus_8) , .LB(LB_w) , .B_OUT(ALU_IN_B));
|
72 |
|
|
ALU UUT13(.ALU_A(ALU_IN_A) , .ALU_B(ALU_IN_B) , .SU(SU_w) , .AD(AD_w) , .EU(EU_w) , .ALU_OUT(bus_8_1));
|
73 |
|
|
OREG UUT14(.clk(clk) , .O_IN(bus_8_2) , .LO(LO_w) , .O_OUT(OREG_IN));
|
74 |
|
|
endmodule
|
75 |
|
|
|
76 |
|
|
module PC(input clk , input rst , input EP , input CP , output[3:0] PC_OUT);
|
77 |
|
|
reg [3:0] PC_OUT_r;
|
78 |
|
|
assign PC_OUT = EP ? PC_OUT_r: 4'h0;
|
79 |
|
|
always@(posedge clk or posedge rst)
|
80 |
|
|
begin
|
81 |
|
|
if(rst)
|
82 |
|
|
PC_OUT_r <= 4'h0;
|
83 |
|
|
else if(CP)
|
84 |
|
|
PC_OUT_r <= PC_OUT_r + 1'b1;
|
85 |
|
|
end
|
86 |
|
|
endmodule
|
87 |
|
|
|
88 |
|
|
module MAR(input clk , input LM , input [3:0] PC_IN , output [3:0] MAR_OUT);
|
89 |
|
|
reg [3:0] MAR_r;
|
90 |
|
|
assign MAR_OUT = MAR_r;
|
91 |
|
|
always@(posedge clk)
|
92 |
|
|
begin
|
93 |
|
|
if(~LM)
|
94 |
|
|
MAR_r <= PC_IN;
|
95 |
|
|
end
|
96 |
|
|
endmodule
|
97 |
|
|
|
98 |
|
|
module SRAM(input CE , input [3:0] MAR_IN , output[8:0] SRAM_OUT);
|
99 |
|
|
reg [8:0] SRAM_r [15:0];
|
100 |
|
|
assign SRAM_OUT = (~CE) ? SRAM_r[MAR_IN] : 9'h000;
|
101 |
|
|
always@(MAR_IN)
|
102 |
|
|
begin
|
103 |
|
|
SRAM_r[0] <= 9'b000001001;// LDA 09
|
104 |
|
|
SRAM_r[1] <= 9'b000011010; // ADD 0A
|
105 |
|
|
SRAM_r[2] <= 9'b000101011; // SUB 0B
|
106 |
|
|
SRAM_r[3] <= 9'b000111111; // OUT
|
107 |
|
|
SRAM_r[4] <= 9'b111111111; // Unused memory locations to be filled with FF
|
108 |
|
|
SRAM_r[5] <= 9'b111111111; // Unused memory locations to be filled with FF
|
109 |
|
|
SRAM_r[6] <= 9'b111111111; // Unused memory locations to be filled with FF
|
110 |
|
|
SRAM_r[7] <= 9'b111111111; // Unused memory locations to be filled with FF
|
111 |
|
|
SRAM_r[8] <= 9'b111111111; // Unused memory locations to be filled with FF
|
112 |
|
|
SRAM_r[9] <= 9'b000000001; // Content of Location 9
|
113 |
|
|
SRAM_r[10] <= 9'b000000010; // Content of Location A
|
114 |
|
|
SRAM_r[11] <= 9'b000000001; // Content of Location B
|
115 |
|
|
SRAM_r[12] <= 9'b111111111; // Unused memory locations to be filled with FF
|
116 |
|
|
SRAM_r[13] <= 9'b111111111; // Unused memory locations to be filled with FF
|
117 |
|
|
SRAM_r[14] <= 9'b111111111; // Unused memory locations to be filled with FF
|
118 |
|
|
SRAM_r[15] <= 9'b111111111; // Unused memory locations to be filled with FF
|
119 |
|
|
end
|
120 |
|
|
endmodule
|
121 |
|
|
|
122 |
|
|
module IR(input clk , input LI , input EI , input [8:0] SRAM_IN , output [4:0] IR_OUT_1 , output [3:0] IR_OUT_2);
|
123 |
|
|
reg [8:0] IR_OUT_r;
|
124 |
|
|
assign IR_OUT_1 = IR_OUT_r[8:4];
|
125 |
|
|
assign IR_OUT_2 = EI ? IR_OUT_r[3:0] : 4'h0;
|
126 |
|
|
always@(posedge clk)
|
127 |
|
|
begin
|
128 |
|
|
if(~LI)
|
129 |
|
|
IR_OUT_r <= SRAM_IN;
|
130 |
|
|
end
|
131 |
|
|
endmodule
|
132 |
|
|
|
133 |
|
|
module ADDR_ROM(input [4:0] IR_OUT , input CS , output [4:0] AR_OUT);// Holds the Micro-routine for a Macro-Instruction fetched from SRAM
|
134 |
|
|
reg [4:0] AR_OUT_r[15:0];
|
135 |
|
|
assign AR_OUT = AR_OUT_r[IR_OUT];// Instruction Fetched from IR serves as the address for reading data from Address ROM. The output of Address ROM is the starting address of a Micro-Routine.
|
136 |
|
|
always@(CS) // Whenever the CS[Chip Select] signal is activated , content of a ROM address will be output.
|
137 |
|
|
begin
|
138 |
|
|
AR_OUT_r[0] <= 5'b00100;
|
139 |
|
|
AR_OUT_r[1] <= 5'b00111;
|
140 |
|
|
AR_OUT_r[2] <= 5'b01100;
|
141 |
|
|
AR_OUT_r[3] <= 5'b10001;
|
142 |
|
|
AR_OUT_r[4] <= 5'hFF;
|
143 |
|
|
AR_OUT_r[5] <= 5'hFF;
|
144 |
|
|
AR_OUT_r[6] <= 5'hFF;
|
145 |
|
|
AR_OUT_r[7] <= 5'hFF;
|
146 |
|
|
AR_OUT_r[8] <= 5'hFF;
|
147 |
|
|
AR_OUT_r[9] <= 5'hFF;
|
148 |
|
|
AR_OUT_r[10] <= 5'hFF;
|
149 |
|
|
AR_OUT_r[11] <= 5'hFF;
|
150 |
|
|
AR_OUT_r[12] <= 5'hFF;
|
151 |
|
|
AR_OUT_r[13] <= 5'hFF;
|
152 |
|
|
AR_OUT_r[14] <= 5'hFF;
|
153 |
|
|
AR_OUT_r[15] <= 5'hFF;
|
154 |
|
|
end
|
155 |
|
|
endmodule
|
156 |
|
|
|
157 |
|
|
module MICRO_PROG_COUNTER (input clk , input rst , input [4:0] AR_ROM_IN , input LOAD_MICRO , input INC_MICRO , input CLEAR_MICRO , output [4:0] PRE_OUT); // This is called Microprogram Counter
|
158 |
|
|
reg [4:0] PRE_OUT_r;
|
159 |
|
|
assign PRE_OUT = PRE_OUT_r;
|
160 |
|
|
always@(posedge clk or posedge rst) // Signals separated by "or" in sensitivity list of "always" statement are Asynchronous.
|
161 |
|
|
begin
|
162 |
|
|
if(rst)
|
163 |
|
|
PRE_OUT_r <= 5'h00;
|
164 |
|
|
else if(LOAD_MICRO)
|
165 |
|
|
PRE_OUT_r <= AR_ROM_IN;
|
166 |
|
|
else if(INC_MICRO)
|
167 |
|
|
PRE_OUT_r <= PRE_OUT_r + 1'b1;
|
168 |
|
|
else if(CLEAR_MICRO) // Difference between RST and CLR is RST is asynchronous signal[Occurs independent of clock edge] whereas CLR is Synchronous signal[i.e. occurs when a clock edge has occured]
|
169 |
|
|
PRE_OUT_r <= 5'h00;
|
170 |
|
|
end
|
171 |
|
|
endmodule
|
172 |
|
|
|
173 |
|
|
module MICROCODE_ROM(input [4:0] PRE_IN , output [5:0] ROM_OUT); // Vertical Microcode ROM
|
174 |
|
|
reg [5:0] ROM_OUT_r[19:0];
|
175 |
|
|
assign ROM_OUT = ROM_OUT_r[PRE_IN];// The output of PRESETTABLE COUNTER acts as the input for reading the content of MICROCODE ROM
|
176 |
|
|
always@(PRE_IN)
|
177 |
|
|
begin
|
178 |
|
|
// CP EP LM CE LI EI CS LOAD INC CLR LA EA SU EU LB LO
|
179 |
|
|
// |------- M1------------------|----------M2-----------------|------LOAD-----|------INC-----|--------CLR--------|
|
180 |
|
|
// 8 7 6 5 4 3 2 1 0
|
181 |
|
|
// 0 0 0 (EP) 0 0 0 (LI)
|
182 |
|
|
// 0 0 1 (CP) 0 0 1 (LM)
|
183 |
|
|
// 0 1 0 (CE) 0 1 0 (LB)
|
184 |
|
|
// 0 1 1 (EI) 0 1 1 (LO)
|
185 |
|
|
// 1 0 0 (CS) 1 0 0 (LA)
|
186 |
|
|
// 1 0 1 (EA) 1 0 1 (SU)
|
187 |
|
|
// 1 1 0 (EU) 1 1 0 (AD)
|
188 |
|
|
// 1 1 1 (NOP) 1 1 1 (NOP)
|
189 |
|
|
|
190 |
|
|
// Fetch Routine
|
191 |
|
|
ROM_OUT_r[0] <= 6'b000000;// EP and LM activated and Preset Counter Incremented
|
192 |
|
|
ROM_OUT_r[1] <= 6'b000001; // CP activated and Preset Counter Incremented
|
193 |
|
|
ROM_OUT_r[2] <= 6'b000010; // CE and LI activated and Preset Counter Incremented
|
194 |
|
|
ROM_OUT_r[3] <= 6'b000011; // CS and LOAD activated
|
195 |
|
|
// LDA Routine
|
196 |
|
|
ROM_OUT_r[4] <= 6'b000100; // EI and LM activated and Preset Counter Incremented
|
197 |
|
|
ROM_OUT_r[5] <= 6'b000101; // CE and LA activated and Preset Counter Incremented
|
198 |
|
|
ROM_OUT_r[6] <= 6'b000110; // Preset CLR
|
199 |
|
|
// ADD Routine
|
200 |
|
|
ROM_OUT_r[7] <= 6'b000100; // EI and LM activated and Preset Counter Incremented
|
201 |
|
|
ROM_OUT_r[8] <= 6'b000111; // CE and LB activated and Preset Counter Incremented
|
202 |
|
|
ROM_OUT_r[9] <= 6'b001000; // AD activated and Preset Counter Incremented
|
203 |
|
|
ROM_OUT_r[10] <= 6'b001001; // EU and LA activated and Preset Counter Incremented
|
204 |
|
|
ROM_OUT_r[11] <= 6'b000110; // Preset CLR
|
205 |
|
|
// SUB Routine
|
206 |
|
|
ROM_OUT_r[12] <= 6'b000100; // EI and LM activated and Preset Counter Incremented
|
207 |
|
|
ROM_OUT_r[13] <= 6'b000111; // CE and LB activated and Preset Counter Incremented
|
208 |
|
|
ROM_OUT_r[14] <= 6'b001010; // SU activated and Preset Counter Incremented
|
209 |
|
|
ROM_OUT_r[15] <= 6'b001001; // EU and LA activated and Preset Counter Incremented
|
210 |
|
|
ROM_OUT_r[16] <= 6'b000110; // Preset CLR. Actually this CPU requires 4-bit Address for SRAM and 5-bit address for Microcode ROM. So that needs to be changed.
|
211 |
|
|
// OUT Routine
|
212 |
|
|
ROM_OUT_r[17] <= 6'b000100; // EI and LM activated and Preset Counter Incremented
|
213 |
|
|
ROM_OUT_r[18] <= 6'b001011; // EA and LO activated and Preset Counter Incremented
|
214 |
|
|
ROM_OUT_r[19] <= 6'b000110; // Preset CLR
|
215 |
|
|
end
|
216 |
|
|
endmodule
|
217 |
|
|
|
218 |
|
|
module NANO_PROG_COUNTER (input [5:0] MCR_IN , output [5:0] NANO_PRE_OUT);
|
219 |
|
|
reg [5:0] NANO_PRE_OUT_r;
|
220 |
|
|
assign NANO_PRE_OUT = NANO_PRE_OUT_r;
|
221 |
|
|
always@(MCR_IN)
|
222 |
|
|
begin
|
223 |
|
|
NANO_PRE_OUT_r <= MCR_IN;
|
224 |
|
|
end
|
225 |
|
|
endmodule
|
226 |
|
|
|
227 |
|
|
module NANOCODE_ROM(input [5:0] NANO_PRE_IN , output [16:0] NANO_ROM_OUT); // Horizontal Microcode Control ROM
|
228 |
|
|
reg [16:0] NANO_ROM_OUT_r[11:0];
|
229 |
|
|
assign NANO_ROM_OUT = NANO_ROM_OUT_r[NANO_PRE_IN];
|
230 |
|
|
always@(NANO_PRE_IN)
|
231 |
|
|
begin
|
232 |
|
|
// Fetch Nanoroutine
|
233 |
|
|
// EP CP LM CE LI EI CS LA EA SU AD EU LB LO LOAD_MICRO CLEAR_MICRO INC_MICRO
|
234 |
|
|
// 1 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 1 - EP , LM and INC_MICRO activated
|
235 |
|
|
// 0 1 1 1 1 0 0 1 0 0 0 0 1 1 0 0 1 - CP and INC_MICRO activated
|
236 |
|
|
// 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 1 - CE , LI and INC_MICRO activated
|
237 |
|
|
// 0 0 1 1 1 0 1 1 0 0 0 0 1 1 1 0 0 - CS , LOAD_MICRO activated
|
238 |
|
|
// 0 0 0 1 1 1 0 1 0 0 0 0 1 1 0 0 1 - EI , LM and INC_MICRO activated
|
239 |
|
|
// 0 0 1 0 1 0 0 0 0 0 0 0 1 1 0 0 1 - CE* , LA* and INC_MICRO activated
|
240 |
|
|
// 0 0 1 1 1 0 0 1 0 0 0 0 1 1 0 1 0 - CLEAR_MICRO activated
|
241 |
|
|
// 0 0 1 0 1 0 0 1 0 0 0 0 0 1 0 0 1 - CE* , LB* and INC_MICRO activated
|
242 |
|
|
// 0 0 1 1 1 0 0 1 0 0 1 0 1 1 0 0 1 - AD and INC_MICRO activated
|
243 |
|
|
// 0 0 1 1 1 0 0 1 0 1 0 0 1 1 0 0 1 - SU and INC_MICRO activated
|
244 |
|
|
// 0 0 1 1 1 0 0 0 0 0 0 1 1 1 0 0 1 - EU,LA* and INC_MICRO activated
|
245 |
|
|
// 0 0 1 1 1 0 0 1 1 0 0 0 1 0 0 0 1 - EA,LO* and INC_MICRO activated
|
246 |
|
|
NANO_ROM_OUT_r[0] <= 17'b10011001000011001; // EP , LM* and INC_MICRO activated
|
247 |
|
|
NANO_ROM_OUT_r[1] <= 17'b01111001000011001; // CP and INC_MICRO activated
|
248 |
|
|
NANO_ROM_OUT_r[2] <= 17'b00100001000011001; // CE* , LI* and INC_MICRO activated
|
249 |
|
|
NANO_ROM_OUT_r[3] <= 17'b00111011000011100; // CS,LOAD_MICRO activated
|
250 |
|
|
NANO_ROM_OUT_r[4] <= 17'b00011101000011001; // EI,LM* and INC_MICRO activated
|
251 |
|
|
NANO_ROM_OUT_r[5] <= 17'b00101000000011001; // CE* , LA* and INC_MICRO activated
|
252 |
|
|
NANO_ROM_OUT_r[6] <= 17'b00111001000011010; // CLEAR_MICRO activated
|
253 |
|
|
NANO_ROM_OUT_r[7] <= 17'b00101001000001001; // CE* , LB* and INC_MICRO activated
|
254 |
|
|
NANO_ROM_OUT_r[8] <= 17'b00111001001011001; // AD and INC_MICRO activated
|
255 |
|
|
NANO_ROM_OUT_r[9] <= 17'b00111000000111001; // EU,LA* and INC_MICRO activated
|
256 |
|
|
NANO_ROM_OUT_r[10] <= 17'b00111001010011001; // SU and INC_MICRO activated
|
257 |
|
|
NANO_ROM_OUT_r[11] <= 17'b00111001100010001; // EA,LO* and INC_MICRO activated
|
258 |
|
|
end
|
259 |
|
|
endmodule
|
260 |
|
|
|
261 |
|
|
module NANOCODE_DECODER(input [16:0] NANO_ROM_IN , output EP_o , output CP_o , output LM_o , output CE_o , output LI_o , output EI_o , output CS_o , output LA_o , output EA_o , output SU_o , output AD_o , output EU_o , output LB_o , output LO_o , output LOAD_MICRO_o , output CLEAR_MICRO_o , output INC_MICRO_o);
|
262 |
|
|
assign EP_o = NANO_ROM_IN[16];
|
263 |
|
|
assign CP_o = NANO_ROM_IN[15];
|
264 |
|
|
assign LM_o = NANO_ROM_IN[14];
|
265 |
|
|
assign CE_o = NANO_ROM_IN[13];
|
266 |
|
|
assign LI_o = NANO_ROM_IN[12];
|
267 |
|
|
assign EI_o = NANO_ROM_IN[11];
|
268 |
|
|
assign CS_o = NANO_ROM_IN[10];
|
269 |
|
|
assign LA_o = NANO_ROM_IN[9];
|
270 |
|
|
assign EA_o = NANO_ROM_IN[8];
|
271 |
|
|
assign SU_o = NANO_ROM_IN[7];
|
272 |
|
|
assign AD_o = NANO_ROM_IN[6];
|
273 |
|
|
assign EU_o = NANO_ROM_IN[5];
|
274 |
|
|
assign LB_o = NANO_ROM_IN[4];
|
275 |
|
|
assign LO_o = NANO_ROM_IN[3];
|
276 |
|
|
assign LOAD_MICRO_o = NANO_ROM_IN[2];
|
277 |
|
|
assign CLEAR_MICRO_o = NANO_ROM_IN[1];
|
278 |
|
|
assign INC_MICRO_o = NANO_ROM_IN[0];
|
279 |
|
|
endmodule
|
280 |
|
|
|
281 |
|
|
module ACC(input clk , input [8:0] ACC_IN , input LA , input EA , output [8:0] ACC_ALU , output [8:0] ACC_BUS);
|
282 |
|
|
reg[8:0] ACC_r;
|
283 |
|
|
assign ACC_ALU = ACC_r;
|
284 |
|
|
assign ACC_BUS = EA ? ACC_r : 9'h000;
|
285 |
|
|
always@(posedge clk)
|
286 |
|
|
begin
|
287 |
|
|
if(~LA)
|
288 |
|
|
ACC_r <= ACC_IN;
|
289 |
|
|
end
|
290 |
|
|
endmodule
|
291 |
|
|
|
292 |
|
|
module BREG(input clk , input [8:0] B_IN , input LB , output [8:0] B_OUT);
|
293 |
|
|
reg [8:0] B_OUT_r;
|
294 |
|
|
assign B_OUT = B_OUT_r;
|
295 |
|
|
always@(posedge clk)
|
296 |
|
|
begin
|
297 |
|
|
if(~LB)
|
298 |
|
|
B_OUT_r <= B_IN;
|
299 |
|
|
end
|
300 |
|
|
endmodule
|
301 |
|
|
|
302 |
|
|
module ALU(input[8:0] ALU_A , input[8:0] ALU_B , input SU , input AD , input EU , output[8:0] ALU_OUT);
|
303 |
|
|
wire [8:0] ALU_OUT_w;
|
304 |
|
|
assign ALU_OUT_w = SU ? ALU_A - ALU_B : AD ? ALU_A + ALU_B : ALU_OUT_w;
|
305 |
|
|
assign ALU_OUT = EU ? ALU_OUT_w : 9'h000;
|
306 |
|
|
endmodule
|
307 |
|
|
|
308 |
|
|
module OREG(input clk , input [8:0] O_IN , input LO , output [8:0] O_OUT);
|
309 |
|
|
reg [8:0] O_OUT_r;
|
310 |
|
|
assign O_OUT = O_OUT_r;
|
311 |
|
|
always@(posedge clk)
|
312 |
|
|
begin
|
313 |
|
|
if(~LO)
|
314 |
|
|
O_OUT_r <= O_IN;
|
315 |
|
|
end
|
316 |
|
|
endmodule
|
317 |
|
|
|
318 |
|
|
|