Design a multi-cycle implementation of the reduced MIPS architecture

profilecasi
7seg.zip

hex_bcd_oct_7seg.v

//hex_bcd_oct_7seg /*This module takes a 32 bit input and allows *it to be displayed on the 7seg displays as *Hex, Decimal, or Octal. It checks the value *in the 32-bit word to ensure that it is displayable *in the chosed format. If not, it displays error. */ module hex_bcd_oct_7seg(binary, mode, oseg0, oseg1, oseg2, oseg3, oseg4, oseg5, oseg6, oseg7, error); input [1:0] mode; //zero is error, one is hex, two is decimal, three is octal input [31:0] binary; output [6:0] oseg0, oseg1, oseg2, oseg3, oseg4, oseg5, oseg6, oseg7; output error; reg [3:0] tenmil, onemil, hundthou, tenthou, thou, hund, ten, one; reg error; integer i; always @(mode or binary) begin //set outputs to zero tenmil = 4'h0; onemil = 4'h0; hundthou = 4'h0; tenthou = 4'h0; thou = 4'h0; hund = 4'h0; ten = 4'h0; one = 4'h0; error = 1'b0; case(mode) 2'h1:begin tenmil = binary[31:28]; //display in hexadecimal onemil = binary[27:24]; hundthou = binary[23:20]; tenthou = binary[19:16]; thou = binary[15:12]; hund = binary[11:8]; ten = binary[7:4]; one = binary[3:0]; end 2'h3: if(binary <= 32'O 77777777) begin tenmil = {1'b0, binary[23:19]}; //display in octal onemil = {1'b0, binary[20:18]}; hundthou = {1'b0, binary[17:15]}; tenthou = {1'b0, binary[14:12]}; thou = {1'b0, binary[11:9]}; hund = {1'b0, binary[8:6]}; ten = {1'b0, binary[5:3]}; one = {1'b0, binary[2:0]}; end else /*output error*/ error = 1'b1; 2'h2: if(binary <= 32'd 99999999) //display in decimal for(i = 26; i >= 0; i = i-1) begin //add three to columns greater than 5 if(tenmil>=4'h5)tenmil = tenmil + 3; if(onemil>=4'h5)onemil = onemil +3; if(hundthou>=4'h5)hundthou = hundthou + 3; if(tenthou>=4'h5) tenthou = tenthou + 3; if(thou>=4'h5)thou = thou + 3; if(hund>=4'h5)hund = hund + 3; if(ten>=4'h5)ten = ten + 3; if(one>=4'h5) one = one + 3; tenmil = tenmil<<1; tenmil[0] = onemil[3]; onemil = onemil<<1; onemil[0] = hundthou[3]; hundthou = hundthou<<1; hundthou[0] = tenthou[3]; tenthou = tenthou<<1; tenthou[0] = thou[3]; thou = thou<<1; thou[0] = hund[3]; hund = hund<<1; hund[0] = ten[3]; ten = ten<<1; ten[0] = one[3]; one = one << 1; one[0] = binary[i]; end else /*output error*/ error = 1'b1; 2'h0: error = 1'b1; endcase end hex_drive hex0( oseg0, error, one, 2'h3 ); hex_drive hex1( oseg1, error, ten, 2'h1 ); hex_drive hex2( oseg2, error, hund, 2'h2 ); hex_drive hex3( oseg3, error, thou, 2'h1 ); hex_drive hex4( oseg4, error, tenthou, 2'h1 ); hex_drive hex5( oseg5, error, hundthou, 2'h0 ); hex_drive hex6( oseg6, error, onemil, 2'h3 ); hex_drive hex7( oseg7, error, tenmil, 2'h3 ); endmodule

hex_drive.v

//hex_drive.v //driver for hex modules module hex_drive ( oSEG, error, iDIG, character ); input [3:0] iDIG; input [1:0] character; input error; output [6:0] oSEG; reg [6:0] oSEG; parameter E = 2'h0, r = 2'h1, o = 2'h2, dash = 2'h3; always @(iDIG or error) begin if(!error) case(iDIG) 4'h1: oSEG = 7'b1111001; // ---0---- 4'h2: oSEG = 7'b0100100; // | | 4'h3: oSEG = 7'b0110000; // 5 1 4'h4: oSEG = 7'b0011001; // | | 4'h5: oSEG = 7'b0010010; // ---6---- 4'h6: oSEG = 7'b0000010; // | | 4'h7: oSEG = 7'b1111000; // 4 2 4'h8: oSEG = 7'b0000000; // | | 4'h9: oSEG = 7'b0011000; // ---3---- 4'ha: oSEG = 7'b0001000; 4'hb: oSEG = 7'b0000011; 4'hc: oSEG = 7'b1000110; 4'hd: oSEG = 7'b0100001; 4'he: oSEG = 7'b0000110; 4'hf: oSEG = 7'b0001110; 4'h0: oSEG = 7'b1000000; endcase else case(character) 2'h0: oSEG = 7'b0000110; //E 2'h1: oSEG = 7'b0101111; //r 2'h2: oSEG = 7'b0100011; //o 2'h3: oSEG = 7'b0111111; //- endcase end endmodule