【FPGA】MIPS 12条整数指令【1】

目录

 修改后的仿真结果

修改后的完整代码 


实现bgtz、bltz、jalr

仿真结果(有问题)

bltz------并未跳转,jCe?

原因是该条跳转语句判断的寄存器r7,在该时刻并未被赋值

代码(InstMem修改前)

`include "define.v"
module InstMem(input wire ce,input wire [31:0] addr,output reg [31:0] data
);reg [31:0] instmem [1023 : 0];    always@(*)      if(ce == `RomDisable)data = `Zero;elsedata = instmem[addr[11 : 2]];   initialbegininstmem [0] = 32'h34011100;   //ori r1,r0,1100h         r1--32'h0000 1100instmem [1] = 32'h34020020;   //ori r2,r0,0020h		r2--32'h0000 0020instmem [2] = 32'h3403ff00;   //ori r3,r0,ff00h		r3--32'h0000 ff00instmem [3] = 32'h3404ffff;   //ori r4,r0,ffffh		r4--32'h0000 ffff
/*	instmem [4] = 32'h3005ffff;	//andi r5,r0,ffff	r5--32'h0000 0000instmem [5] = 32'h3806ffff;	//xori r6,r0,ffff	r6--32'h0000 ffffinstmem [6] = 32'h2007ffff;	//addi r7,r0,ffff	r7--32'hffff ffffinstmem [7] = 32'h3c081234;     //lui r8,1234		r8--32'h1234 0000instmem [8] = 32'h35095679;     //ori r9,r8,5678	r9--32'h1234 5679instmem [9] = 32'h212aa011;     //addi r10,r9,a011	r10--32'h1233 f68ainstmem [10] = 32'h306b1111;	//andi r11,r3,1111	r10--32'h0000 1100instmem [11] = 32'h254C1111;    //subi r12,r10,1111     r12--32'h1234 e579
*/
/*instmem [4] = 32'h00222820;     //add r5,r1,r2		r5--32'h0000 1120instmem [5] = 32'h00223025;	//or r6,r1,r2		r6--32'h0000 1120instmem [6] = 32'h00223822;	//sub r7,r1,r2		r7--32'h0000 10e0instmem [7] = 32'h00224024;	//and r8,r1,r2		r8--32'h0000 0000instmem [8] = 32'h00224826;	//xor r9,r1,r2		r9--32'h0000 1120instmem [9] =32'h3c0affff;	//lui r10,ffff		r10--32'hffff 0000instmem [10] = 32'h000a5840;	//sll r11,ra,r10	r11--32'hfffe 0000instmem [11] = 32'h000a6042;	//srl,r12,ra,r10	r12--32'h7fff 8000instmem [12] = 32'h000a6843;	//sra r13,ra,r10	r13--32'hffff 8000*/	instmem [4] = 32'b000000_00001_00010_00101_00000_100000;//add,R5,R1,R2  00001120instmem [5] = 32'h3405ffff;   //ori r5,r0,ffffh		r4--32'h0000 ffff//instmem [5] = 32'b000000_00001_00010_00110_00000_100101;//or,R6,R1,R2   00001120instmem [6] = 32'b000000_00011_00100_00111_00000_101010;//slt r7,r3,r4instmem [7] = 32'b000111_00101_00000_0000000000000001;//bgtz r5,1instmem [8] = 32'b000000_00001_00010_00111_00000_101010;//slt r7,r1,r2instmem [9] = 32'h2007ffff;	//addi r7,r0,ffff	r7--32'hffff ffff//instmem [10] = 32'b000001_00111_00000_1111111111111101;//bltz r7,-3  instmem [10] = 32'b000001_00111_00000_1111111111111010;//bltz r7,-6instmem [11] = 32'h34010000;   //ori r1,r0,00hinstmem [12] = 32'b000000_00001_00000_01000_00000_001001;//jalr r8,r1//(r1)=0000 1100//    +0000 0018//addr=0000 1118  //    =1000100011000 //    =100 0100 0110 //	  =446H	        //    =46H		    //    =70//mem[70]=(r6)/*instmem[6]=32'b101011_00001_00110_0000_0000_0001_1000; //sw r6,0x18(r1)instmem[7]=32'b100011_00001_00111_0000_0000_0001_1000; //lw r7,0x18(r1)*///(r7)=mem[70]end
endmodule

 修改后的仿真结果

bgtz、bltz

                                        PC

ori r1,r0,1100h                00h

ori r2,r0,0020h                04h

ori r3,r0,ff00h                  08h

ori r4,r0,ffffh                    0ch

add r5,r1,r2                     10h

ori r5,r0,ffffh                     14h

or r6,r2,r3                        18h

bgtz r5,1                          1ch

or r6,r1,r2                        20h

addi r7,r0,ffffh                  24h

or r6,r3,r4                        28h

bltz r7,-6                          2ch

PC   1ch->24h        2ch->18h

jalr

                                        PC

ori r1,r0,1100h                00h

ori r2,r0,0020h                04h

ori r3,r0,ff00h                  08h

ori r4,r0,ffffh                    0ch

ori r1,r0,1ch                    10h

jalr r31,r1                        14h

ori r5,r0,ffffh                    18h

add r5,r1,r2                     1ch

jr r31                                20h

14h-->1ch

20h-->18h

修改后的完整代码 

`define RstEnable       1'b1
`define RstDisable      1'b0
`define RomEnable       1'b1 
`define RomDisable      1'b0
`define Zero	        0
`define Valid	        1'b1
`define Invalid	        1'b0
//I
`define Inst_ori   	6'b001101
`define Inst_addi  	6'b001000
`define Inst_andi  	6'b001100
`define Inst_xori  	6'b001110
`define Inst_lui   	6'b001111
`define Inst_subi  	6'b001001//lw sw
`define Inst_lw 	6'b100011
`define Inst_sw 	6'b101011//beq bne
`define Inst_beq  	6'b000100
`define Inst_bne  	6'b000101//R
`define Inst_r    	6'b000000
`define Inst_add  	6'b100000
`define Inst_sub  	6'b100010
`define Inst_and	6'b100100
`define Inst_or    	6'b100101
`define Inst_xor   	6'b100110
`define Inst_sll   	6'b000000
`define Inst_srl   	6'b000010
`define Inst_sra   	6'b000011`define Inst_jr    	6'b001000
//J
`define Inst_j   	6'b000010
`define Inst_jal 	6'b000011//12条整数指令
`define Inst_slt	6'b101010
`define Inst_bgtz	6'b000111
`define Inst_bltz	6'b000001
`define Inst_jalr	6'b001001
`define Inst_mult	6'b011000
`define Inst_multu	6'b011001
`define Inst_div	6'b011010
`define Inst_divu	6'b011011
`define Inst_mfhi	6'b010000
`define Inst_mflo	6'b010010
`define Inst_mthi	6'b010001
`define Inst_mtlo	6'b010011//中断
`define Inst_ll		6'b110000
`define Inst_sc		6'b111000
`define Inst_mfc0	6'b000000
`define Inst_mtc0	6'b000000
`define Inst_eret	6'b011000
`define syscall		6'b001100`define Nop     	6'b000000
`define Or      	6'b000001
`define Add		6'b000010
`define And		6'b000011
`define Xor		6'b000100
`define Lui		6'b000101
`define Sub     	6'b000110
`define Sll     	6'b000111
`define Srl     	6'b001000
`define Sra		6'b001001
`define J		6'b001010
`define Jal		6'b001011
`define Beq		6'b001100
`define Bne		6'b001101
`define Jr		6'b001110
`define Lw  		6'b010000
`define Sw  		6'b010001
`define Bgtz		6'b010010
`define Bltz		6'b010011//MEM
`define RamWrite 	1'b1
`define RamUnWrite 	1'b0
`define RamEnable 	1'b1
`define RamDisable 	1'b0

`include "define.v"
module EX(input wire rst,//input wire [5:0] op,input wire [5:0] op_i,     input wire [31:0] regaData,input wire [31:0] regbData,input wire regcWrite_i,input wire [4:0]regcAddr_i,output reg [31:0] regcData,output wire regcWrite,output wire [4:0] regcAddr,output wire [5:0] op,output wire [31:0] memAddr,output wire [31:0] memData
);    assign op = op_i;assign memAddr = regaData;assign memData = regbData;always@(*)if(rst == `RstEnable)regcData = `Zero;elsebegin//case(op)case(op_i)`Or:regcData = regaData | regbData;`Add:regcData = regaData + regbData;`And:regcData = regaData & regbData;`Xor:regcData = regaData ^ regbData;`Lui:regcData = regaData;/*`Lui:regcData = regaData | regbData;*/`Sub:regcData = regaData - regbData;`Sll:regcData = regbData << regaData;`Srl:regcData = regbData >> regaData;`Sra:regcData = ($signed(regbData)) >>> regaData;`J:regcData = `Zero;`Jr:regcData = `Zero;`Jal:regcData = regbData;`Beq:regcData = `Zero;`Bne:regcData = `Zero;`Bltz:regcData = `Zero;`Bgtz:regcData = `Zero;default:regcData = `Zero;endcaseendassign regcWrite = regcWrite_i;assign regcAddr = regcAddr_i;
endmodule

`include "define.v";
module  ID (input wire rst,    input wire [31:0] pc,   //Jinput wire [31:0] inst,input wire [31:0] regaData_i,input wire [31:0] regbData_i,output reg [5:0] op,    output reg [31:0] regaData,output reg [31:0] regbData,output reg regaRead,output reg regbRead,output reg regcWrite,output reg [4:0] regaAddr,output reg [4:0] regbAddr,    output reg [4:0] regcAddr,output reg [31:0] jAddr,   //Joutput reg jCe//J);wire [5:0] inst_op = inst[31:26];   reg [31:0] imm;//Rwire[5:0] func = inst[5:0]; //Jwire [31:0] npc = pc + 4;always@(*)if(rst == `RstEnable)beginop = `Nop;            regaRead = `Invalid;regbRead = `Invalid;regcWrite = `Invalid;regaAddr = `Zero;regbAddr = `Zero;regcAddr = `Zero;imm    = `Zero;jCe = `Invalid;//JjAddr = `Zero;//Jendelse beginjCe = `Invalid;//JjAddr = `Zero;//Jcase(inst_op)`Inst_ori:beginop = `Or;                    regaRead = `Valid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = inst[20:16];imm = {16'h0, inst[15:0]};end`Inst_andi:beginop = `And;                    regaRead = `Valid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = inst[20:16];imm = {16'h0, inst[15:0]};end`Inst_xori:beginop = `Xor;                    regaRead = `Valid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = inst[20:16];imm = {16'h0, inst[15:0]};end`Inst_addi:beginop = `Add;                    regaRead = `Valid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = inst[20:16];imm = {{16{inst[15]}}, inst[15:0]};end`Inst_subi:beginop = `Sub;                    regaRead = `Valid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = inst[20:16];imm = {{16{inst[15]}}, inst[15:0]};end`Inst_lui:beginop = `Lui;                    regaRead = `Invalid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = `Zero;regbAddr = `Zero;regcAddr = inst[20:16];imm = {inst[15:0],16'h0};end`Inst_r:case(func)`Inst_add:beginop = `Add;  regaRead = `Valid;regbRead = `Valid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = inst[15:11];imm = `Zero;end`Inst_or:beginop = `Or;regaRead = `Valid;regbRead = `Valid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = inst[15:11];imm = `Zero;end`Inst_sub:beginop = `Sub;regaRead = `Valid;regbRead = `Valid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = inst[15:11];imm = `Zero;end`Inst_and:beginop = `And;regaRead = `Valid;regbRead = `Valid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = inst[15:11];imm = `Zero;end`Inst_xor:beginop = `Xor;regaRead = `Valid;regbRead = `Valid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = inst[15:11];imm = `Zero;end`Inst_sll:beginop = `Sll;regaRead = `Invalid;regbRead = `Valid;regcWrite = `Valid;regaAddr = `Zero;regbAddr = inst[20:16];regcAddr = inst[15:11];imm = {27'b0,inst[10:6]};end`Inst_srl:beginop = `Srl;regaRead = `Invalid;regbRead = `Valid;regcWrite = `Valid;regaAddr = `Zero;regbAddr = inst[20:16];regcAddr = inst[15:11];imm = {27'b0,inst[10:6]};end`Inst_sra:beginop = `Sra;regaRead = `Invalid;regbRead = `Valid;regcWrite = `Valid;regaAddr = `Zero;regbAddr = inst[20:16];regcAddr = inst[15:11];imm = {27'b0,inst[10:6]};end`Inst_jr:beginop = `Jr;regaRead = `Valid;//rsregbRead = `Invalid;regcWrite = `Invalid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = 5'b11111;jAddr = regaData;jCe = `Valid;imm = `Zero;end`Inst_jalr:beginop = `Jal;regaRead = `Valid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = inst[15:11];  //jAddr = regaData;jCe = `Valid;imm = npc;enddefault:beginregaRead = `Invalid;regbRead = `Invalid;regcWrite = `Invalid;regaAddr = `Zero;regbAddr = `Zero;regcAddr = `Zero;imm = `Zero;endendcase//J`Inst_j:beginop = `J;regaRead = `Invalid;regbRead = `Invalid;regcWrite = `Invalid;regaAddr = `Zero;regbAddr = `Zero;regcAddr = `Zero;jAddr = {npc[31:28], inst[25:0], 2'b00};jCe = `Valid;imm = `Zero;end            `Inst_jal:beginop = `Jal;regaRead = `Invalid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = `Zero;regbAddr = `Zero;regcAddr = 5'b11111;jAddr = {npc[31:28], inst[25:0], 2'b00};jCe = `Valid;imm = npc;end//J `Inst_beq:beginop = `Beq;regaRead = `Valid;regbRead = `Valid;regcWrite = `Invalid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = `Zero;jAddr = npc+{{14{inst[15]}},inst[15:0],2'b00};jCe=(regaData==regbData)?`Valid:`Invalid; /* if(regaData==regbData)jCe = `Valid;elsejCe = `Invalid;*/imm = `Zero;end      `Inst_bne:beginop = `Bne;regaRead = `Valid;regbRead = `Valid;regcWrite = `Invalid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = `Zero;jAddr = npc+{{14{inst[15]}},inst[15:0],2'b00};jCe=(regaData!=regbData)?`Valid:`Invalid;   /* if(regaData!=regbData)jCe = `Valid;elsejCe = `Invalid;*/imm = `Zero;end      `Inst_bgtz:beginop = `Bgtz;regaRead = `Valid;regbRead = `Valid;//regcWrite = `Invalid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = `Zero;jAddr = npc+{{14{inst[15]}},inst[15:0],2'b00};jCe = (regaData[31]==0)?`Valid:`Invalid;imm = 32'b0;  //end`Inst_bltz:beginop = `Bgtz;regaRead = `Valid;regbRead = `Valid;//regcWrite = `Invalid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = `Zero;jAddr = npc+{{14{inst[15]}},inst[15:0],2'b00};jCe = (regaData[31]==1)?`Valid:`Invalid;  //imm = 32'b0;  //end`Inst_lw:beginop = `Lw;regaRead = `Valid;regbRead = `Invalid;regcWrite = `Valid;regaAddr = inst[25:21];regbAddr = `Zero;regcAddr = inst[20:16];imm = {{16{inst[15]}},inst[15:0]};end`Inst_sw:beginop = `Sw;regaRead = `Valid;regbRead = `Valid;regcWrite = `Invalid;regaAddr = inst[25:21];regbAddr = inst[20:16];regcAddr = `Zero;imm = {{16{inst[15]}},inst[15:0]};end	default:beginop = `Nop;                    regaRead = `Invalid;regbRead = `Invalid;regcWrite = `Invalid;regaAddr = `Zero;regbAddr = `Zero;regcAddr = `Zero;imm = `Zero;endendcase end/*always@(*)if(rst == `RstEnable)regaData = `Zero;else if(regaRead == `Valid)regaData = regaData_i;else  regaData = imm;always@(*)if(rst == `RstEnable)regbData = `Zero;      else if(regbRead == `Valid)regbData = regbData_i;elseregbData = imm; */
always@(*)      if(rst == `RstEnable)          regaData = `Zero;      else if(op == `Lw || op == `Sw)               regaData = regaData_i + imm;      else if(regaRead == `Valid)          regaData = regaData_i;      else          regaData = imm;    always@(*)      if(rst == `RstEnable)          regbData = `Zero;      else if(regbRead == `Valid)          regbData = regbData_i;      else          regbData = imm;endmodule

`include "define.v"
module IF(input wire clk,input wire rst,input wire [31:0] jAddr,//Jinput wire jCe,//Joutput reg ce, 
output reg [31:0] pc
);always@(*)if(rst == `RstEnable)ce = `RomDisable;elsece = `RomEnable;
/*    always@(posedge clk)if(ce == `RomDisable)pc = `Zero;elsepc = pc + 4;
*/always@(posedge clk)if(ce == `RomDisable)pc = `Zero;else if(jCe == `Valid)//Jpc = jAddr;elsepc = pc + 4;
endmodule

`include "define.v"
module RegFile(input wire clk,input wire rst,input wire we,input wire [4:0] waddr,input wire [31:0] wdata,input wire regaRead,input wire regbRead,input wire [4:0] regaAddr,input wire [4:0] regbAddr,output reg [31:0] regaData,output reg [31:0] regbData
);reg [31:0] reg32 [31 : 0];    always@(*)if(rst == `RstEnable)regaData = `Zero;else if(regaAddr == `Zero)regaData = `Zero;elseregaData = reg32[regaAddr];always@(*)if(rst == `RstEnable)          regbData = `Zero;else if(regbAddr == `Zero)regbData = `Zero;elseregbData = reg32[regbAddr];always@(posedge clk)if(rst != `RstEnable)if((we == `Valid) && (waddr != `Zero))reg32[waddr] = wdata;else ;          
endmodule

`include "define.v";
module DataMem(input wire clk,input wire ce,input wire we,input wire [31:0] addr,input wire [31:0] wtData,output reg [31:0] rdData
);reg [31:0] datamem [1023 : 0];always@(*)      if(ce == `RamDisable)rdData = `Zero;elserdData = datamem[addr[11 : 2]]; always@(posedge clk)if(ce == `RamEnable && we == `RamWrite)datamem[addr[11 : 2]] = wtData;else ;endmodule


`include "define.v";
module MEM(input wire rst,		input wire [5:0] op,input wire [31:0] regcData,input wire [4:0] regcAddr,input wire regcWr,input wire [31:0] memAddr_i,input wire [31:0] memData,	input  wire [31:0] rdData,output wire [4:0]  regAddr,output wire regWr,output wire [31:0] regData,	output wire [31:0] memAddr,output reg [31:0] wtData,output reg memWr,	output reg memCe
);assign regAddr = regcAddr;    assign regWr = regcWr;    assign regData = (op == `Lw) ? rdData : regcData;    assign memAddr = memAddr_i;always @(*)        if(rst == `RstEnable)          begin            wtData = `Zero;            memWr = `RamUnWrite;            memCe = `RamDisable;          end        elsecase(op)                `Lw:                  begin                    wtData = `Zero;                        memWr = `RamUnWrite;                     memCe = `RamEnable;                    end                `Sw:                  begin                    wtData = memData;                    memWr = `RamWrite;                      memCe = `RamEnable;                   enddefault:                  begin                    wtData = `Zero;                    memWr = `RamUnWrite;                    memCe = `RamDisable;                  end            endcase
endmodule
`include "define.v"
module InstMem(input wire ce,input wire [31:0] addr,output reg [31:0] data
);reg [31:0] instmem [1023 : 0];    always@(*)      if(ce == `RomDisable)data = `Zero;elsedata = instmem[addr[11 : 2]];   initialbegininstmem [0] = 32'h34011100;   //ori r1,r0,1100h         r1--32'h0000 1100instmem [1] = 32'h34020020;   //ori r2,r0,0020h		r2--32'h0000 0020instmem [2] = 32'h3403ff00;   //ori r3,r0,ff00h		r3--32'h0000 ff00instmem [3] = 32'h3404ffff;   //ori r4,r0,ffffh		r4--32'h0000 ffff
/*	instmem [4] = 32'h3005ffff;	//andi r5,r0,ffff	r5--32'h0000 0000instmem [5] = 32'h3806ffff;	//xori r6,r0,ffff	r6--32'h0000 ffffinstmem [6] = 32'h2007ffff;	//addi r7,r0,ffff	r7--32'hffff ffffinstmem [7] = 32'h3c081234;     //lui r8,1234		r8--32'h1234 0000instmem [8] = 32'h35095679;     //ori r9,r8,5678	r9--32'h1234 5679instmem [9] = 32'h212aa011;     //addi r10,r9,a011	r10--32'h1233 f68ainstmem [10] = 32'h306b1111;	//andi r11,r3,1111	r10--32'h0000 1100instmem [11] = 32'h254C1111;    //subi r12,r10,1111     r12--32'h1234 e579
*/
/*instmem [4] = 32'h00222820;     //add r5,r1,r2		r5--32'h0000 1120instmem [5] = 32'h00223025;	//or r6,r1,r2		r6--32'h0000 1120instmem [6] = 32'h00223822;	//sub r7,r1,r2		r7--32'h0000 10e0instmem [7] = 32'h00224024;	//and r8,r1,r2		r8--32'h0000 0000instmem [8] = 32'h00224826;	//xor r9,r1,r2		r9--32'h0000 1120instmem [9] =32'h3c0affff;	//lui r10,ffff		r10--32'hffff 0000instmem [10] = 32'h000a5840;	//sll r11,ra,r10	r11--32'hfffe 0000instmem [11] = 32'h000a6042;	//srl,r12,ra,r10	r12--32'h7fff 8000instmem [12] = 32'h000a6843;	//sra r13,ra,r10	r13--32'hffff 8000*/	//instmem [4] = 32'h34010000;   //ori r1,r0,00h//instmem [5] = 32'b000000_00001_00000_01000_00000_001001;//jalr r8,r1instmem [4] = 32'b000000_00001_00010_00101_00000_100000;//add,R5,R1,R2  instmem [5] = 32'h3405ffff;   //ori r5,r0,ffffh		instmem [6] = 32'b000000_00010_00011_00110_00000_100101;//or,R6,R2,R3   instmem [7] = 32'b000111_00101_00000_0000000000000001;//bgtz r5,1instmem [8] = 32'b000000_00001_00010_00110_00000_100101;//or,R6,R1,R2   00001120instmem [9] = 32'h2007ffff;	//addi r7,r0,ffff	r7--32'hffff ffffinstmem [10] = 32'b000000_00011_00100_00110_00000_100101;//or,R6,R3,R4  //instmem [10] = 32'b000001_00111_00000_1111111111111101;//bltz r7,-3  instmem [11] = 32'b000001_00111_00000_1111111111111010;//bltz r7,-6/*instmem [6] = 32'b000000_00011_00100_00111_00000_101010;//slt r7,r3,r4instmem [8] = 32'b000000_00001_00010_00111_00000_101010;//slt r7,r1,r2*///(r1)=0000 1100//    +0000 0018//addr=0000 1118  //    =1000100011000 //    =100 0100 0110 //	  =446H	        //    =46H		    //    =70//mem[70]=(r6)/*instmem[6]=32'b101011_00001_00110_0000_0000_0001_1000; //sw r6,0x18(r1)instmem[7]=32'b100011_00001_00111_0000_0000_0001_1000; //lw r7,0x18(r1)*///(r7)=mem[70]end
endmodule
`include "define.v";
module MIPS(input wire clk,input wire rst,input wire [31:0] instruction,input wire [31:0] rdData,//lsoutput wire romCe,output wire [31:0] instAddr,output wire [31:0] wtData,//lsoutput wire [31:0] memAddr,//lsoutput wire memCe,//lsoutput wire memWr//ls
);wire [31:0] regaData_regFile, regbData_regFile;wire [31:0] regaData_id, regbData_id; wire [31:0] regcData_ex;//wire [5:0] op; wire [5:0] op_id; //ls  wire regaRead, regbRead;wire [4:0] regaAddr, regbAddr;wire regcWrite_id, regcWrite_ex;wire [4:0] regcAddr_id, regcAddr_ex;//Jwire [31:0] jAddr;wire jCe;//lswire [5:0] op_ex;wire[31:0] memAddr_ex,memData_ex;wire [5:0] regAddr_mem;wire [31:0] regData_mem;wire regWr_mem;IF if0(.clk(clk),.rst(rst),.jAddr(jAddr),//J.jCe(jCe),//J.ce(romCe), .pc(instAddr));ID id0(.rst(rst), .pc(instAddr),//J.inst(instruction),.regaData_i(regaData_regFile),.regbData_i(regbData_regFile),//.op(op),.op(op_id),//ls.regaData(regaData_id),.regbData(regbData_id),.regaRead(regaRead),.regbRead(regbRead),.regaAddr(regaAddr),.regbAddr(regbAddr),.regcWrite(regcWrite_id),.regcAddr(regcAddr_id),.jAddr(jAddr),//J.jCe(jCe)//J);EX ex0(.rst(rst),//.op(op),    .op_i(op_id),    .regaData(regaData_id),.regbData(regbData_id),.regcWrite_i(regcWrite_id),.regcAddr_i(regcAddr_id),.regcData(regcData_ex),.regcWrite(regcWrite_ex),.regcAddr(regcAddr_ex),.op(op_ex),//ls.memAddr(memAddr_ex),//ls.memData(memData_ex)//ls);    MEM mem0(.rst(rst),		.op(op_ex),.regcData(regcData_ex),.regcAddr(regcAddr_ex),.regcWr(regcWrite_ex),.memAddr_i(memAddr_ex),.memData(memData_ex),	.rdData(rdData),.regAddr(regAddr_mem),.regWr(regWr_mem),.regData(regData_mem),	.memAddr(memAddr),.wtData(wtData),.memWr(memWr),	.memCe(memCe));RegFile regfile0(.clk(clk),.rst(rst),//.we(regcWrite_ex),.we(regWr_mem),//.waddr(regcAddr_ex),.waddr(regAddr_mem),//.wdata(regcData_ex),.wdata(regData_mem),.regaRead(regaRead),.regbRead(regbRead),.regaAddr(regaAddr),.regbAddr(regbAddr),.regaData(regaData_regFile),.regbData(regbData_regFile));endmodule

module SoC(input wire clk,input wire rst
);wire [31:0] instAddr;wire [31:0] instruction;wire romCe;//lswire memCe, memWr;    wire [31:0] memAddr;wire [31:0] rdData;wire [31:0] wtData;MIPS mips0(.clk(clk),.rst(rst),.instruction(instruction),.instAddr(instAddr),.romCe(romCe),.rdData(rdData),        .wtData(wtData),        .memAddr(memAddr),        .memCe(memCe),        .memWr(memWr) );	InstMem instrom0(.ce(romCe),.addr(instAddr),.data(instruction));//DataMemDataMem datamem0(       .ce(memCe),        .clk(clk),        .we(memWr),        .addr(memAddr),        .wtData(wtData),        .rdData(rdData)  );
endmodule

`include "define.v"
module soc_tb;reg clk;reg rst;initialbeginclk = 0;rst = `RstEnable;#100rst = `RstDisable;#10000 $stop;        endalways #10 clk = ~ clk;SoC soc0(.clk(clk), .rst(rst));
endmodule

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/893253.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java面试专题——常见面试题1

引入 本文属于专题中的常见面试题模块&#xff0c;属于面试时经常遇到的&#xff0c;适合需要面试的小伙伴做面试前复习准备用&#xff0c;后续会持续补充 1.面向对象基本特征 面向对象的基本特征是什么&#xff1f;怎么理解&#xff1f; 面向对象的基本特征是封装、继承、…

VUE实现简单留言板(Timeline+infinite scroll+Springboot+Hibernate)

先贴出效果图&#xff1a; 留言按照倒序排列。在底部的文本框内输入留言后&#xff0c;点击“留言”按钮&#xff0c;留言将保存至数据库中&#xff0c;同时刷新网页&#xff0c;新留言出现在顶部。 当滚动条到底部时&#xff0c;自动调用加载函数&#xff0c;显示更多早期留…

Java基础(3)

Java 数据类型详解 九、运算符 1. 基本运算符 Java 提供了多种运算符来执行不同的操作&#xff1a; 算术运算符&#xff1a;&#xff08;加&#xff09;、-&#xff08;减&#xff09;、*&#xff08;乘&#xff09;、/&#xff08;除&#xff09;、%&#xff08;取模&…

电力场景红外测温图像绝缘套管分割数据集labelme格式2436张1类别

数据集格式&#xff1a;labelme格式(不包含mask文件&#xff0c;仅仅包含jpg图片和对应的json文件) 图片数量(jpg文件个数)&#xff1a;2436 标注数量(json文件个数)&#xff1a;2436 标注类别数&#xff1a;1 标注类别名称:["arrester"] 每个类别标注的框数&am…

降维算法:主成分分析

主成分分析 一种常用的数据分析技术&#xff0c;主要用于数据降维&#xff0c;在众多领域如统计学、机器学习、信号处理等都有广泛应用。 主成分分析是一种通过正交变换将一组可能存在相关性的变量转换为一组线性不相关的变量&#xff08;即主成分&#xff09;的方法。这些主…

深入解析 C++17 中的 u8 字符字面量:提升 Unicode 处理能力

在现代软件开发中&#xff0c;处理多语言文本是一个常见需求&#xff0c;特别是在全球化的应用场景下。C17 标准引入的 u8 字符字面量为开发者提供了一个强大的工具&#xff0c;以更有效地处理和表示 UTF-8 编码的字符串。本文将详细探讨 u8 字符字面量的技术细节、实际应用&am…

ElasticSearch索引别名的应用

个人博客&#xff1a;无奈何杨&#xff08;wnhyang&#xff09; 个人语雀&#xff1a;wnhyang 共享语雀&#xff1a;在线知识共享 Github&#xff1a;wnhyang - Overview Elasticsearch 索引别名是一种极为灵活且强大的功能&#xff0c;它允许用户为一个或多个索引创建逻辑上…

Java高频面试之SE-15

hello啊&#xff0c;各位观众姥爷们&#xff01;&#xff01;&#xff01;本牛马baby今天又来了&#xff01;哈哈哈哈哈嗝&#x1f436; String 怎么转成 Integer 的&#xff1f;它的原理是&#xff1f; 在 Java 中&#xff0c;要将 String 转换为 Integer 类型&#xff0c;可…

2024又是一年的CSDN之旅-总结过去展望未来

一、前言 一年就这样在忙忙碌碌的工作和生活中一晃而过&#xff0c;总结今年在CSDN上发表的博客&#xff0c;也有上百篇之多&#xff0c;首先感谢CSDN这个平台&#xff0c;能让我有一个地方记录工作中的点点滴滴&#xff0c;也在上面学到了不少知识&#xff0c;解决了工作中遇到…

c86机器安装nvaid显卡驱动报错:ERROR:Unable to load the kernel module ‘nvidia.ko‘.

背景&#xff1a; 最近小伙伴要去北京甲方现场搭建我们的AI编码服务&#xff0c;需要使用GPU机器跑大模型&#xff0c;根据现场提供的信息是2台C86的机器&#xff0c;显卡够够的&#xff0c;但是现场是内网环境&#xff0c;因此&#xff0c;需要先准备好需要的安装包&#xff…

LeetCode 热题 100_实现 Trie (前缀树)(54_208_中等_C++)(图;前缀树;字典树)

[TOC](LeetCode 热题 100_实现 Trie (前缀树)&#xff08;54_208&#xff09;) 题目描述&#xff1a; Trie&#xff08;发音类似 “try”&#xff09;或者说 前缀树 是一种树形数据结构&#xff0c;用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景&…

【Maui】视图界面与数据模型绑定

文章目录 前言一、问题描述二、解决方案三、软件开发&#xff08;源码&#xff09;3.1 创建模型3.2 视图界面3.3 控制器逻辑层 四、项目展示 前言 .NET 多平台应用 UI (.NET MAUI) 是一个跨平台框架&#xff0c;用于使用 C# 和 XAML 创建本机移动和桌面应用。 使用 .NET MAUI&…

从 Spark 到 StarRocks:实现58同城湖仓一体架构的高效转型

作者&#xff1a;王世发&#xff0c;吴艳兴等&#xff0c;58同城数据架构部 导读&#xff1a; 本文介绍了58同城在其数据探查平台中引入StarRocks的实践&#xff0c;旨在提升实时查询性能。在面对传统Spark和Hive架构的性能瓶颈时&#xff0c;58同城选择StarRocks作为加速引擎&…

探秘 Linux 进程状态:解锁系统运行的密码

&#x1f31f; 快来参与讨论&#x1f4ac;&#xff0c;点赞&#x1f44d;、收藏⭐、分享&#x1f4e4;&#xff0c;共创活力社区。&#x1f31f; &#x1f6a9;用通俗易懂且不失专业性的文字&#xff0c;讲解计算机领域那些看似枯燥的知识点&#x1f6a9; 在 Linux 系统…

深度学习-89-大语言模型LLM之AI应用开发的基本概念

文章目录 1 什么是智能体(Agent)2 什么是大语言模型(LLM)2.1 LLM的训练及使用2.2 Transformer架构2.3 基于LLM的Agent框架3 什么是检索增强生成(RAG)3.1 RAG是什么3.2 生成式AI应用开发3.3 RAG的整体流程3.4 RAG技术3.4.1 简单RAG(Simple RAG)3.4.2 校正RAG(Corrective RAG)3.4…

鸿蒙产业学院正式揭牌!软通动力与深信息签署校企合作框架协议

12月27日&#xff0c;深圳信息职业技术学院&#xff08;简称“深信息”&#xff09;与软通动力信息技术&#xff08;集团&#xff09;股份有限公司&#xff08;简称“软通动力”&#xff09;正式签署校企合作框架协议&#xff0c;并共同揭牌成立鸿蒙产业学院。深信息校长王晖&a…

python轻量级框架-flask

简述 Flask 是 Python 生态圈中一个基于 Python 的Web 框架。其轻量、模块化和易于扩展的特点导致其被广泛使用&#xff0c;适合快速开发 Web 应用以及构建小型到中型项目。它提供了开发 Web 应用最基础的工具和组件。之所以称为微框架&#xff0c;是因为它与一些大型 Web 框架…

2024年河北省职业院校技能大赛 “信息技术应用创新赛项”(高职组)样题解法

​有问题请留言或主页私信咨询 2024年河北省职业院校技能大赛 “信息技术应用创新赛项”&#xff08;高职组&#xff09;样题 一、初始化环境 1.账号及默认密码如表1所示。 表1 账号及密码规划表 账 号密 码root&#xff08;服务端&#xff09;kylin2024!desk&#xff08…

gozero获取数据库内容报错解决方案与实践

这个错误通常出现在 Go 语言的数据库查询中&#xff0c;表示你尝试将一个不支持的数据类型&#xff08;[]uint8&#xff0c;即字节切片&#xff09;存储到一个 Go 类型&#xff08;*time.Time&#xff09;中。具体来说&#xff0c;create_time 列的类型可能是 DATETIME 或 TIME…

【学习笔记15】如何在非root服务器中,安装属于自己的redis

一、下载安装包 官网下载黑马程序员给的安装包&#xff08;redis-6.2.6&#xff09; 二、将安装包上传至服务器 我将安装包上传在我的文件夹/home/XXX&#xff0c;指定路径中/src/local/redis/&#xff0c;绝对路径为/home/XXX/src/local/redis/解压安装包 XXXomega:~$ cd …