Skip to content

Commit

Permalink
Update core.v
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrejChoo authored Sep 23, 2023
1 parent 560adc8 commit 2e28542
Showing 1 changed file with 106 additions and 106 deletions.
212 changes: 106 additions & 106 deletions firmware/xilinx/core.v
Original file line number Diff line number Diff line change
Expand Up @@ -962,111 +962,111 @@ begin
end
end

//Decoder opcodov
always@(opcode0)
begin
case(opcode0[15:12])
4'h0:
begin
if(opcode0[11:0] == 12'd0) o_num <= NOP;
if(opcode0[11:10] == 2'b11) o_num <= ADD;
if(opcode0[11:10] == 2'b01) o_num <= CPC;
if(opcode0[11:10] == 2'b10) o_num <= SBC;
if(opcode0[11:8] == 4'b0001) o_num <= MOVW;
if(opcode0[11:8] == 4'b0010) o_num <= MULS;
if(opcode0[11:8] == 4'b0011) o_num <= MULSU;
end
4'h1:
begin
if(opcode0[11:10] == 2'b11) o_num <= ADC;
if(opcode0[11:10] == 2'b01) o_num <= CP;
if(opcode0[11:10] == 2'b10) o_num <= SUB;
if(opcode0[11:10] == 2'b00) o_num <= CPSE;
end
4'h2:
begin
if(opcode0[11:10] == 2'b00) o_num <= AND;
if(opcode0[11:10] == 2'b10) o_num <= OR;
if(opcode0[11:10] == 2'b01) o_num <= EOR;
if(opcode0[11:10] == 2'b11) o_num <= MOV;
end
4'h3: o_num <= CPI;
4'h4: o_num <= SBCI;
4'h5: o_num <= SUBI;
4'h6: o_num <= ORI;
4'h7: o_num <= ANDI;
4'h8:
begin
//if({opcode0[11:9],opcode0[2:0]} == 6'b000000) o_num <= LDYZ; //LDDY - LDDZ
//if({opcode0[11:9],opcode0[2:0]} == 6'b001000) o_num <= STYZ; //STDY - STDZ
if(opcode0[9] == 1'b1) o_num <= STYZ; //STDYPQ - STDZPQ
if(opcode0[9] == 1'b0) o_num <= LDYZ; //LDDYPQ - LDDZPQ
end
4'h9:
begin
if(opcode0[11:10] == 2'b11) o_num <= MUL;
if({opcode0[11:9],opcode0[3:1]} == 6'b010110) o_num <= JMP;
if({opcode0[11:9],opcode0[3:1]} == 6'b010111) o_num <= CALL;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100011) o_num <= INC;
if({opcode0[11:9],opcode0[3:0]} == 7'b0101010) o_num <= DEC;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100101) o_num <= ASR;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100000) o_num <= COM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100110) o_num <= LSR;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100001) o_num <= NEG;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100111) o_num <= ROR;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100010) o_num <= SWAP;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011111) o_num <= PUSH;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001111) o_num <= POP;
if(opcode0[11:0] == 12'h409) o_num <= IJMP;
if(opcode0[11:0] == 12'h508) o_num <= RET;
if(opcode0[11:0] == 12'h509) o_num <= ICALL;
if(opcode0[11:0] == 12'h5C8) o_num <= LPM;
if(opcode0[11:0] == 12'h518) o_num <= RETI;
if(opcode0[11:8] == 4'b0110) o_num <= ADIW;
if(opcode0[11:8] == 4'b0111) o_num <= SBIW;
if({opcode0[11:8],opcode0[3:0]} == 8'b01001000) o_num <= BSET; //BSET - BCLR
if({opcode0[11:10],opcode0[8]} == 3'b100) o_num <= CSBI; //CBI - SBI
if({opcode0[11:10],opcode0[8]} == 3'b101) o_num <= SBICS; //SBIC - SBIS
if({opcode0[11:9],opcode0[3:0]} == 7'b0000000) o_num <= LDS;
if({opcode0[11:9],opcode0[3:0]} == 7'b0010000) o_num <= STS;
if({opcode0[11:9],opcode0[3:1]} == 6'b000010) o_num <= LPMZ;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001100) o_num <= LDX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001101) o_num <= LDX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001110) o_num <= LDX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001001) o_num <= LDYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001010) o_num <= LDYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0000001) o_num <= LDZPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0000010) o_num <= LDZPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011100) o_num <= STX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011101) o_num <= STX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011110) o_num <= STX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011001) o_num <= STYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011010) o_num <= STYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0010001) o_num <= STZPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0010010) o_num <= STZPM;
end
4'hA:
begin
if(opcode0[9] == 1'b1) o_num <= STYZ;
if(opcode0[9] == 1'b0) o_num <= LDYZ;
end
4'hB:
begin
if(opcode0[11]== 0) o_num <= IN;
if(opcode0[11]== 1) o_num <= OUT;
end
4'hC: o_num <= RJMP;
4'hD: o_num <= RCALL;
4'hE: o_num <= LDI;
4'hF:
begin
if(opcode0[11]== 1'b0) o_num <= BRBSC; //BRBC - BRBS
if({opcode0[11:9],opcode0[3]}== 4'b1000) o_num <= BLD;
if({opcode0[11:9],opcode0[3]}== 4'b1010) o_num <= BST;
if({opcode0[11:10],opcode0[3]}== 3'b110) o_num <= SBRSC; //SBRC - SBRS
if(opcode0[11:0] == 12'hFFF) o_num <= 0;
end
endcase
//Decoder opcodov
always@(opcode0)
begin
case(opcode0[15:12])
4'h0:
begin
if(opcode0[11:0] == 12'd0) o_num <= NOP;
if(opcode0[11:10] == 2'b11) o_num <= ADD;
if(opcode0[11:10] == 2'b01) o_num <= CPC;
if(opcode0[11:10] == 2'b10) o_num <= SBC;
if(opcode0[11:8] == 4'b0001) o_num <= MOVW;
if(opcode0[11:8] == 4'b0010) o_num <= MULS;
if(opcode0[11:8] == 4'b0011) o_num <= MULSU;
end
4'h1:
begin
if(opcode0[11:10] == 2'b11) o_num <= ADC;
if(opcode0[11:10] == 2'b01) o_num <= CP;
if(opcode0[11:10] == 2'b10) o_num <= SUB;
if(opcode0[11:10] == 2'b00) o_num <= CPSE;
end
4'h2:
begin
if(opcode0[11:10] == 2'b00) o_num <= AND;
if(opcode0[11:10] == 2'b10) o_num <= OR;
if(opcode0[11:10] == 2'b01) o_num <= EOR;
if(opcode0[11:10] == 2'b11) o_num <= MOV;
end
4'h3: o_num <= CPI;
4'h4: o_num <= SBCI;
4'h5: o_num <= SUBI;
4'h6: o_num <= ORI;
4'h7: o_num <= ANDI;
4'h8:
begin
//if({opcode0[11:9],opcode0[2:0]} == 6'b000000) o_num <= LDYZ; //LDDY - LDDZ
//if({opcode0[11:9],opcode0[2:0]} == 6'b001000) o_num <= STYZ; //STDY - STDZ
if(opcode0[9] == 1'b1) o_num <= STYZ; //STDYPQ - STDZPQ
if(opcode0[9] == 1'b0) o_num <= LDYZ; //LDDYPQ - LDDZPQ
end
4'h9:
begin
if(opcode0[11:10] == 2'b11) o_num <= MUL;
if({opcode0[11:9],opcode0[3:1]} == 6'b010110) o_num <= JMP;
if({opcode0[11:9],opcode0[3:1]} == 6'b010111) o_num <= CALL;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100011) o_num <= INC;
if({opcode0[11:9],opcode0[3:0]} == 7'b0101010) o_num <= DEC;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100101) o_num <= ASR;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100000) o_num <= COM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100110) o_num <= LSR;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100001) o_num <= NEG;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100111) o_num <= ROR;
if({opcode0[11:9],opcode0[3:0]} == 7'b0100010) o_num <= SWAP;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011111) o_num <= PUSH;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001111) o_num <= POP;
if(opcode0[11:0] == 12'h409) o_num <= IJMP;
if(opcode0[11:0] == 12'h508) o_num <= RET;
if(opcode0[11:0] == 12'h509) o_num <= ICALL;
if(opcode0[11:0] == 12'h5C8) o_num <= LPM;
if(opcode0[11:0] == 12'h518) o_num <= RETI;
if(opcode0[11:8] == 4'b0110) o_num <= ADIW;
if(opcode0[11:8] == 4'b0111) o_num <= SBIW;
if({opcode0[11:8],opcode0[3:0]} == 8'b01001000) o_num <= BSET; //BSET - BCLR
if({opcode0[11:10],opcode0[8]} == 3'b100) o_num <= CSBI; //CBI - SBI
if({opcode0[11:10],opcode0[8]} == 3'b101) o_num <= SBICS; //SBIC - SBIS
if({opcode0[11:9],opcode0[3:0]} == 7'b0000000) o_num <= LDS;
if({opcode0[11:9],opcode0[3:0]} == 7'b0010000) o_num <= STS;
if({opcode0[11:9],opcode0[3:1]} == 6'b000010) o_num <= LPMZ;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001100) o_num <= LDX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001101) o_num <= LDX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001110) o_num <= LDX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001001) o_num <= LDYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0001010) o_num <= LDYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0000001) o_num <= LDZPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0000010) o_num <= LDZPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011100) o_num <= STX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011101) o_num <= STX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011110) o_num <= STX;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011001) o_num <= STYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0011010) o_num <= STYPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0010001) o_num <= STZPM;
if({opcode0[11:9],opcode0[3:0]} == 7'b0010010) o_num <= STZPM;
end
4'hA:
begin
if(opcode0[9] == 1'b1) o_num <= STYZ;
if(opcode0[9] == 1'b0) o_num <= LDYZ;
end
4'hB:
begin
if(opcode0[11]== 0) o_num <= IN;
if(opcode0[11]== 1) o_num <= OUT;
end
4'hC: o_num <= RJMP;
4'hD: o_num <= RCALL;
4'hE: o_num <= LDI;
4'hF:
begin
if(opcode0[11]== 1'b0) o_num <= BRBSC; //BRBC - BRBS
if({opcode0[11:9],opcode0[3]}== 4'b1000) o_num <= BLD;
if({opcode0[11:9],opcode0[3]}== 4'b1010) o_num <= BST;
if({opcode0[11:10],opcode0[3]}== 3'b110) o_num <= SBRSC; //SBRC - SBRS
if(opcode0[11:0] == 12'hFFF) o_num <= 0;
end
endcase
end


Expand All @@ -1089,7 +1089,7 @@ begin
ADIW: RALU16 = {r[{2'b11, opcode0[5:4], 1'b1}],r[{2'b11, opcode0[5:4], 1'b0}]} + {opcode0[7:6],opcode0[3:0]};
AND: RALU = r[(opcode0[8:4])] & r[{opcode0[9],opcode0[3:0]}];
ANDI: RALU = r[{1'b1, opcode0[7:4]}] & {opcode0[11:8],opcode0[3:0]};
ASR: RALU = {r[(opcode0[8:4])][7],r[(opcode0[8:4])][6:1]};
ASR: RALU = {r[(opcode0[8:4])][7],r[(opcode0[8:4])][7:1]};
CPI: begin RALU = r[{1'b1, opcode0[7:4]}] - {opcode0[11:8],opcode0[3:0]}; operand = {opcode0[11:8],opcode0[3:0]}; end
COM: RALU = 8'hFF - r[(opcode0[8:4])];
CPSE: RALU = r[(opcode0[8:4])] - r[{opcode0[9], opcode0[3:0]}];
Expand Down

0 comments on commit 2e28542

Please sign in to comment.