所以我目前正在制作一个带有Altera Cyclone III板的单周期微处理器,我正在努力让我的时钟工作。时钟是一个按钮我按下我的电路板,以便将周期推进到下一个MIPS指令,并使用7-seg显示屏将其显示在我的电路板上。这是代码,请注意它很长:
module top(input logic clk, reset, switch, //top module that calls the others to form the processor
output logic [31:0] writedata, dataadr,
output logic memwrite,
output logic [6:0] HEX0, HEX1, HEX2, HEX3,
output logic LED1, LED2);
logic [31:0] pc, instr, readdata;
logic [31:0] rf [31:0];
logic rst, clock;
//logic reset;
// instantiate processor and memories
mips mips1(clk, reset, pc, instr, memwrite, dataadr, writedata, readdata);
imem imem1(pc[7:2], instr);
dmem dmem1(clk, memwrite, dataadr, writedata, readdata);
always
rst <= !reset;
//always
//clock <= !clk;
always
begin
LED1 <= clk;
LED2 <= switch; //at ALU out
if (switch)
begin
//always
case (dataadr[3:0])
4'h0: HEX0 <= 7'b100_0000;
4'h1: HEX0 <= 7'b111_1001;
4'h2: HEX0 <= 7'b010_0100;
4'h3: HEX0 <= 7'b011_0000;
4'h4: HEX0 <= 7'b001_1001;
4'h5: HEX0 <= 7'b001_0010;
4'h6: HEX0 <= 7'b000_0010;
4'h7: HEX0 <= 7'b111_1000;
4'h8: HEX0 <= 7'b000_0000;
4'h9: HEX0 <= 7'b001_0000;
4'hA: HEX0 <= 7'b000_1000;
4'hB: HEX0 <= 7'b000_0011;
4'hC: HEX0 <= 7'b100_0110;
4'hD: HEX0 <= 7'b010_0001;
4'hE: HEX0 <= 7'b000_0110;
4'hF: HEX0 <= 7'b000_1110;
default: HEX0 <= 7'b111_1111;
endcase
//always
case (dataadr[7:4])
4'h0: HEX1 <= 7'b100_0000;
4'h1: HEX1 <= 7'b111_1001;
4'h2: HEX1 <= 7'b010_0100;
4'h3: HEX1 <= 7'b011_0000;
4'h4: HEX1 <= 7'b001_1001;
4'h5: HEX1 <= 7'b001_0010;
4'h6: HEX1 <= 7'b000_0010;
4'h7: HEX1 <= 7'b111_1000;
4'h8: HEX1 <= 7'b000_0000;
4'h9: HEX1 <= 7'b001_0000;
4'hA: HEX1 <= 7'b000_1000;
4'hB: HEX1 <= 7'b000_0011;
4'hC: HEX1 <= 7'b100_0110;
4'hD: HEX1 <= 7'b010_0001;
4'hE: HEX1 <= 7'b000_0110;
4'hF: HEX1 <= 7'b000_1110;
default: HEX1 <= 7'b111_1111;
endcase
//always
case (dataadr[11:8])
4'h0: HEX2 <= 7'b100_0000;
4'h1: HEX2 <= 7'b111_1001;
4'h2: HEX2 <= 7'b010_0100;
4'h3: HEX2 <= 7'b011_0000;
4'h4: HEX2 <= 7'b001_1001;
4'h5: HEX2 <= 7'b001_0010;
4'h6: HEX2 <= 7'b000_0010;
4'h7: HEX2 <= 7'b111_1000;
4'h8: HEX2 <= 7'b000_0000;
4'h9: HEX2 <= 7'b001_0000;
4'hA: HEX2 <= 7'b000_1000;
4'hB: HEX2 <= 7'b000_0011;
4'hC: HEX2 <= 7'b100_0110;
4'hD: HEX2 <= 7'b010_0001;
4'hE: HEX2 <= 7'b000_0110;
4'hF: HEX2 <= 7'b000_1110;
default: HEX2 <= 7'b111_1111;
endcase
//always
case (dataadr[15:12])
4'h0: HEX3 <= 7'b100_0000;
4'h1: HEX3 <= 7'b111_1001;
4'h2: HEX3 <= 7'b010_0100;
4'h3: HEX3 <= 7'b011_0000;
4'h4: HEX3 <= 7'b001_1001;
4'h5: HEX3 <= 7'b001_0010;
4'h6: HEX3 <= 7'b000_0010;
4'h7: HEX3 <= 7'b111_1000;
4'h8: HEX3 <= 7'b000_0000;
4'h9: HEX3 <= 7'b001_0000;
4'hA: HEX3 <= 7'b000_1000;
4'hB: HEX3 <= 7'b000_0011;
4'hC: HEX3 <= 7'b100_0110;
4'hD: HEX3 <= 7'b010_0001;
4'hE: HEX3 <= 7'b000_0110;
4'hF: HEX3 <= 7'b000_1110;
default: HEX3 <= 7'b111_1111;
endcase
end
else if(!switch)
begin
case (instr[3:0])
4'h0: HEX0 <= 7'b100_0000;
4'h1: HEX0 <= 7'b111_1001;
4'h2: HEX0 <= 7'b010_0100;
4'h3: HEX0 <= 7'b011_0000;
4'h4: HEX0 <= 7'b001_1001;
4'h5: HEX0 <= 7'b001_0010;
4'h6: HEX0 <= 7'b000_0010;
4'h7: HEX0 <= 7'b111_1000;
4'h8: HEX0 <= 7'b000_0000;
4'h9: HEX0 <= 7'b001_0000;
4'hA: HEX0 <= 7'b000_1000;
4'hB: HEX0 <= 7'b000_0011;
4'hC: HEX0 <= 7'b100_0110;
4'hD: HEX0 <= 7'b010_0001;
4'hE: HEX0 <= 7'b000_0110;
4'hF: HEX0 <= 7'b000_1110;
default: HEX0 <= 7'b111_1111;
endcase
//always
case (instr[7:4])
4'h0: HEX1 <= 7'b100_0000;
4'h1: HEX1 <= 7'b111_1001;
4'h2: HEX1 <= 7'b010_0100;
4'h3: HEX1 <= 7'b011_0000;
4'h4: HEX1 <= 7'b001_1001;
4'h5: HEX1 <= 7'b001_0010;
4'h6: HEX1 <= 7'b000_0010;
4'h7: HEX1 <= 7'b111_1000;
4'h8: HEX1 <= 7'b000_0000;
4'h9: HEX1 <= 7'b001_0000;
4'hA: HEX1 <= 7'b000_1000;
4'hB: HEX1 <= 7'b000_0011;
4'hC: HEX1 <= 7'b100_0110;
4'hD: HEX1 <= 7'b010_0001;
4'hE: HEX1 <= 7'b000_0110;
4'hF: HEX1 <= 7'b000_1110;
default: HEX1 <= 7'b111_1111;
endcase
//always
case (instr[11:8])
4'h0: HEX2 <= 7'b100_0000;
4'h1: HEX2 <= 7'b111_1001;
4'h2: HEX2 <= 7'b010_0100;
4'h3: HEX2 <= 7'b011_0000;
4'h4: HEX2 <= 7'b001_1001;
4'h5: HEX2 <= 7'b001_0010;
4'h6: HEX2 <= 7'b000_0010;
4'h7: HEX2 <= 7'b111_1000;
4'h8: HEX2 <= 7'b000_0000;
4'h9: HEX2 <= 7'b001_0000;
4'hA: HEX2 <= 7'b000_1000;
4'hB: HEX2 <= 7'b000_0011;
4'hC: HEX2 <= 7'b100_0110;
4'hD: HEX2 <= 7'b010_0001;
4'hE: HEX2 <= 7'b000_0110;
4'hF: HEX2 <= 7'b000_1110;
default: HEX2 <= 7'b111_1111;
endcase
//always
case (instr[15:12])
4'h0: HEX3 <= 7'b100_0000;
4'h1: HEX3 <= 7'b111_1001;
4'h2: HEX3 <= 7'b010_0100;
4'h3: HEX3 <= 7'b011_0000;
4'h4: HEX3 <= 7'b001_1001;
4'h5: HEX3 <= 7'b001_0010;
4'h6: HEX3 <= 7'b000_0010;
4'h7: HEX3 <= 7'b111_1000;
4'h8: HEX3 <= 7'b000_0000;
4'h9: HEX3 <= 7'b001_0000;
4'hA: HEX3 <= 7'b000_1000;
4'hB: HEX3 <= 7'b000_0011;
4'hC: HEX3 <= 7'b100_0110;
4'hD: HEX3 <= 7'b010_0001;
4'hE: HEX3 <= 7'b000_0110;
4'hF: HEX3 <= 7'b000_1110;
default: HEX3 <= 7'b111_1111;
endcase
end
end
endmodule
我已分配引脚(BOARD IS EP3C16F484C6),但仍然没有任何反应。我想知道时钟是否进展顺利或重置按钮是否影响它。我只需要能够使用按下的按钮推进时钟周期并能够重置它。有任何想法吗?询问您是否需要更多代码,我很乐意提供。